调整Arduino STM32的串口缓存大小的方法

通常Arduino中调整串口缓存大小的方法是修改HardwareSerial.h中的常量。

其实根本无需修改系统core中的定义值,只需要在代码最上方添加以下常量定义,抢在HardwareSerial.h之前定义缓存大小就可以了。

#define SERIAL_RX_BUFFER_SIZE 512
#define SERIAL_TX_BUFFER_SIZE 128


但是如果使用STM32的板子就没那么简单了。

无论你如何修改HardwareSerial.h的常量定义,或者是在代码上方添加定义都是无效的。

因为在STM32的HardwareSerial.h中即便有该常量的定义,其实也是没有用到的,请看以下代码。

#if 0  
    volatile uint8_t * const _ubrrh;
    volatile uint8_t * const _ubrrl;
    volatile uint8_t * const _ucsra;
    volatile uint8_t * const _ucsrb;
    volatile uint8_t * const _ucsrc;
    volatile uint8_t * const _udr;
    // Has any byte been written to the UART since begin()
    bool _written;

    volatile rx_buffer_index_t _rx_buffer_head;
    volatile rx_buffer_index_t _rx_buffer_tail;
    volatile tx_buffer_index_t _tx_buffer_head;
    volatile tx_buffer_index_t _tx_buffer_tail;	
    // Don't put any members after these 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值