diff --git a/ports/stm/supervisor/serial.c b/ports/stm/supervisor/serial.c index b88b85b04b..013381e4e3 100644 --- a/ports/stm/supervisor/serial.c +++ b/ports/stm/supervisor/serial.c @@ -28,14 +28,16 @@ #include "py/mphal.h" #include #include "supervisor/serial.h" +#if CPY_STM32F4 #include "stm32f4xx_hal.h" #include "stm32f4/gpio.h" - // TODO: Switch this to using DEBUG_UART. UART_HandleTypeDef huart2; +#endif void port_serial_init(void) { + #if CPY_STM32F4 huart2.Instance = USART2; huart2.Init.BaudRate = 115200; huart2.Init.WordLength = UART_WORDLENGTH_8B; @@ -47,6 +49,7 @@ void port_serial_init(void) { if (HAL_UART_Init(&huart2) == HAL_OK) { stm32f4_peripherals_status_led(1,1); } + #endif } bool port_serial_connected(void) { @@ -54,18 +57,25 @@ bool port_serial_connected(void) { } char port_serial_read(void) { + #if CPY_STM32F4 uint8_t data; HAL_UART_Receive(&huart2, &data, 1,500); return data; + #else + return -1; + #endif } bool port_serial_bytes_available(void) { + #if CPY_STM32F4 return __HAL_UART_GET_FLAG(&huart2, UART_FLAG_RXNE); + #else + return false; + #endif } void port_serial_write_substring(const char *text, uint32_t len) { - if (len == 0) { - return; - } + #if CPY_STM32F4 HAL_UART_Transmit(&huart2, (uint8_t *)text, len, 5000); + #endif }