Compare commits

...

2 commits

Author SHA1 Message Date
Jasper Güldenstein
1b3ff2c0b6 Merge branch 'master' of https://git.etud.insa-toulouse.fr/guldenst/projet_voilier 2020-11-14 16:22:28 +01:00
Jasper Güldenstein
83cccf5668 emmeteur send bytes foncotion 2020-11-14 16:20:20 +01:00
2 changed files with 13 additions and 12 deletions

View file

@ -1,4 +1,7 @@
#include "emetteur_rf.h"
#include <stdio.h>
char buf[100];
void emetteur_rf_init(void){
@ -34,22 +37,19 @@ void emetteur_rf_init(void){
LL_USART_Init(USART1,&My_LL_Usart_Init_Struct);
LL_USART_Enable(USART1);
/*int periph_speed;
if (uart_port==USART1) periph_speed = 36000000;
if (uart_port==USART2) periph_speed = 72000000;
if (uart_port==USART3) periph_speed = 72000000;
LL_USART_SetBaudRate(uart_port, periph_speed, baudrate);
*/}
}
void emetteur_send_bytes(char* buf, int len){
LL_GPIO_SetOutputPin(GPIOA,LL_GPIO_PIN_11);
for(int i = 0; i < len; i++){
LL_GPIO_SetOutputPin(GPIOA,LL_GPIO_PIN_11);
LL_USART_TransmitData8(USART1, buf[i]);
while(!LL_USART_IsActiveFlag_TXE(USART1));
LL_GPIO_ResetOutputPin(GPIOA,LL_GPIO_PIN_11);
}
LL_GPIO_ResetOutputPin(GPIOA,LL_GPIO_PIN_11);
}
void emetteur_send_message(int rouli_bon, int alimentation_bon, float angle_voile){
int len = sprintf(buf, "Alim bon: %d, Rouli bon: %d, Angle de voile: %2f\r\n", alimentation_bon, rouli_bon, angle_voile);
emetteur_send_bytes(buf, len);
}

View file

@ -9,6 +9,7 @@
void emetteur_rf_init(void);
void emetteur_send_bytes(char* buf, int len);
void emetteur_send_message(int rouli_bon, int alimentation_bon, float angle_voile);