mirror of
https://github.com/Noltari/pico-uart-bridge.git
synced 2025-05-14 08:12:20 +00:00
uart-bridge: code refactor
Avoid lines with more than 80 characters. Fix indentation (tabs = 8 spaces). Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
This commit is contained in:
parent
f46d93bb54
commit
85383842d5
1 changed files with 44 additions and 40 deletions
|
@ -110,22 +110,15 @@ int update_uart_cfg(void)
|
||||||
return updated;
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
void core1_entry(void)
|
void usb_cdc_process(void)
|
||||||
{
|
{
|
||||||
tusb_init();
|
|
||||||
|
|
||||||
while (1) {
|
|
||||||
tud_task();
|
|
||||||
|
|
||||||
if (tud_cdc_connected()) {
|
|
||||||
uint32_t count;
|
uint32_t count;
|
||||||
|
uint32_t len;
|
||||||
|
|
||||||
tud_cdc_get_line_coding(&CDC_LC);
|
tud_cdc_get_line_coding(&CDC_LC);
|
||||||
|
|
||||||
/* Read bytes from USB */
|
/* Read bytes from USB */
|
||||||
if (tud_cdc_available()) {
|
if (tud_cdc_available()) {
|
||||||
uint32_t len;
|
|
||||||
|
|
||||||
mutex_enter_blocking(&USB_MTX);
|
mutex_enter_blocking(&USB_MTX);
|
||||||
|
|
||||||
len = MIN(tud_cdc_available(), BUFFER_SIZE - USB_POS);
|
len = MIN(tud_cdc_available(), BUFFER_SIZE - USB_POS);
|
||||||
|
@ -149,7 +142,17 @@ void core1_entry(void)
|
||||||
|
|
||||||
mutex_exit(&UART_MTX);
|
mutex_exit(&UART_MTX);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void core1_entry(void)
|
||||||
|
{
|
||||||
|
tusb_init();
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
tud_task();
|
||||||
|
|
||||||
|
if (tud_cdc_connected()) {
|
||||||
|
usb_cdc_process();
|
||||||
gpio_put(LED_PIN, 1);
|
gpio_put(LED_PIN, 1);
|
||||||
} else {
|
} else {
|
||||||
gpio_put(LED_PIN, 0);
|
gpio_put(LED_PIN, 0);
|
||||||
|
@ -187,7 +190,8 @@ int main(void)
|
||||||
if (uart_is_readable(UART_ID)) {
|
if (uart_is_readable(UART_ID)) {
|
||||||
mutex_enter_blocking(&UART_MTX);
|
mutex_enter_blocking(&UART_MTX);
|
||||||
|
|
||||||
while (uart_is_readable(UART_ID) && UART_POS < BUFFER_SIZE) {
|
while (uart_is_readable(UART_ID) &&
|
||||||
|
UART_POS < BUFFER_SIZE) {
|
||||||
UART_BUFFER[UART_POS] = uart_getc(UART_ID);
|
UART_BUFFER[UART_POS] = uart_getc(UART_ID);
|
||||||
UART_POS++;
|
UART_POS++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue