0,0 → 1,184 |
/*#######################################################################################*/ |
/* !!! THIS IS NOT FREE SOFTWARE !!! */ |
/*#######################################################################################*/ |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + www.MikroKopter.com |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Software Nutzungsbedingungen (english version: see below) |
// + der Fa. HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland - nachfolgend Lizenzgeber genannt - |
// + Der Lizenzgeber räumt dem Kunden ein nicht-ausschließliches, zeitlich und räumlich* unbeschränktes Recht ein, die im den |
// + Mikrocontroller verwendete Firmware für die Hardware Flight-Ctrl, Navi-Ctrl, BL-Ctrl, MK3Mag & PC-Programm MikroKopter-Tool |
// + - nachfolgend Software genannt - nur für private Zwecke zu nutzen. |
// + Der Einsatz dieser Software ist nur auf oder mit Produkten des Lizenzgebers zulässig. |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Die vom Lizenzgeber gelieferte Software ist urheberrechtlich geschützt. Alle Rechte an der Software sowie an sonstigen im |
// + Rahmen der Vertragsanbahnung und Vertragsdurchführung überlassenen Unterlagen stehen im Verhältnis der Vertragspartner ausschließlich dem Lizenzgeber zu. |
// + Die in der Software enthaltenen Copyright-Vermerke, Markenzeichen, andere Rechtsvorbehalte, Seriennummern sowie |
// + sonstige der Programmidentifikation dienenden Merkmale dürfen vom Kunden nicht verändert oder unkenntlich gemacht werden. |
// + Der Kunde trifft angemessene Vorkehrungen für den sicheren Einsatz der Software. Er wird die Software gründlich auf deren |
// + Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt. |
// + Die Haftung des Lizenzgebers wird - soweit gesetzlich zulässig - begrenzt in Höhe des typischen und vorhersehbaren |
// + Schadens. Die gesetzliche Haftung bei Personenschäden und nach dem Produkthaftungsgesetz bleibt unberührt. Dem Lizenzgeber steht jedoch der Einwand |
// + des Mitverschuldens offen. |
// + Der Kunde trifft angemessene Vorkehrungen für den Fall, dass die Software ganz oder teilweise nicht ordnungsgemäß arbeitet. |
// + Er wird die Software gründlich auf deren Verwendbarkeit zu dem von ihm beabsichtigten Zweck testen, bevor er diese operativ einsetzt. |
// + Der Kunde wird er seine Daten vor Einsatz der Software nach dem Stand der Technik sichern. |
// + Der Kunde ist darüber unterrichtet, dass der Lizenzgeber seine Daten im zur Vertragsdurchführung erforderlichen Umfang |
// + und auf Grundlage der Datenschutzvorschriften erhebt, speichert, verarbeitet und, sofern notwendig, an Dritte übermittelt. |
// + *) Die räumliche Nutzung bezieht sich nur auf den Einsatzort, nicht auf die Reichweite der programmierten Software. |
// + #### ENDE DER NUTZUNGSBEDINGUNGEN ####' |
// + Hinweis: Informationen über erweiterte Nutzungsrechte (wie z.B. Nutzung für nicht-private Zwecke) sind auf Anfrage per Email an info(@)hisystems.de verfügbar. |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + Software LICENSING TERMS |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
// + of HiSystems GmbH, Flachsmeerstrasse 2, 26802 Moormerland, Germany - the Licensor - |
// + The Licensor grants the customer a non-exclusive license to use the microcontroller firmware of the Flight-Ctrl, Navi-Ctrl, BL-Ctrl, and MK3Mag hardware |
// + (the Software) exclusively for private purposes. The License is unrestricted with respect to time and territory*. |
// + The Software may only be used with the Licensor's products. |
// + The Software provided by the Licensor is protected by copyright. With respect to the relationship between the parties to this |
// + agreement, all rights pertaining to the Software and other documents provided during the preparation and execution of this |
// + agreement shall be the property of the Licensor. |
// + The information contained in the Software copyright notices, trademarks, other legal reservations, serial numbers and other |
// + features that can be used to identify the program may not be altered or defaced by the customer. |
// + The customer shall be responsible for taking reasonable precautions |
// + for the safe use of the Software. The customer shall test the Software thoroughly regarding its suitability for the |
// + intended purpose before implementing it for actual operation. The Licensor's liability shall be limited to the extent of typical and |
// + foreseeable damage to the extent permitted by law, notwithstanding statutory liability for bodily injury and product |
// + liability. However, the Licensor shall be entitled to the defense of contributory negligence. |
// + The customer will take adequate precautions in the case, that the software is not working properly. The customer will test |
// + the software for his purpose before any operational usage. The customer will backup his data before using the software. |
// + The customer understands that the Licensor collects, stores and processes, and, where required, forwards, customer data |
// + to third parties to the extent necessary for executing the agreement, subject to applicable data protection and privacy regulations. |
// + *) The territory aspect only refers to the place where the Software is used, not its programmed range. |
// + #### END OF LICENSING TERMS #### |
// + Note: For information on license extensions (e.g. commercial use), please contact us at info(@)hisystems.de. |
// ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
#include "91x_lib.h" |
#include "timer1.h" |
#include "uart1.h" |
#include "config.h" |
#include "main.h" |
#include "led.h" |
#include "triggerlog.h" |
|
u32 CountMilliseconds; |
DateTime_t SystemTime; |
/* |
void CountInput(void) |
{ |
static u8 p63 = 1, p64 = 0, p65 = 1; |
if(!PIN6_3) { if(p63) DebugOut.Analog[]++; p63 = 0; } else p63 = 1; |
if(!PIN6_4) { if(p64) DebugOut.Analog[]++; p64 = 0; } else p64 = 1; |
if(!PIN6_5) { if(p65) DebugOut.Analog[]++; p65 = 0; } else p65 = 1; |
} |
*/ |
|
|
//---------------------------------------------------------------------------------------------------- |
void TIM1_IRQHandler(void) |
{ |
static u8 p63 = 1, Entprell63 = 100; |
if(TIM_GetFlagStatus(TIM1, TIM_FLAG_OC1) == SET) |
{ |
TIM_ClearFlag(TIM1, TIM_FLAG_OC1); // clear irq pending bit |
TIM1->OC1R += 200; // Timerfreq is 200kHz, generate an interrupt every 1ms |
CountMilliseconds++; |
if(SD_WatchDog) SD_WatchDog--; |
if(SPIWatchDog) SPIWatchDog--; |
if(PollingTimeout) PollingTimeout--; |
//CountInput(); |
if((UART_VersionInfo.HWMajor >= 30) && !Entprell63) |
{ |
if((!TRIGGER_PP_EXTERN && BlitzSchuhConnected) || (TRIGGER_PP_INTERN && !BlitzSchuhConnected)) // either internal or external Trigger event |
{ |
if(p63) |
{ |
TriggerInput(); |
Entprell63 = 50; |
p63 = 0; |
} |
} |
else p63 = 1; |
} else Entprell63--; |
// generate SW Interrupt to make a regular timing |
// independent from the mainloop at the lowest IRQ priority |
VIC_SWITCmd(EXTIT3_ITLine, ENABLE); |
} |
VIC0->VAR = 0xFF; // write any value to VIC0 Vector address register |
} |
|
//---------------------------------------------------------------------------------------------------- |
// 1ms Timer |
//---------------------------------------------------------------------------------------------------- |
void TIMER1_Init(void) |
{ |
TIM_InitTypeDef TIM_InitStructure; |
|
UART1_PutString("\r\n Timer1 init..."); |
|
#define TIM1_FREQ 200000 // 200kHz |
// TimerOCR set in IntHandler |
|
SCU_APBPeriphClockConfig(__TIM01, ENABLE); |
|
TIM_DeInit(TIM1); |
TIM_StructInit(&TIM_InitStructure); |
TIM_InitStructure.TIM_Mode = TIM_OCM_CHANNEL_1; |
TIM_InitStructure.TIM_OC1_Modes = TIM_TIMING; |
TIM_InitStructure.TIM_Clock_Source = TIM_CLK_APB; |
TIM_InitStructure.TIM_Prescaler = (SCU_GetPCLKFreqValue() * 1000) / TIM1_FREQ; // is only valid up to 48 MHz ! |
TIM_Init (TIM1, &TIM_InitStructure); |
|
TIM_ITConfig(TIM1, TIM_IT_OC1, ENABLE); |
TIM_CounterCmd(TIM1, TIM_START); |
|
VIC_Config(TIM1_ITLine, VIC_IRQ, PRIORITY_TIMER1); |
VIC_ITCmd(TIM1_ITLine, ENABLE); |
|
SystemTime.Year = 0; |
SystemTime.Month = 0; |
SystemTime.Day = 0; |
SystemTime.Hour = 0; |
SystemTime.Min = 0; |
SystemTime.Sec = 0; |
SystemTime.mSec = 0; |
SystemTime.Valid = 0; |
|
CountMilliseconds = 0; |
|
UART1_PutString("ok"); |
|
} |
|
// ----------------------------------------------------------------------- |
u32 SetDelay (u32 t) |
{ |
return(CountMilliseconds + t -1); |
} |
|
// ----------------------------------------------------------------------- |
u8 CheckDelay(u32 t) |
{ |
return(((t - CountMilliseconds)& 0x80000000) >> 27); |
} |
|
// ----------------------------------------------------------------------- |
// this function calculates the time difference of t to the current time in ms |
// if t < current time the delay is reportet as zero |
u32 GetDelay(u32 t) |
{ |
u32 delay = 0; |
delay = t - CountMilliseconds; |
if(delay & 0x80000000) delay = 0; // avoid negative delay values |
return(delay); |
} |
|
// ----------------------------------------------------------------------- |
/* |
void Delay_ms(u32 w) |
{ |
u32 akt; |
akt = SetDelay(w); |
while(!CheckDelay(akt)); |
} |
*/ |