From 5a39cb69eb50018106078383a1d0593a1fc4d623 Mon Sep 17 00:00:00 2001 From: Max-Plastix Date: Fri, 19 Aug 2022 16:52:58 -0700 Subject: [PATCH] Statically allocate UART Receive buffers --- cores/asr650x/Serial/HardwareSerial.cpp | 2 -- cores/asr650x/Serial/HardwareSerial.h | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/cores/asr650x/Serial/HardwareSerial.cpp b/cores/asr650x/Serial/HardwareSerial.cpp index f88c56ec..adb5c199 100644 --- a/cores/asr650x/Serial/HardwareSerial.cpp +++ b/cores/asr650x/Serial/HardwareSerial.cpp @@ -137,7 +137,6 @@ bool HardwareSerial::begin(uint32_t baud, uint32_t config, int rxPin, int txPin, } _rxbuff[_uart_num].rx_r=0; _rxbuff[_uart_num].rx_w=0; - _rxbuff[_uart_num].rx_buf=(uint8_t*) malloc(UART_RX_SIZE); if( _uart_num == UART_NUM_0) { @@ -176,7 +175,6 @@ void HardwareSerial::updateBaudRate(unsigned long baud) void HardwareSerial::end() { - free(_rxbuff[_uart_num].rx_buf); if( _uart_num == UART_NUM_0) { UART_1_Stop(); diff --git a/cores/asr650x/Serial/HardwareSerial.h b/cores/asr650x/Serial/HardwareSerial.h index 08b054fd..d40a1276 100644 --- a/cores/asr650x/Serial/HardwareSerial.h +++ b/cores/asr650x/Serial/HardwareSerial.h @@ -60,7 +60,7 @@ #define UART_RX_SIZE (UART_BUFF_SIZE+1) typedef struct { - uint8_t * rx_buf; + uint8_t rx_buf[UART_RX_SIZE]; uint16_t rx_w; uint16_t rx_r; } uart_rxbuff_t;