add pm25 LoRaWAN project

add pm25 LoRaWAN project
This commit is contained in:
supowang
2020-07-30 16:08:08 +08:00
parent e4e2b08363
commit 257a5e9867
33 changed files with 5575 additions and 236 deletions

View File

@@ -9,8 +9,6 @@
#include "gpio.h"
#include "tos_k.h"
#include "stdio.h"
#include "app_system.h"
#include "app_lorawan.h"
void board_init(void);
void SystemClock_Config(void);

View File

@@ -29,9 +29,7 @@ void board_init(void)
{
HAL_Init();
SystemClock_Config();
SystemApp_Init();
MX_LoRaWAN_Init();
MX_USART1_UART_Init();
}
/**

View File

@@ -25,7 +25,6 @@
#include "main.h"
#include "stm32wlxx_it.h"
#include "tos_k.h"
#include "sensor_parser.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
@@ -234,22 +233,10 @@ void USART2_IRQHandler(void)
/* USER CODE END LPUART1_IRQn 1 */
}
void Radio_IRQHandler(void)
{
HAL_SUBGHZ_IRQHandler(&hsubghz);
}
/* USER CODE BEGIN 1 */
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
extern uint8_t msg;
if(huart ->Instance == USART2)
{
tos_shell_input_byte(msg);
HAL_UART_Receive_IT(&huart2, (uint8_t*)&msg, 1);
}
}
/* USER CODE END 1 */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,255 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file Templates/Src/stm32wlxx_it.c
* @author MCD Application Team
* @brief Main Interrupt Service Routines.
* This file provides template for all exceptions handler and
* peripherals interrupt service routine.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "stm32wlxx_it.h"
#include "tos_k.h"
#include "sensor_parser.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN TD */
/* USER CODE END TD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/* External variables --------------------------------------------------------*/
extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart2;
extern SUBGHZ_HandleTypeDef hsubghz;
/* USER CODE BEGIN EV */
/* USER CODE END EV */
/******************************************************************************/
/* Cortex Processor Interruption and Exception Handlers */
/******************************************************************************/
/**
* @brief This function handles Non maskable interrupt.
*/
void NMI_Handler(void)
{
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
/* USER CODE END NonMaskableInt_IRQn 0 */
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
/* USER CODE END NonMaskableInt_IRQn 1 */
}
/**
* @brief This function handles Hard fault interrupt.
*/
void HardFault_Handler(void)
{
/* USER CODE BEGIN HardFault_IRQn 0 */
/* USER CODE END HardFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
/* USER CODE END W1_HardFault_IRQn 0 */
}
}
/**
* @brief This function handles Memory management fault.
*/
void MemManage_Handler(void)
{
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
/* USER CODE END MemoryManagement_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
/* USER CODE END W1_MemoryManagement_IRQn 0 */
}
}
/**
* @brief This function handles Prefetch fault, memory access fault.
*/
void BusFault_Handler(void)
{
/* USER CODE BEGIN BusFault_IRQn 0 */
/* USER CODE END BusFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_BusFault_IRQn 0 */
/* USER CODE END W1_BusFault_IRQn 0 */
}
}
/**
* @brief This function handles Undefined instruction or illegal state.
*/
void UsageFault_Handler(void)
{
/* USER CODE BEGIN UsageFault_IRQn 0 */
/* USER CODE END UsageFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_UsageFault_IRQn 0 */
/* USER CODE END W1_UsageFault_IRQn 0 */
}
}
/**
* @brief This function handles System service call via SWI instruction.
*/
void SVC_Handler(void)
{
/* USER CODE BEGIN SVCall_IRQn 0 */
/* USER CODE END SVCall_IRQn 0 */
/* USER CODE BEGIN SVCall_IRQn 1 */
/* USER CODE END SVCall_IRQn 1 */
}
/**
* @brief This function handles Debug monitor.
*/
void DebugMon_Handler(void)
{
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
/* USER CODE END DebugMonitor_IRQn 0 */
/* USER CODE BEGIN DebugMonitor_IRQn 1 */
/* USER CODE END DebugMonitor_IRQn 1 */
}
/**
* @brief This function handles Pendable request for system service.
*/
__weak void PendSV_Handler(void)
{
/* USER CODE BEGIN PendSV_IRQn 0 */
/* USER CODE END PendSV_IRQn 0 */
/* USER CODE BEGIN PendSV_IRQn 1 */
/* USER CODE END PendSV_IRQn 1 */
}
/**
* @brief This function handles System tick timer.
*/
void SysTick_Handler(void)
{
/* USER CODE BEGIN SysTick_IRQn 0 */
/* USER CODE END SysTick_IRQn 0 */
HAL_IncTick();
if (tos_knl_is_running())
{
tos_knl_irq_enter();
tos_tick_handler();
tos_knl_irq_leave();
}
/* USER CODE BEGIN SysTick_IRQn 1 */
/* USER CODE END SysTick_IRQn 1 */
}
/******************************************************************************/
/* STM32WLxx Peripheral Interrupt Handlers */
/* Add here the Interrupt Handlers for the used peripherals. */
/* For the available peripheral interrupt handler names, */
/* please refer to the startup file (startup_stm32wlxx.s). */
/******************************************************************************/
void USART1_IRQHandler(void)
{
/* USER CODE BEGIN USART1_IRQn 0 */
/* USER CODE END USART1_IRQn 0 */
HAL_UART_IRQHandler(&huart1);
/* USER CODE BEGIN USART2_IRQn 1 */
/* USER CODE END USART2_IRQn 1 */
}
void USART2_IRQHandler(void)
{
/* USER CODE BEGIN LPUART1_IRQn 0 */
/* USER CODE END LPUART1_IRQn 0 */
tos_knl_irq_enter();
HAL_UART_IRQHandler(&huart2);
tos_knl_irq_leave();
/* USER CODE BEGIN LPUART1_IRQn 1 */
/* USER CODE END LPUART1_IRQn 1 */
}
void Radio_IRQHandler(void)
{
HAL_SUBGHZ_IRQHandler(&hsubghz);
}
/* USER CODE BEGIN 1 */
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
extern uint8_t msg;
if(huart ->Instance == USART2)
{
tos_shell_input_byte(msg);
HAL_UART_Receive_IT(&huart2, (uint8_t*)&msg, 1);
}
}
/* USER CODE END 1 */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -159,7 +159,7 @@
<Type>0</Type>
<LineNumber>122</LineNumber>
<EnabledFlag>0</EnabledFlag>
<Address>134244104</Address>
<Address>134235804</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>

View File

@@ -1,18 +0,0 @@
; *************************************************************
; *** Scatter-Loading Description File generated by uVision ***
; *************************************************************
LR_IROM1 0x08000000 0x00020000 { ; load region size_region
ER_IROM1 0x08000000 0x00020000 { ; load address = execution address
*.o (RESET, +First)
*(InRoot$$Sections)
.ANY (+RO)
}
RW_IRAM1 0x20000000 0x00008000 { ; RW data
.ANY (+RW +ZI)
}
RW_IRAM2 0x20008000 0x00008000 {
.ANY (+RW +ZI)
}
}

View File

