refractor remove board_uart_send & board_uart_recv from board API
This commit is contained in:
@@ -121,7 +121,6 @@ void board_init(void);
|
||||
|
||||
void board_leds(uint32_t on_mask, uint32_t off_mask);
|
||||
|
||||
uint32_t board_uart_send(uint8_t *buffer, uint32_t length);
|
||||
uint8_t board_uart_getchar(void);
|
||||
void board_uart_putchar(uint8_t c);
|
||||
|
||||
|
||||
@@ -118,16 +118,6 @@ void board_leds(uint32_t on_mask, uint32_t off_mask)
|
||||
// UART
|
||||
//--------------------------------------------------------------------+
|
||||
#if CFG_UART_ENABLE
|
||||
uint32_t board_uart_send(uint8_t *buffer, uint32_t length)
|
||||
{
|
||||
return UART_Send(BOARD_UART_PORT, buffer, length, BLOCKING);
|
||||
}
|
||||
|
||||
uint32_t board_uart_recv(uint8_t *buffer, uint32_t length)
|
||||
{
|
||||
return UART_Receive(BOARD_UART_PORT, buffer, length, BLOCKING);
|
||||
}
|
||||
|
||||
uint8_t board_uart_getchar(void)
|
||||
{
|
||||
return UART_ReceiveByte(BOARD_UART_PORT);
|
||||
|
||||
@@ -112,14 +112,10 @@ void board_leds(uint32_t on_mask, uint32_t off_mask)
|
||||
// UART
|
||||
//--------------------------------------------------------------------+
|
||||
#if CFG_UART_ENABLE
|
||||
uint32_t board_uart_send(uint8_t *buffer, uint32_t length)
|
||||
{
|
||||
return UART_Send(BOARD_UART_PORT, buffer, length, BLOCKING);
|
||||
}
|
||||
|
||||
void board_uart_putchar(uint8_t c)
|
||||
{
|
||||
UART_SendByte(BOARD_UART_PORT, c);
|
||||
UART_Send(BOARD_UART_PORT, &c, 1, BLOCKING);
|
||||
}
|
||||
|
||||
uint8_t board_uart_getchar(void)
|
||||
|
||||
@@ -109,16 +109,6 @@ void board_leds(uint32_t on_mask, uint32_t off_mask)
|
||||
//--------------------------------------------------------------------+
|
||||
// UART
|
||||
//--------------------------------------------------------------------+
|
||||
uint32_t board_uart_send(uint8_t *p_buffer, uint32_t length)
|
||||
{
|
||||
return UART_Send(BOARD_UART_PORT, p_buffer, length, BLOCKING);
|
||||
}
|
||||
|
||||
uint32_t board_uart_recv(uint8_t *p_buffer, uint32_t length)
|
||||
{
|
||||
return UART_Receive(BOARD_UART_PORT, p_buffer, length, BLOCKING);
|
||||
}
|
||||
|
||||
uint8_t board_uart_getchar(void)
|
||||
{
|
||||
return UART_ReceiveByte(BOARD_UART_PORT);
|
||||
|
||||
@@ -42,8 +42,11 @@
|
||||
|
||||
#if CFG_PRINTF_TARGET == PRINTF_TARGET_UART
|
||||
#define retarget_getchar() board_uart_getchar()
|
||||
#define retarget_putchar(c) board_uart_putchar(c);
|
||||
#elif CFG_PRINTF_TARGET == PRINTF_TARGET_SWO
|
||||
volatile int32_t ITM_RxBuffer; // keil variable to read from SWO
|
||||
#define retarget_getchar() ITM_ReceiveChar()
|
||||
#define retarget_putchar(c) ITM_SendChar(c)
|
||||
#else
|
||||
#error Target is not implemented yet
|
||||
#endif
|
||||
@@ -52,6 +55,11 @@
|
||||
// LPCXPRESSO / RED SUITE
|
||||
//--------------------------------------------------------------------+
|
||||
#if defined __CODE_RED
|
||||
|
||||
#if CFG_PRINTF_TARGET == PRINTF_TARGET_SWO
|
||||
#error author does not know how to retarget SWO with lpcxpresso/red-suite
|
||||
#endif
|
||||
|
||||
// Called by bottom level of printf routine within RedLib C library to write
|
||||
// a character. With the default semihosting stub, this would write the character
|
||||
// to the debugger console window . But this version writes
|
||||
@@ -60,22 +68,17 @@ int __sys_write (int iFileHandle, char *buf, int length)
|
||||
{
|
||||
(void) iFileHandle;
|
||||
|
||||
#if CFG_PRINTF_TARGET == PRINTF_TARGET_UART
|
||||
int ret = length;
|
||||
for (int i=0; i<length; i++)
|
||||
{
|
||||
if (buf[i] == '\n')
|
||||
{
|
||||
board_uart_putchar('\r');
|
||||
retarget_putchar('\r');
|
||||
ret++;
|
||||
}
|
||||
board_uart_putchar( buf[i] );
|
||||
retarget_putchar( buf[i] );
|
||||
}
|
||||
return ret;
|
||||
#elif CFG_PRINTF_TARGET == PRINTF_TARGET_SWO
|
||||
#error author does not know how to retarget SWO with lpcxpresso/red-suite
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// Called by bottom level of scanf routine within RedLib C library to read
|
||||
@@ -92,17 +95,17 @@ int __sys_readc (void)
|
||||
//--------------------------------------------------------------------+
|
||||
#elif defined __CC_ARM // keil
|
||||
|
||||
#if CFG_PRINTF_TARGET == PRINTF_TARGET_UART
|
||||
#define retarget_putc(c) board_uart_send( (uint8_t*) &c, 1);
|
||||
#elif CFG_PRINTF_TARGET == PRINTF_TARGET_SWO
|
||||
volatile int32_t ITM_RxBuffer;
|
||||
#define retarget_putc(c) ITM_SendChar(c)
|
||||
#endif
|
||||
|
||||
struct __FILE {
|
||||
uint32_t handle;
|
||||
};
|
||||
|
||||
void _ttywrch(int ch)
|
||||
{
|
||||
if ( ch == '\n' ) retarget_putchar('\r');
|
||||
|
||||
retarget_putchar(ch);
|
||||
}
|
||||
|
||||
int fgetc(FILE *f)
|
||||
{
|
||||
return retarget_getchar();
|
||||
@@ -110,29 +113,10 @@ int fgetc(FILE *f)
|
||||
|
||||
int fputc(int ch, FILE *f)
|
||||
{
|
||||
if (ch == '\n')
|
||||
{
|
||||
uint8_t carry = '\r';
|
||||
retarget_putc(carry);
|
||||
}
|
||||
|
||||
retarget_putc(ch);
|
||||
|
||||
_ttywrch(ch)
|
||||
return ch;
|
||||
}
|
||||
|
||||
void _ttywrch(int ch)
|
||||
{
|
||||
if ( ch == '\n' )
|
||||
{
|
||||
uint8_t carry = '\r';
|
||||
retarget_putc(carry);
|
||||
}
|
||||
|
||||
retarget_putc(ch);
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
// IAR
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
Reference in New Issue
Block a user