STM32WL LoRaWAN节点设备学习记录(一)
摸了几天开发板,感觉需要再系统学习一下。
以LoRaWAN_AT_Slave和LoRaWAN_End_Node两个工程为例进行学习。
an5406-how-to-build-a-lora-application-with-stm32cubewl-stmicroelectronics.pdf
an5481 LoRaWAN® AT commands for STM32CubeWL - Application note.pdf
en.MB1389-WL55JC-lowband-D04_Schematic.pdf
(1)硬件概要
一个供电
可选的双核--高安全需求场景
这个应该算软件特性
(2)sdk框架
分为driver、middleware、application(进一步分为Lorawan和phy),还有utilities--sequencer和timer。
还有utilities--sequencer和timer
(3)class A流程图
(4)开发板BSP driver
替换的两种方式,我们用哪种?好像是第一种
ST官方开发板,不知道debug lines 和sysclock有啥用?
关于FEctrl,我们模组实际只用2个pin,ctrl1--PB0,ctrl3--PA8
所以模块外部没后这两个pin,内部定义fectrl2-pa15,虽然没用。
关于bsp的tcxo和rf,dcdc,stm32wlxx_LM401_radio.c
/**
* @brief Radio maximum wakeup time (in ms)
* @note override the default configuration of radio_driver.c
*/
#define RF_WAKEUP_TIME ( 1UL )
(5)SubGHz_Phy layer middlewareIt is not aware about hardware interface,,只是一个抽象层,不针对具体硬件。--内部是SX1262,就是semtech官方的驱动,不再描述
主要还是radio_s这个回调结构体和9个中断
(6)LoRaWAN middleware--4大组件
The LoRa stack middleware is split into the following modules:
• LoRaMAC layer module (in Middlewares\Third_Party\LoRaWAN\Mac)
• LoRa utilities module (in Middlewares\Third_Party\LoRaWAN\Utilities)
• LoRa crypto module (in Middlewares\Third_Party\LoRaWAN\Crypto)
• LoRa LmHandler module (in Middlewares\Third_Party\LoRaWAN\LmHandler)
1)
The application layer和LoRaMAC layer之间采用request-confirm and indication-response机制
The LoRaMAC layer provides the following services:--被application主动调用
• MCPS services
In general, the LoRaMAC layer uses the MCPS services for data transmissions and data receptions.
• MLME services
The LoRaMAC layer uses the MLME services to manage the LoRaWAN network
• MIB services
The MIB stores important runtime information (such as MIB_NETWORK_ACTIVATION or MIB_NET_ID) and holds the configuration of the LoRaMAC layer (for example the MIB_ADR, MIB_APP_KEY).
The LoRaMAC user event functions primitives (also named callbacks) to be implemented by the application
--Response to a McpsRequest;
--Notifies the application that a received packet is available;
--MIB-No available functions.-MIB没有回调函数。,其它三个都有。
2)Middleware MAC layer timers-
3)Middleware LmHandler application function---这个重要lora_app.c就是实际业务文件。
LoRaWAN_End_Node and LoRaWAN_AT_Slave APIs used to access the LoRaMAC
services. The corresponding interface files are located in
Middlewares\Third_Party\LoRaWAN\LmHandler\LmHandler.c
The user must implement the application with these APIs.
(7)sequencer
to execute tasks in the background and enters low-power mode when there is no more activity.
allowing any function to wait for an event (where particular event is set by interrupt)
MIPS and power to be easily saved in any application that implements “run to
completion” command.
Any task is run to completion and can not switch to another task like a RTOS can do
on RTOS tick unless a task suspends itself by calling UTIL_SEQ_WaitEvt.
Moreover, one single-memory stack is used. The sequencer is an advanced ‘while loop’ centralizing task and event bitmap flag
void UTIL_SEQ_Idle( void )
{
LPM_EnterLowPower( );在这里
}
(8)Timer server
The timer server allows the user to request timed-tasks execution. As the hardware timer is based on the RTC,the time is always counted, even in low-power modes.
The timer server provides a reliable clock for the user and the stack. The user can request as many timers as the application requires.
(9)Low-power functions
when the DMA is in use to print data to the console, the system must not enter a low-power mode below Sleep mode because the DMA clock is switched off in Stop mode
Low-level APIs must be implemented to define what the system must do to enter/exit a low-power mode.----这个关键,stm32_lpm_if.c
(9)System time
(10)Trace
The trace module enables to print data on a COM port using DMA.