@@ -81,8 +81,8 @@ extern "C" {
#define STATIC_DEVICE_EUI 1 //if 0 , using a ramdom EUI
#define IEEE_OUI 0x01, 0x01, 0x01
#define LORAWAN_DEVICE_EUI { 0x8c, 0xf9, 0x57, 0x20, 0x00, 0x00, 0x4d, 0xf7}
#define LORAWAN_JOIN_EUI /*APP_EUI*/ { 0x8c, 0xf9, 0x57, 0x20, 0x00, 0x00, 0x4d, 0xf7}
#define LORAWAN_DEVICE_EUI { 0x8c, 0xf9, 0x57, 0x20, 0x00, 0x00, 0x4d, 0xf9}
#define LORAWAN_JOIN_EUI /*APP_EUI*/ { 0x8c, 0xf9, 0x57, 0x20, 0x00, 0x00, 0x4d, 0xf9}

View File

@@ -9,17 +9,13 @@
#include "lorawan_version.h"
#include <tos_k.h>
#include "sensor_parser.h"
#define APP_TX_DUTYCYCLE 30000 //ms
#define LORAWAN_DOWNLINK_PORT 2
#define LORAWAN_UPLINK_PORT 10
k_mail_q_t mail_q;
#define DATA_CNT 26
uint8_t mail_buf[DATA_CNT];
#define DATA_CNT 3
typedef struct device_data_st {
uint8_t data[DATA_CNT];
@@ -110,18 +106,11 @@ void MX_LoRaWAN_Init(void)
printf("lorawan init ok.\r\n");
}
uint8_t pool[DATA_CNT];
#define CMD_LEN_MAX 50
char cmd_buf[CMD_LEN_MAX];
dev_data_t dev_data;
dev_data_t dev_data = {28,78,20};
uint16_t report_period = 10;
void uart_output(const char *str)
{
/* if using c lib printf through uart, a simpler one is: */
printf(str);
}
void recv_callback(uint8_t *data, uint8_t len)
{
@@ -148,8 +137,6 @@ void application_entry(void *arg)
int ret = 0;
int send_failed_count = 0;
tos_mail_q_create(&mail_q, pool, DATA_CNT, sizeof(uint8_t));
tos_shell_init(cmd_buf, sizeof(cmd_buf), uart_output);
//create task to process loramac
tos_sem_create_max(&lora_mac_process_sem, 0, 1);
@@ -163,16 +150,12 @@ void application_entry(void *arg)
10);
//report pm2.5 data
while (1) {
size_t mail_size;
tos_mail_q_pend(&mail_q, &dev_data.data, &mail_size, TOS_TIME_FOREVER);
while (1) {
/*fill the data*/
tos_task_delay(20000);
i = 0;
app_data.port = LORAWAN_UPLINK_PORT;
for (i = 0; i < mail_size; i++) {
for (i = 0; i < DATA_CNT; i++) {
app_data.buff[i] = dev_data.data[i];
printf("[%d] %x\n", i, dev_data.data[i]);
}
@@ -205,7 +188,7 @@ void application_entry(void *arg)
send_failed_count = 0;
}
tos_task_delay(10000);
}
//Lora_start_send();

View File

@@ -0,0 +1,120 @@
#include "mcu_init.h"
#include "app_system.h"
#include "app_lorawan.h"
int fputc(int ch, FILE *f)
{
if (ch == '\n') {
HAL_UART_Transmit(&huart1, (void *)"\r", 1, 30000);
}
HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);
return ch;
}
int _write(int fd, char *ptr, int len)
{
(void)HAL_UART_Transmit(&huart1, (uint8_t *)ptr, len, 0xFFFF);
return len;
}
int fgetc(FILE *f)
{
/* Place your implementation of fgetc here */
/* e.g. readwrite a character to the USART2 and Loop until the end of transmission */
uint8_t ch = 0;
HAL_UART_Receive(&huart1, &ch, 1,30000);
return ch;
}
void board_init(void)
{
HAL_Init();
SystemClock_Config();
SystemApp_Init();
MX_LoRaWAN_Init();
}
/**
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Initializes the CPU, AHB and APB busses clocks
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
RCC_OscInitStruct.HSICalibrationValue = 70;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV2;
RCC_OscInitStruct.PLL.PLLN = 30;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV5;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV5;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV5;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Configure the SYSCLKSource, HCLK, PCLK1 and PCLK2 clocks dividers
*/
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_HCLK3);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
{
Error_Handler();
}
}
/* USER CODE BEGIN 4 */
/* USER CODE END 4 */
/**
* @brief This function is executed in case of error occurrence.
* @retval None
*/
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
while(1)
{
}
/* USER CODE END Error_Handler_Debug */
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,247 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file Templates/Src/stm32wlxx_it.c
* @author MCD Application Team
* @brief Main Interrupt Service Routines.
* This file provides template for all exceptions handler and
* peripherals interrupt service routine.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "stm32wlxx_it.h"
#include "tos_k.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN TD */
/* USER CODE END TD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/* External variables --------------------------------------------------------*/
extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart2;
extern SUBGHZ_HandleTypeDef hsubghz;
/* USER CODE BEGIN EV */
/* USER CODE END EV */
/******************************************************************************/
/* Cortex Processor Interruption and Exception Handlers */
/******************************************************************************/
/**
* @brief This function handles Non maskable interrupt.
*/
void NMI_Handler(void)
{
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
/* USER CODE END NonMaskableInt_IRQn 0 */
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
/* USER CODE END NonMaskableInt_IRQn 1 */
}
/**
* @brief This function handles Hard fault interrupt.
*/
void HardFault_Handler(void)
{
/* USER CODE BEGIN HardFault_IRQn 0 */
/* USER CODE END HardFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
/* USER CODE END W1_HardFault_IRQn 0 */
}
}
/**
* @brief This function handles Memory management fault.
*/
void MemManage_Handler(void)
{
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
/* USER CODE END MemoryManagement_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
/* USER CODE END W1_MemoryManagement_IRQn 0 */
}
}
/**
* @brief This function handles Prefetch fault, memory access fault.
*/
void BusFault_Handler(void)
{
/* USER CODE BEGIN BusFault_IRQn 0 */
/* USER CODE END BusFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_BusFault_IRQn 0 */
/* USER CODE END W1_BusFault_IRQn 0 */
}
}
/**
* @brief This function handles Undefined instruction or illegal state.
*/
void UsageFault_Handler(void)
{
/* USER CODE BEGIN UsageFault_IRQn 0 */
/* USER CODE END UsageFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_UsageFault_IRQn 0 */
/* USER CODE END W1_UsageFault_IRQn 0 */
}
}
/**
* @brief This function handles System service call via SWI instruction.
*/
void SVC_Handler(void)
{
/* USER CODE BEGIN SVCall_IRQn 0 */
/* USER CODE END SVCall_IRQn 0 */
/* USER CODE BEGIN SVCall_IRQn 1 */
/* USER CODE END SVCall_IRQn 1 */
}
/**
* @brief This function handles Debug monitor.
*/
void DebugMon_Handler(void)
{
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
/* USER CODE END DebugMonitor_IRQn 0 */
/* USER CODE BEGIN DebugMonitor_IRQn 1 */
/* USER CODE END DebugMonitor_IRQn 1 */
}
/**
* @brief This function handles Pendable request for system service.
*/
__weak void PendSV_Handler(void)
{
/* USER CODE BEGIN PendSV_IRQn 0 */
/* USER CODE END PendSV_IRQn 0 */
/* USER CODE BEGIN PendSV_IRQn 1 */
/* USER CODE END PendSV_IRQn 1 */
}
/**
* @brief This function handles System tick timer.
*/
void SysTick_Handler(void)
{
/* USER CODE BEGIN SysTick_IRQn 0 */
/* USER CODE END SysTick_IRQn 0 */
HAL_IncTick();
if (tos_knl_is_running())
{
tos_knl_irq_enter();
tos_tick_handler();
tos_knl_irq_leave();
}
/* USER CODE BEGIN SysTick_IRQn 1 */
/* USER CODE END SysTick_IRQn 1 */
}
/******************************************************************************/
/* STM32WLxx Peripheral Interrupt Handlers */
/* Add here the Interrupt Handlers for the used peripherals. */
/* For the available peripheral interrupt handler names, */
/* please refer to the startup file (startup_stm32wlxx.s). */
/******************************************************************************/
void USART1_IRQHandler(void)
{
/* USER CODE BEGIN USART1_IRQn 0 */
/* USER CODE END USART1_IRQn 0 */
HAL_UART_IRQHandler(&huart1);
/* USER CODE BEGIN USART2_IRQn 1 */
/* USER CODE END USART2_IRQn 1 */
}
void USART2_IRQHandler(void)
{
/* USER CODE BEGIN LPUART1_IRQn 0 */
/* USER CODE END LPUART1_IRQn 0 */
tos_knl_irq_enter();
HAL_UART_IRQHandler(&huart2);
tos_knl_irq_leave();
/* USER CODE BEGIN LPUART1_IRQn 1 */
/* USER CODE END LPUART1_IRQn 1 */
}
void Radio_IRQHandler(void)
{
HAL_SUBGHZ_IRQHandler(&hsubghz);
}
/* USER CODE BEGIN 1 */
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
}
/* USER CODE END 1 */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -331,18 +331,6 @@
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\BSP\Src\mcu_init.c</PathWithFileName>
<FilenameWithoutPath>mcu_init.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>7</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\BSP\Src\rtc.c</PathWithFileName>
<FilenameWithoutPath>rtc.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
@@ -350,7 +338,7 @@
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>8</FileNumber>
<FileNumber>7</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -362,7 +350,7 @@
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>9</FileNumber>
<FileNumber>8</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -374,7 +362,7 @@
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>10</FileNumber>
<FileNumber>9</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -386,19 +374,7 @@
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>11</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\BSP\Src\stm32wlxx_it.c</PathWithFileName>
<FilenameWithoutPath>stm32wlxx_it.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>12</FileNumber>
<FileNumber>10</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -410,7 +386,7 @@
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>13</FileNumber>
<FileNumber>11</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -420,6 +396,30 @@
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>12</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\App\mcu_init.c</PathWithFileName>
<FilenameWithoutPath>mcu_init.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
<File>
<GroupNumber>2</GroupNumber>
<FileNumber>13</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\App\stm32wlxx_it.c</PathWithFileName>
<FilenameWithoutPath>stm32wlxx_it.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
@@ -1110,14 +1110,6 @@
</File>
</Group>
<Group>
<GroupName>examples</GroupName>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
</Group>
<Group>
<GroupName>TOS-CONFIG</GroupName>
<tvExp>0</tvExp>
@@ -1125,7 +1117,7 @@
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>9</GroupNumber>
<GroupNumber>8</GroupNumber>
<FileNumber>68</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
@@ -1137,7 +1129,7 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>9</GroupNumber>
<GroupNumber>8</GroupNumber>
<FileNumber>69</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
@@ -1157,7 +1149,7 @@
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>10</GroupNumber>
<GroupNumber>9</GroupNumber>
<FileNumber>70</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
@@ -1169,7 +1161,7 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>10</GroupNumber>
<GroupNumber>9</GroupNumber>
<FileNumber>71</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
@@ -1181,7 +1173,7 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>10</GroupNumber>
<GroupNumber>9</GroupNumber>
<FileNumber>72</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
@@ -1193,7 +1185,7 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>10</GroupNumber>
<GroupNumber>9</GroupNumber>
<FileNumber>73</FileNumber>
<FileType>5</FileType>
<tvExp>0</tvExp>
@@ -1205,7 +1197,7 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>10</GroupNumber>
<GroupNumber>9</GroupNumber>
<FileNumber>74</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
@@ -1218,26 +1210,6 @@
</File>
</Group>
<Group>
<GroupName>Hardware</GroupName>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>11</GroupNumber>
<FileNumber>75</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>..\..\BSP\Hardware\PM25\sensor_parser.c</PathWithFileName>
<FilenameWithoutPath>sensor_parser.c</FilenameWithoutPath>
<RteFlg>0</RteFlg>
<bShared>0</bShared>
</File>
</Group>
<Group>
<GroupName>lorawan/pattern</GroupName>
<tvExp>0</tvExp>
@@ -1245,8 +1217,8 @@
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>12</GroupNumber>
<FileNumber>76</FileNumber>
<GroupNumber>10</GroupNumber>
<FileNumber>75</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1257,8 +1229,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>12</GroupNumber>
<FileNumber>77</FileNumber>
<GroupNumber>10</GroupNumber>
<FileNumber>76</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1277,8 +1249,8 @@
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>13</GroupNumber>
<FileNumber>78</FileNumber>
<GroupNumber>11</GroupNumber>
<FileNumber>77</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1289,8 +1261,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>13</GroupNumber>
<FileNumber>79</FileNumber>
<GroupNumber>11</GroupNumber>
<FileNumber>78</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1301,8 +1273,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>13</GroupNumber>
<FileNumber>80</FileNumber>
<GroupNumber>11</GroupNumber>
<FileNumber>79</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1313,8 +1285,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>13</GroupNumber>
<FileNumber>81</FileNumber>
<GroupNumber>11</GroupNumber>
<FileNumber>80</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1325,8 +1297,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>13</GroupNumber>
<FileNumber>82</FileNumber>
<GroupNumber>11</GroupNumber>
<FileNumber>81</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1337,8 +1309,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>13</GroupNumber>
<FileNumber>83</FileNumber>
<GroupNumber>11</GroupNumber>
<FileNumber>82</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1349,8 +1321,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>13</GroupNumber>
<FileNumber>84</FileNumber>
<GroupNumber>11</GroupNumber>
<FileNumber>83</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1361,8 +1333,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>13</GroupNumber>
<FileNumber>85</FileNumber>
<GroupNumber>11</GroupNumber>
<FileNumber>84</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1373,8 +1345,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>13</GroupNumber>
<FileNumber>86</FileNumber>
<GroupNumber>11</GroupNumber>
<FileNumber>85</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1385,8 +1357,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>13</GroupNumber>
<FileNumber>87</FileNumber>
<GroupNumber>11</GroupNumber>
<FileNumber>86</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1397,8 +1369,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>13</GroupNumber>
<FileNumber>88</FileNumber>
<GroupNumber>11</GroupNumber>
<FileNumber>87</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1412,13 +1384,13 @@
<Group>
<GroupName>lorawan/region</GroupName>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>89</FileNumber>
<GroupNumber>12</GroupNumber>
<FileNumber>88</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1429,8 +1401,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>90</FileNumber>
<GroupNumber>12</GroupNumber>
<FileNumber>89</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1441,8 +1413,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>91</FileNumber>
<GroupNumber>12</GroupNumber>
<FileNumber>90</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1453,8 +1425,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>92</FileNumber>
<GroupNumber>12</GroupNumber>
<FileNumber>91</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1465,8 +1437,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>93</FileNumber>
<GroupNumber>12</GroupNumber>
<FileNumber>92</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1477,8 +1449,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>94</FileNumber>
<GroupNumber>12</GroupNumber>
<FileNumber>93</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1489,8 +1461,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>95</FileNumber>
<GroupNumber>12</GroupNumber>
<FileNumber>94</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1501,8 +1473,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>96</FileNumber>
<GroupNumber>12</GroupNumber>
<FileNumber>95</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1513,8 +1485,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>97</FileNumber>
<GroupNumber>12</GroupNumber>
<FileNumber>96</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1525,8 +1497,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>98</FileNumber>
<GroupNumber>12</GroupNumber>
<FileNumber>97</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1537,8 +1509,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>99</FileNumber>
<GroupNumber>12</GroupNumber>
<FileNumber>98</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1549,8 +1521,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>100</FileNumber>
<GroupNumber>12</GroupNumber>
<FileNumber>99</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1561,8 +1533,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>14</GroupNumber>
<FileNumber>101</FileNumber>
<GroupNumber>12</GroupNumber>
<FileNumber>100</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1581,8 +1553,8 @@
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>15</GroupNumber>
<FileNumber>102</FileNumber>
<GroupNumber>13</GroupNumber>
<FileNumber>101</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1601,8 +1573,8 @@
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>16</GroupNumber>
<FileNumber>103</FileNumber>
<GroupNumber>14</GroupNumber>
<FileNumber>102</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1613,8 +1585,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>16</GroupNumber>
<FileNumber>104</FileNumber>
<GroupNumber>14</GroupNumber>
<FileNumber>103</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1633,8 +1605,8 @@
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
<File>
<GroupNumber>17</GroupNumber>
<FileNumber>105</FileNumber>
<GroupNumber>15</GroupNumber>
<FileNumber>104</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1645,8 +1617,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>17</GroupNumber>
<FileNumber>106</FileNumber>
<GroupNumber>15</GroupNumber>
<FileNumber>105</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
@@ -1657,8 +1629,8 @@
<bShared>0</bShared>
</File>
<File>
<GroupNumber>17</GroupNumber>
<FileNumber>107</FileNumber>
<GroupNumber>15</GroupNumber>
<FileNumber>106</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>

