历史上的今天
返回首页

历史上的今天

今天是: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);

}

推荐阅读

史海拾趣

E-Z-HOOK公司的发展小趣事

在电子产品日益复杂化的背景下,E-Z-HOOK公司不断追求技术创新。他们投入大量资源研发新型测试工具,以提高测试效率和准确性。其中一项重要的创新是开发出了可重复使用的测试钩。这种测试钩具有极高的耐用性和可靠性,可以大大降低测试成本。此外,公司还推出了一系列智能化测试解决方案,通过集成先进的传感器和软件技术,实现了对测试过程的实时监控和数据分析。

智浦欣(Chipstar)公司的发展小趣事

随着技术的不断进步和市场需求的日益增长,智浦欣公司意识到,只有不断创新和突破,才能在激烈的市场竞争中立于不败之地。于是,公司加大了对研发团队的投入,引进了一批国内外顶尖的模拟器件和混合信号设计人才。经过数月的努力,团队成功研发出了一款具有高性价比的WLED驱动器产品,该产品以其卓越的性能和稳定的质量赢得了客户的广泛好评。随后,公司又相继推出了多款具有竞争力的新产品,进一步巩固了其在消费类电子市场的地位。

General Diode Corp公司的发展小趣事
送丝不稳定或送丝中断。
Henkel公司的发展小趣事
检查电磁振动系统是否堵塞或损坏,清理或更换故障部件;检查送丝轮是否磨损严重,必要时更换新的送丝轮。
EVER-WAY公司的发展小趣事

在电子产品制造行业,品质是企业的生命线。EVER-WAY公司一直高度重视品质管理,建立了完善的质量管理体系。公司从原材料采购、生产制造到产品检验等各个环节都严格把关,确保产品质量的稳定性和可靠性。同时,公司还加强了对员工的培训和教育,提高了员工的品质意识和操作技能。这些品质管理的提升不仅保证了公司产品的优良品质,也赢得了客户的信任和好评。

Cincon公司的发展小趣事

创新是Cincon持续发展的动力。2003年,公司在台北设立了研发中心,专注于电源产品的技术创新和研发。这一举措极大地提升了公司的技术实力和产品创新能力。几年后,Cincon成功设计并制造了LED电源,进一步丰富了产品线,并满足了市场对高效节能照明解决方案的需求。

问答坊 | AI 解惑

编程

大家是用汇编还是C进行编程 我刚接触到DSP 感觉对DSP的编程无从下手 请高手指点一下…

查看全部问答>

★NAND Flash ECC校验的实现★ ? 疑问?

nandflash 的ECC校验是怎么实现的? 在写的时候产生ECC校验码, 在读的时候也产生ECC校验码, (硬件,与软件 的实现) ----------------         …

查看全部问答>

Keil float转字符串问题

我需要把一个float类型的变量转化为字符串,怎么做呀?有什么函数可用吗?谢谢…

查看全部问答>

VS2005调试嵌入式的代码用TCP/IP方式连接总是“设备未就绪”??

使用VS2005开始嵌入式程序,在调试的时间用TCP/IP方式连接到开发板呢,怎么老说“设备未就绪”呢? …

查看全部问答>

诚聘RF工程师

诚聘RF工程师: 1.三年以上RF独立研发经验 2.精通高频技术,充分了解CE,FCC等技术认证标准及RF天线理论 3.熟练掌握各种高频仪器,有较多的调试经验,熟练运用PADS等PCB设计软件 4.对射频开发具有浓厚兴趣,做事忠实细致,有较好的团对协作精神 ...…

查看全部问答>

MSP430的手持式仪器设计

MSP430的手持式仪器设计 手持式仪器是嵌入式系统应用开发的重要领域,手持式仪器具有便于携带、操作方便、LCD显示清晰等优点,设计了以MSP430F449为核心的手持式仪器。系统采用16位A/D转换器AD7705和128×64像素LCD图形显示器设计互动式图形用户 ...…

查看全部问答>

LPC17XX LWIP裸机移植 运行一段时间后 不进以太中断

LPC17XX LWIP裸机移植  开始运行的时候ARP ICMP UDP 开了SNMP 都通 都正常 运行一段时间后就不进以太中断 不知道有没有谁遇见过类似的问题 求指教…

查看全部问答>

关于按键的问题

为什么key1按下之后第一个led不亮,key1 那个键接的是p3.4口 #include sbit d1=P1^0; sbit key1=P3^4; void main() {P3=0xff;         while(1);         {          &n ...…

查看全部问答>

LaunchPad 32.768kHz晶振问题

焊上晶振之后,下载Verify_Cristal的程序,红灯慢慢的闪,应该是成功了。 但是每当我将手指放在上晶振的时候,红灯就狂闪,说明不成功! 还有,如果将晶振的外壳靠在接地的焊盘上,灯就狂闪,也说明不成功,那个焊盘不就是固定晶振用的吗?这样晶 ...…

查看全部问答>

刚刚做的呼吸灯

自己做的呼吸灯: #include #define uint unsigned int sbit led=P0^0; void delay(uint a) {         while(a--); }                          &nb ...…

查看全部问答>