摸了几天开发板,感觉需要再系统学习一下。

以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

The HAL uses STM32Cube APIs to drive the MCU hardware required by the application. Only specific hardware is included in the LoRa middleware as it is mandatory to run a LoRa application.

The RTC provides a centralized time unit that continues to run even in low-power mode (Stop 2 mode). The RTC alarm is used to wake up the system at specific timings managed by the timer server.

The SubGHz_Phy middleware uses the HAL SubGHz to control the radio (see the above figure). For more details, refer to Section 5

The MAC controls the SubGHz_Phy using the 802.15.4 model. The MAC interfaces with the SubGHz_Phy driver and uses the timer server to add or remove timed tasks.

Since the state machine that controls the LoRa Class A is sensitive, an intermediate level of software is inserted (LmHandler.c) between the MAC and the application (refer to LoRaMAC driver in the above figure). With a limited set of APIs, the user is free to implement the Class A state machine at application level. For more details, refer to Section 6 .

The application, built around an infinite loop, manages the low-power mode, runs the interrupt handlers (alarm or GPIO) and calls the LoRa Class A if any task must be done.

(3)class A流程图

Once the radio has completed the application data transmission, an asynchronous RadioIRQ wakes up the system. The RadioIsr here calls txDone in the handler mode.
All RadioIsr and MAC timer call a LoRaMacProcessNotify callback to request the application layer to update the LoRaMAC state and to do further processing when needed.

For instance, at the end of the reception, rxDone is called in the ISR (handler), but all the Rx packet processing including decryption must not be processed in the ISR. This case is an example of call sequence. If no data is received into the Rx1 window, then another Rx2 window is launched..

(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.

(1)LmHandlerInit--Initialization of the LoRa finite state machine

(2)LmHandlerConfigure--Configuration of all applicative parameters

(3)LmHandlerStop--Stops the LoRa process and waits a new configuration before a
rejoin action.

(4)LmHandlerJoin--Join request to a network either in OTAA or ABP mode.

(5)LmHandlerRequestClass--Requests the MAC layer to change LoRaWAN class.

(6)LmHandlerSend--Sends an uplink frame. This frame can be either an unconfirmed empty frame or an unconfirmed/confirmed payload frame

callbacks---

--OnMacProcessNotify--Will be called each time a Radio IRQ is handled by the MAC layer

--上面并不完整,可以根据需要再增加系统预定的函数。比如OnSysTimeUpdate等。

--还有很多--Getter/setter functions。

(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.--每个任务都会调用吗?如何交出权限

void UTIL_SEQ_Init( void )
{
  TaskSet = UTIL_SEQ_NO_BIT_SET;
  TaskMask = UTIL_SEQ_ALL_BIT_SET;
  SuperMask = UTIL_SEQ_ALL_BIT_SET;
  EvtSet = UTIL_SEQ_NO_BIT_SET;
  EvtWaited = UTIL_SEQ_NO_BIT_SET;
  CurrentTaskIdx = 0U;
  (void)UTIL_SEQ_MEMSET8(TaskCb, 0, sizeof(TaskCb));
  (void)UTIL_SEQ_MEMSET8(TaskPrio, 0, sizeof(TaskPrio));
  UTIL_SEQ_INIT_CRITICAL_SECTION( );
}

Moreover, one single-memory stack is used. The sequencer is an advanced ‘while loop’ centralizing task and event bitmap flag

/core/main.c

while (1)
  {
    /* USER CODE END WHILE */
    MX_LoRaWAN_Process();--

/* USER CODE BEGIN 3 */
  }

application/lorawan/app/app_lorawan.c

void MX_LoRaWAN_Process(void)
{
  /* USER CODE BEGIN MX_LoRaWAN_Process_1 */

/* USER CODE END MX_LoRaWAN_Process_1 */
  UTIL_SEQ_Run(UTIL_SEQ_DEFAULT);
  /* USER CODE BEGIN MX_LoRaWAN_Process_2 */

/* USER CODE END MX_LoRaWAN_Process_2 */
}

/core/sys_app.c

void UTIL_SEQ_Idle( void )
{
LPM_EnterLowPower( );在这里
}

//AT命令串口中断

static void CmdProcessNotify(void)
{
  /* USER CODE BEGIN CmdProcessNotify_1 */

/* USER CODE END CmdProcessNotify_1 */
  UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_Vcom), 0);
  /* USER CODE BEGIN CmdProcessNotify_2 */

/* USER CODE END CmdProcessNotify_2 */
}