View File

@@ -10,14 +10,14 @@
<TargetName>TencentOS_Tiny</TargetName>
<ToolsetNumber>0x4</ToolsetNumber>
<ToolsetName>ARM-ADS</ToolsetName>
<pCCUsed>6140000::V6.14::ARMCLANG</pCCUsed>
<pCCUsed>6100001::V6.10.1::.\ARMCLANG</pCCUsed>
<uAC6>1</uAC6>
<TargetOption>
<TargetCommonOption>
<Device>STM32WLE5JCIx</Device>
<Vendor>STMicroelectronics</Vendor>
<PackID>Keil.STM32WLxx_DFP.1.0.0</PackID>
<PackURL>http://www.keil.com/pack/</PackURL>
<PackID>Keil.STM32WLxx_DFP.1.0.2.OEM</PackID>
<PackURL>http://www.keil.com/pack</PackURL>
<Cpu>IRAM(0x20000000,0x10000) IROM(0x08000000,0x40000) CPUTYPE("Cortex-M4") CLOCK(12000000) ELITTLE</Cpu>
<FlashUtilSpec></FlashUtilSpec>
<StartupFile></StartupFile>
@@ -185,7 +185,6 @@
<uocXRam>0</uocXRam>
<RvdsVP>0</RvdsVP>
<RvdsMve>0</RvdsMve>
<RvdsCdeCp>0</RvdsCdeCp>
<hadIRAM2>0</hadIRAM2>
<hadIROM2>0</hadIROM2>
<StupSel>8</StupSel>
@@ -339,7 +338,7 @@
<MiscControls></MiscControls>
<Define>USE_HAL_DRIVER,STM32WLE5xx,CORE_CM4</Define>
<Undefine></Undefine>
<IncludePath>..\..\..\..\platform\vendor_bsp\st\STM32WLxx_HAL_Driver\Inc;..\..\..\..\platform\vendor_bsp\st\STM32WLxx_HAL_Driver\Inc\Legacy;..\..\..\..\platform\vendor_bsp\st\CMSIS\Device\ST\STM32WLxx\Include;..\..\..\..\platform\vendor_bsp\st\CMSIS\Include;..\..\..\..\arch\arm\arm-v7m\common\include;..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc;..\..\..\..\kernel\core\include;..\..\..\..\kernel\pm\include;..\..\..\..\osal\cmsis_os;..\..\TOS_CONFIG;..\..\BSP\Middlewares\LoRaWAN\Conf;..\..\BSP\Middlewares\LoRaWAN\Crypto;..\..\BSP\Middlewares\LoRaWAN\Mac;..\..\BSP\Middlewares\LoRaWAN\Patterns\Basic;..\..\BSP\Middlewares\LoRaWAN\Utilities;..\..\BSP\Middlewares\SubGHz_Phy;..\..\BSP\Middlewares\SubGHz_Phy\stm32_radio_driver;..\..\BSP\Inc;.\App;.\Target;..\..\BSP\Utilities\lpm\tiny_lpm;..\..\BSP\Utilities\misc;..\..\BSP\Hardware\PM25</IncludePath>
<IncludePath>..\..\..\..\platform\vendor_bsp\st\STM32WLxx_HAL_Driver\Inc;..\..\..\..\platform\vendor_bsp\st\STM32WLxx_HAL_Driver\Inc\Legacy;..\..\..\..\platform\vendor_bsp\st\CMSIS\Device\ST\STM32WLxx\Include;..\..\..\..\platform\vendor_bsp\st\CMSIS\Include;..\..\..\..\arch\arm\arm-v7m\common\include;..\..\..\..\arch\arm\arm-v7m\cortex-m4\armcc;..\..\..\..\kernel\core\include;..\..\..\..\kernel\pm\include;..\..\..\..\osal\cmsis_os;..\..\TOS_CONFIG;..\..\BSP\Middlewares\LoRaWAN\Conf;..\..\BSP\Middlewares\LoRaWAN\Crypto;..\..\BSP\Middlewares\LoRaWAN\Mac;..\..\BSP\Middlewares\LoRaWAN\Patterns\Basic;..\..\BSP\Middlewares\LoRaWAN\Utilities;..\..\BSP\Middlewares\SubGHz_Phy;..\..\BSP\Middlewares\SubGHz_Phy\stm32_radio_driver;..\..\BSP\Inc;.\App;.\Target;..\..\BSP\Utilities\lpm\tiny_lpm;..\..\BSP\Utilities\misc</IncludePath>
</VariousControls>
</Cads>
<Aads>
@@ -352,7 +351,7 @@
<NoWarn>0</NoWarn>
<uSurpInc>0</uSurpInc>
<useXO>0</useXO>
<ClangAsOpt>4</ClangAsOpt>
<uClangAs>0</uClangAs>
<VariousControls>
<MiscControls></MiscControls>
<Define></Define>
@@ -413,11 +412,6 @@
<FileType>1</FileType>
<FilePath>..\..\BSP\Src\gpio.c</FilePath>
</File>
<File>
<FileName>mcu_init.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\BSP\Src\mcu_init.c</FilePath>
</File>
<File>
<FileName>rtc.c</FileName>
<FileType>1</FileType>
@@ -438,11 +432,6 @@
<FileType>1</FileType>
<FilePath>..\..\BSP\Src\stm32wlxx_hal_msp.c</FilePath>
</File>
<File>
<FileName>stm32wlxx_it.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\BSP\Src\stm32wlxx_it.c</FilePath>
</File>
<File>
<FileName>usart.c</FileName>
<FileType>1</FileType>
@@ -453,6 +442,16 @@
<FileType>1</FileType>
<FilePath>..\..\BSP\Src\usart_if.c</FilePath>
</File>
<File>
<FileName>mcu_init.c</FileName>
<FileType>1</FileType>
<FilePath>.\App\mcu_init.c</FilePath>
</File>
<File>
<FileName>stm32wlxx_it.c</FileName>
<FileType>1</FileType>
<FilePath>.\App\stm32wlxx_it.c</FilePath>
</File>
</Files>
</Group>
<Group>
@@ -750,9 +749,6 @@
</File>
</Files>
</Group>
<Group>
<GroupName>examples</GroupName>
</Group>
<Group>
<GroupName>TOS-CONFIG</GroupName>
<Files>
@@ -798,16 +794,6 @@
</File>
</Files>
</Group>
<Group>
<GroupName>Hardware</GroupName>
<Files>
<File>
<FileName>sensor_parser.c</FileName>
<FileType>1</FileType>
<FilePath>..\..\BSP\Hardware\PM25\sensor_parser.c</FilePath>
</File>
</Files>
</Group>
<Group>
<GroupName>lorawan/pattern</GroupName>
<Files>
@@ -1018,19 +1004,4 @@
<files/>
</RTE>
<LayerInfo>
<Layers>
<Layer>
<LayName>&lt;Project Info&gt;</LayName>
<LayDesc></LayDesc>
<LayUrl></LayUrl>
<LayKeys></LayKeys>
<LayCat></LayCat>
<LayLic></LayLic>
<LayTarg>0</LayTarg>
<LayPrjMark>1</LayPrjMark>
</Layer>
</Layers>
</LayerInfo>
</Project>

View File

@@ -0,0 +1,94 @@
/**
**********************************************************************************************************************************************************
* @file commissioning.h
* @author MCD Application Team
* @brief End device commissioning parameters
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LORA_COMMISSIONING_H__
#define __LORA_COMMISSIONING_H__
#ifdef __cplusplus
extern "C" {
#endif
/*!
******************************************************************************
********************************** WARNING ***********************************
******************************************************************************
The crypto-element implementation supports both 1.0.x and 1.1.x LoRaWAN
versions of the specification.
Thus it has been decided to use the 1.1.x keys and EUI name definitions.
The below table shows the names equivalence between versions:
+-------------------+-------------------------+
| 1.0.x | 1.1.x |
+===================+=========================+
| LORAWAN_DEVICE_EUI| LORAWAN_DEVICE_EUI |
+-------------------+-------------------------+
| LORAWAN_APP_EUI | LORAWAN_JOIN_EUI |
+-------------------+-------------------------+
| N/A | LORAWAN_APP_KEY |
+-------------------+-------------------------+
| LORAWAN_APP_KEY | LORAWAN_NWK_KEY |
+-------------------+-------------------------+
| LORAWAN_NWK_S_KEY | LORAWAN_F_NWK_S_INT_KEY |
+-------------------+-------------------------+
| LORAWAN_NWK_S_KEY | LORAWAN_S_NWK_S_INT_KEY |
+-------------------+-------------------------+
| LORAWAN_NWK_S_KEY | LORAWAN_NWK_S_ENC_KEY |
+-------------------+-------------------------+
| LORAWAN_APP_S_KEY | LORAWAN_APP_S_KEY |
+-------------------+-------------------------+
******************************************************************************
******************************************************************************
******************************************************************************
*/
/*!
* Indicates if the end-device is to be connected to a private or public network
*/
#define LORAWAN_PUBLIC_NETWORK true
/*root key*/
#define LORAWAN_APP_KEY { 0x12, 0x34, 0x56, 0x78, 0x91, 0x23, 0x45, 0x67, 0x89, 0x12, 0x34, 0x56, 0x78, 0x91, 0x23, 0x45 }
/*for ABP================================================================================*/
#define STATIC_DEVICE_ADDRESS 1 //if 0 , using a ramdom address
#define LORAWAN_NETWORK_ID ( uint32_t )0
#define LORAWAN_DEVICE_ADDRESS ( uint32_t )0x0100000a
#define LORAWAN_NWK_KEY { 0x12, 0x34, 0x56, 0x78, 0x91, 0x23, 0x45, 0x67, 0x89, 0x12, 0x34, 0x56, 0x78, 0x91, 0x23, 0x45 }
/*for 1.1.x*/
#define LORAWAN_F_NWK_S_INT_KEY { 0x12, 0x34, 0x56, 0x78, 0x91, 0x23, 0x45, 0x67, 0x89, 0x12, 0x34, 0x56, 0x78, 0x91, 0x23, 0x45 }
#define LORAWAN_S_NWK_S_INT_KEY { 0x12, 0x34, 0x56, 0x78, 0x91, 0x23, 0x45, 0x67, 0x89, 0x12, 0x34, 0x56, 0x78, 0x91, 0x23, 0x45 }
#define LORAWAN_NWK_S_ENC_KEY { 0x12, 0x34, 0x56, 0x78, 0x91, 0x23, 0x45, 0x67, 0x89, 0x12, 0x34, 0x56, 0x78, 0x91, 0x23, 0x45 }
#define LORAWAN_APP_S_KEY { 0x12, 0x34, 0x56, 0x78, 0x91, 0x23, 0x45, 0x67, 0x89, 0x12, 0x34, 0x56, 0x78, 0x91, 0x23, 0x45 }
/*for OTAA================================================================================*/
#define STATIC_DEVICE_EUI 1 //if 0 , using a ramdom EUI
#define IEEE_OUI 0x01, 0x01, 0x01
#define LORAWAN_DEVICE_EUI { 0x8c, 0xf9, 0x57, 0x20, 0x00, 0x00, 0x4d, 0xf8}
#define LORAWAN_JOIN_EUI /*APP_EUI*/ { 0x8c, 0xf9, 0x57, 0x20, 0x00, 0x00, 0x4d, 0xf8}
#ifdef __cplusplus
}
#endif
#endif /* __LORA_COMMISSIONING_H__ */

