历史上的今天
今天是:2025年03月06日(星期四)
2020年03月06日 | STM32开发笔记90: SX1268驱动程序设计(数据缓存)
2020-03-06 来源:eefocus
单片机型号:STM32L053R8T6
本系列开发日志,将详述SX1268驱动程序的整个设计过程,本篇介绍数据缓存的相关驱动程序。
一、工作原理

二、接收模式的数据缓存
In receive mode RxBaseAddr specifies the buffer offset in memory at which the received packet payload data will be written. The buffer offset of the last byte written in receive mode is then stored in RxDataPointer which is initialized to the value of RxBaseAddr at the beginning of the reception.(接收之前,需初始化RxBaseAddr,接收到的有效数据从RxBaseAddr 写入,最后1个字节的偏移量,存储于RxDataPointer 中)
The pointer to the first byte of the last packet received and the packet length can be read with the command GetRxbufferStatus().(接收到的最后1包第个字节的指针和包长,可以通过GetRxbufferStatus命令读出)
In single mode, RxDataPointer is automatically initialized to RxBaseAddr each time the transceiver enters Rx mode. In continuous mode the pointer is incremented starting from the previous position.(在单模式下,每当收发器进入Rx模式时,RxDataPointer都会自动初始化为RxBaseAddr。在连续模式下,指针从上一个位置开始递增。)
三、发送模式数据缓存
Upon each transition to transmit mode TxDataPointer is initialized to TxBaseAddr and is incremented each time a byte is sent over the air. This operation stops once the number of bytes sent equals the payloadlength parameter as defined in the function SetPacketParams(...).(每次转换到传输模式时,TxDataPointer都会初始化为TxBaseAddr,并在每次通过空中发送一个字节时递增。一旦发送的字节数等于函数SetPacketParams中定义的payloadlength参数,此操作将停止)
四、使用数据缓存
Both, RxBaseAddr and TxBaseAddr are set using the command SetBufferBaseAddresses(...).(RxBaseAddr 和TxBaseAddr 都使用SetBufferBaseAddresses函数设置)
By default RxBaseAddr and TxBaseAddr are initialized at address 0x00.(缺省,RxBaseAddr 和TxBaseAddr 初始化为0x00)
Due to the contiguous nature of the data buffer, the base addresses for Tx and Rx are fully configurable across the 256-byte memory area. Each pointer can be set independently anywhere within the buffer. To exploit the maximum data buffer size in transmit or receive mode, the whole data buffer can be used in each mode by setting the base addresses TxBaseAddr and RxBaseAddr at the bottom of the memory (0x00).(由于数据缓冲区的连续特性,Tx和Rx的基本地址可以在256字节的内存区域内完全配置。每个指针都可以在缓冲区的任何地方独立设置。要在传输或接收模式下利用最大数据缓冲区大小,可以在每个模式下使用整个数据缓冲区,方法是在内存的底部设置基本地址TxBaseAddr和RxBaseAddr (0x00))
The data buffer is cleared when the device is put into Sleep mode (implying no access). The data is retained in all other modes of operation.(数据缓存在睡眠模式将会被清除,其它模式都会保留)
The data buffer is accessed via the command WriteBuffer(...) and ReadBuffer(...). In this function the parameter offset defines the address pointer of the first data to be written or read. Offset zero defines the first position of the data buffer.(数据缓冲区是通过命令WriteBuffer(…)和ReadBuffer(…)访问的。在这个函数中,参数偏移量定义要写入或读取的第一个数据的地址指针。偏移量0定义数据缓冲区的第一个位置。)
Before any read or write operation it is hence necessary to initialize this offset to the corresponding beginning of the buffer. Upon reading or writing to the data buffer the address pointer will then increment automatically.(因此,在进行任何读或写操作之前,有必要将这个偏移量初始化为缓冲区的对应起始位置。读取或写入数据缓冲区后,地址指针将自动递增。)
Two possibilities exist to obtain the offset value:(有2种可能获得偏移量)
First is to use the RxBaseAddr value since the user defines it before receiving a payload.(首先是使用RxBaseAddr值,因为用户在接收有效负载之前定义了它。)
Second, offset can be initialized with the value of RxStartBufferPointer returned by GetRxbufferStatus(...) command.(其次,可以使用GetRxbufferStatus(…)命令返回的RxStartBufferPointer值初始化偏移量。)
五、需注意的事情
All the received data will be written to the data buffer even if the CRC is invalid, permitting user-defined post processing of corrupted data. When receiving, if the packet size exceeds the buffer memory allocated for the Rx, it will overwrite the transmit portion of the data buffer.(所有接收到的数据都将写入数据缓冲区,即使CRC无效,也允许用户定义损坏数据的后处理。当接收时,如果包大小超过为Rx分配的缓冲区内存,它将覆盖数据缓冲区的传输部分。)
六、SetBufferBaseAddresses函数

七、程序实现
void SX126xSetBufferBaseAddress(uint8_t txBaseAddress, uint8_t rxBaseAddress);
void CSX1268::SX126xSetBufferBaseAddress(uint8_t txBaseAddress, uint8_t rxBaseAddress)
{
uint8_t buf[2];
buf[0] = txBaseAddress;
buf[1] = rxBaseAddress;
SX126xWriteCommand(RADIO_SET_BUFFERBASEADDRESS, buf, 2);
}
史海拾趣
|
nandflash 的ECC校验是怎么实现的? 在写的时候产生ECC校验码, 在读的时候也产生ECC校验码, (硬件,与软件 的实现) ---------------- … 查看全部问答> |
|
MSP430的手持式仪器设计 手持式仪器是嵌入式系统应用开发的重要领域,手持式仪器具有便于携带、操作方便、LCD显示清晰等优点,设计了以MSP430F449为核心的手持式仪器。系统采用16位A/D转换器AD7705和128×64像素LCD图形显示器设计互动式图形用户 ...… 查看全部问答> |
|
LPC17XX LWIP裸机移植 运行一段时间后 不进以太中断 LPC17XX LWIP裸机移植 开始运行的时候ARP ICMP UDP 开了SNMP 都通 都正常 运行一段时间后就不进以太中断 不知道有没有谁遇见过类似的问题 求指教… 查看全部问答> |
|
焊上晶振之后,下载Verify_Cristal的程序,红灯慢慢的闪,应该是成功了。 但是每当我将手指放在上晶振的时候,红灯就狂闪,说明不成功! 还有,如果将晶振的外壳靠在接地的焊盘上,灯就狂闪,也说明不成功,那个焊盘不就是固定晶振用的吗?这样晶 ...… 查看全部问答> |