//LoraWAN中断

static void OnMacProcessNotify(void)
{
  /* USER CODE BEGIN OnMacProcessNotify_1 */

/* USER CODE END OnMacProcessNotify_1 */
  UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LmHandlerProcess), CFG_SEQ_Prio_0);

/* USER CODE BEGIN OnMacProcessNotify_2 */

/* USER CODE END OnMacProcessNotify_2 */
}

//IO中断

void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
  switch (GPIO_Pin)
  {
    case  BUTTON_SW1_PIN:
      /* Note: when "EventType == TX_ON_TIMER" this GPIO is not initialized */
      UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);
      break;
    case  BUTTON_SW2_PIN:
      break;
    case  BUTTON_SW3_PIN:
      break;
    default:
      break;
  }
}

//定时中断

static void OnTxTimerEvent(void *context)
{
  /* USER CODE BEGIN OnTxTimerEvent_1 */

/* USER CODE END OnTxTimerEvent_1 */
  UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent), CFG_SEQ_Prio_0);

/*Wait for next tx slot*/
  UTIL_TIMER_Start(&TxTimer);
  /* USER CODE BEGIN OnTxTimerEvent_2 */

/* USER CODE END OnTxTimerEvent_2 */
}

32个task,32个event都在sequence中处理,

task--不是while(1)无限循环,而是单循环,这个跟rtos的任务不同;

event--跟task没有必然关系,与task一样,一般跟中断有关系,中断到来既可UTIL_SEQ_SetTask()启动一次task,也可以UTIL_SEQ_SetEvt()提供一个evt。知道该谁干,就task,不知道谁来处理,就evt。

void OnTxDone(void)//OnRxDone OnTxTimeout OnRxTimeout  OnRxError
{
  /* Set TxDone flag */
  RadioTxDone_flag = 1;
  UTIL_SEQ_SetEvt(1 << CFG_SEQ_Evt_RadioOnTstRF);
}

void UTIL_SEQ_WaitEvt(UTIL_SEQ_bm_t EvtId_bm)//这个函数比较复杂
{

中间考虑多个waitEvt,死循环的。

}

//好像只有下面2个地方用到,从字面看,主要是测试过程用到,先暂时放下

int32_t TST_TX_Start(int32_t nb_packet)

{       /* Send payload once*/
      Radio.Send(payload, testParam.payloadLen);
      /* Wait Tx done/timeout */
      UTIL_SEQ_WaitEvt(1 << CFG_SEQ_Evt_RadioOnTstRF);
      Radio.Sleep();

}

int32_t TST_RX_Start(int32_t nb_packet)

{      。。。

Radio.Rx(RX_TIMEOUT_VALUE);

/* Wait Rx done/timeout */
      UTIL_SEQ_WaitEvt(1 << CFG_SEQ_Evt_RadioOnTstRF);
      Radio.Sleep();

。。。}

