From 83cccf56689ea02b4c4f82b6f6b15e9b5025bd50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jasper=20G=C3=BCldenstein?= Date: Sat, 14 Nov 2020 16:20:20 +0100 Subject: [PATCH] emmeteur send bytes foncotion --- keil_project/Services/emetteur_rf.c | 27 +++++++++++++++------------ keil_project/Services/emetteur_rf.h | 3 ++- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/keil_project/Services/emetteur_rf.c b/keil_project/Services/emetteur_rf.c index 31e5a1c..db7b130 100644 --- a/keil_project/Services/emetteur_rf.c +++ b/keil_project/Services/emetteur_rf.c @@ -1,4 +1,7 @@ #include "emetteur_rf.h" +#include + +char buf[100]; void emetteur_rf_init(void){ @@ -34,19 +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(USART_TypeDef * uart_port,char* buf, int len){ +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(uart_port, buf[i]); - while(!LL_USART_IsActiveFlag_TXE(uart_port)); - LL_GPIO_ResetOutputPin(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); +} + +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); } diff --git a/keil_project/Services/emetteur_rf.h b/keil_project/Services/emetteur_rf.h index 787b8fb..c9c47b8 100644 --- a/keil_project/Services/emetteur_rf.h +++ b/keil_project/Services/emetteur_rf.h @@ -7,7 +7,8 @@ #include "stm32f1xx_ll_gpio.h" void emetteur_rf_init(void); -void emetteur_send_bytes(USART_TypeDef * uart_port,char* buf, int len); +void emetteur_send_bytes(char* buf, int len); +void emetteur_send_message(int rouli_bon, int alimentation_bon, float angle_voile);