STM32F103 SX1278 驱动

该博客详细介绍了如何在STM32F103上驱动SX1278模块,实现LoRa通信的收发功能。通过MDK5.25和STM32标准库V3.5.0,结合sx12xxDrivers-V2.1.0驱动,作者调整了频率和带宽,并处理了编译问题。在main.c中定义了发送和接收数据的宏,并实现了发送数据后打印提示以及接收到数据后的串口打印。此外,还修改了SX1276的SPI抽象层接口。整个工程代码可供参考。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

本文记录在SX1278 在STM32F103 驱动,实现收发数据功能。(SPI 驱动参考 https://www.cnblogs.com/T0213-ZH/articles/10573067.html)

编译环境:MDK5.25

STM32标准库:V3.5.0

SX1278驱动:sx12xxDrivers-V2.1.0 (https://www.semtech.com/uploads/documents/sx12xxDrivers-V2.1.0.zip)

                       相关文档 https://www.semtech.com/products/wireless-rf/lora-transceivers/sx1278

 

1、MDK工程目录(创建工程方式略)

收发数据由宏“ SX1276_RX_DEF" 区别,定义了为接收数据,未定义为发送数据

2、修改默认sx1276-LoRa.c 里面默认的频率与带宽

 编译时出现bool 没定义,增加 bool类型头文件,sx1276.h文件里

 

main.c 函数实现如下, 发送功能:每间隔1s 发送一组数据  发送完成后打印一串数据“lora send ok”, 接收功能:收到数据后串口打印(本全程打印 ”lora send data“)

#include "platform.h"

static  uint32_t TimeingDelay = 0; 
static  uint32_t timeout_cnt = 1000;   

void Delayms(uint32_t ms){

    TimeingDelay = ms;
    while(TimeingDelay != 0){};
}

void uart_recv_data(uint8_t *p, uint16_t len){

    UART_ApiStructure.send_str(p, len);
}

extern void SX1276Init( void );
extern void SX1276SetTxPacket( const void *buffer, uint16_t size );
extern uint32_t SX1276Process( void );

static uint16_t BufferSize = 30;            // RF buffer size
static uint8_t  Buffer[30];         
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/
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值