mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-16 05:42:56 +00:00
update uart read for lpc18/43 for testing
This commit is contained in:
parent
b00529e287
commit
a6001fc8f2
@ -56,7 +56,7 @@ int main(void)
|
|||||||
{
|
{
|
||||||
uint32_t interval_ms = board_button_read() ? BLINK_PRESSED : BLINK_UNPRESSED;
|
uint32_t interval_ms = board_button_read() ? BLINK_PRESSED : BLINK_UNPRESSED;
|
||||||
|
|
||||||
// Blink every interval ms
|
// Blink and print every interval ms
|
||||||
if ( !(board_millis() - start_ms < interval_ms) )
|
if ( !(board_millis() - start_ms < interval_ms) )
|
||||||
{
|
{
|
||||||
board_uart_write(HELLO_STR, strlen(HELLO_STR));
|
board_uart_write(HELLO_STR, strlen(HELLO_STR));
|
||||||
@ -66,6 +66,13 @@ int main(void)
|
|||||||
board_led_write(led_state);
|
board_led_write(led_state);
|
||||||
led_state = 1 - led_state; // toggle
|
led_state = 1 - led_state; // toggle
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// echo
|
||||||
|
uint8_t ch;
|
||||||
|
if ( board_uart_read(&ch, 1) )
|
||||||
|
{
|
||||||
|
board_uart_write(&ch, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -103,7 +103,8 @@ TU_ATTR_USED int sys_write (int fhdl, const void *buf, size_t count)
|
|||||||
TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count)
|
TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count)
|
||||||
{
|
{
|
||||||
(void) fhdl;
|
(void) fhdl;
|
||||||
return SEGGER_RTT_Read(0, buf, count);
|
int rd = (int) SEGGER_RTT_Read(0, buf, count);
|
||||||
|
return (rd > 0) ? rd : -1;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -143,7 +144,8 @@ TU_ATTR_USED int sys_write (int fhdl, const void *buf, size_t count)
|
|||||||
TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count)
|
TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count)
|
||||||
{
|
{
|
||||||
(void) fhdl;
|
(void) fhdl;
|
||||||
return board_uart_read((uint8_t*) buf, (int) count);
|
int rd = board_uart_read((uint8_t*) buf, (int) count);
|
||||||
|
return (rd > 0) ? rd : -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -66,9 +66,11 @@ void board_led_write(bool state);
|
|||||||
uint32_t board_button_read(void);
|
uint32_t board_button_read(void);
|
||||||
|
|
||||||
// Get characters from UART
|
// Get characters from UART
|
||||||
|
// Return number of read bytes
|
||||||
int board_uart_read(uint8_t* buf, int len);
|
int board_uart_read(uint8_t* buf, int len);
|
||||||
|
|
||||||
// Send characters to UART
|
// Send characters to UART
|
||||||
|
// Return number of sent bytes
|
||||||
int board_uart_write(void const * buf, int len);
|
int board_uart_write(void const * buf, int len);
|
||||||
|
|
||||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||||
|
@ -272,9 +272,7 @@ uint32_t board_button_read(void)
|
|||||||
|
|
||||||
int board_uart_read(uint8_t* buf, int len)
|
int board_uart_read(uint8_t* buf, int len)
|
||||||
{
|
{
|
||||||
//return UART_ReceiveByte(BOARD_UART_DEV);
|
return Chip_UART_Read(UART_DEV, buf, len);
|
||||||
(void) buf; (void) len;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int board_uart_write(void const * buf, int len)
|
int board_uart_write(void const * buf, int len)
|
||||||
|
@ -141,9 +141,7 @@ uint32_t board_button_read(void)
|
|||||||
|
|
||||||
int board_uart_read(uint8_t* buf, int len)
|
int board_uart_read(uint8_t* buf, int len)
|
||||||
{
|
{
|
||||||
//return UART_ReceiveByte(BOARD_UART_PORT);
|
return Chip_UART_Read(UART_DEV, buf, len);
|
||||||
(void) buf; (void) len;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int board_uart_write(void const * buf, int len)
|
int board_uart_write(void const * buf, int len)
|
||||||
|
@ -52,7 +52,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// VBUS enable pin and its active state
|
// VBUS enable pin and its active state
|
||||||
// #define PIO_USB_VBUSEN_PIN 22
|
#define PIO_USB_VBUSEN_PIN 22
|
||||||
|
|
||||||
#ifndef PIO_USB_VBUSEN_STATE
|
#ifndef PIO_USB_VBUSEN_STATE
|
||||||
#define PIO_USB_VBUSEN_STATE 1
|
#define PIO_USB_VBUSEN_STATE 1
|
||||||
|
Loading…
x
Reference in New Issue
Block a user