Skip to content

Commit 2300ef2

Browse files
authored
Merge pull request #248 from Max-Plastix/static-uart-buffer
Statically allocate UART Receive buffers
2 parents f223cb1 + 5a39cb6 commit 2300ef2

File tree

2 files changed

+1
-3
lines changed

2 files changed

+1
-3
lines changed

cores/asr650x/Serial/HardwareSerial.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,6 @@ bool HardwareSerial::begin(uint32_t baud, uint32_t config, int rxPin, int txPin,
137137
}
138138
_rxbuff[_uart_num].rx_r=0;
139139
_rxbuff[_uart_num].rx_w=0;
140-
_rxbuff[_uart_num].rx_buf=(uint8_t*) malloc(UART_RX_SIZE);
141140

142141
if( _uart_num == UART_NUM_0)
143142
{
@@ -176,7 +175,6 @@ void HardwareSerial::updateBaudRate(unsigned long baud)
176175

177176
void HardwareSerial::end()
178177
{
179-
free(_rxbuff[_uart_num].rx_buf);
180178
if( _uart_num == UART_NUM_0)
181179
{
182180
UART_1_Stop();

cores/asr650x/Serial/HardwareSerial.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
#define UART_RX_SIZE (UART_BUFF_SIZE+1)
6161

6262
typedef struct {
63-
uint8_t * rx_buf;
63+
uint8_t rx_buf[UART_RX_SIZE];
6464
uint16_t rx_w;
6565
uint16_t rx_r;
6666
} uart_rxbuff_t;

0 commit comments

Comments
 (0)