华大HC32L196移植Sx1268

一、lora芯片选择sx1268。

关于sx1261、sx1262、sx1268这三者的区别

  本次移植选择了EX-S68F的lora模块,该模块封装了sx1268芯片和lora的外围匹配和电子开关。

接线方式如下,sx1268四线spi连接mcu,接收使能通过mcu的io控制,si1268的dio2控制发射使能。

二、MCU选型 华大HC32L196PCTA

  选华大这个低功耗系列MCU主要是因为...

三、资料下载

       1.sx126x资料可以找Semtech代理商要也可以在官网下载,官网下载地址,

资料下载地址规格和数据表 | 开发者门户

相关的驱动也可以在gitee上下载开源的code,下载地址 LoRaMac-node: LoRaMac-node是Semtech官方发布的LoRaWAN节点端项目

  2.HC32L196资料下载地址

HC32L196PCTA-LQFP100-华大半导体有限公司

四、移植准备

1.新建一个空的HC32L196的keil project,并且添加sx126x驱动

2.添加board文件

添加完如下

 

五、开始移植

  为了方便以后移植到其他型号的MCU上,这里使用模拟SPI进行移植

1.在board-config.h里修改SPI接口和相应的io定义。

  

2.新建board_gpio.c / board_gpio.h  

  Board_gpio.c 主要封装两个gpio初始化函数

3.新建board_spi.c / board_spi.h

Board_spi.c 封装spi io初始化以及模拟的spi读写函数

Board-spi.h里添加

 Spi端口初始化

Spi读写函数参考时序图

4.修改sx126x-board.c

此处修改的函数比较多这里就列出几个关键的函数

io初始化修改

Reset函数busy函数修改

读写命令修改

读写寄存器函数修改,这个是主要的mcu和sx1268通讯接口,比较重要

修改Tcxo配置

由于移植没有使用定时器这里修改函数使用固定值

打开dio2电子开关使能功能

5.Sx126x.c 基本不用改

Sx126x.h

  

6.radio.c修改

radio.c里的函数主要修改了中断响应函数和应答函数

修改如下

编译注释掉所有的定时器相关的代码,消除所有警告

五、收发测试

经过上面的移植,编译无误,就可以做收发测试了

Main.c可以参考demo里给出的初始化流程

1定义lora参数

2.超时函数

3.参数定义

4.main函数

 Mcu初始化

Lora初始化

发射接收测试

移植到这里已经可以进行收发测试了

添加打印函数,连接电脑测试

  

收发测试正常了,回头测一下发射功率和接收灵敏度

  • 4
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 3
    评论
The aim of this project is to show an example of the endpoint LoRaWAN stack implementation. This project has 3 active branches in place. The master branch which provides the latest released source code (v4.4.2), the develop branch which provides the current source code development status to be released next (Milestone 4.4.3) and the feature/5.0.0 branch which provides a preview of the current source code development status for LoRaWAN Specification v1.1 specification.(Milestone 5.0.0) The master branch implementation is based on LoRaWAN Specification v1.0.3 and LoRaWAN Regional Parameters v1.0.3revA specifications. ClassA, ClassB and ClassC end-device classes are fully implemented. The develop branch implementation is based on LoRaWAN Specification v1.0.3 and LoRaWAN Regional Parameters v1.0.3revA specifications. ClassA, ClassB and ClassC end-device classes are fully implemented. The feature/5.0.0 branch implementation is based on LoRaWAN Specification v1.1 and LoRaWAN Regional Parameters v1.1rB specifications. ClassA, ClassB and ClassC end-device classes are fully implemented. This project also provides SX1272/73, SX1276/77/78/79 and SX1261/2 radio drivers. For each currently supported platform example applications are provided. LoRaMac/classA: ClassA end-device example application. LoRaMac/classB: ClassB end-device example application. LoRaMac/classC: ClassC end-device example application. LoRaMac/fuota-test-01: FUOTA test scenario 01 end-device example application. (Based on provided application common packages) LoRaMac/periodic-uplink-lpp: ClassA/B/C end-device example application. Periodically uplinks a frame using the Cayenne LPP protocol. (Based on provided application common packages) ping-pong: Point to point RF link example application. rx-sensi: Example application useful to measure the radio sensitivity level using an RF generator. tx-cw: Example application to show how to generate an RF Continuous Wave transmission. Note: Each LoRaWAN application example (LoRaMac/classX) includes an implementation of the LoRa-Alliance; LoRaWAN certification protocol. Note: The LoRaWAN stack API documentation can be found at: http://stackforce.github.io/LoRaMac-doc/

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

m0_37666038

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值