8000 Fix STM non-F4 builds · domdfcoding/circuitpython@2fa1821 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2fa1821

Browse files
committed
Fix STM non-F4 builds
1 parent f5d90fc commit 2fa1821

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

ports/stm/supervisor/serial.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,16 @@
2828
#include "py/mphal.h"
2929
#include <string.h>
3030
#include "supervisor/serial.h"
31+
#if CPY_STM32F4
3132
#include "stm32f4xx_hal.h"
3233
#include "stm32f4/gpio.h"
33-
3434
// TODO: Switch this to using DEBUG_UART.
3535

3636
UART_HandleTypeDef huart2;
37+
#endif
3738

3839
void port_serial_init(void) {
40+
#if CPY_STM32F4
3941
huart2.Instance = USART2;
4042
huart2.Init.BaudRate = 115200;
4143
huart2.Init.WordLength = UART_WORDLENGTH_8B;
@@ -47,25 +49,33 @@ void port_serial_init(void) {
4749
if (HAL_UART_Init(&huart2) == HAL_OK) {
4850
stm32f4_peripherals_status_led(1,1);
4951
}
52+
#endif
5053
}
5154

5255
bool port_serial_connected(void) {
5356
return true;
5457
}
5558

5659
char port_serial_read(void) {
60+
#if CPY_STM32F4
5761
uint8_t data;
5862
HAL_UART_Receive(&huart2, &data, 1,500);
5963
return data;
64+
#else
65+
return -1;
66+
#endif
6067
}
6168

6269
bool port_serial_bytes_available(void) {
70+
#if CPY_STM32F4
6371
return __HAL_UART_GET_FLAG(&huart2, UART_FLAG_RXNE);
72+
#else
73+
return false;
74+
#endif
6475
}
6576

6677
void port_serial_write_substring(const char *text, uint32_t len) {
67-
if (len == 0) {
68-
return;
69-
}
78+
#if CPY_STM32F4
7079
HAL_UART_Transmit(&huart2, (uint8_t *)text, len, 5000);
80+
#endif
7181
}

0 commit comments

Comments
 (0)
0