mirror of
https://github.com/hathach/tinyusb.git
synced 2025-01-31 05:52:55 +08:00
change DEBUG optimization option from O0 to Og
add uart write to board test example
This commit is contained in:
parent
90b6b5d137
commit
558b4dbde3
@ -42,6 +42,8 @@ enum {
|
||||
BLINK_UNPRESSED = 1000
|
||||
};
|
||||
|
||||
#define HELLO_STR "Hello from TinyUSB\n"
|
||||
|
||||
int main(void)
|
||||
{
|
||||
board_init();
|
||||
@ -49,13 +51,20 @@ int main(void)
|
||||
uint32_t start_ms = 0;
|
||||
bool led_state = false;
|
||||
|
||||
|
||||
while (1)
|
||||
{
|
||||
uint32_t interval_ms = board_button_read() ? BLINK_PRESSED : BLINK_UNPRESSED;
|
||||
|
||||
// uart echo
|
||||
// uint8_t ch;
|
||||
// if ( board_uart_read(&ch, 1) ) board_uart_write(&ch, 1);
|
||||
|
||||
// Blink every interval ms
|
||||
if ( !(board_millis() - start_ms < interval_ms) )
|
||||
{
|
||||
board_uart_write(HELLO_STR, strlen(HELLO_STR));
|
||||
|
||||
start_ms = board_millis();
|
||||
|
||||
board_led_write(led_state);
|
||||
|
@ -79,7 +79,7 @@ CFLAGS += \
|
||||
|
||||
# Debugging/Optimization
|
||||
ifeq ($(DEBUG), 1)
|
||||
CFLAGS += -O0 -ggdb -DCFG_TUSB_DEBUG=1
|
||||
CFLAGS += -Og -ggdb -DCFG_TUSB_DEBUG=2
|
||||
else
|
||||
ifneq ($(BOARD), spresense)
|
||||
CFLAGS += -flto -Os
|
||||
|
@ -107,10 +107,10 @@ static inline void board_delay(uint32_t ms)
|
||||
}
|
||||
}
|
||||
|
||||
static inline int8_t board_uart_getchar(void)
|
||||
static inline int board_uart_getchar(void)
|
||||
{
|
||||
uint8_t c;
|
||||
return board_uart_read(&c, 1) ? c : (-1);
|
||||
return board_uart_read(&c, 1) ? (int) c : (-1);
|
||||
}
|
||||
|
||||
static inline int board_uart_putchar(uint8_t c)
|
||||
|
@ -156,6 +156,7 @@ int board_uart_read(uint8_t* buf, int len)
|
||||
(void) buf;
|
||||
(void) len;
|
||||
return 0;
|
||||
// return NRFX_SUCCESS == nrfx_uart_rx(&_uart_id, buf, (size_t) len) ? len : 0;
|
||||
}
|
||||
|
||||
int board_uart_write(void const * buf, int len)
|
||||
|
Loading…
x
Reference in New Issue
Block a user