void __putchar(const char c) { #if defined(CFG_USB) && defined(CFG_PRINTF_USBCDC) if (usb_isConfigured()) { while(usb_cdc_isConnected() && !usb_cdc_putc(c) ) // blocking { ASM("nop"); } } #endif #ifdef CFG_PRINTF_UART uartSendByte(c); #endif /* Handle PRINTF_DEBUG redirection for Crossworks for ARM */ #ifdef __CROSSWORKS_ARM #ifdef CFG_PRINTF_DEBUG #if defined CFG_MCU_FAMILY_LPC13UXX /* On the M3 we can check if a debugger is connected */ if ((CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk)==CoreDebug_DHCSR_C_DEBUGEN_Msk) { debug_putchar(c); } #else /* On the M0 the processor doesn't have access to CoreDebug, so this * will cause problems if no debugger is connected! */ debug_putchar(c); #endif #endif #endif }
void cliReadLine(uint8_t *str, uint16_t *strLen) { uint8_t ch; uint16_t idx = 0; /* ToDo: Update this to handle UART, etc., with proper #ifdef blocks! */ while (1) { if (usb_isConfigured()) { while (!usb_cdc_getc(&ch)); if ((ch >= 32) && (ch <= 126) && (idx < *strLen)) { str[idx++] = ch; cliRx(ch); } if (((ch == 8) || (ch == 127)) && idx) { str[idx--] = 0; cliRx(ch); } if (ch == KEY_CODE_ENTER) { *strLen = idx; break; } } } }
void cliPoll() { #if defined CFG_BSP_PRINTF_UART while (uartRxBufferDataPending()) { uint8_t c = uartRxBufferRead(); cliRx(c); } #endif #if defined(CFG_LIB_USB) && defined(CFG_LIB_PRINTF_USBCDC) if (usb_isConfigured()) { uint8_t c; while(usb_cdc_getc(&c)) { cliRx(c); } } #endif }
//--------------------------------------------------------------------+ // APPLICATION API (parameter validation required) //--------------------------------------------------------------------+ bool usb_custom_is_ready_to_send(void) { return usb_isConfigured() && is_bulk_in_ready; }