36 lines
1.1 KiB
C
36 lines
1.1 KiB
C
#include "MyUSART.h"
|
|
#include "stm32f1xx_ll_bus.h" // Pour l'activation des horloges
|
|
#include "stm32f1xx_ll_usart.h"
|
|
|
|
|
|
void MyUSART_Conf(USART_TypeDef * USART, int TransferDir)
|
|
{
|
|
LL_USART_InitTypeDef My_LL_USART_Init_Struct;
|
|
LL_USART_ClockInitTypeDef My_LL_USART_Clock;
|
|
|
|
// Validation horloge locale
|
|
if (USART==USART1) LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_USART1);
|
|
else if (USART==USART2) LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART2);
|
|
else LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_USART3);
|
|
|
|
//Activation clk de l'USART en entrée et sortie
|
|
LL_USART_ClockStructInit(&My_LL_USART_Clock);
|
|
My_LL_USART_Clock.ClockOutput = LL_USART_CLOCK_ENABLE;
|
|
LL_USART_ClockInit(USART, &My_LL_USART_Clock);
|
|
|
|
//Initialisation de l'USART
|
|
LL_USART_StructInit(&My_LL_USART_Init_Struct);
|
|
|
|
//My_LL_USART_Init_Struct.TransferDirection = TransferDir;
|
|
|
|
LL_USART_Init(USART, &My_LL_USART_Init_Struct);
|
|
|
|
LL_USART_Enable(USART);
|
|
}
|
|
|
|
|
|
void MyUSART_Transmit_Data_8b(USART_TypeDef * USART, char data)
|
|
{
|
|
LL_USART_TransmitData8(USART, data);
|
|
while (LL_USART_IsActiveFlag_TC(USART) != 1){/*Attendre la fin de l'envoi*/}
|
|
}
|