52 lines
1.7 KiB
C
52 lines
1.7 KiB
C
#include "emetteur_rf.h"
|
|
|
|
void emetteur_rf_init(void){
|
|
|
|
LL_USART_InitTypeDef My_LL_Usart_Init_Struct;
|
|
|
|
|
|
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1);
|
|
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
|
|
LL_GPIO_InitTypeDef tx;
|
|
tx.Mode = LL_GPIO_MODE_ALTERNATE;
|
|
tx.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
tx.Speed = LL_GPIO_SPEED_FREQ_LOW;
|
|
tx.Pin = LL_GPIO_PIN_9;
|
|
LL_GPIO_Init(GPIOA, &tx);
|
|
|
|
LL_GPIO_InitTypeDef pa11_init_conf;
|
|
pa11_init_conf.Mode = LL_GPIO_MODE_OUTPUT;
|
|
pa11_init_conf.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
|
|
pa11_init_conf.Speed = LL_GPIO_SPEED_FREQ_LOW;
|
|
pa11_init_conf.Pin = LL_GPIO_PIN_11;
|
|
LL_GPIO_Init(GPIOA, &pa11_init_conf);
|
|
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_GPIOA);
|
|
|
|
|
|
My_LL_Usart_Init_Struct.BaudRate = 9600;
|
|
My_LL_Usart_Init_Struct.DataWidth = LL_USART_DATAWIDTH_8B ;
|
|
My_LL_Usart_Init_Struct.HardwareFlowControl = LL_USART_HWCONTROL_NONE;
|
|
My_LL_Usart_Init_Struct.OverSampling = LL_USART_OVERSAMPLING_16;
|
|
My_LL_Usart_Init_Struct.Parity = LL_USART_PARITY_NONE;
|
|
My_LL_Usart_Init_Struct.StopBits = LL_USART_STOPBITS_1;
|
|
My_LL_Usart_Init_Struct.TransferDirection = LL_USART_DIRECTION_TX_RX ;
|
|
|
|
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){
|
|
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);
|
|
}
|
|
}
|