mirror of
https://github.com/hathach/tinyusb.git
synced 2025-03-26 08:37:16 +00:00
add initial support for output using ITM via SWO (not tested though)
This commit is contained in:
parent
aae51e985f
commit
10009cba99
@ -56,6 +56,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include "common/binary.h" // This file is too good to not use
|
||||||
|
|
||||||
#define BOARD_AT86RF2XX 0
|
#define BOARD_AT86RF2XX 0
|
||||||
#define BOARD_LPCXPRESSO1347 1
|
#define BOARD_LPCXPRESSO1347 1
|
||||||
|
@ -52,6 +52,11 @@ void board_init(void)
|
|||||||
#if CFG_UART_ENABLE
|
#if CFG_UART_ENABLE
|
||||||
UARTInit(CFG_UART_BAUDRATE);
|
UARTInit(CFG_UART_BAUDRATE);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if CFG_PRINTF_TARGET == PRINTF_TARGET_SWO
|
||||||
|
LPC_IOCON->PIO0_9 &= ~0x07; /* UART I/O config */
|
||||||
|
LPC_IOCON->PIO0_9 |= 0x03; /* UART RXD */
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
@ -49,11 +49,6 @@
|
|||||||
#include "lpc43xx_i2s.h"
|
#include "lpc43xx_i2s.h"
|
||||||
#include "lpc43xx_emc.h"
|
#include "lpc43xx_emc.h"
|
||||||
|
|
||||||
// TODO abstract later: n-th Bit
|
|
||||||
#ifndef BIT_
|
|
||||||
#define BIT_(n) (1 << (n))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define BOARD_MAX_LEDS 2
|
#define BOARD_MAX_LEDS 2
|
||||||
const static struct {
|
const static struct {
|
||||||
uint8_t port;
|
uint8_t port;
|
||||||
|
@ -48,7 +48,20 @@
|
|||||||
int __sys_write (int iFileHandle, char *pcBuffer, int iLength)
|
int __sys_write (int iFileHandle, char *pcBuffer, int iLength)
|
||||||
{
|
{
|
||||||
(void) iFileHandle;
|
(void) iFileHandle;
|
||||||
|
|
||||||
|
#if CFG_PRINTF_TARGET == PRINTF_TARGET_UART
|
||||||
return board_uart_send((uint8_t*)pcBuffer, iLength);
|
return board_uart_send((uint8_t*)pcBuffer, iLength);
|
||||||
|
#elif CFG_PRINTF_TARGET == PRINTF_TARGET_SWO
|
||||||
|
uint32_t i;
|
||||||
|
for (i = 0; i<iLength; i++)
|
||||||
|
{
|
||||||
|
ITM_SendChar(pcBuffer[i]); // print each character
|
||||||
|
}
|
||||||
|
return iLength;
|
||||||
|
#else
|
||||||
|
#error Thach, did you forget something
|
||||||
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called by bottom level of scanf routine within RedLib C library to read
|
// Called by bottom level of scanf routine within RedLib C library to read
|
||||||
@ -58,7 +71,15 @@ int __sys_write (int iFileHandle, char *pcBuffer, int iLength)
|
|||||||
int __sys_readc (void)
|
int __sys_readc (void)
|
||||||
{
|
{
|
||||||
uint8_t c;
|
uint8_t c;
|
||||||
|
|
||||||
|
#if CFG_PRINTF_TARGET == PRINTF_TARGET_UART
|
||||||
board_uart_recv(&c, 1);
|
board_uart_recv(&c, 1);
|
||||||
|
#elif CFG_PRINTF_TARGET == PRINTF_TARGET_SWO
|
||||||
|
c = ITM_ReceiveChar();
|
||||||
|
#else
|
||||||
|
#error Thach, did you forget something
|
||||||
|
#endif
|
||||||
|
|
||||||
return (int)c;
|
return (int)c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user