67 lines
1.6 KiB
C
67 lines
1.6 KiB
C
#include "usart_user.h"
|
|
#include "main.h"
|
|
|
|
|
|
int fputc(int ch, FILE *f)
|
|
{
|
|
LL_USART_TransmitData8(DEBUG_USART,(uint8_t) ch);
|
|
while(LL_USART_IsActiveFlag_TXE(DEBUG_USART)==RESET){}
|
|
|
|
return ch;
|
|
}
|
|
|
|
void UsartUserConfig(void)
|
|
{
|
|
|
|
// LL_USART_ReceiveData8(DEBUG_USART);
|
|
// LL_USART_ClearFlag_IDLE(DEBUG_USART);
|
|
// LL_USART_EnableIT_RXNE(DEBUG_USART);
|
|
// LL_USART_EnableIT_IDLE(DEBUG_USART);
|
|
|
|
LL_USART_ReceiveData8(LORA_USART);
|
|
LL_USART_ClearFlag_IDLE(LORA_USART);
|
|
LL_USART_EnableIT_RXNE(LORA_USART);
|
|
LL_USART_EnableIT_IDLE(LORA_USART);
|
|
|
|
LL_USART_ReceiveData8(CO2_USART);
|
|
LL_USART_ClearFlag_IDLE(CO2_USART);
|
|
LL_USART_EnableIT_RXNE(CO2_USART);
|
|
LL_USART_EnableIT_IDLE(CO2_USART);
|
|
|
|
LL_USART_ReceiveData8(PM25_USART);
|
|
LL_USART_ClearFlag_IDLE(PM25_USART);
|
|
LL_USART_EnableIT_RXNE(PM25_USART);
|
|
LL_USART_EnableIT_IDLE(PM25_USART);
|
|
|
|
LL_USART_ReceiveData8(CH2O_USART);
|
|
LL_USART_ClearFlag_IDLE(CH2O_USART);
|
|
LL_USART_EnableIT_RXNE(CH2O_USART);
|
|
LL_USART_EnableIT_IDLE(CH2O_USART);
|
|
|
|
LL_USART_ReceiveData8(NH3_USART);
|
|
LL_USART_ClearFlag_IDLE(NH3_USART);
|
|
LL_USART_EnableIT_RXNE(NH3_USART);
|
|
LL_USART_EnableIT_IDLE(NH3_USART);
|
|
|
|
LL_USART_ReceiveData8(H2S_USART);
|
|
LL_USART_ClearFlag_IDLE(H2S_USART);
|
|
LL_USART_EnableIT_RXNE(H2S_USART);
|
|
LL_USART_EnableIT_IDLE(H2S_USART);
|
|
|
|
}
|
|
|
|
void UsartxSendDataByte(USART_TypeDef* USARTx, uint16_t Data)
|
|
{
|
|
LL_USART_TransmitData8(USARTx, Data);
|
|
while(LL_USART_IsActiveFlag_TXE(USARTx) == RESET);
|
|
}
|
|
|
|
void UsartxSendDataStr(USART_TypeDef* USARTx, const uint8_t *Data, uint32_t len)
|
|
{
|
|
while(len--)
|
|
{
|
|
LL_USART_TransmitData8(USARTx, *(Data++));
|
|
while(LL_USART_IsActiveFlag_TXE(USARTx) == RESET);
|
|
}
|
|
}
|