diff --git a/driver/adc.c b/driver/adc.c index 0004c62..c64b7da 100644 --- a/driver/adc.c +++ b/driver/adc.c @@ -23,7 +23,7 @@ void MyADC_Init(MyADC_Struct_TypeDef * ADCStructPtr) ADCStructPtr->ADC->SQR3 |= ADCStructPtr->channel; //Sequence Reader, seulement le SQ1 est lu dans notre cas, nous associons un channel � ce dernier. ADCStructPtr->ADC->CR2 |= ADC_CR2_EXTTRIG; //Activation du trigger externe ADCStructPtr->ADC->CR2 |= ADC_CR2_EXTSEL; //Event externe choisie : SWSTART - MyADC_ActiveIT(ADCStructPtr->ADC,1); + MyADC_ActiveIT(ADCStructPtr->ADC,2); ADCStructPtr->ADC->CR2 |= ADC_CR2_ADON; //Init l'ADC MyADC_Base_Start(ADCStructPtr->ADC); //Debut du premier ADC } @@ -37,8 +37,13 @@ void MyADC_ActiveIT(ADC_TypeDef * ADC, uint8_t Prio) void ADC1_2_IRQHandler(void) { - if (pFncADC != 0) - (*pFncADC) (ADC1->DR); /* appel indirect de la fonction */ - MyADC_Base_Start(ADC1); - ADC1->SR &= ~ADC_SR_EOC; //Prochaine lecture pouvant �tre effectu�e. + if (ADC1->SR & ADC_SR_EOC) + { + ADC1->SR &= ~ADC_SR_EOC; //Prochaine lecture pouvant �tre effectu�e. + if (pFncADC != 0) + { + (*pFncADC) (ADC1->DR); /* appel indirect de la fonction */ + } + MyADC_Base_Start(ADC1); + } } diff --git a/driver/uart.c b/driver/uart.c index 6e6698a..59f413b 100644 --- a/driver/uart.c +++ b/driver/uart.c @@ -80,7 +80,7 @@ void MyUART_Init(MyUART_Struct_Typedef * UARTStructPtr){ } //TxD Enable, RxD Enable, USART Global Enable UARTStructPtr->UART->CR1 |= (USART_CR1_TE | USART_CR1_RE); - MyUART_ActiveIT(UARTStructPtr->UART,2); + MyUART_ActiveIT(UARTStructPtr->UART,3); } void MyUART_InitGPIO(MyUART_Struct_Typedef * UARTStructPtr) diff --git a/implementation/battery.c b/implementation/battery.c index 3d0f95b..e8c6090 100644 --- a/implementation/battery.c +++ b/implementation/battery.c @@ -13,17 +13,20 @@ void battery(uint32_t data) { return; } + float percentBattery = ((float)data)/MAX_BAT; + if(percentBattery > 1) + { + return; + } oldAdc = data; actualMinutes = rtcBattery.minutes; - float percentBattery = ((float)data)/MAX_BAT; char batteryBar[13]="[__________]"; - char testChar[24]; + char testChar[25]; getGauge(batteryBar, percentBattery); - sprintf(testChar,"[%.2d:%.2d] %s %.2d%%",rtcBattery.hours,rtcBattery.minutes,batteryBar,(int)(percentBattery*100)); - MyUART_SendArray(&uartCool, (uint8_t *)testChar, 24); - + sprintf(testChar,"[%.2d:%.2d] %s %.3d%%",rtcBattery.hours,rtcBattery.minutes,batteryBar,(int)(percentBattery*100)); + MyUART_SendArray(&uartCool, (uint8_t *)testChar, 25); MyUART_Send(&uartCool, '\n'); } @@ -31,10 +34,6 @@ void getGauge(char gauge[], float percent) { int i; percent=percent*10; - if(percent>10) - { - percent = 10.0; - } for(i=(10-percent)+1; i<11; i++) { gauge[i]='#'; @@ -54,7 +53,7 @@ char isClose(uint32_t data, uint32_t compare, int precision) void initBattery(void) { MyADC_Init_Periph(battery); - MyADC_Struct_TypeDef adcBattery = {ADC1,10,cycles41d5}; + MyADC_Struct_TypeDef adcBattery = {ADC1,10,cycles239d5}; MyADC_Init(&adcBattery); MyGPIO_Struct_TypeDef gpioBattery = {GPIOC,0,In_Analog}; MyGPIO_Init(&gpioBattery); diff --git a/implementation/girouette.c b/implementation/girouette.c index a5dfcda..15bd619 100644 --- a/implementation/girouette.c +++ b/implementation/girouette.c @@ -42,6 +42,7 @@ void MyGirouette_Init_IT_Z(uint8_t GPIO_Pin) EXTI->IMR |= (0x01<RTSR|= (0x01<EXTICR[0] &= ~(0x0000000F);// L'interruption « EXTI0 » doit être provoquée par une modification PA0 + NVIC->IP[EXTI0_IRQn] |= (1 << 0x4); //Prio de l'interruption (p.197 manuel reference RM0008 pour ADC1_IRQn) NVIC->ISER[0] |= (1 << (6 & 0x1F)); // Autorisation de l'interruption « EXTI0 » NUMERO 6, } diff --git a/keilproject/Source/Principale.c b/keilproject/Source/Principale.c index a741249..3b33f9d 100644 --- a/keilproject/Source/Principale.c +++ b/keilproject/Source/Principale.c @@ -34,13 +34,12 @@ int main (void) void initImplementation(void) { + initRemote(); MyServo_Init(); MyServo_ChangeAngle(179); - initRemote(); Init_accelerometre(); MyGirouette_Init(TIM4); MyGirouette_Init_IT_Z(0); - testRemote(); MyMotor_Init(); MyMotor_ChangeSpeed(0); MyMotor_ChangeDirection(HORAIRE); diff --git a/keilproject/voilier.uvoptx b/keilproject/voilier.uvoptx index 07bce37..2eb6932 100644 --- a/keilproject/voilier.uvoptx +++ b/keilproject/voilier.uvoptx @@ -125,7 +125,7 @@ 0 DLGDARM - (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=429,109,850,536,0)(121=247,294,668,721,0)(122=875,109,1296,536,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=123,134,717,885,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0) + (1010=752,272,1128,829,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)(100=-1,-1,-1,-1,0)(110=-1,-1,-1,-1,0)(111=-1,-1,-1,-1,0)(1011=-1,-1,-1,-1,0)(180=-1,-1,-1,-1,0)(120=429,109,850,536,0)(121=247,294,668,721,0)(122=875,109,1296,536,0)(123=-1,-1,-1,-1,0)(140=-1,-1,-1,-1,0)(240=-1,-1,-1,-1,0)(190=-1,-1,-1,-1,0)(200=-1,-1,-1,-1,0)(170=-1,-1,-1,-1,0)(130=-1,-1,-1,-1,0)(131=123,134,717,885,0)(132=-1,-1,-1,-1,0)(133=-1,-1,-1,-1,0)(160=-1,-1,-1,-1,0)(161=-1,-1,-1,-1,0)(162=-1,-1,-1,-1,0)(210=-1,-1,-1,-1,0)(211=-1,-1,-1,-1,0)(220=-1,-1,-1,-1,0)(221=-1,-1,-1,-1,0)(230=-1,-1,-1,-1,0)(234=-1,-1,-1,-1,0)(231=-1,-1,-1,-1,0)(232=-1,-1,-1,-1,0)(233=-1,-1,-1,-1,0)(150=-1,-1,-1,-1,0)(151=-1,-1,-1,-1,0) 0 @@ -312,7 +312,7 @@ 0 ST-LINKIII-KEIL_SWO - -U066FFF504955857567155843 -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8000 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM) -WA0 -WE0 -WVCE4 -WS2710 -WM0 -WP2 + -U066FFF504955857567155843 -O206 -SF10000 -C0 -A0 -I0 -HNlocalhost -HP7184 -P1 -N00("ARM CoreSight SW-DP (ARM Core") -D00(1BA01477) -L00(0) -TO131090 -TC10000000 -TT10000000 -TP21 -TDS8000 -TDT0 -TDC1F -TIEFFFFFFFF -TIP8 -FO7 -FD20000000 -FC1000 -FN1 -FF0STM32F10x_128.FLM -FS08000000 -FL020000 -FP0($$Device:STM32F103RB$Flash\STM32F10x_128.FLM) 0 @@ -395,6 +395,12 @@ + + + System Viewer\ADC1 + 35905 + + 1 0 @@ -498,8 +504,8 @@ 0 0 0 - ..\driver\adc.h - adc.h + ..\driver\MyI2C.h + MyI2C.h 0 0 @@ -510,70 +516,22 @@ 0 0 0 - ..\driver\gpio.h - gpio.h - 0 - 0 - - - 2 - 9 - 5 - 0 - 0 - 0 - ..\driver\MyI2C.h - MyI2C.h - 0 - 0 - - - 2 - 10 - 5 - 0 - 0 - 0 ..\driver\MySPI.h MySPI.h 0 0 - - 2 - 11 - 5 - 0 - 0 - 0 - ..\driver\timer.h - timer.h - 0 - 0 - - - 2 - 12 - 5 - 0 - 0 - 0 - ..\driver\uart.h - uart.h - 0 - 0 - - New Group + MesImplementations 1 0 0 0 3 - 13 + 9 1 0 0 @@ -585,7 +543,7 @@ 3 - 14 + 10 1 0 0 @@ -597,7 +555,7 @@ 3 - 15 + 11 1 0 0 @@ -609,7 +567,7 @@ 3 - 16 + 12 1 0 0 @@ -621,7 +579,7 @@ 3 - 17 + 13 1 0 0 @@ -633,7 +591,7 @@ 3 - 18 + 14 1 0 0 @@ -645,9 +603,9 @@ 3 - 19 + 15 1 - 1 + 0 0 0 ..\implementation\girouette.c diff --git a/keilproject/voilier.uvprojx b/keilproject/voilier.uvprojx index 2af6843..6114206 100644 --- a/keilproject/voilier.uvprojx +++ b/keilproject/voilier.uvprojx @@ -10,7 +10,7 @@ Simulé 0x4 ARM-ADS - 5060960::V5.06 update 7 (build 960)::.\ARM_Compiler_5.06u7 + 5060960::V5.06 update 7 (build 960)::.\ARMCC 0 @@ -418,16 +418,6 @@ 1 ..\driver\uart.c - - adc.h - 5 - ..\driver\adc.h - - - gpio.h - 5 - ..\driver\gpio.h - MyI2C.h 5 @@ -438,20 +428,10 @@ 5 ..\driver\MySPI.h - - timer.h - 5 - ..\driver\timer.h - - - uart.h - 5 - ..\driver\uart.h - - New Group + MesImplementations accelerometer.c @@ -910,16 +890,6 @@ 1 ..\driver\uart.c - - adc.h - 5 - ..\driver\adc.h - - - gpio.h - 5 - ..\driver\gpio.h - MyI2C.h 5 @@ -930,20 +900,10 @@ 5 ..\driver\MySPI.h - - timer.h - 5 - ..\driver\timer.h - - - uart.h - 5 - ..\driver\uart.h - - New Group + MesImplementations accelerometer.c