emmeteur send bytes foncotion

This commit is contained in:
Jasper Güldenstein 2020-11-14 16:20:20 +01:00
parent c91f969dcf
commit 83cccf5668
2 changed files with 17 additions and 13 deletions

View file

@ -1,4 +1,7 @@
#include "emetteur_rf.h"
#include <stdio.h>
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);
}

View file

@ -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);