View File

@@ -0,0 +1,109 @@
/**
******************************************************************************
* @file app_conf.h
* @author MCD Application Team
* @brief applic configuration, e.g. : debug, trace, low power, sensors
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __APP_CONF_H__
#define __APP_CONF_H__
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************************************
* lw APP configuration
******************************************************************************/
/* lw application configuration (Mw is configured by lorawan_conf.h) */
#define LORAWAN_DEFAULT_ACTIVE_REGION LORAMAC_REGION_CN470
/*enable Low power*/
#define LOW_POWER_ENBLE 0
/* LPM_STOP_MODE_DISABLE = 0 : LowPowerMode enabled : MCU enters stop2 mode*/
/* LPM_STOP_MODE_DISABLE = 1 : LowPowerMode disabled : MCU enters sleep mode only */
#define LPM_STOP_MODE_DISABLE 0
/******************************************************************************
* classB configuration
******************************************************************************/
/*using class b must define LORAMAC_CLASSB_ENABLED and active ClassB*/
/* Class B ------------------------------------*/
//#define LORAMAC_CLASSB_ENABLED
#define LORAMAC_CLASSB_ACTIVE 0 /* 0 if not active, 1 if active */
/******************************************************************************
* DEBUGGING configuration
******************************************************************************/
/* Enable trace logs. Note verbose level can be selected in app_system.h */
#define APP_LOG_ENABLED 1
#define MW_LOG_ENABLED 1
/*
0 only print the informtion
1.print the function and line
2 print the file , line ,function
*/
#define LOG_LEVEL 0
/******************************************************************************
* Sequencer
******************************************************************************/
#define CFG_SEQ_Prio_0 0
/**
* This is the list of task id required by the application
* Each Id shall be in the range 0..1<31
*/
#define CFG_SEQ_TASK_LORAMAC_PROCESS (1 << 1)
#define CFG_SEQ_TASK_LORA_SEND_ON_TX_TIMER (1 << 2)
#define CFG_SEQ_TASK_LORA_CERTIF_PROCESS (1 << 3)
/******************************************************************************
* LOW POWER MANAGER
******************************************************************************/
/**
* Supported requester to the MCU Low Power Manager - can be increased up to 32
* It lits a bit mapping of all user of the Low Power Manager
*/
typedef enum
{
LPM_APPLI_Id = (1 << 0),
LPM_LIB_Id = (1 << 1),
LPM_RTC_Id = (1 << 2),
LPM_GPS_Id = (1 << 3),
LPM_UART_RX_Id = (1 << 4),
LPM_UART_TX_Id = (1 << 5),
LPM_TCXO_WA_Id = (1 << 6),
} LPM_Id_t;
#ifdef __cplusplus
}
#endif
#endif /* __APP_CONF_H__ */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,413 @@
/* Includes ------------------------------------------------------------------*/
#include "timer.h"
#include "app_system.h"
#include "app_lorawan.h"
#include "stm32_lpm.h"
#include "adc_if.h"
#include "lorawan_version.h"
#include <tos_k.h>
#include "sensor_parser.h"
#define APP_TX_DUTYCYCLE 30000 //ms
#define LORAWAN_DOWNLINK_PORT 2
#define LORAWAN_UPLINK_PORT 10
k_mail_q_t mail_q;
#define DATA_CNT 26
uint8_t mail_buf[DATA_CNT];
typedef struct device_data_st {
uint8_t data[DATA_CNT];
} __PACKED__ dev_data_t;
/*!
* user main_callback function declare , you need to implement them
* and register.
*/
static uint8_t LORA_GetBatteryLevel(void);
static uint16_t LORA_GetTemperatureLevel(void);
static void GetUniqueId(uint8_t *id);
static uint32_t GetRandomSeed(void);
static void LoraMacProcessNotify(void);
void mac_event_callback(APP_EVENT_t evt,const void* param);
static LoRaMainCallback_t LoRaMainCallbacks = { mac_event_callback,
LoraMacProcessNotify,
LORA_GetBatteryLevel,
LORA_GetTemperatureLevel,
GetUniqueId,
GetRandomSeed,
};
#define LORAWAN_APP_DATA_BUFF_SIZE 64
static uint8_t app_data_buff[LORAWAN_APP_DATA_BUFF_SIZE];
lw_app_data_t app_data = { app_data_buff, 0, 0 };
/*send task function declaration*/
static TimerEvent_t send_timer;
static void send_process(void *args);
static void cycle_send_event(void *context);
static void Lora_start_send(void);
k_task_t lora_mac_process_task;
//4096 is miniest stack size to work normally
k_stack_t lora_mac_process_task_stack[4096];
k_sem_t lora_mac_process_sem;
//MAC<41><43><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void LoraMacProcess_task_entry(void *args)
{
while(1)
{
tos_sem_pend(&lora_mac_process_sem, TOS_TIME_FOREVER);
LoRaMacProcess(NULL);
}
}
/*Exported functions ---------------------------------------------------------*/
void MX_LoRaWAN_Init(void)
{
printf("Lora node powered by TencentOS-tiny\r\n");
/* Configure the Lora Stack*/
lw_init(&LoRaMainCallbacks);
APP_LOG("APP_VERSION= %02X.%02X.%02X.%02X\r\n", (uint8_t)(__APP_VERSION >> 24), (uint8_t)(__APP_VERSION >> 16), (uint8_t)(__APP_VERSION >> 8), (uint8_t)__APP_VERSION);
APP_LOG("MAC_VERSION= %02X.%02X.%02X.%02X\r\n", (uint8_t)(__LORA_MAC_VERSION >> 24), (uint8_t)(__LORA_MAC_VERSION >> 16), (uint8_t)(__LORA_MAC_VERSION >> 8), (uint8_t)__LORA_MAC_VERSION);
/*Class*/
lw_request_class(CLASS_A);
/*channel 80-87*/
LWChannel_mask_t ch={0x0000,0,0,0,0,0x00FF};
lw_current_chmask_set(&ch);
/*tx dr*/
lw_config_tx_datarate_set(DR_3);
/*OTAA*/
lw_config_otaa_set(LORA_ENABLE);
/*enable adr*/
lw_adr_set(LORA_ENABLE);
/*set retry*/
lw_confirm_retry_set(3);
printf("lorawan init ok.\r\n");
}
uint8_t pool[DATA_CNT];
#define CMD_LEN_MAX 50
char cmd_buf[CMD_LEN_MAX];
dev_data_t dev_data;
uint16_t report_period = 10;
void uart_output(const char *str)
{
/* if using c lib printf through uart, a simpler one is: */
printf(str);
}
void recv_callback(uint8_t *data, uint8_t len)
{
int i = 0;
printf("len: %d\n", len);
for (i = 0; i < len; ++i) {
printf("data[%d]: %d\n", i, data[i]);
}
if (len == 1) {
report_period = data[0];
} else if (len >= 2) {
report_period = data[0] | (data[1] << 8);
}
printf("report_period: %d\n", report_period);
}
void application_entry(void *arg)
{
int i = 0;
int ret = 0;
int send_failed_count = 0;
tos_mail_q_create(&mail_q, pool, DATA_CNT, sizeof(uint8_t));
tos_shell_init(cmd_buf, sizeof(cmd_buf), uart_output);
//create task to process loramac
tos_sem_create_max(&lora_mac_process_sem, 0, 1);
tos_task_create(&lora_mac_process_task,
"lora_mac_process_task",
LoraMacProcess_task_entry,
NULL,
2,
lora_mac_process_task_stack,
sizeof(lora_mac_process_task_stack),
10);
//report pm2.5 data
while (1) {
size_t mail_size;
tos_mail_q_pend(&mail_q, &dev_data.data, &mail_size, TOS_TIME_FOREVER);
/*fill the data*/
i = 0;
app_data.port = LORAWAN_UPLINK_PORT;
for (i = 0; i < mail_size; i++) {
app_data.buff[i] = dev_data.data[i];
printf("[%d] %x\n", i, dev_data.data[i]);
}
printf("\n\n");
app_data.size = i;
/*Check if it is in OTAA mode*/
if(LORA_ENABLE == lw_config_otaa_get())
{
/*check if it is already joined*/
if(lw_join_status() != LORA_SET)
{
lw_join();
continue;
}
}
ret = lw_send(&app_data, LORAWAN_CONFIRMED_MSG);
if (ret != LORAMAC_STATUS_OK )
{
printf("LoRa Send data faild!, retcode = %d, count is %d\r\n",ret, send_failed_count);
send_failed_count++;
if (send_failed_count > 10)
{
NVIC_SystemReset();// when lora send faied more than 10 times , cpu reset to reconnect.
}
}
else
{
send_failed_count = 0;
}
//tos_task_delay(10000);
}
//Lora_start_send();
}
void Lora_start_send(void)
{
/* send everytime timer elapses */
TimerInit(&send_timer, cycle_send_event);
TimerSetValue(&send_timer, APP_TX_DUTYCYCLE);
cycle_send_event(NULL);
}
static void cycle_send_event(void *args)
{
send_process(NULL);
/*Wait for next tx slot*/
TimerStart(&send_timer);
//tos_timer_start(&send_timer);
}
static void send_process(void *args)
{
int16_t temperature = 0;
uint8_t batteryLevel=0;
/*Check if it is in OTAA mode*/
if(LORA_ENABLE == lw_config_otaa_get())
{
/*check if it is already joined*/
if(lw_join_status() != LORA_SET)
{
lw_join();
return;
}
}
APP_LOG("SEND REQUEST=======================================>\n\r");
/*fill the data*/
uint32_t i = 0;
app_data.port = LORAWAN_UPLINK_PORT;
batteryLevel = LORA_GetBatteryLevel(); /* 1 (very low) to 254 (fully charged) */
temperature = SYS_GetTemperatureLevel(); /* report Temperature */
app_data.buff[i++] = batteryLevel * 100 / 254;
app_data.buff[i++] = temperature>>8;
app_data.buff[i++] = temperature&0xff;
app_data.size = i;
/*you can set the channel by using these function*/
// LWChannel_mask_t ch_r={0};
// LWChannel_mask_t ch_w={0x00FF,0,0,0,0,0};
// lw_current_chmask_set(&ch_w);
// APP_LOG("ch_write: %04X %04X %04X %04X %04X %04X\r\n",ch_w.mask[0],ch_w.mask[1],ch_w.mask[2],ch_w.mask[3],ch_w.mask[4],ch_w.mask[5]);
// lw_current_chmask_get(&ch_r);
// APP_LOG("ch_read: %04X %04X %04X %04X %04X %04X\r\n",ch_r.mask[0],ch_r.mask[1],ch_r.mask[2],ch_r.mask[3],ch_r.mask[4],ch_r.mask[5]);
lw_send(&app_data, LORAWAN_CONFIRMED_MSG);
}
void mac_event_callback(APP_EVENT_t evt,const void* param)
{
switch(evt)
{
case APP_RX_EVENT:{
lw_app_data_t* rx_data = (lw_app_data_t*)param;
switch(rx_data->port)
{
case 2:
APP_LOG("%s\r\n",rx_data->buff);
APP_LOG("size = %d\r\n",rx_data->size);
APP_LOG("<===============================>");break;
case 3:
lw_request_class(CLASS_A);break;
case 4:
lw_request_class(CLASS_B);break;
case 5:
lw_request_class(CLASS_C);break;
}
if(rx_data->fpending)
{
app_data.size = 0;
app_data.port = LORAWAN_UPLINK_PORT;
lw_send(&app_data, LORAWAN_UNCONFIRMED_MSG);
}
}break;
case APP_JOINED_EVENT:{
APP_LOG("end node joined \n\r");
//lw_request_class(CLASS_A);
}break;
case APP_CONFIRM_ClASS_EVENT:{
DeviceClass_t* cur_class = (DeviceClass_t*)param;
APP_LOG("==================Switch to Class%c done\n\r","ABC"[*cur_class]);
/*Optionnal*/
/*informs the server that switch has occurred ASAP*/
app_data.size = 0;
app_data.port = LORAWAN_UPLINK_PORT;
lw_send(&app_data, LORAWAN_UNCONFIRMED_MSG);
}break;
case APP_TX_DONE_EVENT:{
lw_app_data_t* tx_done = (lw_app_data_t*)param;
if(tx_done->ack){
APP_LOG("Network Server \"ack\" an uplink data confirmed message transmission\n\r");
}
else{
APP_LOG("tx =======> down\n\r");
}
}break;
default :break;
}
}
static void LoraMacProcessNotify(void)
{
tos_sem_post(&lora_mac_process_sem);
}
/**
* @brief This function return the battery level
* @param none
* @retval the battery level 1 (very low) to 254 (fully charged)
*/
static uint8_t LORA_GetBatteryLevel(void)
{
/* USER CODE BEGIN 1 */
uint16_t batteryLevelmV;
uint8_t batteryLevel = 0;
batteryLevelmV = (uint16_t) SYS_GetBatteryLevel();
/* Convert batterey level from mV to linea scale: 1 (very low) to 254 (fully charged) */
if(batteryLevelmV > VDD_BAT)
{
batteryLevel = 254;
}
else if(batteryLevelmV < VDD_MIN)
{
batteryLevel = 0;
}
else
{
batteryLevel = (((uint32_t)(batteryLevelmV - VDD_MIN) * 254) / (VDD_BAT - VDD_MIN));
}
APP_LOG("VDDA= %d\n\r", batteryLevel);
return batteryLevel; /* 1 (very low) to 254 (fully charged) */
/* USER CODE END 1 */
}
static uint16_t LORA_GetTemperatureLevel(void)
{
return (uint16_t) SYS_GetTemperatureLevel();
}
/**
* @brief This function return a random seed
* @note based on the device unique ID
* @param None
* @retval see
*/
static uint32_t GetRandomSeed(void)
{
return ((HAL_GetUIDw0()) ^ (HAL_GetUIDw1()) ^ (HAL_GetUIDw2()));
}
/**
* @brief This function return a unique ID
* @param unique ID
* @retval none
*/
static void GetUniqueId(uint8_t *id)
{
uint32_t ID_1_3_val = HAL_GetUIDw0() + HAL_GetUIDw2();
uint32_t ID_2_val = HAL_GetUIDw1();
id[7] = (ID_1_3_val) >> 24;
id[6] = (ID_1_3_val) >> 16;
id[5] = (ID_1_3_val) >> 8;
id[4] = (ID_1_3_val);
id[3] = (ID_2_val) >> 24;
id[2] = (ID_2_val) >> 16;
id[1] = (ID_2_val) >> 8;
id[0] = (ID_2_val);
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,57 @@
/**
******************************************************************************
* @file app_lorawan.h
* @author MCD Application Team
* @brief header of application of the LRWAN Middleware
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __APP_LORAWAN_H__
#define __APP_LORAWAN_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "lora.h"
/* Exported constants --------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
/* External variables --------------------------------------------------------*/
/* Exported macros -----------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
/**
* @brief Init Lora Application
* @param None
* @retval None
*/
void MX_LoRaWAN_Init(void);
/**
* @brief Send Lora Data
* @param None
* @retval None
*/
void MX_LoRaWAN_Process(void);
#ifdef __cplusplus
}
#endif
#endif /*__APP_LORAWAN_H__*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,129 @@
#include <stdio.h>
#include <string.h>
#include "main.h"
#include "app_system.h"
#include "adc_if.h"
#include "stm32_systime.h"
#include "stm32_lpm.h"
#include "usart_if.h"
/**
* @brief Set all pins such to minimized consumption (necessary for some STM32 families)
* @param none
* @retval None
*/
static void Gpio_PreInit(void);
/**
* @brief Returns sec and msec based on the systime in use
* @param none
* @retval none
*/
static void TimestampNow(uint8_t *buff, uint16_t* size);
/* Exported functions ---------------------------------------------------------*/
/**
* @brief initialises the system (dbg pins, trace, mbmux, systiemr, LPM, ...)
* @param none
* @retval none
*/
void SystemApp_Init(void)
{
Gpio_PreInit();
vcom_Init(NULL);
MX_USART2_UART_Init();
/*Initialize the temperature and Battery measurement services */
SYS_InitMeasurement();
#if LOW_POWER_MODE_ENBLE
/*Init low power manager*/
UTIL_LPM_Init();
/* Disable Stand-by mode */
UTIL_LPM_SetOffMode(LPM_APPLI_Id, UTIL_LPM_DISABLE);
#if defined (LPM_STOP_MODE_DISABLE) && (LPM_STOP_MODE_DISABLE == 1)
/* Disable Stop Mode */
UTIL_LPM_SetStopMode(LPM_APPLI_Id, UTIL_LPM_DISABLE);
#elif !defined (LPM_STOP_MODE_DISABLE)
#error LPM_STOP_MODE_DISABLE not defined
#endif
#endif
}
/**
* @brief redefines __weak function in stm32_seq.c such to enter low power
* @param none
* @retval none
*/
void UTIL_SEQ_Idle(void)
{
#if LOW_POWER_MODE_ENBLE
UTIL_LPM_EnterLowPower();
#endif
}
/* Private functions ---------------------------------------------------------*/
static void TimestampNow(uint8_t *buff, uint16_t* size)
{
SysTime_t curtime = SysTimeGet();
sprintf((char *)buff, "%ds%d:", curtime.Seconds, curtime.SubSeconds);
*size = strlen((char *)buff);
}
static void Gpio_PreInit(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* Configure all IOs in analog input */
/* Except PA143 and PA14 (SWCLK and SWD) for debug*/
/* PA13 and PA14 are configured in debug_init */
/* Configure all GPIO as analog to reduce current consumption on non used IOs */
/* Enable GPIOs clock */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
GPIO_InitStruct.Pull = GPIO_NOPULL;
/* All GPIOs except debug pins (SWCLK and SWD) */
GPIO_InitStruct.Pin = GPIO_PIN_All & (~(GPIO_PIN_13 | GPIO_PIN_14));
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* All GPIOs */
GPIO_InitStruct.Pin = GPIO_PIN_All;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
HAL_GPIO_Init(GPIOH, &GPIO_InitStruct);
/* Disable GPIOs clock */
__HAL_RCC_GPIOA_CLK_DISABLE();
__HAL_RCC_GPIOB_CLK_DISABLE();
__HAL_RCC_GPIOC_CLK_DISABLE();
__HAL_RCC_GPIOH_CLK_DISABLE();
}
/* Disable StopMode when traces need to be printed */
void UTIL_ADV_TRACE_PreSendHook (void)
{
#if LOW_POWER_MODE_ENBLE
UTIL_LPM_SetStopMode(LPM_UART_TX_Id , UTIL_LPM_DISABLE );
#endif
}
/* Reenable StopMode when traces have been printed */
void UTIL_ADV_TRACE_PostSendHook (void)
{
#if LOW_POWER_MODE_ENBLE
UTIL_LPM_SetStopMode(LPM_UART_TX_Id , UTIL_LPM_ENABLE );
#endif
}
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,71 @@
/**
******************************************************************************
* @file app_system.h
* @author MCD Application Team
* @brief function prototypes for app_system.c file
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __APP_SYSTEM_H__
#define __APP_SYSTEM_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
#include "app_conf.h"
#include "mw_log_conf.h"
#include <stdio.h>
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* External variables --------------------------------------------------------*/
/* Exported macros -----------------------------------------------------------*/
#if defined (APP_LOG_ENABLED) && (APP_LOG_ENABLED == 1)
#define APP_LOG LOG_PRINT
#define APP_PPRINTF printf
#define APP_TPRINTF printf
#define APP_PRINTF printf
#elif defined (APP_LOG_ENABLED) && (APP_LOG_ENABLED == 0)
#define APP_LOG(...)
#define APP_PPRINTF(...)
#define APP_TPRINTF(...)
#define APP_PRINTF(...)
#else
#error "APP_LOG_ENABLED not defined or out of range <0,1>"
#endif
/* Defines -------------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
/**
* @brief initialises the system (dbg pins, trace, systiemr, LPM, ...)
* @param none
* @retval none
*/
void SystemApp_Init(void);
#ifdef __cplusplus
}
#endif
#endif /* __APP_SYSTEM_H__ */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,52 @@
/******************************************************************************
* @file lorawan_version.h
* @author MCD Application Team
* @brief defines the lora mac version
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LORAWAN_VERSION_H__
#define __LORAWAN_VERSION_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "lora_mac_version.h"
/* Exported constants --------------------------------------------------------*/
#define __APP_VERSION_MAIN (0x00U) /*!< [31:24] main version */
#define __APP_VERSION_SUB1 (0x04U) /*!< [23:16] sub1 version */
#define __APP_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */
#define __APP_VERSION_RC (0x00U) /*!< [7:0] release candidate */
#define __APP_VERSION ((__APP_VERSION_MAIN <<24)\
|(__APP_VERSION_SUB1 << 16)\
|(__APP_VERSION_SUB2 << 8 )\
|(__APP_VERSION_RC))
#define __MAC_VERSION (uint32_t) (LORA_MAC_VERSION )
/* Exported types ------------------------------------------------------------*/
/* External variables --------------------------------------------------------*/
/* Exported macros -----------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
#ifdef __cplusplus
}
#endif
#endif /*__LORAWAN_VERSION_H__*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,120 @@
#include "mcu_init.h"
#include "app_system.h"
#include "app_lorawan.h"
int fputc(int ch, FILE *f)
{
if (ch == '\n') {
HAL_UART_Transmit(&huart1, (void *)"\r", 1, 30000);
}
HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);
return ch;
}
int _write(int fd, char *ptr, int len)
{
(void)HAL_UART_Transmit(&huart1, (uint8_t *)ptr, len, 0xFFFF);
return len;
}
int fgetc(FILE *f)
{
/* Place your implementation of fgetc here */
/* e.g. readwrite a character to the USART2 and Loop until the end of transmission */
uint8_t ch = 0;
HAL_UART_Receive(&huart1, &ch, 1,30000);
return ch;
}
void board_init(void)
{
HAL_Init();
SystemClock_Config();
SystemApp_Init();
MX_LoRaWAN_Init();
}
/**
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
/** Initializes the CPU, AHB and APB busses clocks
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI;
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
RCC_OscInitStruct.LSEState = RCC_LSE_OFF;
RCC_OscInitStruct.HSICalibrationValue = 70;
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV2;
RCC_OscInitStruct.PLL.PLLN = 30;
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV5;
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV5;
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV5;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Configure the SYSCLKSource, HCLK, PCLK1 and PCLK2 clocks dividers
*/
RCC_ClkInitStruct.ClockType = (RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 | RCC_CLOCKTYPE_HCLK3);
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
{
Error_Handler();
}
}
/* USER CODE BEGIN 4 */
/* USER CODE END 4 */
/**
* @brief This function is executed in case of error occurrence.
* @retval None
*/
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
while(1)
{
}
/* USER CODE END Error_Handler_Debug */
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,255 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file Templates/Src/stm32wlxx_it.c
* @author MCD Application Team
* @brief Main Interrupt Service Routines.
* This file provides template for all exceptions handler and
* peripherals interrupt service routine.
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
#include "stm32wlxx_it.h"
#include "tos_k.h"
#include "sensor_parser.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN TD */
/* USER CODE END TD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
/* USER CODE BEGIN PV */
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* USER CODE END 0 */
/* External variables --------------------------------------------------------*/
extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart2;
extern SUBGHZ_HandleTypeDef hsubghz;
/* USER CODE BEGIN EV */
/* USER CODE END EV */
/******************************************************************************/
/* Cortex Processor Interruption and Exception Handlers */
/******************************************************************************/
/**
* @brief This function handles Non maskable interrupt.
*/
void NMI_Handler(void)
{
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
/* USER CODE END NonMaskableInt_IRQn 0 */
/* USER CODE BEGIN NonMaskableInt_IRQn 1 */
/* USER CODE END NonMaskableInt_IRQn 1 */
}
/**
* @brief This function handles Hard fault interrupt.
*/
void HardFault_Handler(void)
{
/* USER CODE BEGIN HardFault_IRQn 0 */
/* USER CODE END HardFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
/* USER CODE END W1_HardFault_IRQn 0 */
}
}
/**
* @brief This function handles Memory management fault.
*/
void MemManage_Handler(void)
{
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
/* USER CODE END MemoryManagement_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
/* USER CODE END W1_MemoryManagement_IRQn 0 */
}
}
/**
* @brief This function handles Prefetch fault, memory access fault.
*/
void BusFault_Handler(void)
{
/* USER CODE BEGIN BusFault_IRQn 0 */
/* USER CODE END BusFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_BusFault_IRQn 0 */
/* USER CODE END W1_BusFault_IRQn 0 */
}
}
/**
* @brief This function handles Undefined instruction or illegal state.
*/
void UsageFault_Handler(void)
{
/* USER CODE BEGIN UsageFault_IRQn 0 */
/* USER CODE END UsageFault_IRQn 0 */
while (1)
{
/* USER CODE BEGIN W1_UsageFault_IRQn 0 */
/* USER CODE END W1_UsageFault_IRQn 0 */
}
}
/**
* @brief This function handles System service call via SWI instruction.
*/
void SVC_Handler(void)
{
/* USER CODE BEGIN SVCall_IRQn 0 */
/* USER CODE END SVCall_IRQn 0 */
/* USER CODE BEGIN SVCall_IRQn 1 */
/* USER CODE END SVCall_IRQn 1 */
}
/**
* @brief This function handles Debug monitor.
*/
void DebugMon_Handler(void)
{
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
/* USER CODE END DebugMonitor_IRQn 0 */
/* USER CODE BEGIN DebugMonitor_IRQn 1 */
/* USER CODE END DebugMonitor_IRQn 1 */
}
/**
* @brief This function handles Pendable request for system service.
*/
__weak void PendSV_Handler(void)
{
/* USER CODE BEGIN PendSV_IRQn 0 */
/* USER CODE END PendSV_IRQn 0 */
/* USER CODE BEGIN PendSV_IRQn 1 */
/* USER CODE END PendSV_IRQn 1 */
}
/**
* @brief This function handles System tick timer.
*/
void SysTick_Handler(void)
{
/* USER CODE BEGIN SysTick_IRQn 0 */
/* USER CODE END SysTick_IRQn 0 */
HAL_IncTick();
if (tos_knl_is_running())
{
tos_knl_irq_enter();
tos_tick_handler();
tos_knl_irq_leave();
}
/* USER CODE BEGIN SysTick_IRQn 1 */
/* USER CODE END SysTick_IRQn 1 */
}
/******************************************************************************/
/* STM32WLxx Peripheral Interrupt Handlers */
/* Add here the Interrupt Handlers for the used peripherals. */
/* For the available peripheral interrupt handler names, */
/* please refer to the startup file (startup_stm32wlxx.s). */
/******************************************************************************/
void USART1_IRQHandler(void)
{
/* USER CODE BEGIN USART1_IRQn 0 */
/* USER CODE END USART1_IRQn 0 */
HAL_UART_IRQHandler(&huart1);
/* USER CODE BEGIN USART2_IRQn 1 */
/* USER CODE END USART2_IRQn 1 */
}
void USART2_IRQHandler(void)
{
/* USER CODE BEGIN LPUART1_IRQn 0 */
/* USER CODE END LPUART1_IRQn 0 */
tos_knl_irq_enter();
HAL_UART_IRQHandler(&huart2);
tos_knl_irq_leave();
/* USER CODE BEGIN LPUART1_IRQn 1 */
/* USER CODE END LPUART1_IRQn 1 */
}
void Radio_IRQHandler(void)
{
HAL_SUBGHZ_IRQHandler(&hsubghz);
}
/* USER CODE BEGIN 1 */
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
extern uint8_t msg;
if(huart ->Instance == USART2)
{
tos_shell_input_byte(msg);
HAL_UART_Receive_IT(&huart2, (uint8_t*)&msg, 1);
}
}
/* USER CODE END 1 */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,91 @@
/**
******************************************************************************
* @file lorawan_conf.h
* @author MCD Application Team
* @brief configures lorawan instances
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __LORAWAN_CONF_H__
#define __LORAWAN_CONF_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32_systime.h"
#include "app_conf.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* External variables --------------------------------------------------------*/
/* Exported macros -----------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
/* Defines ------------------------------------------------------------------*/
#ifndef CRITICAL_SECTION_BEGIN
#define CRITICAL_SECTION_BEGIN( ) UTILS_ENTER_CRITICAL_SECTION( )
#endif
#ifndef CRITICAL_SECTION_END
#define CRITICAL_SECTION_END( ) UTILS_EXIT_CRITICAL_SECTION( )
#endif
/* Region ------------------------------------*/
/* the region listed here will be linked in the MW code */
/* the applic (on app_conf.h) shall just configure one region at the time */
//#define REGION_AS923
//#define REGION_AU915
#define REGION_CN470
#define REGION_CN470ALI
//#define REGION_CN779
//#define REGION_EU433
#define REGION_EU868
//#define REGION_KR920
//#define REGION_IN865
#define REGION_US915
//#define REGION_RU864
#ifdef LORAMAC_CLASSB_ENABLED
/* CLASS B LSE crystall calibration*/
/*!
* \brief Temperature coefficient of the clock source
*/
#define RTC_TEMP_COEFFICIENT ( -0.035 )
/*!
* \brief Temperature coefficient deviation of the clock source
*/
#define RTC_TEMP_DEV_COEFFICIENT ( 0.0035 )
/*!
* \brief Turnover temperature of the clock source
*/
#define RTC_TEMP_TURNOVER ( 25.0 )
/*!
* \brief Turnover temperature deviation of the clock source
*/
#define RTC_TEMP_DEV_TURNOVER ( 5.0 )
#endif
#ifdef __cplusplus
}
#endif
#endif /* __LORAWAN_CONF_H__ */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,73 @@
/**
******************************************************************************
* @file mw_log_conf.h
* @author MCD Application Team
* @brief Interface layer CM4 System to MBMUX (Mailbox Multiplexer)
*******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __MW_LOG_CONF_H__
#define __MW_LOG_CONF_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
#include <stdio.h>
#include "app_conf.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Exported macros -----------------------------------------------------------*/
#if LOG_LEVEL == 0
#define LOG_PRINT printf
#elif LOG_LEVEL == 1
#define LOG_PRINT(...) do{printf("<<line:%d ;function:%s >>\r\n"\
,__LINE__, __FUNCTION__);\
printf(__VA_ARGS__);}while(0);
#elif LOG_LEVEL == 2
#define LOG_PRINT(...) do{printf("<<<%s ->line:%d ;function:%s >>>\r\n"\
,__FILE__,__LINE__, __FUNCTION__);\
printf(__VA_ARGS__);}while(0);
#endif
#if defined (MW_LOG_ENABLED) && (MW_LOG_ENABLED == 1)
#define PPRINTF printf
#define TPRINTF printf
#define PRINTF printf
#define MW_LOG LOG_PRINT
#else
#define PPRINTF(...)
#define TPRINTF(...)
#define PRINTF(...)
#define MW_LOG(...)
#endif
/* Defines -------------------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
#ifdef __cplusplus
}
#endif
#endif /*__MW_LOG_CONF_H__ */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,64 @@
/*******************************************************************************
* @file radio_conf.h
* @author MCD Application Team
* @brief Header of radio configuration
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __RADIO_CONF_H__
#define __RADIO_CONF_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "platform.h"
#include "mw_log_conf.h"
#include "radio_driver.h"
#include "app_conf.h"
#include "stm32_mem.h"
#ifndef CRITICAL_SECTION_BEGIN
#define CRITICAL_SECTION_BEGIN( ) UTILS_ENTER_CRITICAL_SECTION( )
#endif
#ifndef CRITICAL_SECTION_END
#define CRITICAL_SECTION_END( ) UTILS_EXIT_CRITICAL_SECTION( )
#endif
/* Exported types ------------------------------------------------------------*/
/* Defines ------------------------*/
#define RADIO_RX_BUF_SIZE 255
//#define LET_SUBGHZ_MW_USING_DGB_LINE1_PIN
//#define LET_SUBGHZ_MW_USING_DGB_LINE2_PIN
/* Function mapping */
#define RADIO_DELAY_MS HAL_Delay
#define RADIO_MEMSET8( dest, value, size ) UTIL_MEM_set_8(dest, value, size )
/* Exported constants --------------------------------------------------------*/
/* External variables --------------------------------------------------------*/
/* Exported macros -----------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
#ifdef __cplusplus
}
#endif
#endif /* __RADIO_CONF_H__*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,41 @@
/******************************************************************************
* @file systime.h
* @author MCD Application Team
* @brief map middleware systime
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __SYSTIME_H__
#define __SYSTIME_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32_systime.h"
/* Exported constants --------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
/* External variables --------------------------------------------------------*/
/* Exported macros -----------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
#ifdef __cplusplus
}
#endif
#endif /*__SYSTIME_H__*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,72 @@
/******************************************************************************
* @file timer.h
* @author MCD Application Team
* @brief wrapper to timer server
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under Ultimate Liberty license
* SLA0044, the "License"; You may not use this file except in compliance with
* the License. You may obtain a copy of the License at:
* www.st.com/SLA0044
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __TIMER_H__
#define __TIMER_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
//#include "stm32_timer.h"
#include <tos_k.h>
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
#define TIMER_MAX_VAL 0xFFFFFFFFU
/* External variables --------------------------------------------------------*/
/* Exported macros -----------------------------------------------------------*/
#define TimerTime_t k_tick_t
#define TimerEvent_t k_timer_t
#define TimerInit(HANDLE, CB) do {\
tos_timer_create( HANDLE, TIMER_MAX_VAL, 0, CB, NULL, TOS_OPT_TIMER_ONESHOT);\
} while(0)
#define TimerSetValue(HANDLE, TIMEOUT) do{ \
tos_timer_delay_change(HANDLE, TIMEOUT);\
} while(0)
#define TimerStart(HANDLE) do {\
tos_timer_start(HANDLE);\
} while(0)
#define TimerStop(HANDLE) do {\
tos_timer_stop(HANDLE);\
} while(0)
#define TimerGetCurrentTime TIMER_GetCurrentTime
#define TimerGetElapsedTime TIMER_GetElapsedTime
uint8_t TIMER_GetCurrentTime(void);
uint8_t TIMER_GetElapsedTime(TimerTime_t past);
/* Exported functions ------------------------------------------------------- */
#ifdef __cplusplus
}
#endif
#endif /* __TIMER_H__*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