(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.

--32个task,32个event,但是可以很多timers。

(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.

STM32WL LoRaWAN节点设备学习记录(一)相关推荐

  1. 日常学习记录——决策树根节点的选择

    日常学习记录--决策树根节点的选择 1 数据集 2 根节点的选择 1 信息增益的计算 2 计算单列属性信息熵 3 计算各属性信息增益 3 存在问题与反思 1 数据集 本例使用的是经过预处理的模糊数据集 ...

  2. 2022-10-20 学习记录——节点边际电价

    学习记录--节点边际电价 1.概念   节点边际电价:某一节点的单位电量发生变化而引起整个系统边际发电成本的变化量.   节点边际电价 = 系统能量电价 + 阻塞价格 + 网损费用(暂不考虑)   多 ...

  3. 2023.2.3,周五【图神经网络 学习记录17】二部图——BiNE算法:显式关系,隐式关系;新的随机游走方式 特点:随机游走次数 是跟节点中心性相关的,在随机游走的过程中 添加一个停止随机游走的概率

    声明:仅学习使用~ 前情提要: 2023.2.2,周四[图神经网络 学习记录16]异构图Graph Embedding算法--GATNE(异构图多属性 多边 类型算法),不建议普通PC跑-PyChar ...

  4. CVPR2019| 百度17篇CVPR论文学习记录(包含:无人驾驶、神经网络、GAN、无监督学习、目标检测)

    首先感谢现在网上资源丰富,能够获得很多人的总结,结合自身实际进行了学习记录. 并着重标注了其中关键核心 目录 1)Taking A Closer Look at Domain Shift: Categ ...

  5. linux个人学习记录

    linux学习记录 资料: Linux 黑马程序员_bilibili AcWing Linux基础课 可能是东半球最全面易懂的 Tmux 使用教程! Shell 教程 | 菜鸟教程 (runoob.c ...

  6. Android 学习记录(持续更新)

    Android 学习记录(持续更新) 1.AndroidManifest.xml 详解: http://www.jb51.net/article/73731.htm (AndroidManifest. ...

  7. docker 学习记录1

    一. 1. Docker 是一个开源的应用容器引擎,基于 Go 语言 并遵从 Apache2.0 协议开源. Docker 可以让开发者打包他们的应用以及依赖包到一个轻量级.可移植的容器中,然后发布到 ...

  8. Unity游戏优化[第二版]学习记录6

    以下内容是根据Unity 2020.1.01f版本进行编写的 Unity游戏优化[第二版]学习记录6 第6章 动态图形 一.管线渲染 1.GPU前端 2.GPU后端 3.光照和阴影 4.多线程渲染 5 ...

  9. Modbus学习记录(3)

    Modbus学习记录(3)--API详解 初始化相关API modbus_new_rtu() modbus_new_tcp() modbus_new_tcp_pi() 连接相关API modbus_c ...

最新文章

  1. 在Solaris系统中,查看tcp/ip配置
  2. js学习笔记1---使用方法
  3. Qt修炼手册10_QTableWidget控件使用说明及实践
  4. 十字路口红绿灯plc程序_交通灯程序的最优化(西门子S7-200PLC为例)
  5. vb计算机水平考试笔试,全国计算机等级考试VB二级笔试复习资料-20210522014715.docx-原创力文档...
  6. 【转载】简直可爱极了的即时通讯
  7. python 内存释放gc_如何释放内存的python删除对象?
  8. iOS 工程中引入另一个工程,多工程管理
  9. php-cs-fixer不起作用,使用 PHP-CS-Fixer 规范PHP代码
  10. 镜像分割与高可用性灾难恢复
  11. 如何修改hosts文件?几种修改hosts文件的方法
  12. 手游传奇架设教程_「教程」传奇新手架设简单教程,自己做GM,「GEE版本」
  13. 某头条安卓逆向学习----改机/逆向/Hook/协议
  14. Vivado使用技巧(2):综合运行与OOC
  15. beyondCompare this license key has been revoked密钥被撤销
  16. 小程序使用mp-html解析html
  17. React 初探 [五] React 组件的生命周期
  18. 编写文件服务器,编写服务器的头文件
  19. vue中echarts纵轴添加点击事件
  20. 张丽俊最新演讲:要像竹子一样扎根,你终会一飞冲天

热门文章

  1. 阿龙的学习笔记---如何用C++ STL 实现一个 LRU缓存
  2. 最优化及其运用 学习笔记(二)
  3. 数据库中索引的填充因子
  4. 2020/04/12 02-HTML和URL提取、豆瓣读书爬虫编写
  5. 【python】幼儿园分班
  6. aso优化师是什么_【aso优化师赵星凯】简述为什么要做aso?
  7. ASO | APP推广之ASO优化中的九大奥义。
  8. 电机仿真系列-基于LabVIEW的电机测试系统研究
  9. nexus 仓库类型_Nexus仓库构建
  10. 如何快速将图片中的文字提取出来