diff --git a/Services/Batterie.c b/Services/Batterie.c index 387a479..c94cd05 100644 --- a/Services/Batterie.c +++ b/Services/Batterie.c @@ -5,9 +5,7 @@ #include float d; -short v; int p; -char test; void MyBatterie_Init(void){ MyGPIO_Init(GPIOC,4,In_Analog); // Init PORT pour recevoir tension @@ -15,26 +13,20 @@ void MyBatterie_Init(void){ MyADC_Init(ADC1,14); // Init ADC channel 14 pour convertir valeur MyADC_ActiveIT(ADC1,15,&handler_ADC); // Init interruption quand conversion finie - My_USART_Init(USART2); // Init USART pour envoyer batterie - - My_USART_Init(USART1); - MyUSART_ActiveIT(USART1,10,&handler); + My_USART_Init(USART1); // Init USART pour envoyer batterie start_conversion(ADC1); // Premiere conversion } void handler_ADC (void){ - d = 1044;//ADC1->DR &~ (0xF << 12); // Retourne valeur numérique + d = ADC1->DR &~ (0xF << 12); // Retourne valeur numérique d = d*3.3/4096; d = d*13*100/12; - p = (int) d; - send_USART(USART2,(p/10) + '0'); // Envoie le chiffre des dizaines - send_USART(USART2,(p%10) + '0'); // Envoie le chiffre des unités - send_USART(USART2,'%'); - //start_conversion(ADC1); // Recommence la conversion pour le prochain -} - -void handler(void){ - test = USART1->DR; - test = test + 1; + if ((p%10 > (int)d%10+2) || (p%10 < (int)d%10-2)){ + p = (int) d; + send_USART(USART1,(p/10) + '0'); // Envoie le chiffre des dizaines + send_USART(USART1,(p%10) + '0'); // Envoie le chiffre des unités + send_USART(USART1,'%'); + } + start_conversion(ADC1); // Recommence la conversion pour le prochain } \ No newline at end of file diff --git a/Services/Batterie.h b/Services/Batterie.h index f3e0dfb..059636f 100644 --- a/Services/Batterie.h +++ b/Services/Batterie.h @@ -3,6 +3,5 @@ void MyBatterie_Init(void); void handler_ADC(void); -void handler(void); #endif \ No newline at end of file diff --git a/readme.txt b/readme.txt index b68695d..6c94b46 100644 --- a/readme.txt +++ b/readme.txt @@ -1,5 +1,3 @@ -Driver SPI normalement bon, roulis a tester - Port map carte nucléo : Plateau : @@ -23,4 +21,8 @@ prio interruption timer2 : 0 Batterie : ?PC4 : Floating input (ADC12 CHANNEL14) -!PA2 : Alternate output push pull (UART2 TX) \ No newline at end of file +!PA9 : Alternate output push pull (UART1 TX) +prio interruption ADC : 15 + +Fonctionnement de la batterie okay, il faut voir quand est-ce qu'on recommence la conversion ou quand est-ce qu'on envoie la batterie. +Il faudrait vérifier le driver SPI qui ne fonctionne pas. \ No newline at end of file