View File

@@ -0,0 +1,18 @@
#include <tos_k.h>
#include "timer.h"
#include "rtc_if.h"
uint8_t TIMER_GetCurrentTime(void)
{
uint32_t now = RTC_GetTimerValue( );
return RTC_Tick2ms(now);
}
uint8_t TIMER_GetElapsedTime(TimerTime_t past)
{
uint32_t nowInTicks = RTC_GetTimerValue();
uint32_t pastInTicks = RTC_ms2Tick(past);
/* intentional wrap around. Works Ok if tick duation below 1ms */
return RTC_Tick2ms(nowInTicks - pastInTicks);
}

View File

@@ -0,0 +1,118 @@
/**
******************************************************************************
* @file utilities_conf.h
* @author MCD Application Team
* @brief Configuration file to utilities
******************************************************************************
* @attention
*
* <h2><center>&copy; Copyright (c) 2019 STMicroelectronics.
* All rights reserved.</center></h2>
*
* This software component is licensed by ST under BSD 3-Clause license,
* the "License"; You may not use this file except in compliance with the
* License. You may obtain a copy of the License at:
* opensource.org/licenses/BSD-3-Clause
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef UTILITIES_CONF_H
#define UTILITIES_CONF_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
#include "stm32wlxx.h"
/* definitions to be provided to "sequencer" utility */
#include "stm32_mem.h"
/* definition and callback for tiny_vsnprintf */
#include "stm32_tiny_vsnprintf.h"
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/******************************************************************************
* Common
******************************************************************************/
#if defined(__CC_ARM)
#define UTIL_PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__), zero_init))
#elif defined(__ICCARM__)
#define UTIL_PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__)))
#else /* __GNUC__ */
#define UTIL_PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__)))
#endif
#undef ALIGN
#ifdef WIN32
#define ALIGN(n)
#else
#define ALIGN(n) __attribute__((aligned(n)))
#endif
/*---------------------------------------------------------------------------*/
/* sequencer configuration */
/*---------------------------------------------------------------------------*/
#define UTIL_SEQ_RFU 0
#define UTIL_SEQ_INIT_CRITICAL_SECTION( ) UTILS_INIT_CRITICAL_SECTION()
#define UTIL_SEQ_ENTER_CRITICAL_SECTION( ) UTILS_ENTER_CRITICAL_SECTION()
#define UTIL_SEQ_EXIT_CRITICAL_SECTION( ) UTILS_EXIT_CRITICAL_SECTION()
#define UTIL_SEQ_MEMSET8( dest, value, size ) UTIL_MEM_set_8( dest, value, size )
/* External variables --------------------------------------------------------*/
/* Exported macros -----------------------------------------------------------*/
#define UTILS_INIT_CRITICAL_SECTION()
#define UTILS_ENTER_CRITICAL_SECTION() uint32_t primask_bit= __get_PRIMASK();\
__disable_irq()
#define UTILS_EXIT_CRITICAL_SECTION() __set_PRIMASK(primask_bit)
/* Exported functions ------------------------------------------------------- */
/******************************************************************************
* trace\advanced
* the define option
* UTIL_ADV_TRACE_CONDITIONNAL shall be defined if you want use conditionnal function
* UTIL_ADV_TRACE_UNCHUNK_MODE shall be defined if you want use the unchunk mode
*
******************************************************************************/
#define VLEVEL_OFF 0
#define VLEVEL_L 1 /* just essential traces */
#define VLEVEL_M 2
#define VLEVEL_H 3 /* all traces */
#define TS_OFF 0 /*Log without TimeStamp*/
#define TS_ON 1 /*Log with TimeStamp*/
#define T_REG_OFF 0 /*Log without bitmask*/
#define UTIL_ADV_TRACE_CONDITIONNAL
#define UTIL_ADV_TRACE_UNCHUNK_MODE
#define UTIL_ADV_TRACE_DEBUG(...)
#define UTIL_ADV_TRACE_INIT_CRITICAL_SECTION( ) UTILS_INIT_CRITICAL_SECTION()
#define UTIL_ADV_TRACE_ENTER_CRITICAL_SECTION( ) UTILS_ENTER_CRITICAL_SECTION()
#define UTIL_ADV_TRACE_EXIT_CRITICAL_SECTION( ) UTILS_EXIT_CRITICAL_SECTION()
#define UTIL_ADV_TRACE_TMP_BUF_SIZE (256U)
#define UTIL_ADV_TRACE_TMP_MAX_TIMESTMAP_SIZE (15U)
#define UTIL_ADV_TRACE_FIFO_SIZE (512U)
#define UTIL_ADV_TRACE_MEMSET8( dest, value, size) UTIL_MEM_set_8((dest),(value),(size))
#define UTIL_ADV_TRACE_VSNPRINTF(...) tiny_vsnprintf_like(__VA_ARGS__)
#ifdef __cplusplus
}
#endif
#endif /*UTILITIES_CONF_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,359 @@
;******************************************************************************
;* File Name : startup_stm32wle5xx_cm4.s
;* Author : MCD Application Team
;* Description : STM32WLE5xx devices vector table for MDK-ARM toolchain.
;* This module performs:
;* - Set the initial SP
;* - Set the initial PC == Reset_Handler
;* - Set the vector table entries with the exceptions ISR address
;* - Branches to __main in the C library (which eventually
;* calls main()).
;* After Reset the CortexM4 processor is in Thread mode,
;* priority is Privileged, and the Stack is set to Main.
;* <<< Use Configuration Wizard in Context Menu >>>
;******************************************************************************
;* @attention
;*
;* Copyright (c) 2019 STMicroelectronics. All rights reserved.
;*
;* This software component is licensed by ST under BSD 3-Clause license,
;* the "License"; You may not use this file except in compliance with the
;* License. You may obtain a copy of the License at:
;* opensource.org/licenses/BSD-3-Clause
;*
;******************************************************************************
; Amount of memory (in bytes) allocated for Stack
; Tailor this value to your application needs
; <h> Stack Configuration
; <o> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Stack_Size EQU 0x00000800
AREA STACK, NOINIT, READWRITE, ALIGN=3
Stack_Mem SPACE Stack_Size
__initial_sp
; <h> Heap Configuration
; <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
; </h>
Heap_Size EQU 0x00000200
AREA HEAP, NOINIT, READWRITE, ALIGN=3
__heap_base
Heap_Mem SPACE Heap_Size
__heap_limit
PRESERVE8
THUMB
; Vector Table Mapped to Address 0 at Reset
AREA RESET, DATA, READONLY
EXPORT __Vectors
EXPORT __Vectors_End
EXPORT __Vectors_Size
__Vectors DCD __initial_sp ; Top of Stack
DCD Reset_Handler ; Reset Handler
DCD NMI_Handler ; NMI Handler
DCD HardFault_Handler ; Hard Fault Handler
DCD MemManage_Handler ; MPU Fault Handler
DCD BusFault_Handler ; Bus Fault Handler
DCD UsageFault_Handler ; Usage Fault Handler
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD SVC_Handler ; SVCall Handler
DCD DebugMon_Handler ; Debug Monitor Handler
DCD 0 ; Reserved
DCD PendSV_Handler ; PendSV Handler
DCD SysTick_Handler ; SysTick Handler
; External Interrupts
DCD WWDG_IRQHandler ; Window WatchDog
DCD PVD_PVM_IRQHandler ; PVD and PVM detector
DCD TAMP_STAMP_LSECSS_SSRU_IRQHandler ; RTC Tamper, RTC TimeStamp, LSECSS and RTC SSR Underflow Interrupts
DCD RTC_WKUP_IRQHandler ; RTC Wakeup Interrupt
DCD FLASH_IRQHandler ; FLASH global Interrupt
DCD RCC_IRQHandler ; RCC Interrupt
DCD EXTI0_IRQHandler ; EXTI Line 0 Interrupt
DCD EXTI1_IRQHandler ; EXTI Line 1 Interrupt
DCD EXTI2_IRQHandler ; EXTI Line 2 Interrupt
DCD EXTI3_IRQHandler ; EXTI Line 3 Interrup
DCD EXTI4_IRQHandler ; EXTI Line 4 Interrupt
DCD DMA1_Channel1_IRQHandler ; DMA1 Channel 1 Interrupt
DCD DMA1_Channel2_IRQHandler ; DMA1 Channel 2 Interrupt
DCD DMA1_Channel3_IRQHandler ; DMA1 Channel 3 Interrupt
DCD DMA1_Channel4_IRQHandler ; DMA1 Channel 4 Interrupt
DCD DMA1_Channel5_IRQHandler ; DMA1 Channel 5 Interrupt
DCD DMA1_Channel6_IRQHandler ; DMA1 Channel 6 Interrupt
DCD DMA1_Channel7_IRQHandler ; DMA1 Channel 7 Interrupt
DCD ADC1_IRQHandler ; ADC1 Interrupt
DCD DAC_IRQHandler ; DAC Interrupt
DCD 0 ; Reserved
DCD COMP_IRQHandler ; COMP1 and COMP2 Interrupts
DCD EXTI9_5_IRQHandler ; EXTI Lines [9:5] Interrupt
DCD TIM1_BRK_IRQHandler ; TIM1 Break Interrupt
DCD TIM1_UP_IRQHandler ; TIM1 Update Interrupts
DCD TIM1_TRG_COM_IRQHandler ; TIM1 Trigger and Communication Interrupts
DCD TIM1_CC_IRQHandler ; TIM1 Capture Compare Interrupt
DCD TIM2_IRQHandler ; TIM2 Global Interrupt
DCD TIM16_IRQHandler ; TIM16 Global Interrupt
DCD TIM17_IRQHandler ; TIM17 Global Interrupt
DCD I2C1_EV_IRQHandler ; I2C1 Event Interrupt
DCD I2C1_ER_IRQHandler ; I2C1 Error Interrupt
DCD I2C2_EV_IRQHandler ; I2C2 Event Interrupt
DCD I2C2_ER_IRQHandler ; I2C2 Error Interrupt
DCD SPI1_IRQHandler ; SPI1 Interrupt
DCD SPI2_IRQHandler ; SPI2 Interrupt
DCD USART1_IRQHandler ; USART1 Interrupt
DCD USART2_IRQHandler ; USART2 Interrupt
DCD LPUART1_IRQHandler ; LPUART1 Interrupt
DCD LPTIM1_IRQHandler ; LPTIM1 Interrupt
DCD LPTIM2_IRQHandler ; LPTIM2 Interrupt
DCD EXTI15_10_IRQHandler ; EXTI Lines1[15:10 ]Interrupts
DCD RTC_Alarm_IRQHandler ; RTC Alarms (A and B) Interrupt
DCD LPTIM3_IRQHandler ; LPTIM3 Interrupt
DCD SUBGHZSPI_IRQHandler ; SUBGHZSPI Interrupt
DCD 0 ; Reserved
DCD 0 ; Reserved
DCD HSEM_IRQHandler ; HSEM0 Interrupt
DCD I2C3_EV_IRQHandler ; I2C3 Event Interrupt
DCD I2C3_ER_IRQHandler ; I2C3 Error Interrupt
DCD Radio_IRQHandler ; Radio Interrupt
DCD AES_IRQHandler ; AES Interrupt
DCD RNG_IRQHandler ; RNG1 Interrupt
DCD PKA_IRQHandler ; PKA Interrupt
DCD DMA2_Channel1_IRQHandler ; DMA2 Channel 1 Interrupt
DCD DMA2_Channel2_IRQHandler ; DMA2 Channel 2 Interrupt
DCD DMA2_Channel3_IRQHandler ; DMA2 Channel 3 Interrupt
DCD DMA2_Channel4_IRQHandler ; DMA2 Channel 4 Interrupt
DCD DMA2_Channel5_IRQHandler ; DMA2 Channel 5 Interrupt
DCD DMA2_Channel6_IRQHandler ; DMA2 Channel 6 Interrupt
DCD DMA2_Channel7_IRQHandler ; DMA2 Channel 7 Interrupt
DCD DMAMUX1_OVR_IRQHandler ; DMAMUX overrun Interrupt
__Vectors_End
__Vectors_Size EQU __Vectors_End - __Vectors
AREA |.text|, CODE, READONLY
; Reset handler
Reset_Handler PROC
EXPORT Reset_Handler [WEAK]
IMPORT SystemInit
IMPORT __main
LDR R0, =SystemInit
BLX R0
LDR R0, =__main
BX R0
ENDP
; Dummy Exception Handlers (infinite loops which can be modified)
NMI_Handler PROC
EXPORT NMI_Handler [WEAK]
B .
ENDP
HardFault_Handler\
PROC
EXPORT HardFault_Handler [WEAK]
B .
ENDP
MemManage_Handler\
PROC
EXPORT MemManage_Handler [WEAK]
B .
ENDP
BusFault_Handler\
PROC
EXPORT BusFault_Handler [WEAK]
B .
ENDP
UsageFault_Handler\
PROC
EXPORT UsageFault_Handler [WEAK]
B .
ENDP
SVC_Handler PROC
EXPORT SVC_Handler [WEAK]
B .
ENDP
DebugMon_Handler\
PROC
EXPORT DebugMon_Handler [WEAK]
B .
ENDP
PendSV_Handler PROC
EXPORT PendSV_Handler [WEAK]
B .
ENDP
SysTick_Handler PROC
EXPORT SysTick_Handler [WEAK]
B .
ENDP
Default_Handler PROC
EXPORT WWDG_IRQHandler [WEAK]
EXPORT PVD_PVM_IRQHandler [WEAK]
EXPORT TAMP_STAMP_LSECSS_SSRU_IRQHandler [WEAK]
EXPORT RTC_WKUP_IRQHandler [WEAK]
EXPORT FLASH_IRQHandler [WEAK]
EXPORT RCC_IRQHandler [WEAK]
EXPORT EXTI0_IRQHandler [WEAK]
EXPORT EXTI1_IRQHandler [WEAK]
EXPORT EXTI2_IRQHandler [WEAK]
EXPORT EXTI3_IRQHandler [WEAK]
EXPORT EXTI4_IRQHandler [WEAK]
EXPORT DMA1_Channel1_IRQHandler [WEAK]
EXPORT DMA1_Channel2_IRQHandler [WEAK]
EXPORT DMA1_Channel3_IRQHandler [WEAK]
EXPORT DMA1_Channel4_IRQHandler [WEAK]
EXPORT DMA1_Channel5_IRQHandler [WEAK]
EXPORT DMA1_Channel6_IRQHandler [WEAK]
EXPORT DMA1_Channel7_IRQHandler [WEAK]
EXPORT ADC1_IRQHandler [WEAK]
EXPORT DAC_IRQHandler [WEAK]
EXPORT COMP_IRQHandler [WEAK]
EXPORT EXTI9_5_IRQHandler [WEAK]
EXPORT TIM1_BRK_IRQHandler [WEAK]
EXPORT TIM1_UP_IRQHandler [WEAK]
EXPORT TIM1_TRG_COM_IRQHandler [WEAK]
EXPORT TIM1_CC_IRQHandler [WEAK]
EXPORT TIM2_IRQHandler [WEAK]
EXPORT TIM16_IRQHandler [WEAK]
EXPORT TIM17_IRQHandler [WEAK]
EXPORT I2C1_EV_IRQHandler [WEAK]
EXPORT I2C1_ER_IRQHandler [WEAK]
EXPORT I2C2_EV_IRQHandler [WEAK]
EXPORT I2C2_ER_IRQHandler [WEAK]
EXPORT SPI1_IRQHandler [WEAK]
EXPORT SPI2_IRQHandler [WEAK]
EXPORT USART1_IRQHandler [WEAK]
EXPORT USART2_IRQHandler [WEAK]
EXPORT LPUART1_IRQHandler [WEAK]
EXPORT LPTIM1_IRQHandler [WEAK]
EXPORT LPTIM2_IRQHandler [WEAK]
EXPORT EXTI15_10_IRQHandler [WEAK]
EXPORT RTC_Alarm_IRQHandler [WEAK]
EXPORT LPTIM3_IRQHandler [WEAK]
EXPORT SUBGHZSPI_IRQHandler [WEAK]
EXPORT HSEM_IRQHandler [WEAK]
EXPORT I2C3_EV_IRQHandler [WEAK]
EXPORT I2C3_ER_IRQHandler [WEAK]
EXPORT Radio_IRQHandler [WEAK]
EXPORT AES_IRQHandler [WEAK]
EXPORT RNG_IRQHandler [WEAK]
EXPORT PKA_IRQHandler [WEAK]
EXPORT DMA2_Channel1_IRQHandler [WEAK]
EXPORT DMA2_Channel2_IRQHandler [WEAK]
EXPORT DMA2_Channel3_IRQHandler [WEAK]
EXPORT DMA2_Channel4_IRQHandler [WEAK]
EXPORT DMA2_Channel5_IRQHandler [WEAK]
EXPORT DMA2_Channel6_IRQHandler [WEAK]
EXPORT DMA2_Channel7_IRQHandler [WEAK]
EXPORT DMAMUX1_OVR_IRQHandler [WEAK]
WWDG_IRQHandler
PVD_PVM_IRQHandler
TAMP_STAMP_LSECSS_SSRU_IRQHandler
RTC_WKUP_IRQHandler
FLASH_IRQHandler
RCC_IRQHandler
EXTI0_IRQHandler
EXTI1_IRQHandler
EXTI2_IRQHandler
EXTI3_IRQHandler
EXTI4_IRQHandler
DMA1_Channel1_IRQHandler
DMA1_Channel2_IRQHandler
DMA1_Channel3_IRQHandler
DMA1_Channel4_IRQHandler
DMA1_Channel5_IRQHandler
DMA1_Channel6_IRQHandler
DMA1_Channel7_IRQHandler
ADC1_IRQHandler
DAC_IRQHandler
COMP_IRQHandler
EXTI9_5_IRQHandler
TIM1_BRK_IRQHandler
TIM1_UP_IRQHandler
TIM1_TRG_COM_IRQHandler
TIM1_CC_IRQHandler
TIM2_IRQHandler
TIM16_IRQHandler
TIM17_IRQHandler
I2C1_EV_IRQHandler
I2C1_ER_IRQHandler
I2C2_EV_IRQHandler
I2C2_ER_IRQHandler
SPI1_IRQHandler
SPI2_IRQHandler
USART1_IRQHandler
USART2_IRQHandler
LPUART1_IRQHandler
LPTIM1_IRQHandler
LPTIM2_IRQHandler
EXTI15_10_IRQHandler
RTC_Alarm_IRQHandler
LPTIM3_IRQHandler
SUBGHZSPI_IRQHandler
HSEM_IRQHandler
I2C3_EV_IRQHandler
I2C3_ER_IRQHandler
Radio_IRQHandler
AES_IRQHandler
RNG_IRQHandler
PKA_IRQHandler
DMA2_Channel1_IRQHandler
DMA2_Channel2_IRQHandler
DMA2_Channel3_IRQHandler
DMA2_Channel4_IRQHandler
DMA2_Channel5_IRQHandler
DMA2_Channel6_IRQHandler
DMA2_Channel7_IRQHandler
DMAMUX1_OVR_IRQHandler
B .
ENDP
ALIGN
;*******************************************************************************
; User Stack and Heap initialization
;*******************************************************************************
IF :DEF:__MICROLIB
EXPORT __initial_sp
EXPORT __heap_base
EXPORT __heap_limit
ELSE
IMPORT __use_two_region_memory
EXPORT __user_initial_stackheap
__user_initial_stackheap
LDR R0, = Heap_Mem
LDR R1, =(Stack_Mem + Stack_Size)
LDR R2, = (Heap_Mem + Heap_Size)
LDR R3, = Stack_Mem
BX LR
ALIGN
ENDIF
END
;************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE*****