65 lines
984 B
C++
65 lines
984 B
C++
/*
|
|
* serial.cpp
|
|
*
|
|
* Created on: Jun 23, 2023
|
|
* Author: Carst
|
|
*/
|
|
|
|
#include <cstdint>
|
|
#include "stm32g0xx_ll_lpuart.h"
|
|
|
|
extern "C" int _write(int file, char *ptr, int len)
|
|
{
|
|
(void)file;
|
|
int DataIdx;
|
|
|
|
for (DataIdx = 0; DataIdx < len; DataIdx++)
|
|
{
|
|
if(LL_LPUART_IsActiveFlag_TXE_TXFNF(LPUART1))
|
|
{
|
|
LL_LPUART_TransmitData8(LPUART1, static_cast<std::uint8_t>(*ptr++));
|
|
}
|
|
}
|
|
return len;
|
|
}
|
|
|
|
extern "C" int _close(int file)
|
|
{
|
|
(void)file;
|
|
return -1;
|
|
}
|
|
|
|
extern "C" int _lseek(int file, int ptr, int dir)
|
|
{
|
|
(void)file;
|
|
(void)ptr;
|
|
(void)dir;
|
|
return 0;
|
|
}
|
|
|
|
extern "C" int _read(int file, char *ptr, int len)
|
|
{
|
|
#if 0
|
|
(void)file;
|
|
int DataIdx;
|
|
|
|
for (DataIdx = 0; DataIdx < len; DataIdx++)
|
|
{
|
|
*ptr++ = __io_getchar();
|
|
}
|
|
|
|
return len;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
}
|
|
|
|
extern "C" void USART3_4_LPUART1_IRQHandler(void)
|
|
{
|
|
if(LL_LPUART_IsActiveFlag_RXNE_RXFNE(LPUART1))
|
|
{
|
|
|
|
}
|
|
}
|
|
|