├── .cproject ├── .mxproject ├── .project ├── .settings ├── language.settings.xml └── stm32cubeide.project.prefs ├── Core ├── Inc │ ├── adc.h │ ├── adc_if.h │ ├── dma.h │ ├── flash_if.h │ ├── gpio.h │ ├── main.h │ ├── platform.h │ ├── rtc.h │ ├── stm32_lpm_if.h │ ├── stm32wlxx_hal_conf.h │ ├── stm32wlxx_it.h │ ├── stm32wlxx_nucleo_conf.h │ ├── subghz.h │ ├── sys_app.h │ ├── sys_conf.h │ ├── sys_debug.h │ ├── sys_sensors.h │ ├── timer_if.h │ ├── usart.h │ ├── usart_if.h │ ├── utilities_conf.h │ └── utilities_def.h ├── Src │ ├── adc.c │ ├── adc_if.c │ ├── dma.c │ ├── flash_if.c │ ├── gpio.c │ ├── main.c │ ├── rtc.c │ ├── stm32_lpm_if.c │ ├── stm32wlxx_hal_msp.c │ ├── stm32wlxx_it.c │ ├── subghz.c │ ├── sys_app.c │ ├── sys_debug.c │ ├── sys_sensors.c │ ├── system_stm32wlxx.c │ ├── timer_if.c │ ├── usart.c │ └── usart_if.c └── Startup │ └── startup_stm32wle5ccux.s ├── Drivers ├── BSP │ └── STM32WLxx_Nucleo │ │ ├── LICENSE.txt │ │ ├── stm32wlxx_nucleo.c │ │ ├── stm32wlxx_nucleo.h │ │ ├── stm32wlxx_nucleo_errno.h │ │ ├── stm32wlxx_nucleo_radio.c │ │ └── stm32wlxx_nucleo_radio.h ├── CMSIS │ ├── Device │ │ └── ST │ │ │ └── STM32WLxx │ │ │ ├── Include │ │ │ ├── stm32wle5xx.h │ │ │ ├── stm32wlxx.h │ │ │ └── system_stm32wlxx.h │ │ │ └── LICENSE.txt │ ├── Include │ │ ├── cmsis_armcc.h │ │ ├── cmsis_armclang.h │ │ ├── cmsis_armclang_ltm.h │ │ ├── cmsis_compiler.h │ │ ├── cmsis_gcc.h │ │ ├── cmsis_iccarm.h │ │ ├── cmsis_version.h │ │ ├── core_armv81mml.h │ │ ├── core_armv8mbl.h │ │ ├── core_armv8mml.h │ │ ├── core_cm0.h │ │ ├── core_cm0plus.h │ │ ├── core_cm1.h │ │ ├── core_cm23.h │ │ ├── core_cm3.h │ │ ├── core_cm33.h │ │ ├── core_cm35p.h │ │ ├── core_cm4.h │ │ ├── core_cm7.h │ │ ├── core_sc000.h │ │ ├── core_sc300.h │ │ ├── mpu_armv7.h │ │ ├── mpu_armv8.h │ │ └── tz_context.h │ └── LICENSE.txt └── STM32WLxx_HAL_Driver │ ├── Inc │ ├── Legacy │ │ └── stm32_hal_legacy.h │ ├── stm32wlxx_hal.h │ ├── stm32wlxx_hal_adc.h │ ├── stm32wlxx_hal_adc_ex.h │ ├── stm32wlxx_hal_cortex.h │ ├── stm32wlxx_hal_def.h │ ├── stm32wlxx_hal_dma.h │ ├── stm32wlxx_hal_dma_ex.h │ ├── stm32wlxx_hal_exti.h │ ├── stm32wlxx_hal_flash.h │ ├── stm32wlxx_hal_flash_ex.h │ ├── stm32wlxx_hal_gpio.h │ ├── stm32wlxx_hal_gpio_ex.h │ ├── stm32wlxx_hal_pwr.h │ ├── stm32wlxx_hal_pwr_ex.h │ ├── stm32wlxx_hal_rcc.h │ ├── stm32wlxx_hal_rcc_ex.h │ ├── stm32wlxx_hal_rtc.h │ ├── stm32wlxx_hal_rtc_ex.h │ ├── stm32wlxx_hal_subghz.h │ ├── stm32wlxx_hal_tim.h │ ├── stm32wlxx_hal_tim_ex.h │ ├── stm32wlxx_hal_uart.h │ ├── stm32wlxx_hal_uart_ex.h │ ├── stm32wlxx_ll_adc.h │ ├── stm32wlxx_ll_bus.h │ ├── stm32wlxx_ll_cortex.h │ ├── stm32wlxx_ll_dma.h │ ├── stm32wlxx_ll_dmamux.h │ ├── stm32wlxx_ll_exti.h │ ├── stm32wlxx_ll_gpio.h │ ├── stm32wlxx_ll_lpuart.h │ ├── stm32wlxx_ll_pwr.h │ ├── stm32wlxx_ll_rcc.h │ ├── stm32wlxx_ll_rtc.h │ ├── stm32wlxx_ll_spi.h │ ├── stm32wlxx_ll_system.h │ ├── stm32wlxx_ll_usart.h │ └── stm32wlxx_ll_utils.h │ ├── LICENSE.txt │ ├── License.md │ └── Src │ ├── stm32wlxx_hal.c │ ├── stm32wlxx_hal_adc.c │ ├── stm32wlxx_hal_adc_ex.c │ ├── stm32wlxx_hal_cortex.c │ ├── stm32wlxx_hal_dma.c │ ├── stm32wlxx_hal_dma_ex.c │ ├── stm32wlxx_hal_exti.c │ ├── stm32wlxx_hal_flash.c │ ├── stm32wlxx_hal_flash_ex.c │ ├── stm32wlxx_hal_gpio.c │ ├── stm32wlxx_hal_pwr.c │ ├── stm32wlxx_hal_pwr_ex.c │ ├── stm32wlxx_hal_rcc.c │ ├── stm32wlxx_hal_rcc_ex.c │ ├── stm32wlxx_hal_rtc.c │ ├── stm32wlxx_hal_rtc_ex.c │ ├── stm32wlxx_hal_subghz.c │ ├── stm32wlxx_hal_tim.c │ ├── stm32wlxx_hal_tim_ex.c │ ├── stm32wlxx_hal_uart.c │ ├── stm32wlxx_hal_uart_ex.c │ └── stm32wlxx_ll_adc.c ├── LoRaWAN ├── App │ ├── CayenneLpp.c │ ├── CayenneLpp.h │ ├── Commissioning.h │ ├── app_lorawan.c │ ├── app_lorawan.h │ ├── lora_app.c │ ├── lora_app.h │ ├── lora_app_version.h │ ├── lora_info.c │ ├── lora_info.h │ └── se-identity.h └── Target │ ├── lorawan_conf.h │ ├── mw_log_conf.h │ ├── radio_board_if.c │ ├── radio_board_if.h │ ├── radio_conf.h │ ├── systime.h │ └── timer.h ├── Middlewares └── Third_Party │ ├── LoRaWAN │ ├── Crypto │ │ ├── cmac.c │ │ ├── cmac.h │ │ ├── lorawan_aes.c │ │ ├── lorawan_aes.h │ │ └── soft-se.c │ ├── LICENSE │ ├── LICENSE.txt │ ├── LmHandler │ │ ├── LmHandler.c │ │ ├── LmHandler.h │ │ ├── LmHandlerTypes.h │ │ ├── NvmDataMgmt.c │ │ ├── NvmDataMgmt.h │ │ ├── Packages │ │ │ ├── LmhPackage.h │ │ │ ├── LmhpCompliance.c │ │ │ └── LmhpCompliance.h │ │ └── lorawan_version.h │ ├── Mac │ │ ├── LoRaMac.c │ │ ├── LoRaMac.h │ │ ├── LoRaMacAdr.c │ │ ├── LoRaMacAdr.h │ │ ├── LoRaMacClassB.c │ │ ├── LoRaMacClassB.h │ │ ├── LoRaMacClassBConfig.h │ │ ├── LoRaMacClassBNvm.h │ │ ├── LoRaMacCommands.c │ │ ├── LoRaMacCommands.h │ │ ├── LoRaMacConfirmQueue.c │ │ ├── LoRaMacConfirmQueue.h │ │ ├── LoRaMacCrypto.c │ │ ├── LoRaMacCrypto.h │ │ ├── LoRaMacCryptoNvm.h │ │ ├── LoRaMacHeaderTypes.h │ │ ├── LoRaMacInterfaces.h │ │ ├── LoRaMacMessageTypes.h │ │ ├── LoRaMacParser.c │ │ ├── LoRaMacParser.h │ │ ├── LoRaMacSerializer.c │ │ ├── LoRaMacSerializer.h │ │ ├── LoRaMacTest.h │ │ ├── LoRaMacTypes.h │ │ ├── LoRaMacVersion.h │ │ ├── Region │ │ │ ├── Region.c │ │ │ ├── Region.h │ │ │ ├── RegionAS923.c │ │ │ ├── RegionAS923.h │ │ │ ├── RegionAU915.c │ │ │ ├── RegionAU915.h │ │ │ ├── RegionBaseUS.c │ │ │ ├── RegionBaseUS.h │ │ │ ├── RegionCN470.c │ │ │ ├── RegionCN470.h │ │ │ ├── RegionCN470A20.c │ │ │ ├── RegionCN470A20.h │ │ │ ├── RegionCN470A26.c │ │ │ ├── RegionCN470A26.h │ │ │ ├── RegionCN470B20.c │ │ │ ├── RegionCN470B20.h │ │ │ ├── RegionCN470B26.c │ │ │ ├── RegionCN470B26.h │ │ │ ├── RegionCN779.c │ │ │ ├── RegionCN779.h │ │ │ ├── RegionCommon.c │ │ │ ├── RegionCommon.h │ │ │ ├── RegionEU433.c │ │ │ ├── RegionEU433.h │ │ │ ├── RegionEU868.c │ │ │ ├── RegionEU868.h │ │ │ ├── RegionIN865.c │ │ │ ├── RegionIN865.h │ │ │ ├── RegionKR920.c │ │ │ ├── RegionKR920.h │ │ │ ├── RegionNvm.h │ │ │ ├── RegionRU864.c │ │ │ ├── RegionRU864.h │ │ │ ├── RegionUS915.c │ │ │ ├── RegionUS915.h │ │ │ └── RegionVersion.h │ │ ├── secure-element-nvm.h │ │ └── secure-element.h │ └── Utilities │ │ ├── utilities.c │ │ └── utilities.h │ └── SubGHz_Phy │ ├── LICENSE │ ├── radio.h │ ├── radio_ex.h │ └── stm32_radio_driver │ ├── radio.c │ ├── radio_driver.c │ ├── radio_driver.h │ ├── radio_fw.c │ ├── radio_fw.h │ └── subghz_phy_version.h ├── RAK3172 Debug.launch ├── RAK3172.ioc ├── RAK3172.pdf ├── RAK3172.txt ├── README.md ├── STM32WLE5CCUX_FLASH.ld └── Utilities ├── lpm └── tiny_lpm │ ├── stm32_lpm.c │ └── stm32_lpm.h ├── misc ├── stm32_mem.c ├── stm32_mem.h ├── stm32_systime.c ├── stm32_systime.h ├── stm32_tiny_sscanf.c ├── stm32_tiny_sscanf.h ├── stm32_tiny_vsnprintf.c └── stm32_tiny_vsnprintf.h ├── sequencer ├── stm32_seq.c └── stm32_seq.h ├── timer ├── stm32_timer.c └── stm32_timer.h └── trace └── adv_trace ├── stm32_adv_trace.c └── stm32_adv_trace.h /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | RAK3172 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | com.st.stm32cube.ide.mcu.MCUProjectNature 23 | com.st.stm32cube.ide.mcu.MCUCubeProjectNature 24 | org.eclipse.cdt.core.cnature 25 | com.st.stm32cube.ide.mcu.MCUCubeIdeServicesRevAev2ProjectNature 26 | com.st.stm32cube.ide.mcu.MCUAdvancedStructureProjectNature 27 | com.st.stm32cube.ide.mcu.MCUSingleCpuProjectNature 28 | com.st.stm32cube.ide.mcu.MCURootProjectNature 29 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 30 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 31 | 32 | 33 | -------------------------------------------------------------------------------- /.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /.settings/stm32cubeide.project.prefs: -------------------------------------------------------------------------------- 1 | 66BE74F758C12D739921AEA421D593D3=1 2 | 8DF89ED150041C4CBC7CB9A9CAA90856=114F9991D47A1AF2F1697612EC38B604 3 | DC22A860405A8BF2F2C095E5B6529F12=114F9991D47A1AF2F1697612EC38B604 4 | eclipse.preferences.version=1 5 | -------------------------------------------------------------------------------- /Core/Inc/adc.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file adc.h 5 | * @brief This file contains all the function prototypes for 6 | * the adc.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2021 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __ADC_H__ 22 | #define __ADC_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | extern ADC_HandleTypeDef hadc; 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_ADC_Init(void); 42 | 43 | /* USER CODE BEGIN Prototypes */ 44 | 45 | /* USER CODE END Prototypes */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __ADC_H__ */ 52 | 53 | -------------------------------------------------------------------------------- /Core/Inc/adc_if.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file adc_if.h 5 | * @author MCD Application Team 6 | * @brief Header for ADC interface configuration 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2021 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __ADC_IF_H__ 23 | #define __ADC_IF_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "adc.h" 30 | #include "platform.h" 31 | 32 | /* USER CODE BEGIN Includes */ 33 | 34 | /* USER CODE END Includes */ 35 | 36 | /* Exported types ------------------------------------------------------------*/ 37 | /* USER CODE BEGIN ET */ 38 | 39 | /* USER CODE END ET */ 40 | 41 | /* Exported constants --------------------------------------------------------*/ 42 | /** 43 | * @brief Battery level in mV 44 | */ 45 | #define BAT_CR2032 ((uint32_t) 3000) 46 | /** 47 | * @brief Maximum battery level in mV 48 | */ 49 | #define VDD_BAT BAT_CR2032 50 | /** 51 | * @brief Minimum battery level in mV 52 | */ 53 | #define VDD_MIN 1800 54 | 55 | /* USER CODE BEGIN EC */ 56 | 57 | /* USER CODE END EC */ 58 | 59 | /* External variables --------------------------------------------------------*/ 60 | /* USER CODE BEGIN EV */ 61 | 62 | /* USER CODE END EV */ 63 | 64 | /* Exported macro ------------------------------------------------------------*/ 65 | /* USER CODE BEGIN EM */ 66 | 67 | /* USER CODE END EM */ 68 | 69 | /* Exported functions prototypes ---------------------------------------------*/ 70 | 71 | /** 72 | * @brief Initializes the ADC input 73 | */ 74 | void SYS_InitMeasurement(void); 75 | 76 | /** 77 | * @brief DeInitializes the ADC 78 | */ 79 | void SYS_DeInitMeasurement(void); 80 | 81 | /** 82 | * @brief Get the current temperature 83 | * @return value temperature in degree Celsius( q7.8 ) 84 | */ 85 | int16_t SYS_GetTemperatureLevel(void); 86 | 87 | /** 88 | * @brief Get the current battery level 89 | * @return value battery level in linear scale 90 | */ 91 | uint16_t SYS_GetBatteryLevel(void); 92 | 93 | /* USER CODE BEGIN EFP */ 94 | 95 | /* USER CODE END EFP */ 96 | 97 | #ifdef __cplusplus 98 | } 99 | #endif 100 | 101 | #endif /* __ADC_IF_H__ */ 102 | -------------------------------------------------------------------------------- /Core/Inc/dma.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file dma.h 5 | * @brief This file contains all the function prototypes for 6 | * the dma.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2021 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __DMA_H__ 22 | #define __DMA_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* DMA memory to memory transfer handles -------------------------------------*/ 32 | 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_DMA_Init(void); 42 | 43 | /* USER CODE BEGIN Prototypes */ 44 | 45 | /* USER CODE END Prototypes */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __DMA_H__ */ 52 | 53 | -------------------------------------------------------------------------------- /Core/Inc/flash_if.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file flash_if.h 5 | * @author MCD Application Team 6 | * @brief This file contains definitions for FLASH Interface functionalities. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __FLASH_IF_H__ 23 | #define __FLASH_IF_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "platform.h" 31 | 32 | /* USER CODE BEGIN Includes */ 33 | 34 | /* USER CODE END Includes */ 35 | 36 | /* Exported types ------------------------------------------------------------*/ 37 | /** 38 | * @brief Flash status enumeration 39 | */ 40 | enum 41 | { 42 | FLASH_PARAM_ERROR = -5, 43 | FLASH_LOCK_ERROR = -4, 44 | FLASH_WRITE_ERROR = -3, 45 | FLASH_ERASE_ERROR = -2, 46 | FLASH_ERROR = -1, 47 | FLASH_OK = 0, 48 | FLASH_BUSY = 1 49 | }; 50 | 51 | /* USER CODE BEGIN ET */ 52 | 53 | /* USER CODE END ET */ 54 | 55 | /* Exported constants --------------------------------------------------------*/ 56 | /* USER CODE BEGIN EC */ 57 | 58 | /* USER CODE END EC */ 59 | 60 | /* External variables --------------------------------------------------------*/ 61 | /* USER CODE BEGIN EV */ 62 | 63 | /* USER CODE END EV */ 64 | 65 | /* Exported macro ------------------------------------------------------------*/ 66 | #define PAGE(__ADDRESS__) (uint32_t)((((__ADDRESS__) - FLASH_BASE) % FLASH_BANK_SIZE) / FLASH_PAGE_SIZE) /*!< Get page index from page address */ 67 | 68 | /* USER CODE BEGIN EM */ 69 | 70 | /* USER CODE END EM */ 71 | 72 | /* Exported functions prototypes ---------------------------------------------*/ 73 | /** 74 | * @brief This function writes a user flash area (read/modify/write) 75 | * @param address: ptr to user flash area 76 | * @param data: ptr to data to be written 77 | * @param size: number of 32b. 78 | * @param dataTempPage: ptr used to copy already written page in ram 79 | * @return Flash status. 80 | */ 81 | int32_t FLASH_IF_Write(uint32_t address, uint8_t *data, uint32_t size, uint8_t *dataTempPage); 82 | 83 | /** 84 | * Writes a 64-bit word in flash at a specific address. 85 | * @param address (in bytes) must be a multiple of 8. 86 | * @param data data to write 87 | * @returns FLASH_OK, FLASH_BUSY, FLASH_ERASE_ERROR 88 | */ 89 | int32_t FLASH_IF_Write64(uint32_t address, uint64_t data); 90 | 91 | /** 92 | * Erases 'n' flash pages from page number 'page' to page number 93 | * 'page + n - 1'. 94 | * - If 'interrupt' is set to 0, the erasing is performed in polling mode. 95 | * - If 'interrupt' is set to 1, the erasing is performed under FLASH 96 | * interrupt: the function returns immediately and the user is informed of 97 | * the end of erasing procedure by a call to the following function that 98 | * must be implemented by the user: void HWCB_FLASH_EndOfCleanup( void ); 99 | * this call-back function is called under FLASH IRQ handler. 100 | * @param page memory start page number 101 | * @param n number of page 102 | * @param interrupt choice polling/interrupt 103 | * @returns FLASH_OK, FLASH_BUSY, FLASH_ERASE_ERROR 104 | */ 105 | int32_t FLASH_IF_EraseByPages(uint32_t page, uint16_t n, int32_t interrupt); 106 | 107 | /** 108 | * Callback 109 | */ 110 | void HWCB_FLASH_EndOfCleanup(void); 111 | 112 | /* USER CODE BEGIN EFP */ 113 | 114 | /* USER CODE END EFP */ 115 | 116 | #ifdef __cplusplus 117 | } 118 | #endif 119 | 120 | #endif /* __FLASH_IF_H__ */ 121 | -------------------------------------------------------------------------------- /Core/Inc/gpio.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.h 5 | * @brief This file contains all the function prototypes for 6 | * the gpio.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __GPIO_H__ 22 | #define __GPIO_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | /* USER CODE BEGIN Private defines */ 36 | 37 | /* USER CODE END Private defines */ 38 | 39 | void MX_GPIO_Init(void); 40 | 41 | /* USER CODE BEGIN Prototypes */ 42 | 43 | /* USER CODE END Prototypes */ 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | #endif /*__ GPIO_H__ */ 49 | 50 | -------------------------------------------------------------------------------- /Core/Inc/main.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file : main.h 5 | * @brief : Header for main.c file. 6 | * This file contains the common defines of the application. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2021 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __MAIN_H 23 | #define __MAIN_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32wlxx_hal.h" 31 | 32 | /* Private includes ----------------------------------------------------------*/ 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* USER CODE BEGIN ET */ 39 | 40 | /* USER CODE END ET */ 41 | 42 | /* Exported constants --------------------------------------------------------*/ 43 | /* USER CODE BEGIN EC */ 44 | 45 | /* USER CODE END EC */ 46 | 47 | /* Exported macro ------------------------------------------------------------*/ 48 | /* USER CODE BEGIN EM */ 49 | 50 | /* USER CODE END EM */ 51 | 52 | /* Exported functions prototypes ---------------------------------------------*/ 53 | void Error_Handler(void); 54 | 55 | /* USER CODE BEGIN EFP */ 56 | 57 | /* USER CODE END EFP */ 58 | 59 | /* Private defines -----------------------------------------------------------*/ 60 | #define RTC_PREDIV_A ((1<<(15-RTC_N_PREDIV_S))-1) 61 | #define RTC_N_PREDIV_S 10 62 | #define RTC_PREDIV_S ((1< 38 | #include "stm32wlxx.h" 39 | #include "main.h" 40 | #include "stm32wlxx_ll_gpio.h" 41 | #if defined(USE_BSP_DRIVER) 42 | /* code generated by STM32CubeMX does not support BSP. */ 43 | /* In order to use BSP, users can add the BSP files in the IDE project space */ 44 | /* and define USE_BSP_DRIVER in the preprocessor definitions */ 45 | #include "stm32wlxx_nucleo_radio.h" 46 | #include "stm32wlxx_nucleo.h" /* not used by this project*/ 47 | #endif /* defined(USE_BSP_DRIVER) */ 48 | 49 | /* USER CODE BEGIN include */ 50 | 51 | /* USER CODE END include */ 52 | 53 | /* Exported types ------------------------------------------------------------*/ 54 | /* USER CODE BEGIN ET */ 55 | 56 | /* USER CODE END ET */ 57 | 58 | /* External variables --------------------------------------------------------*/ 59 | /* USER CODE BEGIN EV */ 60 | 61 | /* USER CODE END EV */ 62 | 63 | /* Exported macro ------------------------------------------------------------*/ 64 | /* USER CODE BEGIN EM */ 65 | 66 | /* USER CODE END EM */ 67 | 68 | /* Exported functions prototypes ---------------------------------------------*/ 69 | /* USER CODE BEGIN EFP */ 70 | 71 | /* USER CODE END EFP */ 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif /* __PLATFORM_H__ */ 78 | -------------------------------------------------------------------------------- /Core/Inc/rtc.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file rtc.h 5 | * @brief This file contains all the function prototypes for 6 | * the rtc.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2021 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __RTC_H__ 22 | #define __RTC_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | extern RTC_HandleTypeDef hrtc; 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_RTC_Init(void); 42 | 43 | /* USER CODE BEGIN Prototypes */ 44 | 45 | /* USER CODE END Prototypes */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __RTC_H__ */ 52 | 53 | -------------------------------------------------------------------------------- /Core/Inc/stm32_lpm_if.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32_lpm_if.h 5 | * @author MCD Application Team 6 | * @brief Header for Low Power Manager interface configuration 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2021 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __STM32_LPM_IF_H__ 23 | #define __STM32_LPM_IF_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32_lpm.h" 31 | 32 | /* USER CODE BEGIN Includes */ 33 | 34 | /* USER CODE END Includes */ 35 | 36 | /* Exported types ------------------------------------------------------------*/ 37 | /* USER CODE BEGIN ET */ 38 | 39 | /* USER CODE END ET */ 40 | 41 | /* Exported constants --------------------------------------------------------*/ 42 | /* USER CODE BEGIN EC */ 43 | 44 | /* USER CODE END EC */ 45 | 46 | /* External variables --------------------------------------------------------*/ 47 | /* USER CODE BEGIN EV */ 48 | 49 | /* USER CODE END EV */ 50 | 51 | /* Exported macro ------------------------------------------------------------*/ 52 | /* USER CODE BEGIN EM */ 53 | 54 | /* USER CODE END EM */ 55 | 56 | /* Exported functions prototypes ---------------------------------------------*/ 57 | /** 58 | * @brief Enters Low Power Off Mode 59 | */ 60 | void PWR_EnterOffMode(void); 61 | 62 | /** 63 | * @brief Exits Low Power Off Mode 64 | */ 65 | void PWR_ExitOffMode(void); 66 | 67 | /** 68 | * @brief Enters Low Power Stop Mode 69 | * @note ARM exists the function when waking up 70 | */ 71 | void PWR_EnterStopMode(void); 72 | 73 | /** 74 | * @brief Exits Low Power Stop Mode 75 | * @note Enable the pll at 32MHz 76 | */ 77 | void PWR_ExitStopMode(void); 78 | 79 | /** 80 | * @brief Enters Low Power Sleep Mode 81 | * @note ARM exits the function when waking up 82 | */ 83 | void PWR_EnterSleepMode(void); 84 | 85 | /** 86 | * @brief Exits Low Power Sleep Mode 87 | * @note ARM exits the function when waking up 88 | */ 89 | void PWR_ExitSleepMode(void); 90 | 91 | /* USER CODE BEGIN EFP */ 92 | 93 | /* USER CODE END EFP */ 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | #endif /*__STM32_LPM_IF_H__ */ 100 | -------------------------------------------------------------------------------- /Core/Inc/stm32wlxx_it.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32wlxx_it.h 5 | * @brief This file contains the headers of the interrupt handlers. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2021 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | /* USER CODE END Header */ 19 | 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __STM32WLxx_IT_H 22 | #define __STM32WLxx_IT_H 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Private includes ----------------------------------------------------------*/ 29 | /* USER CODE BEGIN Includes */ 30 | 31 | /* USER CODE END Includes */ 32 | 33 | /* Exported types ------------------------------------------------------------*/ 34 | /* USER CODE BEGIN ET */ 35 | 36 | /* USER CODE END ET */ 37 | 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* USER CODE BEGIN EC */ 40 | 41 | /* USER CODE END EC */ 42 | 43 | /* Exported macro ------------------------------------------------------------*/ 44 | /* USER CODE BEGIN EM */ 45 | 46 | /* USER CODE END EM */ 47 | 48 | /* Exported functions prototypes ---------------------------------------------*/ 49 | void NMI_Handler(void); 50 | void HardFault_Handler(void); 51 | void MemManage_Handler(void); 52 | void BusFault_Handler(void); 53 | void UsageFault_Handler(void); 54 | void SVC_Handler(void); 55 | void DebugMon_Handler(void); 56 | void PendSV_Handler(void); 57 | void SysTick_Handler(void); 58 | void TAMP_STAMP_LSECSS_SSRU_IRQHandler(void); 59 | void DMA1_Channel1_IRQHandler(void); 60 | void USART2_IRQHandler(void); 61 | void RTC_Alarm_IRQHandler(void); 62 | void SUBGHZ_Radio_IRQHandler(void); 63 | /* USER CODE BEGIN EFP */ 64 | 65 | /* USER CODE END EFP */ 66 | 67 | #ifdef __cplusplus 68 | } 69 | #endif 70 | 71 | #endif /* __STM32WLxx_IT_H */ 72 | -------------------------------------------------------------------------------- /Core/Inc/stm32wlxx_nucleo_conf.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32wlxx_nucleo_conf.h 5 | * @author MCD Application Team 6 | * @brief STM32WLxx_Nucleo board configuration file. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2021 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef STM32WLXX_NUCLEO_CONF_H 23 | #define STM32WLXX_NUCLEO_CONF_H 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32wlxx_hal.h" 31 | 32 | /* USER CODE BEGIN Includes */ 33 | 34 | /* USER CODE END Includes */ 35 | 36 | /* Exported types ------------------------------------------------------------*/ 37 | /* USER CODE BEGIN ET */ 38 | 39 | /* USER CODE END ET */ 40 | 41 | /* Exported constants --------------------------------------------------------*/ 42 | /** @addtogroup BSP 43 | * @{ 44 | */ 45 | 46 | /** @addtogroup STM32WLXX_NUCLEO 47 | * @{ 48 | */ 49 | 50 | /** @defgroup STM32WLXX_NUCLEO_CONFIG CONFIG 51 | * @{ 52 | */ 53 | 54 | /** @defgroup STM32WLXX_NUCLEO_CONFIG_Exported_Constants Exported Constants 55 | * @{ 56 | */ 57 | /* COM usage define */ 58 | #define USE_BSP_COM_FEATURE 0U 59 | 60 | /* COM log define */ 61 | #define USE_COM_LOG 0U 62 | 63 | /* IRQ priorities */ 64 | #define BSP_BUTTON_USER_IT_PRIORITY 14U 65 | 66 | /** 67 | * @} 68 | */ 69 | 70 | /** 71 | * @} 72 | */ 73 | 74 | /** 75 | * @} 76 | */ 77 | 78 | /** 79 | * @} 80 | */ 81 | 82 | /* USER CODE BEGIN EC */ 83 | 84 | /* USER CODE END EC */ 85 | 86 | /* External variables --------------------------------------------------------*/ 87 | /* USER CODE BEGIN EV */ 88 | 89 | /* USER CODE END EV */ 90 | 91 | /* Exported macro ------------------------------------------------------------*/ 92 | /* USER CODE BEGIN EM */ 93 | 94 | /* USER CODE END EM */ 95 | 96 | /* Exported functions prototypes ---------------------------------------------*/ 97 | /* USER CODE BEGIN EFP */ 98 | 99 | /* USER CODE END EFP */ 100 | 101 | #ifdef __cplusplus 102 | } 103 | #endif 104 | 105 | #endif /* STM32WLXX_NUCLEO_CONF_H */ 106 | -------------------------------------------------------------------------------- /Core/Inc/subghz.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file subghz.h 5 | * @brief This file contains all the function prototypes for 6 | * the subghz.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2021 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __SUBGHZ_H__ 22 | #define __SUBGHZ_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | extern SUBGHZ_HandleTypeDef hsubghz; 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_SUBGHZ_Init(void); 42 | 43 | /* USER CODE BEGIN Prototypes */ 44 | 45 | /* USER CODE END Prototypes */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __SUBGHZ_H__ */ 52 | 53 | -------------------------------------------------------------------------------- /Core/Inc/sys_app.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file sys_app.h 5 | * @author MCD Application Team 6 | * @brief Function prototypes for sys_app.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2021 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __SYS_APP_H__ 23 | #define __SYS_APP_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stdint.h" 31 | #include "sys_conf.h" 32 | #include "stm32_adv_trace.h" 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* Exported defines ----------------------------------------------------------*/ 38 | /* USER CODE BEGIN ED */ 39 | 40 | /* USER CODE END ED */ 41 | 42 | /* Exported types ------------------------------------------------------------*/ 43 | /* USER CODE BEGIN ET */ 44 | 45 | /* USER CODE END ET */ 46 | 47 | /* Exported constants --------------------------------------------------------*/ 48 | /* USER CODE BEGIN EC */ 49 | 50 | /* USER CODE END EC */ 51 | 52 | /* External variables --------------------------------------------------------*/ 53 | /* USER CODE BEGIN EV */ 54 | 55 | /* USER CODE END EV */ 56 | 57 | /* Exported macros -----------------------------------------------------------*/ 58 | #define APP_PPRINTF(...) do{ } while( UTIL_ADV_TRACE_OK \ 59 | != UTIL_ADV_TRACE_COND_FSend(VLEVEL_ALWAYS, T_REG_OFF, TS_OFF, __VA_ARGS__) ) /* Polling Mode */ 60 | #define APP_TPRINTF(...) do{ {UTIL_ADV_TRACE_COND_FSend(VLEVEL_ALWAYS, T_REG_OFF, TS_ON, __VA_ARGS__);} }while(0); /* with timestamp */ 61 | #define APP_PRINTF(...) do{ {UTIL_ADV_TRACE_COND_FSend(VLEVEL_ALWAYS, T_REG_OFF, TS_OFF, __VA_ARGS__);} }while(0); 62 | 63 | #if defined (APP_LOG_ENABLED) && (APP_LOG_ENABLED == 1) 64 | #define APP_LOG(TS,VL,...) do{ {UTIL_ADV_TRACE_COND_FSend(VL, T_REG_OFF, TS, __VA_ARGS__);} }while(0); 65 | #elif defined (APP_LOG_ENABLED) && (APP_LOG_ENABLED == 0) /* APP_LOG disabled */ 66 | #define APP_LOG(TS,VL,...) 67 | #else 68 | #error "APP_LOG_ENABLED not defined or out of range <0,1>" 69 | #endif /* APP_LOG_ENABLED */ 70 | 71 | /* USER CODE BEGIN EM */ 72 | 73 | /* USER CODE END EM */ 74 | 75 | /* Exported functions prototypes ---------------------------------------------*/ 76 | /** 77 | * @brief initialize the system (dbg pins, trace, mbmux, sys timer, LPM, ...) 78 | */ 79 | void SystemApp_Init(void); 80 | 81 | /** 82 | * @brief callback to get the battery level in % of full charge (254 full charge, 0 no charge) 83 | * @retval battery level 84 | */ 85 | uint8_t GetBatteryLevel(void); 86 | 87 | /** 88 | * @brief callback to get the current temperature in the MCU 89 | * @retval temperature level 90 | */ 91 | int16_t GetTemperatureLevel(void); 92 | 93 | /** 94 | * @brief callback to get the board 64 bits unique ID 95 | * @param id unique ID 96 | */ 97 | void GetUniqueId(uint8_t *id); 98 | 99 | /** 100 | * @brief callback to get the board 32 bits unique ID (LSB) 101 | * @retval devAddr Device Address 102 | */ 103 | uint32_t GetDevAddr(void); 104 | 105 | /* USER CODE BEGIN EFP */ 106 | 107 | /* USER CODE END EFP */ 108 | 109 | #ifdef __cplusplus 110 | } 111 | #endif 112 | 113 | #endif /* __SYS_APP_H__ */ 114 | -------------------------------------------------------------------------------- /Core/Inc/sys_conf.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file sys_conf.h 5 | * @author MCD Application Team 6 | * @brief Applicative configuration, e.g. : debug, trace, low power, sensors 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2021 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __SYS_CONF_H__ 23 | #define __SYS_CONF_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | /* USER CODE BEGIN Includes */ 31 | 32 | /* USER CODE END Includes */ 33 | 34 | /* Exported types ------------------------------------------------------------*/ 35 | /* USER CODE BEGIN ET */ 36 | 37 | /* USER CODE END ET */ 38 | 39 | /* Exported constants --------------------------------------------------------*/ 40 | 41 | /** 42 | * @brief Temperature and pressure values are retrieved from sensors shield 43 | * (instead of sending dummy values). It requires MEMS IKS shield 44 | */ 45 | #define SENSOR_ENABLED 0 46 | 47 | /** 48 | * @brief Verbose level for all trace logs 49 | */ 50 | #define VERBOSE_LEVEL VLEVEL_H 51 | 52 | /** 53 | * @brief Enable trace logs 54 | */ 55 | #define APP_LOG_ENABLED 1 56 | 57 | /** 58 | * @brief Activate monitoring (probes) of some internal RF signals for debug purpose 59 | */ 60 | #define DEBUG_SUBGHZSPI_MONITORING_ENABLED 0 61 | 62 | #define DEBUG_RF_NRESET_ENABLED_ENABLED 0 63 | 64 | #define DEBUG_RF_HSE32RDY_ENABLED_ENABLED 0 65 | 66 | #define DEBUG_RF_SMPSRDY_ENABLED 0 67 | 68 | #define DEBUG_RF_LDORDY_ENABLED 0 69 | 70 | #define DEBUG_RF_DTB1_ENABLED 0 71 | 72 | #define DEBUG_RF_BUSY_ENABLED 0 73 | 74 | /** 75 | * @brief Enable/Disable MCU Debugger pins (dbg serial wires) 76 | * @note by HW serial wires are ON by default, need to put them OFF to save power 77 | */ 78 | #define DEBUGGER_ENABLED 0 79 | 80 | /** 81 | * @brief Disable Low Power mode 82 | * @note 0: LowPowerMode enabled. MCU enters stop2 mode, 1: LowPowerMode disabled. MCU enters sleep mode only 83 | */ 84 | #define LOW_POWER_DISABLE 0 85 | 86 | /* USER CODE BEGIN EC */ 87 | 88 | /* USER CODE END EC */ 89 | 90 | /* External variables --------------------------------------------------------*/ 91 | /* USER CODE BEGIN EV */ 92 | 93 | /* USER CODE END EV */ 94 | 95 | /* Exported macro ------------------------------------------------------------*/ 96 | /* USER CODE BEGIN EM */ 97 | 98 | /* USER CODE END EM */ 99 | 100 | /* Exported functions prototypes ---------------------------------------------*/ 101 | /* USER CODE BEGIN EFP */ 102 | 103 | /* USER CODE END EFP */ 104 | 105 | #ifdef __cplusplus 106 | } 107 | #endif 108 | 109 | #endif /* __SYS_CONF_H__ */ 110 | -------------------------------------------------------------------------------- /Core/Inc/sys_debug.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file sys_debug.h 5 | * @author MCD Application Team 6 | * @brief Configuration of the debug.c instances 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __SYS_DEBUG_H__ 23 | #define __SYS_DEBUG_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "sys_conf.h" 31 | #include "platform.h" 32 | 33 | /* USER CODE BEGIN Includes */ 34 | 35 | /* USER CODE END Includes */ 36 | 37 | /* Exported types ------------------------------------------------------------*/ 38 | /* USER CODE BEGIN ET */ 39 | 40 | /* USER CODE END ET */ 41 | 42 | /* Exported constants --------------------------------------------------------*/ 43 | /* Pin defines */ 44 | 45 | /* USER CODE BEGIN EC */ 46 | 47 | /* USER CODE END EC */ 48 | 49 | /* External variables --------------------------------------------------------*/ 50 | /* USER CODE BEGIN EV */ 51 | 52 | /* USER CODE END EV */ 53 | 54 | /* Exported macro ------------------------------------------------------------*/ 55 | #if !defined (DISABLE_PROBE_GPIO) 56 | 57 | /** 58 | * @brief Set pin to x value 59 | */ 60 | #define PROBE_GPIO_WRITE( gpio, n, x ) HAL_GPIO_WritePin( gpio, n, (GPIO_PinState)(x) ) 61 | 62 | /** 63 | * @brief Set pin to high level 64 | */ 65 | #define PROBE_GPIO_SET_LINE( gpio, n ) LL_GPIO_SetOutputPin( gpio, n ) 66 | 67 | /** 68 | * @brief Set pin to low level 69 | */ 70 | #define PROBE_GPIO_RST_LINE( gpio, n ) LL_GPIO_ResetOutputPin( gpio, n ) 71 | 72 | #else /* DISABLE_PROBE_GPIO */ 73 | 74 | /** 75 | * @brief not usable 76 | */ 77 | #define PROBE_GPIO_WRITE( gpio, n, x ) 78 | 79 | /** 80 | * @brief not usable 81 | */ 82 | #define PROBE_GPIO_SET_LINE( gpio, n ) 83 | 84 | /** 85 | * @brief not usable 86 | */ 87 | #define PROBE_GPIO_RST_LINE( gpio, n ) 88 | 89 | #endif /* DISABLE_PROBE_GPIO */ 90 | 91 | /* USER CODE BEGIN EM */ 92 | 93 | /* USER CODE END EM */ 94 | 95 | /* Exported functions prototypes ---------------------------------------------*/ 96 | /** 97 | * @brief Initializes the SW probes pins and the monitor RF pins via Alternate Function 98 | */ 99 | void DBG_Init(void); 100 | 101 | /* USER CODE BEGIN EFP */ 102 | 103 | /* USER CODE END EFP */ 104 | 105 | #ifdef __cplusplus 106 | } 107 | #endif 108 | 109 | #endif /* __SYS_DEBUG_H__ */ 110 | -------------------------------------------------------------------------------- /Core/Inc/sys_sensors.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file sys_sensors.h 5 | * @author MCD Application Team 6 | * @brief Header for sensors application 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __SENSORS_H__ 23 | #define __SENSORS_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | /* Includes ------------------------------------------------------------------*/ 29 | 30 | /* USER CODE BEGIN Includes */ 31 | 32 | /* USER CODE END Includes */ 33 | 34 | /* Exported types ------------------------------------------------------------*/ 35 | /** 36 | * Sensor data parameters 37 | */ 38 | typedef struct 39 | { 40 | float pressure; /*!< in mbar */ 41 | float temperature; /*!< in degC */ 42 | float humidity; /*!< in % */ 43 | int32_t latitude; /*!< latitude converted to binary */ 44 | int32_t longitude; /*!< longitude converted to binary */ 45 | int16_t altitudeGps; /*!< in m */ 46 | int16_t altitudeBar; /*!< in m * 10 */ 47 | /**more may be added*/ 48 | /* USER CODE BEGIN sensor_t */ 49 | 50 | /* USER CODE END sensor_t */ 51 | } sensor_t; 52 | 53 | /* USER CODE BEGIN ET */ 54 | 55 | /* USER CODE END ET */ 56 | 57 | /* Exported constants --------------------------------------------------------*/ 58 | 59 | /* USER CODE BEGIN EC */ 60 | #if defined (SENSOR_ENABLED) && (SENSOR_ENABLED == 1) && defined (X_NUCLEO_IKS01A2) 61 | #define HTS221_0 0U 62 | #define LPS22HB_0 1U 63 | #endif /* SENSOR_ENABLED & X_NUCLEO_IKS01A2 */ 64 | /* USER CODE END EC */ 65 | 66 | /* External variables --------------------------------------------------------*/ 67 | /* USER CODE BEGIN EV */ 68 | 69 | /* USER CODE END EV */ 70 | 71 | /* Exported macro ------------------------------------------------------------*/ 72 | /* USER CODE BEGIN EM */ 73 | 74 | /* USER CODE END EM */ 75 | 76 | /* Exported functions prototypes ---------------------------------------------*/ 77 | /** 78 | * @brief initialize the environmental sensor 79 | */ 80 | int32_t EnvSensors_Init(void); 81 | 82 | /** 83 | * @brief Environmental sensor read. 84 | * @param sensor_data sensor data 85 | */ 86 | int32_t EnvSensors_Read(sensor_t *sensor_data); 87 | 88 | /* USER CODE BEGIN EFP */ 89 | 90 | /* USER CODE END EFP */ 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* __SENSORS_H__ */ 97 | -------------------------------------------------------------------------------- /Core/Inc/usart.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file usart.h 5 | * @brief This file contains all the function prototypes for 6 | * the usart.c file 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Define to prevent recursive inclusion -------------------------------------*/ 21 | #ifndef __USART_H__ 22 | #define __USART_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include "main.h" 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | extern UART_HandleTypeDef huart2; 36 | 37 | /* USER CODE BEGIN Private defines */ 38 | 39 | /* USER CODE END Private defines */ 40 | 41 | void MX_USART2_UART_Init(void); 42 | 43 | /* USER CODE BEGIN Prototypes */ 44 | 45 | /* USER CODE END Prototypes */ 46 | 47 | #ifdef __cplusplus 48 | } 49 | #endif 50 | 51 | #endif /* __USART_H__ */ 52 | 53 | -------------------------------------------------------------------------------- /Core/Inc/usart_if.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file usart_if.h 5 | * @author MCD Application Team 6 | * @brief Header for USART interface configuration 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | #include "stm32_adv_trace.h" 22 | #include "usart.h" 23 | #include "dma.h" 24 | 25 | /* Define to prevent recursive inclusion -------------------------------------*/ 26 | #ifndef __USART_IF_H__ 27 | #define __USART_IF_H__ 28 | 29 | #ifdef __cplusplus 30 | extern "C" { 31 | #endif 32 | 33 | /* Includes ------------------------------------------------------------------*/ 34 | /* USER CODE BEGIN Includes */ 35 | 36 | /* USER CODE END Includes */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* USER CODE BEGIN ET */ 40 | 41 | /* USER CODE END ET */ 42 | 43 | /* Exported constants --------------------------------------------------------*/ 44 | /* USER CODE BEGIN EC */ 45 | 46 | /* USER CODE END EC */ 47 | 48 | /* External variables --------------------------------------------------------*/ 49 | /* USER CODE BEGIN EV */ 50 | 51 | /* USER CODE END EV */ 52 | 53 | /* Exported macro ------------------------------------------------------------*/ 54 | /* USER CODE BEGIN EM */ 55 | 56 | /* USER CODE END EM */ 57 | 58 | /* Exported functions prototypes ---------------------------------------------*/ 59 | /** 60 | * @brief Init the UART and associated DMA. 61 | * @param cb TxCpltCallback 62 | * @return @ref UTIL_ADV_TRACE_Status_t 63 | */ 64 | UTIL_ADV_TRACE_Status_t vcom_Init(void (*cb)(void *)); 65 | 66 | /** 67 | * @brief init receiver of vcom 68 | * @param RxCb callback when Rx char is received 69 | * @return @ref UTIL_ADV_TRACE_Status_t 70 | */ 71 | UTIL_ADV_TRACE_Status_t vcom_ReceiveInit(void (*RxCb)(uint8_t *rxChar, uint16_t size, uint8_t error)); 72 | 73 | /** 74 | * @brief DeInit the UART and associated DMA. 75 | * @return @ref UTIL_ADV_TRACE_Status_t 76 | */ 77 | UTIL_ADV_TRACE_Status_t vcom_DeInit(void); 78 | 79 | /** 80 | * @brief send buffer \p p_data of size \p size to vcom in polling mode 81 | * @param p_data data to be sent 82 | * @param size of buffer p_data to be sent 83 | */ 84 | void vcom_Trace(uint8_t *p_data, uint16_t size); 85 | 86 | /** 87 | * @brief send buffer \p p_data of size \p size to vcom using DMA 88 | * @param p_data data to be sent 89 | * @param size of buffer p_data to be sent 90 | * @return @ref UTIL_ADV_TRACE_Status_t 91 | */ 92 | UTIL_ADV_TRACE_Status_t vcom_Trace_DMA(uint8_t *p_data, uint16_t size); 93 | 94 | /** 95 | * @brief last byte has been sent on the uart line 96 | */ 97 | void vcom_IRQHandler(void); 98 | 99 | /** 100 | * @brief last byte has been sent from memory to uart data register 101 | */ 102 | void vcom_DMA_TX_IRQHandler(void); 103 | 104 | /** 105 | * @brief Resume the UART and associated DMA (used by LPM) 106 | */ 107 | void vcom_Resume(void); 108 | 109 | /* USER CODE BEGIN EFP */ 110 | 111 | /* USER CODE END EFP */ 112 | 113 | #ifdef __cplusplus 114 | } 115 | #endif 116 | 117 | #endif /* __USART_IF_H__ */ 118 | -------------------------------------------------------------------------------- /Core/Inc/utilities_def.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file utilities_def.h 5 | * @author MCD Application Team 6 | * @brief Definitions for modules requiring utilities 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __UTILITIES_DEF_H__ 23 | #define __UTILITIES_DEF_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | /* USER CODE BEGIN Includes */ 31 | 32 | /* USER CODE END Includes */ 33 | 34 | /* Exported types ------------------------------------------------------------*/ 35 | /****************************************************************************** 36 | * LOW POWER MANAGER 37 | ******************************************************************************/ 38 | /** 39 | * Supported requester to the MCU Low Power Manager - can be increased up to 32 40 | * It lists a bit mapping of all user of the Low Power Manager 41 | */ 42 | typedef enum 43 | { 44 | /* USER CODE BEGIN CFG_LPM_Id_t_0 */ 45 | 46 | /* USER CODE END CFG_LPM_Id_t_0 */ 47 | CFG_LPM_APPLI_Id, 48 | CFG_LPM_UART_TX_Id, 49 | /* USER CODE BEGIN CFG_LPM_Id_t */ 50 | 51 | /* USER CODE END CFG_LPM_Id_t */ 52 | } CFG_LPM_Id_t; 53 | 54 | /*---------------------------------------------------------------------------*/ 55 | /* sequencer definitions */ 56 | /*---------------------------------------------------------------------------*/ 57 | 58 | /** 59 | * This is the list of priority required by the application 60 | * Each Id shall be in the range 0..31 61 | */ 62 | typedef enum 63 | { 64 | CFG_SEQ_Prio_0, 65 | /* USER CODE BEGIN CFG_SEQ_Prio_Id_t */ 66 | 67 | /* USER CODE END CFG_SEQ_Prio_Id_t */ 68 | CFG_SEQ_Prio_NBR, 69 | } CFG_SEQ_Prio_Id_t; 70 | 71 | /** 72 | * This is the list of task id required by the application 73 | * Each Id shall be in the range 0..31 74 | */ 75 | typedef enum 76 | { 77 | CFG_SEQ_Task_LmHandlerProcess, 78 | CFG_SEQ_Task_LoRaSendOnTxTimerOrButtonEvent, 79 | CFG_SEQ_Task_LoRaStoreContextEvent, 80 | CFG_SEQ_Task_LoRaStopJoinEvent, 81 | /* USER CODE BEGIN CFG_SEQ_Task_Id_t */ 82 | 83 | /* USER CODE END CFG_SEQ_Task_Id_t */ 84 | CFG_SEQ_Task_NBR 85 | } CFG_SEQ_Task_Id_t; 86 | 87 | /* USER CODE BEGIN ET */ 88 | 89 | /* USER CODE END ET */ 90 | 91 | /* Exported constants --------------------------------------------------------*/ 92 | /* USER CODE BEGIN EC */ 93 | 94 | /* USER CODE END EC */ 95 | 96 | /* External variables --------------------------------------------------------*/ 97 | /* USER CODE BEGIN EV */ 98 | 99 | /* USER CODE END EV */ 100 | 101 | /* Exported macro ------------------------------------------------------------*/ 102 | /* USER CODE BEGIN EM */ 103 | 104 | /* USER CODE END EM */ 105 | 106 | /* Exported functions prototypes ---------------------------------------------*/ 107 | /* USER CODE BEGIN EFP */ 108 | 109 | /* USER CODE END EFP */ 110 | 111 | #ifdef __cplusplus 112 | } 113 | #endif 114 | 115 | #endif /* __UTILITIES_DEF_H__ */ 116 | -------------------------------------------------------------------------------- /Core/Src/adc.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file adc.c 5 | * @brief This file provides code for the configuration 6 | * of the ADC instances. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "adc.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | ADC_HandleTypeDef hadc; 28 | 29 | /* ADC init function */ 30 | void MX_ADC_Init(void) 31 | { 32 | 33 | /* USER CODE BEGIN ADC_Init 0 */ 34 | 35 | /* USER CODE END ADC_Init 0 */ 36 | 37 | /* USER CODE BEGIN ADC_Init 1 */ 38 | 39 | /* USER CODE END ADC_Init 1 */ 40 | 41 | /** Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) 42 | */ 43 | hadc.Instance = ADC; 44 | hadc.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV4; 45 | hadc.Init.Resolution = ADC_RESOLUTION_12B; 46 | hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT; 47 | hadc.Init.ScanConvMode = ADC_SCAN_DISABLE; 48 | hadc.Init.EOCSelection = ADC_EOC_SINGLE_CONV; 49 | hadc.Init.LowPowerAutoWait = DISABLE; 50 | hadc.Init.LowPowerAutoPowerOff = ENABLE; 51 | hadc.Init.ContinuousConvMode = DISABLE; 52 | hadc.Init.NbrOfConversion = 1; 53 | hadc.Init.DiscontinuousConvMode = DISABLE; 54 | hadc.Init.ExternalTrigConv = ADC_SOFTWARE_START; 55 | hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE; 56 | hadc.Init.DMAContinuousRequests = DISABLE; 57 | hadc.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN; 58 | hadc.Init.SamplingTimeCommon1 = ADC_SAMPLETIME_160CYCLES_5; 59 | hadc.Init.SamplingTimeCommon2 = ADC_SAMPLETIME_160CYCLES_5; 60 | hadc.Init.OversamplingMode = DISABLE; 61 | hadc.Init.TriggerFrequencyMode = ADC_TRIGGER_FREQ_LOW; 62 | if (HAL_ADC_Init(&hadc) != HAL_OK) 63 | { 64 | Error_Handler(); 65 | } 66 | /* USER CODE BEGIN ADC_Init 2 */ 67 | 68 | /* USER CODE END ADC_Init 2 */ 69 | 70 | } 71 | 72 | void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle) 73 | { 74 | 75 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 76 | if(adcHandle->Instance==ADC) 77 | { 78 | /* USER CODE BEGIN ADC_MspInit 0 */ 79 | 80 | /* USER CODE END ADC_MspInit 0 */ 81 | /* ADC clock enable */ 82 | __HAL_RCC_ADC_CLK_ENABLE(); 83 | 84 | __HAL_RCC_GPIOB_CLK_ENABLE(); 85 | /**ADC GPIO Configuration 86 | PB3 ------> ADC_IN2 87 | */ 88 | GPIO_InitStruct.Pin = GPIO_PIN_3; 89 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; 90 | GPIO_InitStruct.Pull = GPIO_NOPULL; 91 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); 92 | 93 | /* USER CODE BEGIN ADC_MspInit 1 */ 94 | 95 | /* USER CODE END ADC_MspInit 1 */ 96 | } 97 | } 98 | 99 | void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle) 100 | { 101 | 102 | if(adcHandle->Instance==ADC) 103 | { 104 | /* USER CODE BEGIN ADC_MspDeInit 0 */ 105 | 106 | /* USER CODE END ADC_MspDeInit 0 */ 107 | /* Peripheral clock disable */ 108 | __HAL_RCC_ADC_CLK_DISABLE(); 109 | 110 | /**ADC GPIO Configuration 111 | PB3 ------> ADC_IN2 112 | */ 113 | HAL_GPIO_DeInit(GPIOB, GPIO_PIN_3); 114 | 115 | /* USER CODE BEGIN ADC_MspDeInit 1 */ 116 | 117 | /* USER CODE END ADC_MspDeInit 1 */ 118 | } 119 | } 120 | 121 | /* USER CODE BEGIN 1 */ 122 | 123 | /* USER CODE END 1 */ 124 | -------------------------------------------------------------------------------- /Core/Src/dma.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file dma.c 5 | * @brief This file provides code for the configuration 6 | * of all the requested memory to memory DMA transfers. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "dma.h" 23 | 24 | /* USER CODE BEGIN 0 */ 25 | 26 | /* USER CODE END 0 */ 27 | 28 | /*----------------------------------------------------------------------------*/ 29 | /* Configure DMA */ 30 | /*----------------------------------------------------------------------------*/ 31 | 32 | /* USER CODE BEGIN 1 */ 33 | 34 | /* USER CODE END 1 */ 35 | 36 | /** 37 | * Enable DMA controller clock 38 | */ 39 | void MX_DMA_Init(void) 40 | { 41 | 42 | /* DMA controller clock enable */ 43 | __HAL_RCC_DMAMUX1_CLK_ENABLE(); 44 | __HAL_RCC_DMA1_CLK_ENABLE(); 45 | 46 | /* DMA interrupt init */ 47 | /* DMA1_Channel1_IRQn interrupt configuration */ 48 | HAL_NVIC_SetPriority(DMA1_Channel1_IRQn, 2, 0); 49 | HAL_NVIC_EnableIRQ(DMA1_Channel1_IRQn); 50 | 51 | } 52 | 53 | /* USER CODE BEGIN 2 */ 54 | 55 | /* USER CODE END 2 */ 56 | 57 | -------------------------------------------------------------------------------- /Core/Src/gpio.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file gpio.c 5 | * @brief This file provides code for the configuration 6 | * of all used GPIO pins. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "gpio.h" 23 | 24 | /* USER CODE BEGIN 0 */ 25 | 26 | /* USER CODE END 0 */ 27 | 28 | /*----------------------------------------------------------------------------*/ 29 | /* Configure GPIO */ 30 | /*----------------------------------------------------------------------------*/ 31 | /* USER CODE BEGIN 1 */ 32 | 33 | /* USER CODE END 1 */ 34 | 35 | /** Configure pins as 36 | * Analog 37 | * Input 38 | * Output 39 | * EVENT_OUT 40 | * EXTI 41 | */ 42 | void MX_GPIO_Init(void) 43 | { 44 | 45 | GPIO_InitTypeDef GPIO_InitStruct = {0}; 46 | 47 | /* GPIO Ports Clock Enable */ 48 | __HAL_RCC_GPIOB_CLK_ENABLE(); 49 | __HAL_RCC_GPIOA_CLK_ENABLE(); 50 | __HAL_RCC_GPIOC_CLK_ENABLE(); 51 | 52 | /*Configure GPIO pin Output Level */ 53 | HAL_GPIO_WritePin(GPIOA, LED1_Pin|LED2_Pin, GPIO_PIN_RESET); 54 | 55 | /*Configure GPIO pins : PAPin PAPin */ 56 | GPIO_InitStruct.Pin = LED1_Pin|LED2_Pin; 57 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; 58 | GPIO_InitStruct.Pull = GPIO_NOPULL; 59 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH; 60 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); 61 | 62 | /*Configure GPIO pin : PtPin */ 63 | GPIO_InitStruct.Pin = FREQ_HIGH_Pin; 64 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT; 65 | GPIO_InitStruct.Pull = GPIO_NOPULL; 66 | HAL_GPIO_Init(FREQ_HIGH_GPIO_Port, &GPIO_InitStruct); 67 | 68 | } 69 | 70 | /* USER CODE BEGIN 2 */ 71 | 72 | /* USER CODE END 2 */ 73 | -------------------------------------------------------------------------------- /Core/Src/rtc.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file rtc.c 5 | * @brief This file provides code for the configuration 6 | * of the RTC instances. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "rtc.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | RTC_HandleTypeDef hrtc; 28 | 29 | /* RTC init function */ 30 | void MX_RTC_Init(void) 31 | { 32 | 33 | /* USER CODE BEGIN RTC_Init 0 */ 34 | 35 | /* USER CODE END RTC_Init 0 */ 36 | 37 | RTC_AlarmTypeDef sAlarm = {0}; 38 | 39 | /* USER CODE BEGIN RTC_Init 1 */ 40 | 41 | /* USER CODE END RTC_Init 1 */ 42 | 43 | /** Initialize RTC Only 44 | */ 45 | hrtc.Instance = RTC; 46 | hrtc.Init.AsynchPrediv = RTC_PREDIV_A; 47 | hrtc.Init.OutPut = RTC_OUTPUT_DISABLE; 48 | hrtc.Init.OutPutRemap = RTC_OUTPUT_REMAP_NONE; 49 | hrtc.Init.OutPutPolarity = RTC_OUTPUT_POLARITY_HIGH; 50 | hrtc.Init.OutPutType = RTC_OUTPUT_TYPE_OPENDRAIN; 51 | hrtc.Init.OutPutPullUp = RTC_OUTPUT_PULLUP_NONE; 52 | hrtc.Init.BinMode = RTC_BINARY_ONLY; 53 | if (HAL_RTC_Init(&hrtc) != HAL_OK) 54 | { 55 | Error_Handler(); 56 | } 57 | 58 | /* USER CODE BEGIN Check_RTC_BKUP */ 59 | 60 | /* USER CODE END Check_RTC_BKUP */ 61 | 62 | /** Initialize RTC and set the Time and Date 63 | */ 64 | if (HAL_RTCEx_SetSSRU_IT(&hrtc) != HAL_OK) 65 | { 66 | Error_Handler(); 67 | } 68 | 69 | /** Enable the Alarm A 70 | */ 71 | sAlarm.BinaryAutoClr = RTC_ALARMSUBSECONDBIN_AUTOCLR_NO; 72 | sAlarm.AlarmTime.SubSeconds = 0x0; 73 | sAlarm.AlarmMask = RTC_ALARMMASK_NONE; 74 | sAlarm.AlarmSubSecondMask = RTC_ALARMSUBSECONDBINMASK_NONE; 75 | sAlarm.Alarm = RTC_ALARM_A; 76 | if (HAL_RTC_SetAlarm_IT(&hrtc, &sAlarm, 0) != HAL_OK) 77 | { 78 | Error_Handler(); 79 | } 80 | /* USER CODE BEGIN RTC_Init 2 */ 81 | 82 | /* USER CODE END RTC_Init 2 */ 83 | 84 | } 85 | 86 | void HAL_RTC_MspInit(RTC_HandleTypeDef* rtcHandle) 87 | { 88 | 89 | RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; 90 | if(rtcHandle->Instance==RTC) 91 | { 92 | /* USER CODE BEGIN RTC_MspInit 0 */ 93 | 94 | /* USER CODE END RTC_MspInit 0 */ 95 | 96 | /** Initializes the peripherals clocks 97 | */ 98 | PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_RTC; 99 | PeriphClkInitStruct.RTCClockSelection = RCC_RTCCLKSOURCE_LSE; 100 | 101 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) 102 | { 103 | Error_Handler(); 104 | } 105 | 106 | /* RTC clock enable */ 107 | __HAL_RCC_RTC_ENABLE(); 108 | __HAL_RCC_RTCAPB_CLK_ENABLE(); 109 | 110 | /* RTC interrupt Init */ 111 | HAL_NVIC_SetPriority(TAMP_STAMP_LSECSS_SSRU_IRQn, 0, 0); 112 | HAL_NVIC_EnableIRQ(TAMP_STAMP_LSECSS_SSRU_IRQn); 113 | HAL_NVIC_SetPriority(RTC_Alarm_IRQn, 0, 0); 114 | HAL_NVIC_EnableIRQ(RTC_Alarm_IRQn); 115 | /* USER CODE BEGIN RTC_MspInit 1 */ 116 | 117 | /* USER CODE END RTC_MspInit 1 */ 118 | } 119 | } 120 | 121 | void HAL_RTC_MspDeInit(RTC_HandleTypeDef* rtcHandle) 122 | { 123 | 124 | if(rtcHandle->Instance==RTC) 125 | { 126 | /* USER CODE BEGIN RTC_MspDeInit 0 */ 127 | 128 | /* USER CODE END RTC_MspDeInit 0 */ 129 | /* Peripheral clock disable */ 130 | __HAL_RCC_RTC_DISABLE(); 131 | __HAL_RCC_RTCAPB_CLK_DISABLE(); 132 | 133 | /* RTC interrupt Deinit */ 134 | HAL_NVIC_DisableIRQ(TAMP_STAMP_LSECSS_SSRU_IRQn); 135 | HAL_NVIC_DisableIRQ(RTC_Alarm_IRQn); 136 | /* USER CODE BEGIN RTC_MspDeInit 1 */ 137 | 138 | /* USER CODE END RTC_MspDeInit 1 */ 139 | } 140 | } 141 | 142 | /* USER CODE BEGIN 1 */ 143 | 144 | /* USER CODE END 1 */ 145 | -------------------------------------------------------------------------------- /Core/Src/stm32_lpm_if.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32_lpm_if.c 5 | * @author MCD Application Team 6 | * @brief Low layer function to enter/exit low power modes (stop, sleep) 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "platform.h" 23 | #include "stm32_lpm.h" 24 | #include "stm32_lpm_if.h" 25 | #include "usart_if.h" 26 | 27 | /* USER CODE BEGIN Includes */ 28 | 29 | /* USER CODE END Includes */ 30 | 31 | /* External variables ---------------------------------------------------------*/ 32 | /* USER CODE BEGIN EV */ 33 | 34 | /* USER CODE END EV */ 35 | 36 | /* Private typedef -----------------------------------------------------------*/ 37 | /** 38 | * @brief Power driver callbacks handler 39 | */ 40 | const struct UTIL_LPM_Driver_s UTIL_PowerDriver = 41 | { 42 | PWR_EnterSleepMode, 43 | PWR_ExitSleepMode, 44 | 45 | PWR_EnterStopMode, 46 | PWR_ExitStopMode, 47 | 48 | PWR_EnterOffMode, 49 | PWR_ExitOffMode, 50 | }; 51 | 52 | /* USER CODE BEGIN PTD */ 53 | 54 | /* USER CODE END PTD */ 55 | 56 | /* Private define ------------------------------------------------------------*/ 57 | /* USER CODE BEGIN PD */ 58 | 59 | /* USER CODE END PD */ 60 | 61 | /* Private macro -------------------------------------------------------------*/ 62 | /* USER CODE BEGIN PM */ 63 | 64 | /* USER CODE END PM */ 65 | 66 | /* Private variables ---------------------------------------------------------*/ 67 | /* USER CODE BEGIN PV */ 68 | 69 | /* USER CODE END PV */ 70 | 71 | /* Private function prototypes -----------------------------------------------*/ 72 | /* USER CODE BEGIN PFP */ 73 | 74 | /* USER CODE END PFP */ 75 | 76 | /* Exported functions --------------------------------------------------------*/ 77 | 78 | void PWR_EnterOffMode(void) 79 | { 80 | /* USER CODE BEGIN EnterOffMode_1 */ 81 | 82 | /* USER CODE END EnterOffMode_1 */ 83 | } 84 | 85 | void PWR_ExitOffMode(void) 86 | { 87 | /* USER CODE BEGIN ExitOffMode_1 */ 88 | 89 | /* USER CODE END ExitOffMode_1 */ 90 | } 91 | 92 | void PWR_EnterStopMode(void) 93 | { 94 | /* USER CODE BEGIN EnterStopMode_1 */ 95 | 96 | /* USER CODE END EnterStopMode_1 */ 97 | HAL_SuspendTick(); 98 | /* Clear Status Flag before entering STOP/STANDBY Mode */ 99 | LL_PWR_ClearFlag_C1STOP_C1STB(); 100 | 101 | /* USER CODE BEGIN EnterStopMode_2 */ 102 | 103 | /* USER CODE END EnterStopMode_2 */ 104 | HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI); 105 | /* USER CODE BEGIN EnterStopMode_3 */ 106 | 107 | /* USER CODE END EnterStopMode_3 */ 108 | } 109 | 110 | void PWR_ExitStopMode(void) 111 | { 112 | /* USER CODE BEGIN ExitStopMode_1 */ 113 | 114 | /* USER CODE END ExitStopMode_1 */ 115 | /* Resume sysTick : work around for debugger problem in dual core */ 116 | HAL_ResumeTick(); 117 | /*Not retained periph: 118 | ADC interface 119 | DAC interface USARTx, TIMx, i2Cx, SPIx 120 | SRAM ctrls, DMAx, DMAMux, AES, RNG, HSEM */ 121 | 122 | /* Resume not retained USARTx and DMA */ 123 | vcom_Resume(); 124 | /* USER CODE BEGIN ExitStopMode_2 */ 125 | 126 | /* USER CODE END ExitStopMode_2 */ 127 | } 128 | 129 | void PWR_EnterSleepMode(void) 130 | { 131 | /* USER CODE BEGIN EnterSleepMode_1 */ 132 | 133 | /* USER CODE END EnterSleepMode_1 */ 134 | /* Suspend sysTick */ 135 | HAL_SuspendTick(); 136 | /* USER CODE BEGIN EnterSleepMode_2 */ 137 | 138 | /* USER CODE END EnterSleepMode_2 */ 139 | HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI); 140 | /* USER CODE BEGIN EnterSleepMode_3 */ 141 | 142 | /* USER CODE END EnterSleepMode_3 */ 143 | } 144 | 145 | void PWR_ExitSleepMode(void) 146 | { 147 | /* USER CODE BEGIN ExitSleepMode_1 */ 148 | 149 | /* USER CODE END ExitSleepMode_1 */ 150 | /* Resume sysTick */ 151 | HAL_ResumeTick(); 152 | 153 | /* USER CODE BEGIN ExitSleepMode_2 */ 154 | 155 | /* USER CODE END ExitSleepMode_2 */ 156 | } 157 | 158 | /* USER CODE BEGIN EF */ 159 | 160 | /* USER CODE END EF */ 161 | 162 | /* Private Functions Definition -----------------------------------------------*/ 163 | /* USER CODE BEGIN PrFD */ 164 | 165 | /* USER CODE END PrFD */ 166 | -------------------------------------------------------------------------------- /Core/Src/stm32wlxx_hal_msp.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file stm32wlxx_hal_msp.c 5 | * @brief This file provides code for the MSP Initialization 6 | * and de-Initialization codes. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "main.h" 23 | /* USER CODE BEGIN Includes */ 24 | 25 | /* USER CODE END Includes */ 26 | 27 | /* Private typedef -----------------------------------------------------------*/ 28 | /* USER CODE BEGIN TD */ 29 | 30 | /* USER CODE END TD */ 31 | 32 | /* Private define ------------------------------------------------------------*/ 33 | /* USER CODE BEGIN Define */ 34 | 35 | /* USER CODE END Define */ 36 | 37 | /* Private macro -------------------------------------------------------------*/ 38 | /* USER CODE BEGIN Macro */ 39 | 40 | /* USER CODE END Macro */ 41 | 42 | /* Private variables ---------------------------------------------------------*/ 43 | /* USER CODE BEGIN PV */ 44 | 45 | /* USER CODE END PV */ 46 | 47 | /* Private function prototypes -----------------------------------------------*/ 48 | /* USER CODE BEGIN PFP */ 49 | 50 | /* USER CODE END PFP */ 51 | 52 | /* External functions --------------------------------------------------------*/ 53 | /* USER CODE BEGIN ExternalFunctions */ 54 | 55 | /* USER CODE END ExternalFunctions */ 56 | 57 | /* USER CODE BEGIN 0 */ 58 | 59 | /* USER CODE END 0 */ 60 | /** 61 | * Initializes the Global MSP. 62 | */ 63 | void HAL_MspInit(void) 64 | { 65 | /* USER CODE BEGIN MspInit 0 */ 66 | 67 | /* USER CODE END MspInit 0 */ 68 | 69 | /* System interrupt init*/ 70 | 71 | /* USER CODE BEGIN MspInit 1 */ 72 | 73 | /* USER CODE END MspInit 1 */ 74 | } 75 | 76 | /* USER CODE BEGIN 1 */ 77 | 78 | /* USER CODE END 1 */ 79 | -------------------------------------------------------------------------------- /Core/Src/subghz.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file subghz.c 5 | * @brief This file provides code for the configuration 6 | * of the SUBGHZ instances. 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | /* Includes ------------------------------------------------------------------*/ 21 | #include "subghz.h" 22 | 23 | /* USER CODE BEGIN 0 */ 24 | 25 | /* USER CODE END 0 */ 26 | 27 | SUBGHZ_HandleTypeDef hsubghz; 28 | 29 | /* SUBGHZ init function */ 30 | void MX_SUBGHZ_Init(void) 31 | { 32 | 33 | /* USER CODE BEGIN SUBGHZ_Init 0 */ 34 | 35 | /* USER CODE END SUBGHZ_Init 0 */ 36 | 37 | /* USER CODE BEGIN SUBGHZ_Init 1 */ 38 | 39 | /* USER CODE END SUBGHZ_Init 1 */ 40 | hsubghz.Init.BaudratePrescaler = SUBGHZSPI_BAUDRATEPRESCALER_4; 41 | if (HAL_SUBGHZ_Init(&hsubghz) != HAL_OK) 42 | { 43 | Error_Handler(); 44 | } 45 | /* USER CODE BEGIN SUBGHZ_Init 2 */ 46 | 47 | /* USER CODE END SUBGHZ_Init 2 */ 48 | 49 | } 50 | 51 | void HAL_SUBGHZ_MspInit(SUBGHZ_HandleTypeDef* subghzHandle) 52 | { 53 | 54 | /* USER CODE BEGIN SUBGHZ_MspInit 0 */ 55 | 56 | /* USER CODE END SUBGHZ_MspInit 0 */ 57 | /* SUBGHZ clock enable */ 58 | __HAL_RCC_SUBGHZSPI_CLK_ENABLE(); 59 | 60 | /* SUBGHZ interrupt Init */ 61 | HAL_NVIC_SetPriority(SUBGHZ_Radio_IRQn, 0, 0); 62 | HAL_NVIC_EnableIRQ(SUBGHZ_Radio_IRQn); 63 | /* USER CODE BEGIN SUBGHZ_MspInit 1 */ 64 | 65 | /* USER CODE END SUBGHZ_MspInit 1 */ 66 | } 67 | 68 | void HAL_SUBGHZ_MspDeInit(SUBGHZ_HandleTypeDef* subghzHandle) 69 | { 70 | 71 | /* USER CODE BEGIN SUBGHZ_MspDeInit 0 */ 72 | 73 | /* USER CODE END SUBGHZ_MspDeInit 0 */ 74 | /* Peripheral clock disable */ 75 | __HAL_RCC_SUBGHZSPI_CLK_DISABLE(); 76 | 77 | /* SUBGHZ interrupt Deinit */ 78 | HAL_NVIC_DisableIRQ(SUBGHZ_Radio_IRQn); 79 | /* USER CODE BEGIN SUBGHZ_MspDeInit 1 */ 80 | 81 | /* USER CODE END SUBGHZ_MspDeInit 1 */ 82 | } 83 | 84 | /* USER CODE BEGIN 1 */ 85 | 86 | /* USER CODE END 1 */ 87 | -------------------------------------------------------------------------------- /Drivers/BSP/STM32WLxx_Nucleo/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the BSD-3-Clause license shall apply. 5 | You may obtain a copy of the BSD-3-Clause at: 6 | https://opensource.org/licenses/BSD-3-Clause 7 | -------------------------------------------------------------------------------- /Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo_errno.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32wlxx_nucleo_errno.h 4 | * @author MCD Application Team 5 | * @brief Error Code. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2020-2021 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32WLXX_NUCLEO_ERRNO_H 21 | #define STM32WLXX_NUCLEO_ERRNO_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Common Error codes */ 28 | #define BSP_ERROR_NONE 0 29 | #define BSP_ERROR_NO_INIT -1 30 | #define BSP_ERROR_WRONG_PARAM -2 31 | #define BSP_ERROR_BUSY -3 32 | #define BSP_ERROR_PERIPH_FAILURE -4 33 | #define BSP_ERROR_COMPONENT_FAILURE -5 34 | #define BSP_ERROR_UNKNOWN_FAILURE -6 35 | #define BSP_ERROR_UNKNOWN_COMPONENT -7 36 | #define BSP_ERROR_BUS_FAILURE -8 37 | #define BSP_ERROR_CLOCK_FAILURE -9 38 | #define BSP_ERROR_MSP_FAILURE -10 39 | #define BSP_ERROR_FEATURE_NOT_SUPPORTED -11 40 | 41 | #ifdef __cplusplus 42 | } 43 | #endif 44 | 45 | #endif /* STM32WLXX_NUCLEO_ERRNO_H */ 46 | -------------------------------------------------------------------------------- /Drivers/BSP/STM32WLxx_Nucleo/stm32wlxx_nucleo_radio.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32wlxx_nucleo_radio.h 4 | * @author MCD Application Team 5 | * @brief Header for stm32wlxx_nucleo_radio.c 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2020-2021 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32WLXX_NUCLEO_RADIO_H 21 | #define STM32WLXX_NUCLEO_RADIO_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32wlxx_nucleo_errno.h" 29 | #include "stm32wlxx_nucleo_conf.h" 30 | 31 | /* 32 | * Modifications by Dana Myers for the Seeed LoRa-E5 33 | */ 34 | 35 | /** @addtogroup BSP 36 | * @{ 37 | */ 38 | 39 | /** @addtogroup STM32WLXX_NUCLEO STM32WLXX-NUCLEO 40 | * @{ 41 | */ 42 | 43 | /** @defgroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL RADIO LOW LEVEL 44 | * @{ 45 | */ 46 | 47 | /** @defgroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL_Exported_Types RADIO LOW LEVEL Exported Types 48 | * @{ 49 | */ 50 | 51 | typedef enum 52 | { 53 | RADIO_SWITCH_OFF = 0, 54 | RADIO_SWITCH_RX = 1, 55 | RADIO_SWITCH_RFO_LP = 2, 56 | RADIO_SWITCH_RFO_HP = 3, 57 | }BSP_RADIO_Switch_TypeDef; 58 | 59 | typedef enum 60 | { 61 | RADIO_RFO_LP_MAXPOWER = 0, 62 | RADIO_RFO_HP_MAXPOWER, 63 | } BSP_RADIO_RFOMaxPowerConfig_TypeDef; 64 | 65 | /** 66 | * @} 67 | */ 68 | 69 | /** @defgroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL_Exported_Constants RADIO LOW LEVEL Exported Constants 70 | * @{ 71 | */ 72 | 73 | /** @defgroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL_RADIOCONFIG RADIO LOW LEVEL RADIO CONFIG Constants 74 | * @{ 75 | */ 76 | #define RADIO_CONF_RFO_LP_HP 0U 77 | #define RADIO_CONF_RFO_LP 1U 78 | #define RADIO_CONF_RFO_HP 2U 79 | 80 | #define RADIO_CONF_TCXO_NOT_SUPPORTED 0U 81 | #define RADIO_CONF_TCXO_SUPPORTED 1U 82 | 83 | #define RADIO_CONF_DCDC_NOT_SUPPORTED 0U 84 | #define RADIO_CONF_DCDC_SUPPORTED 1U 85 | 86 | #define RADIO_CONF_RFO_HP_MAX_22_dBm ((int32_t) 22) 87 | #define RADIO_CONF_RFO_HP_MAX_20_dBm ((int32_t) 20) 88 | #define RADIO_CONF_RFO_HP_MAX_17_dBm ((int32_t) 17) 89 | #define RADIO_CONF_RFO_HP_MAX_14_dBm ((int32_t) 14) 90 | #define RADIO_CONF_RFO_LP_MAX_15_dBm ((int32_t) 15) 91 | #define RADIO_CONF_RFO_LP_MAX_14_dBm ((int32_t) 14) 92 | #define RADIO_CONF_RFO_LP_MAX_10_dBm ((int32_t) 10) 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | /** @defgroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL_RFSWITCH RADIO LOW LEVEL RF SWITCH Constants 99 | * @{ 100 | */ 101 | #define RF_SW_CTRL1_PIN GPIO_PIN_8 102 | #define RF_SW_CTRL1_GPIO_PORT GPIOB 103 | #define RF_SW_CTRL1_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() 104 | #define RF_SW_RX_GPIO_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() 105 | 106 | #define RF_SW_CTRL2_PIN GPIO_PIN_13 107 | #define RF_SW_CTRL2_GPIO_PORT GPIOC 108 | #define RF_SW_CTRL2_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE() 109 | #define RF_SW_CTRL2_GPIO_CLK_DISABLE() __HAL_RCC_GPIOC_CLK_DISABLE() 110 | 111 | #define RF_TCXO_VCC_PIN GPIO_PIN_0 112 | #define RF_TCXO_VCC_GPIO_PORT GPIOB 113 | #define RF_TCXO_VCC_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE() 114 | #define RF_TCXO_VCC_CLK_DISABLE() __HAL_RCC_GPIOB_CLK_DISABLE() 115 | /** 116 | * @} 117 | */ 118 | 119 | /** 120 | * @} 121 | */ 122 | 123 | /** @defgroup STM32WLXX_NUCLEO_RADIO_LOW_LEVEL_Exported_Functions RADIO LOW LEVEL Exported Functions 124 | * @{ 125 | */ 126 | int32_t BSP_RADIO_Init(void); 127 | int32_t BSP_RADIO_DeInit(void); 128 | int32_t BSP_RADIO_ConfigRFSwitch(BSP_RADIO_Switch_TypeDef Config); 129 | int32_t BSP_RADIO_GetTxConfig(void); 130 | int32_t BSP_RADIO_IsTCXO(void); 131 | int32_t BSP_RADIO_IsDCDC(void); 132 | int32_t BSP_RADIO_GetRFOMaxPowerConfig(BSP_RADIO_RFOMaxPowerConfig_TypeDef Config); 133 | 134 | /** 135 | * @} 136 | */ 137 | 138 | /** 139 | * @} 140 | */ 141 | 142 | /** 143 | * @} 144 | */ 145 | 146 | /** 147 | * @} 148 | */ 149 | 150 | #ifdef __cplusplus 151 | } 152 | #endif 153 | 154 | #endif /* STM32WLXX_NUCLEO_RADIO_H */ 155 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32WLxx/Include/system_stm32wlxx.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file system_stm32wlxx.h 4 | * @author MCD Application Team 5 | * @brief CMSIS Cortex Device System Source File for STM32WLxx devices. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2020-2021 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /** @addtogroup CMSIS 20 | * @{ 21 | */ 22 | 23 | /** @addtogroup stm32wlxx_system 24 | * @{ 25 | */ 26 | 27 | /** 28 | * @brief Define to prevent recursive inclusion 29 | */ 30 | #ifndef __SYSTEM_STM32WLXX_H 31 | #define __SYSTEM_STM32WLXX_H 32 | 33 | #ifdef __cplusplus 34 | extern "C" { 35 | #endif 36 | 37 | #include 38 | 39 | /** @addtogroup STM32WLxx_System_Includes 40 | * @{ 41 | */ 42 | 43 | /** 44 | * @} 45 | */ 46 | 47 | 48 | /** @addtogroup STM32WLxx_System_Exported_types 49 | * @{ 50 | */ 51 | /* The SystemCoreClock variable is updated in three ways: 52 | 1) from within HAL_Init() 53 | 2) by calling CMSIS function SystemCoreClockUpdate() 54 | 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency 55 | */ 56 | 57 | extern uint32_t SystemCoreClock; /*!< System Clock Frequency */ 58 | 59 | extern const uint32_t AHBPrescTable[16]; /*!< AHB prescalers table values */ 60 | extern const uint32_t APBPrescTable[8]; /*!< APB prescalers table values */ 61 | extern const uint32_t MSIRangeTable[16]; /*!< MSI ranges table values */ 62 | 63 | /** 64 | * @} 65 | */ 66 | 67 | /** @addtogroup STM32WLxx_System_Exported_Constants 68 | * @{ 69 | */ 70 | 71 | /** 72 | * @} 73 | */ 74 | 75 | /** @addtogroup STM32WLxx_System_Exported_Macros 76 | * @{ 77 | */ 78 | 79 | /** 80 | * @} 81 | */ 82 | 83 | /** @addtogroup STM32WLxx_System_Exported_Functions 84 | * @{ 85 | */ 86 | 87 | extern void SystemInit(void); 88 | extern void SystemCoreClockUpdate(void); 89 | /** 90 | * @} 91 | */ 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /*__SYSTEM_STM32WLXX_H */ 98 | 99 | /** 100 | * @} 101 | */ 102 | 103 | /** 104 | * @} 105 | */ 106 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Device/ST/STM32WLxx/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the Apache-2.0 license shall apply. 5 | You may obtain a copy of the Apache-2.0 at: 6 | https://opensource.org/licenses/Apache-2.0 7 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/cmsis_version.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************//** 2 | * @file cmsis_version.h 3 | * @brief CMSIS Core(M) Version definitions 4 | * @version V5.0.3 5 | * @date 24. June 2019 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2009-2019 ARM Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef __CMSIS_VERSION_H 32 | #define __CMSIS_VERSION_H 33 | 34 | /* CMSIS Version definitions */ 35 | #define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */ 36 | #define __CM_CMSIS_VERSION_SUB ( 3U) /*!< [15:0] CMSIS Core(M) sub version */ 37 | #define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \ 38 | __CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */ 39 | #endif 40 | -------------------------------------------------------------------------------- /Drivers/CMSIS/Include/tz_context.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file tz_context.h 3 | * @brief Context Management for Armv8-M TrustZone 4 | * @version V1.0.1 5 | * @date 10. January 2018 6 | ******************************************************************************/ 7 | /* 8 | * Copyright (c) 2017-2018 Arm Limited. All rights reserved. 9 | * 10 | * SPDX-License-Identifier: Apache-2.0 11 | * 12 | * Licensed under the Apache License, Version 2.0 (the License); you may 13 | * not use this file except in compliance with the License. 14 | * You may obtain a copy of the License at 15 | * 16 | * www.apache.org/licenses/LICENSE-2.0 17 | * 18 | * Unless required by applicable law or agreed to in writing, software 19 | * distributed under the License is distributed on an AS IS BASIS, WITHOUT 20 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 21 | * See the License for the specific language governing permissions and 22 | * limitations under the License. 23 | */ 24 | 25 | #if defined ( __ICCARM__ ) 26 | #pragma system_include /* treat file as system include file for MISRA check */ 27 | #elif defined (__clang__) 28 | #pragma clang system_header /* treat file as system include file */ 29 | #endif 30 | 31 | #ifndef TZ_CONTEXT_H 32 | #define TZ_CONTEXT_H 33 | 34 | #include 35 | 36 | #ifndef TZ_MODULEID_T 37 | #define TZ_MODULEID_T 38 | /// \details Data type that identifies secure software modules called by a process. 39 | typedef uint32_t TZ_ModuleId_t; 40 | #endif 41 | 42 | /// \details TZ Memory ID identifies an allocated memory slot. 43 | typedef uint32_t TZ_MemoryId_t; 44 | 45 | /// Initialize secure context memory system 46 | /// \return execution status (1: success, 0: error) 47 | uint32_t TZ_InitContextSystem_S (void); 48 | 49 | /// Allocate context memory for calling secure software modules in TrustZone 50 | /// \param[in] module identifies software modules called from non-secure mode 51 | /// \return value != 0 id TrustZone memory slot identifier 52 | /// \return value 0 no memory available or internal error 53 | TZ_MemoryId_t TZ_AllocModuleContext_S (TZ_ModuleId_t module); 54 | 55 | /// Free context memory that was previously allocated with \ref TZ_AllocModuleContext_S 56 | /// \param[in] id TrustZone memory slot identifier 57 | /// \return execution status (1: success, 0: error) 58 | uint32_t TZ_FreeModuleContext_S (TZ_MemoryId_t id); 59 | 60 | /// Load secure context (called on RTOS thread context switch) 61 | /// \param[in] id TrustZone memory slot identifier 62 | /// \return execution status (1: success, 0: error) 63 | uint32_t TZ_LoadContext_S (TZ_MemoryId_t id); 64 | 65 | /// Store secure context (called on RTOS thread context switch) 66 | /// \param[in] id TrustZone memory slot identifier 67 | /// \return execution status (1: success, 0: error) 68 | uint32_t TZ_StoreContext_S (TZ_MemoryId_t id); 69 | 70 | #endif // TZ_CONTEXT_H 71 | -------------------------------------------------------------------------------- /Drivers/STM32WLxx_HAL_Driver/Inc/stm32wlxx_hal_flash_ex.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32wlxx_hal_flash_ex.h 4 | * @author MCD Application Team 5 | * @brief Header file of FLASH HAL Extended module. 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2020 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef STM32WLxx_HAL_FLASH_EX_H 21 | #define STM32WLxx_HAL_FLASH_EX_H 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include "stm32wlxx_hal_def.h" 29 | 30 | /** @addtogroup STM32WLxx_HAL_Driver 31 | * @{ 32 | */ 33 | 34 | /** @addtogroup FLASHEx 35 | * @{ 36 | */ 37 | 38 | /* Exported types ------------------------------------------------------------*/ 39 | /* Exported constants --------------------------------------------------------*/ 40 | /** @defgroup FLASHEx_Exported_Constants FLASH Exported Constants 41 | * @{ 42 | */ 43 | /** @defgroup FLASHEx_EMPTY_CHECK FLASHEx Empty Check 44 | * @{ 45 | */ 46 | #define FLASH_PROG_NOT_EMPTY 0x00000000U /*!< 1st location in Flash is programmed */ 47 | #define FLASH_PROG_EMPTY FLASH_ACR_EMPTY /*!< 1st location in Flash is empty */ 48 | /** 49 | * @} 50 | */ 51 | 52 | /** @defgroup FLASHEx_PRIV_MODE_CFG FLASHEx privilege mode configuration 53 | * @{ 54 | */ 55 | #define FLASH_PRIV_GRANTED 0x00000000U /*!< access to Flash registers is granted */ 56 | #define FLASH_PRIV_DENIED FLASH_ACR2_PRIVMODE /*!< access to Flash registers is denied to non-privilege access */ 57 | /** 58 | * @} 59 | */ 60 | /** 61 | * @} 62 | */ 63 | 64 | /* Exported macro ------------------------------------------------------------*/ 65 | /* Exported functions --------------------------------------------------------*/ 66 | /** @addtogroup FLASHEx_Exported_Functions 67 | * @{ 68 | */ 69 | 70 | /* Extended Program operation functions *************************************/ 71 | /** @addtogroup FLASHEx_Exported_Functions_Group1 72 | * @{ 73 | */ 74 | HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError); 75 | HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit); 76 | uint32_t HAL_FLASHEx_FlashEmptyCheck(void); 77 | void HAL_FLASHEx_ForceFlashEmpty(uint32_t FlashEmpty); 78 | HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit); 79 | void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit); 80 | void HAL_FLASHEx_SuspendOperation(void); 81 | void HAL_FLASHEx_AllowOperation(void); 82 | uint32_t HAL_FLASHEx_IsOperationSuspended(void); 83 | #if defined(DUAL_CORE) 84 | void HAL_FLASHEx_DisableC2Debug(void); 85 | void HAL_FLASHEx_EnableC2Debug(void); 86 | void HAL_FLASHEx_EnableSecHideProtection(void); 87 | void HAL_FLASHEx_ConfigPrivMode(uint32_t PrivMode); 88 | uint32_t HAL_FLASHEx_GetPrivMode(void); 89 | #endif /* DUAL_CORE */ 90 | /** 91 | * @} 92 | */ 93 | 94 | /** 95 | * @} 96 | */ 97 | 98 | /* Private macros ------------------------------------------------------------*/ 99 | /** @defgroup FLASHEx_Private_Macros FLASHEx Private Macros 100 | * @{ 101 | */ 102 | #define IS_FLASH_EMPTY_CHECK(__VALUE__) (((__VALUE__) == FLASH_PROG_EMPTY) || ((__VALUE__) == FLASH_PROG_NOT_EMPTY)) 103 | 104 | #define IS_FLASH_CFGPRIVMODE(__VALUE__) (((__VALUE__) == FLASH_PRIV_GRANTED) || ((__VALUE__) == FLASH_PRIV_DENIED)) 105 | /** 106 | * @} 107 | */ 108 | 109 | /* Private Functions ---------------------------------------------------------*/ 110 | /** @defgroup FLASHEx_Private_Functions FLASHEx Private Functions 111 | * @{ 112 | */ 113 | void FLASH_PageErase(uint32_t Page); 114 | /** 115 | * @} 116 | */ 117 | 118 | /** 119 | * @} 120 | */ 121 | 122 | /** 123 | * @} 124 | */ 125 | 126 | #ifdef __cplusplus 127 | } 128 | #endif 129 | 130 | #endif /* STM32WLxx_HAL_FLASH_EX_H */ 131 | 132 | -------------------------------------------------------------------------------- /Drivers/STM32WLxx_HAL_Driver/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the BSD-3-Clause license shall apply. 5 | You may obtain a copy of the BSD-3-Clause at: 6 | https://opensource.org/licenses/BSD-3-Clause 7 | -------------------------------------------------------------------------------- /Drivers/STM32WLxx_HAL_Driver/License.md: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 STMicroelectronics 2 | 3 | This software component is licensed by STMicroelectronics under the **BSD-3-Clause** license. You may not use this software except in compliance with this license. You may obtain a copy of the license [here](https://opensource.org/licenses/BSD-3-Clause). -------------------------------------------------------------------------------- /LoRaWAN/App/CayenneLpp.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * @file CayenneLpp.h 3 | * 4 | * @brief Implements the Cayenne Low Power Protocol 5 | * 6 | * @copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * @code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2018 Semtech 16 | * 17 | * @endcode 18 | * 19 | * @author Miguel Luis ( Semtech ) 20 | */ 21 | #ifndef __CAYENNE_LPP_H__ 22 | #define __CAYENNE_LPP_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | /* Exported types ------------------------------------------------------------*/ 36 | /* USER CODE BEGIN ET */ 37 | 38 | /* USER CODE END ET */ 39 | 40 | /* Exported constants --------------------------------------------------------*/ 41 | /* USER CODE BEGIN EC */ 42 | 43 | /* USER CODE END EC */ 44 | 45 | /* External variables --------------------------------------------------------*/ 46 | /* USER CODE BEGIN EV */ 47 | 48 | /* USER CODE END EV */ 49 | 50 | /* Exported macro ------------------------------------------------------------*/ 51 | /* USER CODE BEGIN EM */ 52 | 53 | /* USER CODE END EM */ 54 | 55 | /* Exported functions prototypes ---------------------------------------------*/ 56 | void CayenneLppInit(void); 57 | 58 | void CayenneLppReset(void); 59 | 60 | uint8_t CayenneLppGetSize(void); 61 | 62 | uint8_t *CayenneLppGetBuffer(void); 63 | 64 | uint8_t CayenneLppCopy(uint8_t *buffer); 65 | 66 | uint8_t CayenneLppAddDigitalInput(uint8_t channel, uint8_t value); 67 | 68 | uint8_t CayenneLppAddDigitalOutput(uint8_t channel, uint8_t value); 69 | 70 | uint8_t CayenneLppAddAnalogInput( uint8_t channel, float value ); 71 | 72 | uint8_t CayenneLppAddAnalogOutput( uint8_t channel, float value ); 73 | 74 | uint8_t CayenneLppAddLuminosity(uint8_t channel, uint16_t lux); 75 | 76 | uint8_t CayenneLppAddPresence(uint8_t channel, uint8_t value); 77 | 78 | uint8_t CayenneLppAddTemperature( uint8_t channel, float celsius ); 79 | 80 | uint8_t CayenneLppAddRelativeHumidity( uint8_t channel, float rh ); 81 | 82 | uint8_t CayenneLppAddAccelerometer( uint8_t channel, float x, float y, float z ); 83 | 84 | uint8_t CayenneLppAddBarometricPressure( uint8_t channel, float hpa ); 85 | 86 | uint8_t CayenneLppAddGyrometer( uint8_t channel, float x, float y, float z ); 87 | 88 | uint8_t CayenneLppAddGps( uint8_t channel, float latitude, float longitude, float meters ); 89 | 90 | /* USER CODE BEGIN EFP */ 91 | 92 | /* USER CODE END EFP */ 93 | 94 | #ifdef __cplusplus 95 | } 96 | #endif 97 | 98 | #endif /* __CAYENNE_LPP_H__ */ 99 | -------------------------------------------------------------------------------- /LoRaWAN/App/Commissioning.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file Commissioning.h 3 | * 4 | * \brief End-device commissioning parameters 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2020 Semtech 16 | * 17 | * \endcode 18 | */ 19 | /** 20 | ****************************************************************************** 21 | * 22 | * Portions COPYRIGHT 2020 STMicroelectronics 23 | * 24 | * @file Commissioning.h 25 | * @author MCD Application Team 26 | * @brief End-device commissioning parameters 27 | ****************************************************************************** 28 | */ 29 | 30 | /* Define to prevent recursive inclusion -------------------------------------*/ 31 | #ifndef __COMMISSIONING_H__ 32 | #define __COMMISSIONING_H__ 33 | 34 | /*! 35 | ****************************************************************************** 36 | ********************************** WARNING *********************************** 37 | ****************************************************************************** 38 | 39 | The LoRaWAN AES128 keys are stored and provisioned on secure-elements. 40 | 41 | This project provides a software emulated secure-element. 42 | The LoRaWAN AES128 keys SHALL be updated under 43 | src/peripherals/-se\se-identity.h file. 44 | 45 | ****************************************************************************** 46 | ****************************************************************************** 47 | ****************************************************************************** 48 | */ 49 | #include "se-identity.h" 50 | #include "LoRaMacVersion.h" 51 | 52 | /* USER CODE BEGIN EC1 */ 53 | 54 | /* USER CODE END EC1 */ 55 | 56 | /*! 57 | * When using ABP activation the MAC layer must know in advance to which server 58 | * version it will be connected. 59 | */ 60 | #define ABP_ACTIVATION_LRWAN_VERSION LORAMAC_VERSION 61 | 62 | /*! 63 | * Indicates if the end-device support the operation with repeaters 64 | */ 65 | #define LORAWAN_REPEATER_SUPPORT false 66 | 67 | /*! 68 | * Indicates if the end-device is to be connected to a private or public network 69 | */ 70 | #define LORAWAN_PUBLIC_NETWORK true 71 | 72 | /*! 73 | * Current network ID 74 | */ 75 | #define LORAWAN_NETWORK_ID ( uint32_t )0 76 | 77 | /* USER CODE BEGIN EC2 */ 78 | 79 | /* USER CODE END EC2 */ 80 | 81 | #endif /* __COMMISSIONING_H__ */ 82 | -------------------------------------------------------------------------------- /LoRaWAN/App/app_lorawan.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file app_lorawan.c 5 | * @author MCD Application Team 6 | * @brief Application of the LRWAN Middleware 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "app_lorawan.h" 23 | #include "lora_app.h" 24 | #include "sys_app.h" 25 | #include "stm32_seq.h" 26 | 27 | /* USER CODE BEGIN Includes */ 28 | 29 | /* USER CODE END Includes */ 30 | 31 | /* External variables ---------------------------------------------------------*/ 32 | /* USER CODE BEGIN EV */ 33 | 34 | /* USER CODE END EV */ 35 | 36 | /* Private typedef -----------------------------------------------------------*/ 37 | /* USER CODE BEGIN PTD */ 38 | 39 | /* USER CODE END PTD */ 40 | 41 | /* Private define ------------------------------------------------------------*/ 42 | /* USER CODE BEGIN PD */ 43 | 44 | /* USER CODE END PD */ 45 | 46 | /* Private macro -------------------------------------------------------------*/ 47 | /* USER CODE BEGIN PM */ 48 | 49 | /* USER CODE END PM */ 50 | 51 | /* Private variables ---------------------------------------------------------*/ 52 | 53 | /* USER CODE BEGIN PV */ 54 | 55 | /* USER CODE END PV */ 56 | 57 | /* Private function prototypes -----------------------------------------------*/ 58 | 59 | /* USER CODE BEGIN PFP */ 60 | 61 | /* USER CODE END PFP */ 62 | 63 | /* Exported functions --------------------------------------------------------*/ 64 | 65 | void MX_LoRaWAN_Init(void) 66 | { 67 | /* USER CODE BEGIN MX_LoRaWAN_Init_1 */ 68 | 69 | /* USER CODE END MX_LoRaWAN_Init_1 */ 70 | SystemApp_Init(); 71 | /* USER CODE BEGIN MX_LoRaWAN_Init_2 */ 72 | 73 | /* USER CODE END MX_LoRaWAN_Init_2 */ 74 | LoRaWAN_Init(); 75 | /* USER CODE BEGIN MX_LoRaWAN_Init_3 */ 76 | 77 | /* USER CODE END MX_LoRaWAN_Init_3 */ 78 | } 79 | 80 | void MX_LoRaWAN_Process(void) 81 | { 82 | /* USER CODE BEGIN MX_LoRaWAN_Process_1 */ 83 | 84 | /* USER CODE END MX_LoRaWAN_Process_1 */ 85 | UTIL_SEQ_Run(UTIL_SEQ_DEFAULT); 86 | /* USER CODE BEGIN MX_LoRaWAN_Process_2 */ 87 | 88 | /* USER CODE END MX_LoRaWAN_Process_2 */ 89 | } 90 | 91 | /* USER CODE BEGIN EF */ 92 | 93 | /* USER CODE END EF */ 94 | 95 | /* Private Functions Definition -----------------------------------------------*/ 96 | /* USER CODE BEGIN PrFD */ 97 | 98 | /* USER CODE END PrFD */ 99 | -------------------------------------------------------------------------------- /LoRaWAN/App/app_lorawan.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file app_lorawan.h 5 | * @author MCD Application Team 6 | * @brief Header of application of the LRWAN Middleware 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __APP_LORAWAN_H__ 23 | #define __APP_LORAWAN_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | /* USER CODE BEGIN Includes */ 31 | 32 | /* USER CODE END Includes */ 33 | 34 | /* Exported types ------------------------------------------------------------*/ 35 | /* USER CODE BEGIN ET */ 36 | 37 | /* USER CODE END ET */ 38 | 39 | /* Exported constants --------------------------------------------------------*/ 40 | /* USER CODE BEGIN EC */ 41 | 42 | /* USER CODE END EC */ 43 | 44 | /* External variables --------------------------------------------------------*/ 45 | /* USER CODE BEGIN EV */ 46 | 47 | /* USER CODE END EV */ 48 | 49 | /* Exported macro ------------------------------------------------------------*/ 50 | /* USER CODE BEGIN EM */ 51 | 52 | /* USER CODE END EM */ 53 | 54 | /* Exported Functions Prototypes ---------------------------------------------*/ 55 | /** 56 | * @brief Init Lora Application 57 | */ 58 | void MX_LoRaWAN_Init(void); 59 | 60 | /** 61 | * @brief Entry Lora Process or scheduling 62 | */ 63 | void MX_LoRaWAN_Process(void); 64 | 65 | /* USER CODE BEGIN EFP */ 66 | 67 | /* USER CODE END EFP */ 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /*__APP_LORAWAN_H__*/ 74 | -------------------------------------------------------------------------------- /LoRaWAN/App/lora_app.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file lora_app.h 5 | * @author MCD Application Team 6 | * @brief Header of application of the LRWAN Middleware 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __LORA_APP_H__ 23 | #define __LORA_APP_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | /* USER CODE BEGIN Includes */ 31 | 32 | /* USER CODE END Includes */ 33 | 34 | /* Exported types ------------------------------------------------------------*/ 35 | /* USER CODE BEGIN ET */ 36 | 37 | /* USER CODE END ET */ 38 | 39 | /* Exported constants --------------------------------------------------------*/ 40 | 41 | /* LoraWAN application configuration (Mw is configured by lorawan_conf.h) */ 42 | #define ACTIVE_REGION LORAMAC_REGION_US915 43 | 44 | /*! 45 | * CAYENNE_LPP is myDevices Application server. 46 | */ 47 | /*#define CAYENNE_LPP*/ 48 | 49 | /*! 50 | * Defines the application data transmission duty cycle. 10s, value in [ms]. 51 | */ 52 | #define APP_TX_DUTYCYCLE 900000 53 | 54 | /*! 55 | * LoRaWAN User application port 56 | * @note do not use 224. It is reserved for certification 57 | */ 58 | #define LORAWAN_USER_APP_PORT 2 59 | 60 | /*! 61 | * LoRaWAN Switch class application port 62 | * @note do not use 224. It is reserved for certification 63 | */ 64 | #define LORAWAN_SWITCH_CLASS_PORT 3 65 | 66 | /*! 67 | * LoRaWAN default class 68 | */ 69 | #define LORAWAN_DEFAULT_CLASS CLASS_A 70 | 71 | /*! 72 | * LoRaWAN default confirm state 73 | */ 74 | #define LORAWAN_DEFAULT_CONFIRMED_MSG_STATE LORAMAC_HANDLER_UNCONFIRMED_MSG 75 | 76 | /*! 77 | * LoRaWAN Adaptive Data Rate 78 | * @note Please note that when ADR is enabled the end-device should be static 79 | */ 80 | #define LORAWAN_ADR_STATE LORAMAC_HANDLER_ADR_ON 81 | 82 | /*! 83 | * LoRaWAN Default data Rate Data Rate 84 | * @note Please note that LORAWAN_DEFAULT_DATA_RATE is used only when LORAWAN_ADR_STATE is disabled 85 | */ 86 | #define LORAWAN_DEFAULT_DATA_RATE DR_0 87 | 88 | /*! 89 | * LoRaWAN default activation type 90 | */ 91 | #define LORAWAN_DEFAULT_ACTIVATION_TYPE ACTIVATION_TYPE_OTAA 92 | 93 | /*! 94 | * LoRaWAN force rejoin even if the NVM context is restored 95 | * @note useful only when context management is enabled by CONTEXT_MANAGEMENT_ENABLED 96 | */ 97 | #define LORAWAN_FORCE_REJOIN_AT_BOOT true 98 | 99 | /*! 100 | * User application data buffer size 101 | */ 102 | #define LORAWAN_APP_DATA_BUFFER_MAX_SIZE 242 103 | 104 | /*! 105 | * Default Unicast ping slots periodicity 106 | * 107 | * \remark periodicity is equal to 2^LORAWAN_DEFAULT_PING_SLOT_PERIODICITY seconds 108 | * example: 2^4 = 16 seconds. The end-device will open an Rx slot every 16 seconds. 109 | */ 110 | #define LORAWAN_DEFAULT_PING_SLOT_PERIODICITY 4 111 | 112 | /*! 113 | * Default response timeout for class b and class c confirmed 114 | * downlink frames in milli seconds. 115 | * 116 | * The value shall not be smaller than RETRANSMIT_TIMEOUT plus 117 | * the maximum time on air. 118 | */ 119 | #define LORAWAN_DEFAULT_CLASS_B_C_RESP_TIMEOUT 8000 120 | 121 | /* USER CODE BEGIN EC */ 122 | 123 | /* USER CODE END EC */ 124 | 125 | /* Exported macros -----------------------------------------------------------*/ 126 | /* USER CODE BEGIN EM */ 127 | 128 | /* USER CODE END EM */ 129 | 130 | /* Exported functions prototypes ---------------------------------------------*/ 131 | /** 132 | * @brief Init Lora Application 133 | */ 134 | void LoRaWAN_Init(void); 135 | 136 | /* USER CODE BEGIN EFP */ 137 | 138 | /* USER CODE END EFP */ 139 | 140 | #ifdef __cplusplus 141 | } 142 | #endif 143 | 144 | #endif /*__LORA_APP_H__*/ 145 | -------------------------------------------------------------------------------- /LoRaWAN/App/lora_app_version.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file lora_app_version.h 5 | * @author MCD Application Team 6 | * @brief Definition the version of the application 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __APP_VERSION_H__ 23 | #define __APP_VERSION_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | /* Exported types ------------------------------------------------------------*/ 36 | /* USER CODE BEGIN ET */ 37 | 38 | /* USER CODE END ET */ 39 | 40 | /* Exported constants --------------------------------------------------------*/ 41 | #define APP_VERSION_MAIN (0x01U) /*!< [31:24] main version */ 42 | #define APP_VERSION_SUB1 (0x02U) /*!< [23:16] sub1 version */ 43 | #define APP_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */ 44 | #define APP_VERSION_RC (0x00U) /*!< [7:0] release candidate */ 45 | 46 | #define APP_VERSION_MAIN_SHIFT 24 /*!< main byte shift */ 47 | #define APP_VERSION_SUB1_SHIFT 16 /*!< sub1 byte shift */ 48 | #define APP_VERSION_SUB2_SHIFT 8 /*!< sub2 byte shift */ 49 | #define APP_VERSION_RC_SHIFT 0 /*!< release candidate byte shift */ 50 | 51 | /* USER CODE BEGIN EC */ 52 | 53 | /* USER CODE END EC */ 54 | 55 | /* External variables --------------------------------------------------------*/ 56 | /* USER CODE BEGIN EV */ 57 | 58 | /* USER CODE END EV */ 59 | 60 | /* Exported macros -----------------------------------------------------------*/ 61 | /** 62 | * @brief Application version 63 | */ 64 | #define APP_VERSION ((APP_VERSION_MAIN << APP_VERSION_MAIN_SHIFT)\ 65 | |(APP_VERSION_SUB1 << APP_VERSION_SUB1_SHIFT)\ 66 | |(APP_VERSION_SUB2 << APP_VERSION_SUB2_SHIFT)\ 67 | |(APP_VERSION_RC << APP_VERSION_RC_SHIFT)) 68 | 69 | /* USER CODE BEGIN EM */ 70 | 71 | /* USER CODE END EM */ 72 | 73 | /* Exported functions prototypes ---------------------------------------------*/ 74 | /* USER CODE BEGIN EFP */ 75 | 76 | /* USER CODE END EFP */ 77 | 78 | #ifdef __cplusplus 79 | } 80 | #endif 81 | 82 | #endif /*__APP_VERSION_H__*/ 83 | -------------------------------------------------------------------------------- /LoRaWAN/App/lora_info.c: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file lora_info.c 5 | * @author MCD Application Team 6 | * @brief To give info to the application about LoRaWAN configuration 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Includes ------------------------------------------------------------------*/ 22 | #include "LoRaMac.h" 23 | #include "lora_info.h" 24 | #include "lorawan_conf.h" 25 | #include "sys_app.h" /* APP_PRINTF */ 26 | 27 | /* USER CODE BEGIN Includes */ 28 | 29 | /* USER CODE END Includes */ 30 | 31 | /* Private typedef -----------------------------------------------------------*/ 32 | 33 | /* USER CODE BEGIN PTD */ 34 | 35 | /* USER CODE END PTD */ 36 | 37 | /* Private define ------------------------------------------------------------*/ 38 | 39 | /* USER CODE BEGIN PD */ 40 | 41 | /* USER CODE END PD */ 42 | 43 | /* Private macro -------------------------------------------------------------*/ 44 | 45 | /* USER CODE BEGIN PM */ 46 | 47 | /* USER CODE END PM */ 48 | 49 | /* Private variables ---------------------------------------------------------*/ 50 | static LoraInfo_t loraInfo = {0, 0}; 51 | 52 | /* USER CODE BEGIN PV */ 53 | 54 | /* USER CODE END PV */ 55 | 56 | /* Private function prototypes -----------------------------------------------*/ 57 | 58 | /* USER CODE BEGIN PFP */ 59 | 60 | /* USER CODE END PFP */ 61 | 62 | /* Exported variables --------------------------------------------------------*/ 63 | 64 | /* USER CODE BEGIN EV */ 65 | 66 | /* USER CODE END EV */ 67 | 68 | /* Exported functions --------------------------------------------------------*/ 69 | void LoraInfo_Init(void) 70 | { 71 | loraInfo.ActivationMode = 0; 72 | loraInfo.Region = 0; 73 | loraInfo.ClassB = 0; 74 | loraInfo.Kms = 0; 75 | /* USER CODE BEGIN LoraInfo_Init_1 */ 76 | 77 | /* USER CODE END LoraInfo_Init_1 */ 78 | 79 | #ifdef REGION_AS923 80 | loraInfo.Region |= (1 << LORAMAC_REGION_AS923); 81 | #endif /* REGION_AS923 */ 82 | #ifdef REGION_AU915 83 | loraInfo.Region |= (1 << LORAMAC_REGION_AU915); 84 | #endif /* REGION_AU915 */ 85 | #ifdef REGION_CN470 86 | loraInfo.Region |= (1 << LORAMAC_REGION_CN470); 87 | #endif /* REGION_CN470 */ 88 | #ifdef REGION_CN779 89 | loraInfo.Region |= (1 << LORAMAC_REGION_CN779); 90 | #endif /* REGION_CN779 */ 91 | #ifdef REGION_EU433 92 | loraInfo.Region |= (1 << LORAMAC_REGION_EU433); 93 | #endif /* REGION_EU433 */ 94 | #ifdef REGION_EU868 95 | loraInfo.Region |= (1 << LORAMAC_REGION_EU868); 96 | #endif /* REGION_EU868 */ 97 | #ifdef REGION_KR920 98 | loraInfo.Region |= (1 << LORAMAC_REGION_KR920); 99 | #endif /* REGION_KR920 */ 100 | #ifdef REGION_IN865 101 | loraInfo.Region |= (1 << LORAMAC_REGION_IN865); 102 | #endif /* REGION_IN865 */ 103 | #ifdef REGION_US915 104 | loraInfo.Region |= (1 << LORAMAC_REGION_US915); 105 | #endif /* REGION_US915 */ 106 | #ifdef REGION_RU864 107 | loraInfo.Region |= (1 << LORAMAC_REGION_RU864); 108 | #endif /* REGION_RU864 */ 109 | 110 | if (loraInfo.Region == 0) 111 | { 112 | APP_PRINTF("error: At least one region shall be defined in the MW: check lorawan_conf.h \r\n"); 113 | while (1 != UTIL_ADV_TRACE_IsBufferEmpty()) 114 | { 115 | /* Wait that all printfs are completed*/ 116 | } 117 | while (1) {} /* At least one region shall be defined */ 118 | } 119 | 120 | #if ( LORAMAC_CLASSB_ENABLED == 1 ) 121 | loraInfo.ClassB = 1; 122 | #elif !defined (LORAMAC_CLASSB_ENABLED) 123 | #error LORAMAC_CLASSB_ENABLED not defined ( shall be <0 or 1> ) 124 | #endif /* LORAMAC_CLASSB_ENABLED */ 125 | 126 | #if (!defined (LORAWAN_KMS) || (LORAWAN_KMS == 0)) 127 | loraInfo.Kms = 0; 128 | loraInfo.ActivationMode = 3; 129 | #else /* LORAWAN_KMS == 1 */ 130 | loraInfo.Kms = 1; 131 | loraInfo.ActivationMode = ACTIVATION_BY_PERSONALIZATION + (OVER_THE_AIR_ACTIVATION << 1); 132 | #endif /* LORAWAN_KMS */ 133 | /* USER CODE BEGIN LoraInfo_Init_2 */ 134 | 135 | /* USER CODE END LoraInfo_Init_2 */ 136 | } 137 | 138 | LoraInfo_t *LoraInfo_GetPtr(void) 139 | { 140 | /* USER CODE BEGIN LoraInfo_GetPtr */ 141 | 142 | /* USER CODE END LoraInfo_GetPtr */ 143 | return &loraInfo; 144 | } 145 | 146 | /* USER CODE BEGIN EF */ 147 | 148 | /* USER CODE END EF */ 149 | 150 | /* Private functions --------------------------------------------------------*/ 151 | 152 | /* USER CODE BEGIN PF */ 153 | 154 | /* USER CODE END PF */ 155 | -------------------------------------------------------------------------------- /LoRaWAN/App/lora_info.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file lora_info.h 5 | * @author MCD Application Team 6 | * @brief To give info to the application about LoRaWAN configuration 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | #ifndef __LORA_INFO_H__ 22 | #define __LORA_INFO_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | #include 30 | 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | /* Exported constants --------------------------------------------------------*/ 36 | 37 | /* USER CODE BEGIN EC */ 38 | 39 | /* USER CODE END EC */ 40 | 41 | /* Exported types ------------------------------------------------------------*/ 42 | /*! 43 | * To give info to the application about LoraWAN capability 44 | * it can depend how it has been compiled (e.g. compiled regions ...) 45 | * Params should be better uint32_t foe easier alignment with info_table concept 46 | */ 47 | typedef struct 48 | { 49 | uint32_t ActivationMode; /*!< 1: ABP, 2 : OTAA, 3: ABP & OTAA */ 50 | uint32_t Region; /*!< Combination of regions compiled on MW */ 51 | uint32_t ClassB; /*!< 0: not compiled in Mw, 1 : compiled in MW */ 52 | uint32_t Kms; /*!< 0: not compiled in Mw, 1 : compiled in MW */ 53 | } LoraInfo_t; 54 | 55 | /* USER CODE BEGIN ET */ 56 | 57 | /* USER CODE END ET */ 58 | 59 | /* External variables --------------------------------------------------------*/ 60 | 61 | /* USER CODE BEGIN EV */ 62 | 63 | /* USER CODE END EV */ 64 | 65 | /* Exported macros -----------------------------------------------------------*/ 66 | 67 | /* USER CODE BEGIN EM */ 68 | 69 | /* USER CODE END EM */ 70 | 71 | /* Exported functions ------------------------------------------------------- */ 72 | /** 73 | * @brief initialize the LoraInfo table 74 | */ 75 | void LoraInfo_Init(void); 76 | 77 | /** 78 | * @brief returns the pointer to the LoraInfo capabilities table 79 | * @retval LoraInfo pointer 80 | */ 81 | LoraInfo_t *LoraInfo_GetPtr(void); 82 | 83 | /* USER CODE BEGIN EF */ 84 | 85 | /* USER CODE END EF */ 86 | 87 | #ifdef __cplusplus 88 | } 89 | #endif 90 | 91 | #endif /* __LORA_INFO_H__ */ 92 | -------------------------------------------------------------------------------- /LoRaWAN/Target/mw_log_conf.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file mw_log_conf.h 5 | * @author MCD Application Team 6 | * @brief Configure (enable/disable) traces for CM0 7 | ******************************************************************************* 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __MW_LOG_CONF_H__ 23 | #define __MW_LOG_CONF_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32_adv_trace.h" 31 | 32 | /* USER CODE BEGIN Includes */ 33 | 34 | /* USER CODE END Includes */ 35 | 36 | /* Exported types ------------------------------------------------------------*/ 37 | /* USER CODE BEGIN ET */ 38 | 39 | /* USER CODE END ET */ 40 | 41 | /* Exported constants --------------------------------------------------------*/ 42 | #define MW_LOG_ENABLED 43 | 44 | /* USER CODE BEGIN EC */ 45 | 46 | /* USER CODE END EC */ 47 | 48 | /* External variables --------------------------------------------------------*/ 49 | /* USER CODE BEGIN EV */ 50 | 51 | /* USER CODE END EV */ 52 | 53 | /* Exported macro ------------------------------------------------------------*/ 54 | #ifdef MW_LOG_ENABLED 55 | #define MW_LOG(TS,VL, ...) do{ {UTIL_ADV_TRACE_COND_FSend(VL, T_REG_OFF, TS, __VA_ARGS__);} }while(0) 56 | #else /* MW_LOG_ENABLED */ 57 | #define MW_LOG(TS,VL, ...) 58 | #endif /* MW_LOG_ENABLED */ 59 | /* USER CODE BEGIN EM */ 60 | 61 | /* USER CODE END EM */ 62 | 63 | /* Exported functions prototypes ---------------------------------------------*/ 64 | /* USER CODE BEGIN EFP */ 65 | 66 | /* USER CODE END EFP */ 67 | 68 | #ifdef __cplusplus 69 | } 70 | #endif 71 | 72 | #endif /*__MW_LOG_CONF_H__ */ 73 | -------------------------------------------------------------------------------- /LoRaWAN/Target/systime.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file systime.h 5 | * @author MCD Application Team 6 | * @brief Map middleware systime 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __SYSTIME_H__ 23 | #define __SYSTIME_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32_systime.h" 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | /* Exported types ------------------------------------------------------------*/ 36 | /* USER CODE BEGIN ET */ 37 | 38 | /* USER CODE END ET */ 39 | 40 | /* Exported constants --------------------------------------------------------*/ 41 | /* USER CODE BEGIN EC */ 42 | 43 | /* USER CODE END EC */ 44 | 45 | /* External variables --------------------------------------------------------*/ 46 | /* USER CODE BEGIN EV */ 47 | 48 | /* USER CODE END EV */ 49 | 50 | /* Exported macro ------------------------------------------------------------*/ 51 | /* USER CODE BEGIN EM */ 52 | 53 | /* USER CODE END EM */ 54 | 55 | /* Exported functions prototypes ---------------------------------------------*/ 56 | /* USER CODE BEGIN EFP */ 57 | 58 | /* USER CODE END EFP */ 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif 63 | 64 | #endif /*__SYSTIME_H__*/ 65 | -------------------------------------------------------------------------------- /LoRaWAN/Target/timer.h: -------------------------------------------------------------------------------- 1 | /* USER CODE BEGIN Header */ 2 | /** 3 | ****************************************************************************** 4 | * @file timer.h 5 | * @author MCD Application Team 6 | * @brief Wrapper to timer server 7 | ****************************************************************************** 8 | * @attention 9 | * 10 | * Copyright (c) 2022 STMicroelectronics. 11 | * All rights reserved. 12 | * 13 | * This software is licensed under terms that can be found in the LICENSE file 14 | * in the root directory of this software component. 15 | * If no LICENSE file comes with this software, it is provided AS-IS. 16 | * 17 | ****************************************************************************** 18 | */ 19 | /* USER CODE END Header */ 20 | 21 | /* Define to prevent recursive inclusion -------------------------------------*/ 22 | #ifndef __TIMER_H__ 23 | #define __TIMER_H__ 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /* Includes ------------------------------------------------------------------*/ 30 | #include "stm32_timer.h" 31 | /* USER CODE BEGIN Includes */ 32 | 33 | /* USER CODE END Includes */ 34 | 35 | /* Exported types ------------------------------------------------------------*/ 36 | /* USER CODE BEGIN ET */ 37 | 38 | /* USER CODE END ET */ 39 | 40 | /* Exported constants --------------------------------------------------------*/ 41 | /** 42 | * @brief Max timer mask 43 | */ 44 | #define TIMERTIME_T_MAX ( ( uint32_t )~0 ) 45 | 46 | /* USER CODE BEGIN EC */ 47 | 48 | /* USER CODE END EC */ 49 | 50 | /* External variables --------------------------------------------------------*/ 51 | /* USER CODE BEGIN EV */ 52 | 53 | /* USER CODE END EV */ 54 | 55 | /* Exported macro ------------------------------------------------------------*/ 56 | /** 57 | * @brief Timer value on 32 bits 58 | */ 59 | #define TimerTime_t UTIL_TIMER_Time_t 60 | 61 | /** 62 | * @brief Timer object description 63 | */ 64 | #define TimerEvent_t UTIL_TIMER_Object_t 65 | 66 | /** 67 | * @brief Create the timer object 68 | */ 69 | #define TimerInit(HANDLE, CB) do {\ 70 | UTIL_TIMER_Create( HANDLE, TIMERTIME_T_MAX, UTIL_TIMER_ONESHOT, CB, NULL);\ 71 | } while(0) 72 | 73 | /** 74 | * @brief update the period and start the timer 75 | */ 76 | #define TimerSetValue(HANDLE, TIMEOUT) do{ \ 77 | UTIL_TIMER_SetPeriod(HANDLE, TIMEOUT);\ 78 | } while(0) 79 | 80 | /** 81 | * @brief Start and adds the timer object to the list of timer events 82 | */ 83 | #define TimerStart(HANDLE) do {\ 84 | UTIL_TIMER_Start(HANDLE);\ 85 | } while(0) 86 | 87 | /** 88 | * @brief Stop and removes the timer object from the list of timer events 89 | */ 90 | #define TimerStop(HANDLE) do {\ 91 | UTIL_TIMER_Stop(HANDLE);\ 92 | } while(0) 93 | 94 | /** 95 | * @brief return the current time 96 | */ 97 | #define TimerGetCurrentTime UTIL_TIMER_GetCurrentTime 98 | 99 | /** 100 | * @brief return the elapsed time 101 | */ 102 | #define TimerGetElapsedTime UTIL_TIMER_GetElapsedTime 103 | 104 | /* USER CODE BEGIN EM */ 105 | 106 | /* USER CODE END EM */ 107 | 108 | /* Exported functions prototypes ---------------------------------------------*/ 109 | /* USER CODE BEGIN EFP */ 110 | 111 | /* USER CODE END EFP */ 112 | 113 | #ifdef __cplusplus 114 | } 115 | #endif 116 | 117 | #endif /* __TIMER_H__*/ 118 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/Crypto/cmac.h: -------------------------------------------------------------------------------- 1 | /************************************************************************** 2 | Copyright (C) 2009 Lander Casado, Philippas Tsigas 3 | 4 | All rights reserved. 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining 7 | a copy of this software and associated documentation files 8 | (the "Software"), to deal with the Software without restriction, including 9 | without limitation the rights to use, copy, modify, merge, publish, 10 | distribute, sublicense, and/or sell copies of the Software, and to 11 | permit persons to whom the Software is furnished to do so, subject to 12 | the following conditions: 13 | 14 | Redistributions of source code must retain the above copyright notice, 15 | this list of conditions and the following disclaimers. Redistributions in 16 | binary form must reproduce the above copyright notice, this list of 17 | conditions and the following disclaimers in the documentation and/or 18 | other materials provided with the distribution. 19 | 20 | In no event shall the authors or copyright holders be liable for any special, 21 | incidental, indirect or consequential damages of any kind, or any damages 22 | whatsoever resulting from loss of use, data or profits, whether or not 23 | advised of the possibility of damage, and on any theory of liability, 24 | arising out of or in connection with the use or performance of this software. 25 | 26 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 27 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 28 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 29 | CONTRIBUTORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 30 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 31 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 32 | DEALINGS WITH THE SOFTWARE 33 | 34 | *****************************************************************************/ 35 | 36 | #ifndef _CMAC_H_ 37 | #define _CMAC_H_ 38 | 39 | #ifdef __cplusplus 40 | extern "C" { 41 | #endif 42 | 43 | #include "lorawan_aes.h" 44 | 45 | #define AES_CMAC_KEY_LENGTH 16 46 | #define AES_CMAC_DIGEST_LENGTH 16 47 | 48 | typedef struct _AES_CMAC_CTX { 49 | lorawan_aes_context rijndael; 50 | uint8_t X[16]; 51 | uint8_t M_last[16]; 52 | uint32_t M_n; 53 | } AES_CMAC_CTX; 54 | 55 | //#include 56 | 57 | //__BEGIN_DECLS 58 | void AES_CMAC_Init(AES_CMAC_CTX * ctx); 59 | void AES_CMAC_SetKey(AES_CMAC_CTX * ctx, const uint8_t key[AES_CMAC_KEY_LENGTH]); 60 | void AES_CMAC_Update(AES_CMAC_CTX * ctx, const uint8_t * data, uint32_t len); 61 | // __attribute__((__bounded__(__string__,2,3))); 62 | void AES_CMAC_Final(uint8_t digest[AES_CMAC_DIGEST_LENGTH], AES_CMAC_CTX * ctx); 63 | // __attribute__((__bounded__(__minbytes__,1,AES_CMAC_DIGEST_LENGTH))); 64 | //__END_DECLS 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif /* _CMAC_H_ */ 71 | 72 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/LICENSE: -------------------------------------------------------------------------------- 1 | The Clear BSD License 2 | Copyright Semtech Corporation 2021. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted (subject to the limitations in the disclaimer 6 | below) provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Semtech corporation nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 17 | THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 18 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 19 | NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/LICENSE.txt: -------------------------------------------------------------------------------- 1 | This software component is provided to you as part of a software package and 2 | applicable license terms are in the Package_license file. If you received this 3 | software component outside of a package or without applicable license terms, 4 | the terms of the BSD-3-Clause license shall apply. 5 | You may obtain a copy of the BSD-3-Clause at: 6 | https://opensource.org/licenses/BSD-3-Clause 7 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/LmHandler/LmHandlerTypes.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LmHandlerTypes.h 3 | * 4 | * \brief Defines the types used by LmHandler 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2018 Semtech 16 | * 17 | * \endcode 18 | * 19 | * \author Miguel Luis ( Semtech ) 20 | */ 21 | /** 22 | ****************************************************************************** 23 | * 24 | * Portions COPYRIGHT 2020 STMicroelectronics 25 | * 26 | * @file LmHandlerTypes.h 27 | * @author MCD Application Team 28 | * @brief Header for Global types used by LoRaMAC Layer handler 29 | ****************************************************************************** 30 | */ 31 | #ifndef __LORAMAC_HANDLER_TYPES_H__ 32 | #define __LORAMAC_HANDLER_TYPES_H__ 33 | 34 | /* Includes ------------------------------------------------------------------*/ 35 | #include "LoRaMacInterfaces.h" 36 | 37 | /* Exported defines ----------------------------------------------------------*/ 38 | /* Exported constants --------------------------------------------------------*/ 39 | /* Exported types ------------------------------------------------------------*/ 40 | /*! 41 | * 42 | */ 43 | typedef enum 44 | { 45 | LORAMAC_HANDLER_ADR_OFF = 0, 46 | LORAMAC_HANDLER_ADR_ON = !LORAMAC_HANDLER_ADR_OFF 47 | }LmHandlerAdrStates_t; 48 | 49 | /*! 50 | * 51 | */ 52 | typedef enum 53 | { 54 | LORAMAC_HANDLER_RESET = 0, 55 | LORAMAC_HANDLER_SET = !LORAMAC_HANDLER_RESET 56 | }LmHandlerFlagStatus_t; 57 | 58 | /*! 59 | * 60 | */ 61 | typedef enum 62 | { 63 | LORAMAC_HANDLER_ERROR = -1, 64 | LORAMAC_HANDLER_BUSY_ERROR = -2, 65 | LORAMAC_HANDLER_NO_NETWORK_JOINED = -3, 66 | LORAMAC_HANDLER_COMPLIANCE_RUNNING = -4, 67 | LORAMAC_HANDLER_CRYPTO_ERROR = -5, 68 | LORAMAC_HANDLER_DUTYCYCLE_RESTRICTED = -6, 69 | LORAMAC_HANDLER_PAYLOAD_LENGTH_RESTRICTED = -7, 70 | LORAMAC_HANDLER_NVM_DATA_UP_TO_DATE = -8, 71 | LORAMAC_HANDLER_SUCCESS = 0 72 | }LmHandlerErrorStatus_t; 73 | 74 | /*! 75 | * 76 | */ 77 | typedef enum 78 | { 79 | LORAMAC_HANDLER_UNCONFIRMED_MSG = 0, 80 | LORAMAC_HANDLER_CONFIRMED_MSG = !LORAMAC_HANDLER_UNCONFIRMED_MSG 81 | }LmHandlerMsgTypes_t; 82 | 83 | /*! 84 | * 85 | */ 86 | typedef enum 87 | { 88 | LORAMAC_HANDLER_FALSE = 0, 89 | LORAMAC_HANDLER_TRUE = !LORAMAC_HANDLER_FALSE 90 | }LmHandlerBoolean_t; 91 | 92 | typedef enum 93 | { 94 | LORAMAC_HANDLER_BEACON_ACQUIRING, 95 | LORAMAC_HANDLER_BEACON_LOST, 96 | LORAMAC_HANDLER_BEACON_RX, 97 | LORAMAC_HANDLER_BEACON_NRX 98 | }LmHandlerBeaconState_t; 99 | 100 | typedef enum 101 | { 102 | LORAMAC_HANDLER_NVM_RESTORE, 103 | LORAMAC_HANDLER_NVM_STORE, 104 | }LmHandlerNvmContextStates_t; 105 | 106 | typedef enum 107 | { 108 | LORAMAC_HANDLER_L2_VERSION, 109 | LORAMAC_HANDLER_REGION_VERSION, 110 | }LmHandlerVersionType_t; 111 | /*! 112 | * Commissioning parameters 113 | */ 114 | typedef struct CommissioningParams_s 115 | { 116 | uint8_t DevEui[8]; 117 | uint8_t JoinEui[8]; 118 | uint32_t NetworkId; 119 | uint32_t DevAddr; 120 | }CommissioningParams_t; 121 | 122 | /*! 123 | * Application data structure 124 | */ 125 | typedef struct LmHandlerAppData_s 126 | { 127 | uint8_t Port; 128 | uint8_t BufferSize; 129 | uint8_t *Buffer; 130 | }LmHandlerAppData_t; 131 | 132 | typedef struct LmHandlerRequestParams_s 133 | { 134 | uint8_t IsMcpsRequest; 135 | LoRaMacStatus_t Status; 136 | union 137 | { 138 | Mcps_t Mcps; 139 | Mlme_t Mlme; 140 | }RequestType; 141 | }LmHandlerRequestParams_t; 142 | 143 | /* External variables --------------------------------------------------------*/ 144 | /* Exported macros -----------------------------------------------------------*/ 145 | /* Exported functions ------------------------------------------------------- */ 146 | 147 | #endif /* __LORAMAC_HANDLER_TYPES_H__ */ 148 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/LmHandler/NvmDataMgmt.c: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file NvmDataMgmt.c 3 | * 4 | * \brief NVM context management implementation 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2017 Semtech 16 | * 17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 | * embedded.connectivity.solutions=============== 22 | * 23 | * \endcode 24 | * 25 | * \author Miguel Luis ( Semtech ) 26 | * 27 | * \author Gregory Cristian ( Semtech ) 28 | * 29 | * \author Daniel Jaeckle ( STACKFORCE ) 30 | * 31 | * \author Johannes Bruder ( STACKFORCE ) 32 | */ 33 | /** 34 | ****************************************************************************** 35 | * 36 | * Portions COPYRIGHT 2020 STMicroelectronics 37 | * 38 | * @file NvmDataMgmt.c 39 | * @author MCD Application Team 40 | * @brief NVM context management implementation 41 | ****************************************************************************** 42 | */ 43 | #include "utilities.h" 44 | #include "LoRaMac.h" 45 | #include "NvmDataMgmt.h" 46 | /*! 47 | * Enables/Disables the context storage management storage. 48 | * Must be enabled for LoRaWAN 1.0.4 or later. 49 | */ 50 | #ifndef CONTEXT_MANAGEMENT_ENABLED 51 | #define CONTEXT_MANAGEMENT_ENABLED 0 52 | #endif 53 | 54 | #if( CONTEXT_MANAGEMENT_ENABLED == 1 ) 55 | static uint16_t NvmNotifyFlags = 0; 56 | 57 | #endif /* CONTEXT_MANAGEMENT_ENABLED == 1 */ 58 | 59 | void NvmDataMgmtEvent( uint16_t notifyFlags ) 60 | { 61 | #if( CONTEXT_MANAGEMENT_ENABLED == 1 ) 62 | NvmNotifyFlags |= notifyFlags; 63 | #endif /* CONTEXT_MANAGEMENT_ENABLED == 1 */ 64 | } 65 | 66 | int32_t NvmDataMgmtStoreBegin( void ) 67 | { 68 | #if( CONTEXT_MANAGEMENT_ENABLED == 1 ) 69 | // Input checks 70 | if( NvmNotifyFlags == LORAMAC_NVM_NOTIFY_FLAG_NONE ) 71 | { 72 | // There was no update. 73 | return NVM_DATA_NO_UPDATED_DATA; 74 | } 75 | if( LoRaMacStop( ) != LORAMAC_STATUS_OK ) 76 | { 77 | return NVM_DATA_NOT_AVAILABLE; 78 | } 79 | return NVM_DATA_OK; 80 | #else 81 | return NVM_DATA_DISABLED; 82 | #endif /* CONTEXT_MANAGEMENT_ENABLED */ 83 | } 84 | 85 | int32_t NvmDataMgmtStoreEnd( void ) 86 | { 87 | #if( CONTEXT_MANAGEMENT_ENABLED == 1 ) 88 | // Reset notification flags 89 | NvmNotifyFlags = LORAMAC_NVM_NOTIFY_FLAG_NONE; 90 | 91 | // Resume LoRaMac 92 | LoRaMacStart( ); 93 | return NVM_DATA_OK; 94 | #else 95 | return NVM_DATA_DISABLED; 96 | #endif /* CONTEXT_MANAGEMENT_ENABLED */ 97 | } 98 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/LmHandler/NvmDataMgmt.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file NvmDataMgmt.h 3 | * 4 | * \brief NVM context management implementation 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2017 Semtech 16 | * 17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 | * embedded.connectivity.solutions=============== 22 | * 23 | * \endcode 24 | * 25 | * \author Miguel Luis ( Semtech ) 26 | * 27 | * \author Gregory Cristian ( Semtech ) 28 | * 29 | * \author Daniel Jaeckle ( STACKFORCE ) 30 | * 31 | * \author Johannes Bruder ( STACKFORCE ) 32 | * 33 | * \defgroup NVMDATAMGMT NVM context management implementation 34 | * This module implements the NVM context handling 35 | * \{ 36 | */ 37 | #ifndef __NVMDATAMGMT_H__ 38 | #define __NVMDATAMGMT_H__ 39 | 40 | typedef enum NvmDataErrorStatus_e 41 | { 42 | NVM_DATA_ERROR = -1, 43 | NVM_DATA_NO_UPDATED_DATA = -2, 44 | NVM_DATA_NOT_AVAILABLE = -3, 45 | NVM_DATA_INCONSISTENT = -4, 46 | NVM_DATA_DISABLED = -5, 47 | NVM_DATA_OK = 0 48 | 49 | }NvmDataErrorStatus_t; 50 | 51 | /*! 52 | * \brief NVM Management event. 53 | * 54 | * \param [in] notifyFlags Bitmap which contains the information about modules that 55 | * changed. 56 | */ 57 | void NvmDataMgmtEvent( uint16_t notifyFlags ); 58 | 59 | /*! 60 | * \brief Check the NVM Flag status and LoRaMAC state 61 | * 62 | * \retval status NVM_DATA_OK, NVM_DATA_DISABLED, NVM_DATA_NOT_AVAILABLE, NVM_DATA_NO_UPDATED_DATA 63 | */ 64 | int32_t NvmDataMgmtStoreBegin( void ); 65 | 66 | /*! 67 | * \brief Clean the NVM Flag status and resume LoRaMAC process 68 | * 69 | * \retval status NVM_DATA_OK, NVM_DATA_DISABLED 70 | */ 71 | int32_t NvmDataMgmtStoreEnd( void ); 72 | 73 | /*! \} defgroup NVMDATAMGMT */ 74 | 75 | #endif // __NVMDATAMGMT_H__ 76 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/LmHandler/Packages/LmhpCompliance.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LmhpCompliance.h 3 | * 4 | * \brief Implements the LoRa-Alliance certification protocol handling 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2018 Semtech 16 | * 17 | * \endcode 18 | * 19 | * \author Miguel Luis ( Semtech ) 20 | */ 21 | #ifndef __LMHP_COMPLIANCE__ 22 | #define __LMHP_COMPLIANCE__ 23 | 24 | #include "LmhPackage.h" 25 | #include "LoRaMacVersion.h" 26 | 27 | /*! 28 | * Compliance package identifier. 29 | * 30 | * \remark This value must be unique amongst the packages 31 | */ 32 | #define PACKAGE_ID_COMPLIANCE 0 33 | 34 | #if (defined( LORAMAC_VERSION ) && ( LORAMAC_VERSION == 0x01000300 )) 35 | /*! 36 | * Compliance test protocol handler parameters 37 | */ 38 | typedef struct LmhpComplianceParams_s 39 | { 40 | /*! 41 | * Holds the ADR state 42 | */ 43 | bool AdrEnabled; 44 | /*! 45 | * LoRaWAN ETSI duty cycle control enable/disable 46 | * 47 | * \remark Please note that ETSI mandates duty cycled transmissions. Use only for test purposes 48 | */ 49 | bool DutyCycleEnabled; 50 | /*! 51 | * Stops unnecessary peripherals. 52 | * 53 | * \remark Use for the compliance tests protocol handling in order to 54 | * reduce the power consumption. 55 | */ 56 | void ( *StopPeripherals )( void ); 57 | /*! 58 | * Starts previously stopped peripherals. 59 | * 60 | * \remark Use for the compliance tests protocol handling in order to 61 | * reduce the power consumption. 62 | */ 63 | void ( *StartPeripherals )( void ); 64 | }LmhpComplianceParams_t; 65 | #elif (defined( LORAMAC_VERSION ) && ( LORAMAC_VERSION == 0x01000400 )) 66 | /*! 67 | * Compliance test protocol handler parameters 68 | */ 69 | typedef struct LmhpComplianceParams_s 70 | { 71 | /*! 72 | * Current firmware version 73 | */ 74 | Version_t FwVersion; 75 | /*! 76 | * 77 | */ 78 | void ( *OnTxPeriodicityChanged )( uint32_t periodicity ); 79 | /*! 80 | * 81 | */ 82 | void ( *OnTxFrameCtrlChanged )( LmHandlerMsgTypes_t isTxConfirmed ); 83 | /*! 84 | * 85 | */ 86 | void ( *OnPingSlotPeriodicityChanged )( uint8_t pingSlotPeriodicity ); 87 | }LmhpComplianceParams_t; 88 | #endif /* LORAMAC_VERSION */ 89 | 90 | LmhPackage_t *LmhpCompliancePackageFactory( void ); 91 | 92 | #endif // __LMHP_COMPLIANCE__ 93 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/LmHandler/lorawan_version.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file lorawan_version.h 4 | * @author MCD Application Team 5 | * @brief Identifies the version of LoRaWAN 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2020(-2021) STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | 21 | #ifndef __LORAWAN_VERSION_H__ 22 | #define __LORAWAN_VERSION_H__ 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /* Includes ------------------------------------------------------------------*/ 29 | /* Exported constants --------------------------------------------------------*/ 30 | 31 | #define LORAWAN_VERSION_MAIN (0x02U) /*!< [31:24] main version */ 32 | #define LORAWAN_VERSION_SUB1 (0x04U) /*!< [23:16] sub1 version */ 33 | #define LORAWAN_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */ 34 | #define LORAWAN_VERSION_RC (0x00U) /*!< [7:0] release candidate */ 35 | 36 | #define LORAWAN_MAIN_SHIFT 24 37 | #define LORAWAN_SUB1_SHIFT 16 38 | #define LORAWAN_SUB2_SHIFT 8 39 | #define LORAWAN_RC_SHIFT 0 40 | 41 | /* Exported types ------------------------------------------------------------*/ 42 | /* External variables --------------------------------------------------------*/ 43 | /* Exported macros -----------------------------------------------------------*/ 44 | #define LORAWAN_VERSION ((LORAWAN_VERSION_MAIN << LORAWAN_MAIN_SHIFT)\ 45 | |(LORAWAN_VERSION_SUB1 << LORAWAN_SUB1_SHIFT)\ 46 | |(LORAWAN_VERSION_SUB2 << LORAWAN_SUB2_SHIFT)\ 47 | |(LORAWAN_VERSION_RC << LORAWAN_RC_SHIFT)) 48 | /* Exported functions ------------------------------------------------------- */ 49 | 50 | #ifdef __cplusplus 51 | } 52 | #endif 53 | 54 | #endif /*__LORAWAN_VERSION_H__*/ 55 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/Mac/LoRaMacAdr.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LoRaMacAdr.h 3 | * 4 | * \brief LoRa MAC ADR implementation 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2017 Semtech 16 | * 17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 | * embedded.connectivity.solutions=============== 22 | * 23 | * \endcode 24 | * 25 | * \author Miguel Luis ( Semtech ) 26 | * 27 | * \author Gregory Cristian ( Semtech ) 28 | * 29 | * \author Daniel Jaeckle ( STACKFORCE ) 30 | * 31 | * \author Johannes Bruder ( STACKFORCE ) 32 | * 33 | * \defgroup LORAMACADR LoRa MAC ADR implementation 34 | * Implementation of the ADR algorithm for LoRa. 35 | * \{ 36 | */ 37 | #ifndef __LORAMACADR_H__ 38 | #define __LORAMACADR_H__ 39 | 40 | #ifdef __cplusplus 41 | extern "C" 42 | { 43 | #endif 44 | 45 | /*! \} defgroup LORAMACADR */ 46 | 47 | /* 48 | * Parameter structure for the function CalcNextAdr. 49 | */ 50 | typedef struct sCalcNextAdrParams 51 | { 52 | #if (defined( LORAMAC_VERSION ) && ( LORAMAC_VERSION == 0x01000300 )) 53 | /*! 54 | * LoRaWAN Minor Version 1.X 55 | */ 56 | Version_t Version; 57 | #endif /* LORAMAC_VERSION */ 58 | /*! 59 | * Set to true, if the function should update the channels mask. 60 | */ 61 | bool UpdateChanMask; 62 | /*! 63 | * Set to true, if ADR is enabled. 64 | */ 65 | bool AdrEnabled; 66 | /*! 67 | * ADR ack counter. 68 | */ 69 | uint32_t AdrAckCounter; 70 | /*! 71 | * ADR Ack limit 72 | */ 73 | uint16_t AdrAckLimit; 74 | /*! 75 | * ADR Ack delay 76 | */ 77 | uint16_t AdrAckDelay; 78 | /*! 79 | * Datarate used currently. 80 | */ 81 | int8_t Datarate; 82 | /*! 83 | * TX power used currently. 84 | */ 85 | int8_t TxPower; 86 | #if (defined( LORAMAC_VERSION ) && ( LORAMAC_VERSION == 0x01000400 )) 87 | /*! 88 | * NbTrans counter used currently. 89 | */ 90 | uint8_t NbTrans; 91 | #endif /* LORAMAC_VERSION */ 92 | /*! 93 | * UplinkDwellTime 94 | */ 95 | uint8_t UplinkDwellTime; 96 | /*! 97 | * Region 98 | */ 99 | LoRaMacRegion_t Region; 100 | }CalcNextAdrParams_t; 101 | 102 | #if (defined( LORAMAC_VERSION ) && ( LORAMAC_VERSION == 0x01000300 )) 103 | /*! 104 | * \brief Calculates the next datarate to set, when ADR is on or off. 105 | * 106 | * \param [IN] adrNext Pointer to the function parameters. 107 | * 108 | * \param [OUT] drOut The calculated datarate for the next TX. 109 | * 110 | * \param [OUT] txPowOut The TX power for the next TX. 111 | * 112 | * \param [OUT] adrAckCounter The calculated ADR acknowledgement counter. 113 | * 114 | * \retval Returns true, if an ADR request should be performed. 115 | */ 116 | bool LoRaMacAdrCalcNext( CalcNextAdrParams_t* adrNext, int8_t* drOut, int8_t* txPowOut, uint32_t* adrAckCounter ); 117 | #elif (defined( LORAMAC_VERSION ) && ( LORAMAC_VERSION == 0x01000400 )) 118 | /*! 119 | * \brief Calculates the next datarate to set, when ADR is on or off. 120 | * 121 | * \details Here is a summary of the actions: 122 | * 123 | * | ADR_ACK_CNT | Action | 124 | * | ----------- | --------------------------------------------------------- | 125 | * | 0... 63 | Do nothing | 126 | * | 64...95 | Set ADR ack bit | 127 | * | 96...127 | Set TX power to default (if already default, do nothing) | 128 | * | 128...159 | Set data rate to default (if already default, do nothing) | 129 | * | >=160 | Set NbTrans to 1, re-enable default channels | 130 | * 131 | * \param [in] adrNext Pointer to the function parameters. 132 | * 133 | * \param [out] drOut The calculated datarate for the next TX. 134 | * 135 | * \param [out] txPowOut The TX power for the next TX. 136 | * 137 | * \param [out] nbTransOut The NbTrans counter. 138 | * 139 | * \param [out] adrAckCounter The calculated ADR acknowledgement counter. 140 | * 141 | * \retval Returns true, if an ADR request should be performed. 142 | */ 143 | bool LoRaMacAdrCalcNext( CalcNextAdrParams_t* adrNext, int8_t* drOut, int8_t* txPowOut, 144 | uint8_t* nbTransOut, uint32_t* adrAckCounter ); 145 | #endif /* LORAMAC_VERSION */ 146 | 147 | #ifdef __cplusplus 148 | } 149 | #endif 150 | 151 | #endif // __LORAMACADR_H__ 152 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/Mac/LoRaMacClassBConfig.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LoRaMacClassBConfig.h 3 | * 4 | * \brief LoRa MAC Class B configuration 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013 Semtech 16 | * 17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 | * embedded.connectivity.solutions=============== 22 | * 23 | * \endcode 24 | * 25 | * \author Miguel Luis ( Semtech ) 26 | * 27 | * \author Gregory Cristian ( Semtech ) 28 | * 29 | * \author Daniel Jaeckle ( STACKFORCE ) 30 | * 31 | * \defgroup LORAMACCLASSBCONFIG LoRa MAC Class B configuration 32 | * This header file contains parameters to configure the class b operation. 33 | * By default, all parameters are set according to the specification. 34 | * \{ 35 | */ 36 | #ifndef __LORAMACCLASSBCONFIG_H__ 37 | #define __LORAMACCLASSBCONFIG_H__ 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /*! 45 | * Defines the beacon interval in ms 46 | */ 47 | #define CLASSB_BEACON_INTERVAL 128000 48 | 49 | /*! 50 | * Beacon reserved time in ms 51 | */ 52 | #define CLASSB_BEACON_RESERVED 2120 53 | 54 | /*! 55 | * Beacon guard time in ms 56 | */ 57 | #define CLASSB_BEACON_GUARD 3000 58 | 59 | /*! 60 | * Beacon window time in ms 61 | */ 62 | #define CLASSB_BEACON_WINDOW 122880 63 | 64 | /*! 65 | * Beacon window time in number of slots 66 | */ 67 | #define CLASSB_BEACON_WINDOW_SLOTS 4096 68 | 69 | /*! 70 | * Ping slot length time in ms 71 | */ 72 | #define CLASSB_PING_SLOT_WINDOW 30 73 | 74 | /*! 75 | * Maximum allowed beacon less time in ms 76 | */ 77 | #define CLASSB_MAX_BEACON_LESS_PERIOD 7200000 78 | 79 | /*! 80 | * Delay time for the BeaconTimingAns in ms 81 | */ 82 | #define CLASSB_BEACON_DELAY_BEACON_TIMING_ANS 30 83 | 84 | /*! 85 | * Default symbol timeout for beacons and ping slot windows 86 | */ 87 | #define CLASSB_BEACON_SYMBOL_TO_DEFAULT 8 88 | 89 | /*! 90 | * Maximum symbol timeout for beacons 91 | */ 92 | #define CLASSB_BEACON_SYMBOL_TO_EXPANSION_MAX 255 93 | 94 | /*! 95 | * Maximum symbol timeout for ping slots 96 | */ 97 | #define CLASSB_PING_SLOT_SYMBOL_TO_EXPANSION_MAX 30 98 | 99 | /*! 100 | * Symbol expansion value for beacon windows in case of beacon 101 | * loss in symbols 102 | */ 103 | #define CLASSB_BEACON_SYMBOL_TO_EXPANSION_FACTOR 2 104 | 105 | /*! 106 | * Defines the default window movement time 107 | */ 108 | #define CLASSB_WINDOW_MOVE_DEFAULT 2 109 | 110 | /*! 111 | * Defines the maximum time for the beacon movement 112 | */ 113 | #define CLASSB_WINDOW_MOVE_EXPANSION_MAX 256 114 | 115 | /*! 116 | * Defines the expansion factor for the beacon movement 117 | */ 118 | #define CLASSB_WINDOW_MOVE_EXPANSION_FACTOR 2 119 | 120 | /*! \} defgroup LORAMACCLASSBCONFIG */ 121 | 122 | #ifdef __cplusplus 123 | } 124 | #endif 125 | 126 | #endif // __LORAMACCLASSBCONFIG_H__ 127 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/Mac/LoRaMacClassBNvm.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LoRaMacClassBNvm.h 3 | * 4 | * \brief LoRa MAC Class B non-volatile data. 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013 Semtech 16 | * 17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 | * embedded.connectivity.solutions=============== 22 | * 23 | * \endcode 24 | * 25 | * \author Miguel Luis ( Semtech ) 26 | * 27 | * \author Daniel Jaeckle ( STACKFORCE ) 28 | * 29 | * \addtogroup LORAMACCLASSB 30 | * 31 | * \{ 32 | */ 33 | #ifndef __LORAMACCLASSBNVM_H__ 34 | #define __LORAMACCLASSBNVM_H__ 35 | 36 | #ifdef __cplusplus 37 | extern "C" 38 | { 39 | #endif 40 | 41 | #include "LoRaMacVersion.h" 42 | 43 | /*! 44 | * LoRaMac Class B Context structure for NVM parameters 45 | * related to ping slots 46 | */ 47 | typedef struct sLoRaMacClassBPingSlotNvmData 48 | { 49 | struct sPingSlotCtrlNvm 50 | { 51 | /*! 52 | * Set when the server assigned a ping slot to the node 53 | */ 54 | uint8_t Assigned : 1; 55 | /*! 56 | * Set when a custom frequency is used 57 | */ 58 | uint8_t CustomFreq : 1; 59 | }Ctrl; 60 | /*! 61 | * Number of ping slots 62 | */ 63 | uint8_t PingNb; 64 | /*! 65 | * Period of the ping slots 66 | */ 67 | uint16_t PingPeriod; 68 | /*! 69 | * Reception frequency of the ping slot windows 70 | */ 71 | uint32_t Frequency; 72 | /*! 73 | * Datarate of the ping slot 74 | */ 75 | int8_t Datarate; 76 | #if (defined( LORAMAC_VERSION ) && ( LORAMAC_VERSION == 0x01000400 )) 77 | /*! 78 | * Set to 1, if the FPending bit is set 79 | */ 80 | uint8_t FPendingSet; 81 | #endif /* LORAMAC_VERSION */ 82 | } LoRaMacClassBPingSlotNvmData_t; 83 | 84 | /*! 85 | * LoRaMac Class B Context structure for NVM parameters 86 | * related to beaconing 87 | */ 88 | typedef struct sLoRaMacClassBBeaconNvmData 89 | { 90 | struct sBeaconCtrlNvm 91 | { 92 | /*! 93 | * Set if the node has a custom frequency for beaconing and ping slots 94 | */ 95 | uint8_t CustomFreq : 1; 96 | }Ctrl; 97 | /*! 98 | * Beacon reception frequency 99 | */ 100 | uint32_t Frequency; 101 | } LoRaMacClassBBeaconNvmData_t; 102 | 103 | /*! 104 | * LoRaMac Class B Context structure 105 | */ 106 | typedef struct sLoRaMacClassBNvmData 107 | { 108 | /*! 109 | * Class B ping slot context 110 | */ 111 | LoRaMacClassBPingSlotNvmData_t PingSlotCtx; 112 | /*! 113 | * Class B beacon context 114 | */ 115 | LoRaMacClassBBeaconNvmData_t BeaconCtx; 116 | /*! 117 | * CRC32 value of the ClassB data structure. 118 | */ 119 | uint32_t Crc32; 120 | } LoRaMacClassBNvmData_t; 121 | 122 | /*! \} defgroup LORAMACCLASSB */ 123 | 124 | #ifdef __cplusplus 125 | } 126 | #endif 127 | 128 | #endif // __LORAMACCLASSBNVM_H__ 129 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/Mac/LoRaMacCryptoNvm.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LoRaMacCryptoNvm.h 3 | * 4 | * \brief LoRa MAC layer cryptographic NVM data. 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2017 Semtech 16 | * 17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 | * embedded.connectivity.solutions=============== 22 | * 23 | * \endcode 24 | * 25 | * \author Miguel Luis ( Semtech ) 26 | * 27 | * \author Daniel Jaeckle ( STACKFORCE ) 28 | * 29 | * addtogroup LORAMAC 30 | * \{ 31 | * 32 | */ 33 | #ifndef __LORAMAC_CRYPTO_NVM_H__ 34 | #define __LORAMAC_CRYPTO_NVM_H__ 35 | 36 | #ifdef __cplusplus 37 | extern "C" 38 | { 39 | #endif 40 | 41 | #include "utilities.h" 42 | #include "LoRaMacTypes.h" 43 | 44 | /*! 45 | * LoRaWAN Frame counter list. 46 | */ 47 | typedef struct sFCntList 48 | { 49 | /*! 50 | * Uplink frame counter which is incremented with each uplink. 51 | */ 52 | uint32_t FCntUp; 53 | /*! 54 | * Network downlink frame counter which is incremented with each downlink on FPort 0 55 | * or when the FPort field is missing. 56 | */ 57 | uint32_t NFCntDown; 58 | /*! 59 | * Application downlink frame counter which is incremented with each downlink 60 | * on a port different than 0. 61 | */ 62 | uint32_t AFCntDown; 63 | /*! 64 | * In case if the device is connected to a LoRaWAN 1.0 Server, 65 | * this counter is used for every kind of downlink frame. 66 | */ 67 | uint32_t FCntDown; 68 | /*! 69 | * Multicast downlink counters 70 | */ 71 | uint32_t McFCntDown[LORAMAC_MAX_MC_CTX]; 72 | #if( USE_LRWAN_1_1_X_CRYPTO == 1 ) 73 | /*! 74 | * RJcount1 is a counter incremented with every Rejoin request Type 1 frame transmitted. 75 | */ 76 | uint16_t RJcount1; 77 | #endif 78 | }FCntList_t; 79 | 80 | /*! 81 | * LoRaMac Crypto Non Volatile Context structure 82 | */ 83 | typedef struct sLoRaMacCryptoNvmData 84 | { 85 | /*! 86 | * Stores the information if the device is connected to a LoRaWAN network 87 | * server with prior to 1.1.0 implementation. 88 | */ 89 | Version_t LrWanVersion; 90 | /*! 91 | * Device nonce is a counter starting at 0 when the device is initially 92 | * powered up and incremented with every JoinRequest. 93 | */ 94 | uint16_t DevNonce; 95 | /*! 96 | * JoinNonce is a device specific counter value (that never repeats itself) 97 | * provided by the join server and incremented with every JoinAccept message. 98 | */ 99 | uint32_t JoinNonce; 100 | /*! 101 | * Frame counter list 102 | */ 103 | FCntList_t FCntList; 104 | /*! 105 | * LastDownFCnt stores the information which frame counter was used to 106 | * decrypt the last frame. This information is needed to compute ConfFCnt in 107 | * B1 block for the MIC. 108 | */ 109 | uint32_t LastDownFCnt; 110 | /*! 111 | * CRC32 value of the Crypto data structure. 112 | */ 113 | uint32_t Crc32; 114 | }LoRaMacCryptoNvmData_t; 115 | 116 | /*! \} addtogroup LORAMAC */ 117 | 118 | #ifdef __cplusplus 119 | } 120 | #endif 121 | 122 | #endif // __LORAMAC_CRYPTO_NVM_H__ 123 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/Mac/LoRaMacParser.c: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LoRaMacParser.c 3 | * 4 | * \brief LoRa MAC layer message parser functionality implementation 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013 Semtech 16 | * 17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 | * embedded.connectivity.solutions=============== 22 | * 23 | * \endcode 24 | * 25 | * \author Miguel Luis ( Semtech ) 26 | * 27 | * \author Gregory Cristian ( Semtech ) 28 | * 29 | * \author Daniel Jaeckle ( STACKFORCE ) 30 | * 31 | * \author Johannes Bruder ( STACKFORCE ) 32 | */ 33 | #include "LoRaMacParser.h" 34 | #include "utilities.h" 35 | 36 | LoRaMacParserStatus_t LoRaMacParserJoinAccept( LoRaMacMessageJoinAccept_t* macMsg ) 37 | { 38 | if( ( macMsg == 0 ) || ( macMsg->Buffer == 0 ) ) 39 | { 40 | return LORAMAC_PARSER_ERROR_NPE; 41 | } 42 | 43 | uint16_t bufItr = 0; 44 | 45 | macMsg->MHDR.Value = macMsg->Buffer[bufItr++]; 46 | 47 | memcpy1( macMsg->JoinNonce, &macMsg->Buffer[bufItr], 3 ); 48 | bufItr = bufItr + 3; 49 | 50 | memcpy1( macMsg->NetID, &macMsg->Buffer[bufItr], 3 ); 51 | bufItr = bufItr + 3; 52 | 53 | macMsg->DevAddr = ( uint32_t ) macMsg->Buffer[bufItr++]; 54 | macMsg->DevAddr |= ( ( uint32_t ) macMsg->Buffer[bufItr++] << 8 ); 55 | macMsg->DevAddr |= ( ( uint32_t ) macMsg->Buffer[bufItr++] << 16 ); 56 | macMsg->DevAddr |= ( ( uint32_t ) macMsg->Buffer[bufItr++] << 24 ); 57 | 58 | macMsg->DLSettings.Value = macMsg->Buffer[bufItr++]; 59 | 60 | macMsg->RxDelay = macMsg->Buffer[bufItr++]; 61 | 62 | if( ( macMsg->BufSize - LORAMAC_MIC_FIELD_SIZE - bufItr ) == LORAMAC_CF_LIST_FIELD_SIZE ) 63 | { 64 | memcpy1( macMsg->CFList, &macMsg->Buffer[bufItr], LORAMAC_CF_LIST_FIELD_SIZE ); 65 | bufItr = bufItr + LORAMAC_CF_LIST_FIELD_SIZE; 66 | } 67 | else if( ( macMsg->BufSize - LORAMAC_MIC_FIELD_SIZE - bufItr ) > 0 ) 68 | { 69 | return LORAMAC_PARSER_FAIL; 70 | } 71 | 72 | macMsg->MIC = ( uint32_t ) macMsg->Buffer[bufItr++]; 73 | macMsg->MIC |= ( ( uint32_t ) macMsg->Buffer[bufItr++] << 8 ); 74 | macMsg->MIC |= ( ( uint32_t ) macMsg->Buffer[bufItr++] << 16 ); 75 | macMsg->MIC |= ( ( uint32_t ) macMsg->Buffer[bufItr++] << 24 ); 76 | 77 | return LORAMAC_PARSER_SUCCESS; 78 | } 79 | 80 | LoRaMacParserStatus_t LoRaMacParserData( LoRaMacMessageData_t* macMsg ) 81 | { 82 | if( ( macMsg == 0 ) || ( macMsg->Buffer == 0 ) ) 83 | { 84 | return LORAMAC_PARSER_ERROR_NPE; 85 | } 86 | 87 | uint16_t bufItr = 0; 88 | 89 | macMsg->MHDR.Value = macMsg->Buffer[bufItr++]; 90 | 91 | macMsg->FHDR.DevAddr = macMsg->Buffer[bufItr++]; 92 | macMsg->FHDR.DevAddr |= ( ( uint32_t ) macMsg->Buffer[bufItr++] << 8 ); 93 | macMsg->FHDR.DevAddr |= ( ( uint32_t ) macMsg->Buffer[bufItr++] << 16 ); 94 | macMsg->FHDR.DevAddr |= ( ( uint32_t ) macMsg->Buffer[bufItr++] << 24 ); 95 | 96 | macMsg->FHDR.FCtrl.Value = macMsg->Buffer[bufItr++]; 97 | 98 | macMsg->FHDR.FCnt = macMsg->Buffer[bufItr++]; 99 | macMsg->FHDR.FCnt |= macMsg->Buffer[bufItr++] << 8; 100 | 101 | if( macMsg->FHDR.FCtrl.Bits.FOptsLen <= 15 ) 102 | { 103 | memcpy1( macMsg->FHDR.FOpts, &macMsg->Buffer[bufItr], macMsg->FHDR.FCtrl.Bits.FOptsLen ); 104 | bufItr = bufItr + macMsg->FHDR.FCtrl.Bits.FOptsLen; 105 | } 106 | else 107 | { 108 | return LORAMAC_PARSER_FAIL; 109 | } 110 | 111 | // Initialize anyway with zero. 112 | macMsg->FPort = 0; 113 | macMsg->FRMPayloadSize = 0; 114 | 115 | if( ( macMsg->BufSize - bufItr - LORAMAC_MIC_FIELD_SIZE ) > 0 ) 116 | { 117 | macMsg->FPort = macMsg->Buffer[bufItr++]; 118 | 119 | macMsg->FRMPayloadSize = ( macMsg->BufSize - bufItr - LORAMAC_MIC_FIELD_SIZE ); 120 | memcpy1( macMsg->FRMPayload, &macMsg->Buffer[bufItr], macMsg->FRMPayloadSize ); 121 | bufItr = bufItr + macMsg->FRMPayloadSize; 122 | } 123 | 124 | macMsg->MIC = ( uint32_t ) macMsg->Buffer[( macMsg->BufSize - LORAMAC_MIC_FIELD_SIZE )]; 125 | macMsg->MIC |= ( ( uint32_t ) macMsg->Buffer[( macMsg->BufSize - LORAMAC_MIC_FIELD_SIZE ) + 1] << 8 ); 126 | macMsg->MIC |= ( ( uint32_t ) macMsg->Buffer[( macMsg->BufSize - LORAMAC_MIC_FIELD_SIZE ) + 2] << 16 ); 127 | macMsg->MIC |= ( ( uint32_t ) macMsg->Buffer[( macMsg->BufSize - LORAMAC_MIC_FIELD_SIZE ) + 3] << 24 ); 128 | 129 | return LORAMAC_PARSER_SUCCESS; 130 | } 131 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/Mac/LoRaMacParser.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LoRaMacParser.h 3 | * 4 | * \brief LoRa MAC layer message parser functionality implementation 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013 Semtech 16 | * 17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 | * embedded.connectivity.solutions=============== 22 | * 23 | * \endcode 24 | * 25 | * \author Miguel Luis ( Semtech ) 26 | * 27 | * \author Gregory Cristian ( Semtech ) 28 | * 29 | * \author Daniel Jaeckle ( STACKFORCE ) 30 | * 31 | * \author Johannes Bruder ( STACKFORCE ) 32 | * 33 | * addtogroup LORAMAC 34 | * \{ 35 | * 36 | */ 37 | #ifndef __LORAMAC_PARSER_H__ 38 | #define __LORAMAC_PARSER_H__ 39 | 40 | #ifdef __cplusplus 41 | extern "C" 42 | { 43 | #endif 44 | 45 | #include "LoRaMacMessageTypes.h" 46 | 47 | /*! 48 | * LoRaMac Parser Status 49 | */ 50 | typedef enum eLoRaMacParserStatus 51 | { 52 | /*! 53 | * No error occurred 54 | */ 55 | LORAMAC_PARSER_SUCCESS = 0, 56 | /*! 57 | * Failure during parsing occurred 58 | */ 59 | LORAMAC_PARSER_FAIL, 60 | /*! 61 | * Null pointer exception 62 | */ 63 | LORAMAC_PARSER_ERROR_NPE, 64 | /*! 65 | * Undefined Error occurred 66 | */ 67 | LORAMAC_PARSER_ERROR, 68 | }LoRaMacParserStatus_t; 69 | 70 | /*! 71 | * Parse a serialized join-accept message and fills the structured object. 72 | * 73 | * \param [in,out] macMsg - Join-accept message object 74 | * \retval - Status of the operation 75 | */ 76 | LoRaMacParserStatus_t LoRaMacParserJoinAccept( LoRaMacMessageJoinAccept_t *macMsg ); 77 | 78 | /*! 79 | * Parse a serialized data message and fills the structured object. 80 | * 81 | * \param [in,out] macMsg - Data message object 82 | * \retval - Status of the operation 83 | */ 84 | LoRaMacParserStatus_t LoRaMacParserData( LoRaMacMessageData_t *macMsg ); 85 | 86 | /*! \} addtogroup LORAMAC */ 87 | 88 | #ifdef __cplusplus 89 | } 90 | #endif 91 | 92 | #endif // __LORAMAC_PARSER_H__ 93 | 94 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/Mac/LoRaMacSerializer.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LoRaMacSerializer.h 3 | * 4 | * \brief LoRa MAC layer message serializer functionality implementation 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013 Semtech 16 | * 17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 | * embedded.connectivity.solutions=============== 22 | * 23 | * \endcode 24 | * 25 | * \author Miguel Luis ( Semtech ) 26 | * 27 | * \author Gregory Cristian ( Semtech ) 28 | * 29 | * \author Daniel Jaeckle ( STACKFORCE ) 30 | * 31 | * \author Johannes Bruder ( STACKFORCE ) 32 | * 33 | * addtogroup LORAMAC 34 | * \{ 35 | * 36 | */ 37 | #ifndef __LORAMAC_SERIALIZER_H__ 38 | #define __LORAMAC_SERIALIZER_H__ 39 | 40 | #ifdef __cplusplus 41 | extern "C" 42 | { 43 | #endif 44 | #include "LoRaMacMessageTypes.h" 45 | 46 | /*! 47 | * LoRaMac Serializer Status 48 | */ 49 | typedef enum eLoRaMacSerializerStatus 50 | { 51 | /*! 52 | * No error occurred 53 | */ 54 | LORAMAC_SERIALIZER_SUCCESS = 0, 55 | /*! 56 | * Null pointer exception 57 | */ 58 | LORAMAC_SERIALIZER_ERROR_NPE, 59 | /*! 60 | * Incompatible buffer size 61 | */ 62 | LORAMAC_SERIALIZER_ERROR_BUF_SIZE, 63 | /*! 64 | * Undefined Error occurred 65 | */ 66 | LORAMAC_SERIALIZER_ERROR, 67 | }LoRaMacSerializerStatus_t; 68 | 69 | /*! 70 | * Creates serialized MAC message of structured object. 71 | * 72 | * \param [in,out] macMsg - Join-request message object 73 | * \retval - Status of the operation 74 | */ 75 | LoRaMacSerializerStatus_t LoRaMacSerializerJoinRequest( LoRaMacMessageJoinRequest_t* macMsg ); 76 | 77 | /*! 78 | * Creates serialized MAC message of structured object. 79 | * 80 | * \param [in,out] macMsg - Join-request message object 81 | * \retval - Status of the operation 82 | */ 83 | LoRaMacSerializerStatus_t LoRaMacSerializerReJoinType1( LoRaMacMessageReJoinType1_t* macMsg ); 84 | 85 | /*! 86 | * Creates serialized MAC message of structured object. 87 | * 88 | * \param [in,out] macMsg - Join-request message object 89 | * \retval - Status of the operation 90 | */ 91 | LoRaMacSerializerStatus_t LoRaMacSerializerReJoinType0or2( LoRaMacMessageReJoinType0or2_t* macMsg ); 92 | 93 | /*! 94 | * Creates serialized MAC message of structured object. 95 | * 96 | * \param [in,out] macMsg - Data message object 97 | * \retval - Status of the operation 98 | */ 99 | LoRaMacSerializerStatus_t LoRaMacSerializerData( LoRaMacMessageData_t* macMsg ); 100 | 101 | /*! \} addtogroup LORAMAC */ 102 | 103 | #ifdef __cplusplus 104 | } 105 | #endif 106 | 107 | #endif // __LORAMAC_SERIALIZER_H__ 108 | 109 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/Mac/LoRaMacTest.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LoRaMacTest.h 3 | * 4 | * \brief LoRa MAC layer test function implementation 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2017 Semtech 16 | * 17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 | * embedded.connectivity.solutions=============== 22 | * 23 | * \endcode 24 | * 25 | * \author Miguel Luis ( Semtech ) 26 | * 27 | * \author Gregory Cristian ( Semtech ) 28 | * 29 | * \author Daniel Jaeckle ( STACKFORCE ) 30 | * 31 | * \defgroup LORAMACTEST LoRa MAC layer test function implementation 32 | * This module specifies the API implementation of test function of the LoRaMAC layer. 33 | * The functions in this file are only for testing purposes only. 34 | * \{ 35 | */ 36 | #ifndef __LORAMACTEST_H__ 37 | #define __LORAMACTEST_H__ 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | /*! 45 | * \brief Enabled or disables the duty cycle 46 | * 47 | * \details This is a test function. It shall be used for testing purposes only. 48 | * Changing this attribute may lead to a non-conformance LoRaMac operation. 49 | * 50 | * \param [in] enable - Enabled or disables the duty cycle 51 | */ 52 | void LoRaMacTestSetDutyCycleOn( bool enable ); 53 | 54 | /*! \} defgroup LORAMACTEST */ 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif // __LORAMACTEST_H__ 61 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/Mac/LoRaMacVersion.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file LoRaMacVersion.h 4 | * @author MCD Application Team 5 | * @brief Identifies the version of LoRaMAC 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2020(-2021) STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | #ifndef __LORAMAC_VERSION_H__ 19 | #define __LORAMAC_VERSION_H__ 20 | 21 | #ifdef __cplusplus 22 | extern "C" 23 | { 24 | #endif 25 | 26 | #include "lorawan_conf.h" 27 | 28 | #ifndef LORAMAC_VERSION 29 | /*! 30 | * @brief LoRaWAN version definition. 31 | * @note TS001-1.0.4 : https://lora-alliance.org/resource_hub/lorawan-104-specification-package/ 32 | */ 33 | #define LORAMAC_VERSION LORAMAC_SPECIFICATION_VERSION 34 | #endif 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif // __LORAMAC_VERSION_H__ 41 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionBaseUS.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file RegionBaseUS.h 3 | * 4 | * \brief Definitions common with US region. 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2017 Semtech 16 | * 17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 | * embedded.connectivity.solutions=============== 22 | * 23 | * \endcode 24 | * 25 | * \author Miguel Luis ( Semtech ) 26 | * 27 | * \author Gregory Cristian ( Semtech ) 28 | * 29 | * \author Daniel Jaeckle ( STACKFORCE ) 30 | * 31 | * \author Phanindra Kumar Yellapu ( STACKFORCE ) 32 | * 33 | * \defgroup REGIONBASEUS US region common implementations. 34 | * \{ 35 | */ 36 | #ifndef __REGIONBASEUS_H__ 37 | #define __REGIONBASEUS_H__ 38 | 39 | #ifdef __cplusplus 40 | extern "C" 41 | { 42 | #endif 43 | 44 | #include "LoRaMac.h" 45 | 46 | /*! 47 | * \brief Computes the next 125kHz channel used for join requests. 48 | * And it returns all the parameters updated. 49 | * 50 | * \param [in] channelsMaskRemaining pointer to remaining channels. 51 | * 52 | * \param [in] groupsCurrentIndex Index of current channel. 53 | * 54 | * \param [out] newChannelIndex Index of next available channel. 55 | * 56 | * \retval Status 57 | */ 58 | LoRaMacStatus_t RegionBaseUSComputeNext125kHzJoinChannel( uint16_t* channelsMaskRemaining, 59 | uint8_t* groupsCurrentIndex, uint8_t* newChannelIndex ); 60 | 61 | /*! 62 | * \brief Verifies if the frequency is in the correct range with a 63 | * specific stepwidth. 64 | * 65 | * \param [in] freq Frequency to verify. 66 | * 67 | * \param [in] minFreq Minimum frequency. 68 | * 69 | * \param [in] maxFreq Maximum frequency. 70 | * 71 | * \param [in] stepwidth Frequency stepwidth. 72 | * 73 | * \retval True, if the frequency is valid, false if not. 74 | */ 75 | bool RegionBaseUSVerifyFrequencyGroup( uint32_t freq, uint32_t minFreq, uint32_t maxFreq, uint32_t stepwidth ); 76 | 77 | /*! 78 | * \brief Calculates the downlink frequency for a given channel. This 79 | * function is used in class B only. 80 | * 81 | * \param [in] channel The channel according to the channel plan. 82 | * 83 | * \param [in] frequency The base frequency. 84 | * 85 | * \param [in] stepwidth The frequency stepwidth. 86 | * 87 | * \retval The downlink frequency. 88 | */ 89 | uint32_t RegionBaseUSCalcDownlinkFrequency( uint8_t channel, uint32_t frequency, 90 | uint32_t stepwidth ); 91 | 92 | /*! \} defgroup REGIONBASEUS */ 93 | 94 | #ifdef __cplusplus 95 | } 96 | #endif 97 | 98 | #endif // __REGIONBASEUS_H__ 99 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionCN470B26.c: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file RegionCN470B26.c 3 | * 4 | * \brief Specific Region implementation of CN470 Channel plan type B, 26MHz. 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2017 Semtech 16 | * 17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 | * embedded.connectivity.solutions=============== 22 | * 23 | * \endcode 24 | * 25 | * \author Miguel Luis ( Semtech ) 26 | * 27 | * \author Daniel Jaeckle ( STACKFORCE ) 28 | * 29 | * \addtogroup REGIONCN470 30 | * 31 | * \{ 32 | */ 33 | #include "RegionCN470.h" 34 | #include "RegionBaseUS.h" 35 | #include "RegionCN470A26.h" 36 | #include "RegionCN470B26.h" 37 | 38 | uint32_t RegionCN470B26GetDownlinkFrequency( uint8_t channel, uint8_t joinChannelIndex, bool isPingSlot ) 39 | { 40 | return CN470_B26_BEACON_FREQ; 41 | } 42 | 43 | uint8_t RegionCN470B26GetBeaconChannelOffset( uint8_t joinChannelIndex ) 44 | { 45 | return 0; 46 | } 47 | 48 | uint8_t RegionCN470B26LinkAdrChMaskUpdate( uint16_t* channelsMask, uint8_t chMaskCntl, 49 | uint16_t chanMask, ChannelParams_t* channels ) 50 | { 51 | return RegionCN470A26LinkAdrChMaskUpdate( channelsMask, chMaskCntl, 52 | chanMask, channels ); 53 | } 54 | 55 | bool RegionCN470B26VerifyRfFreq( uint32_t freq ) 56 | { 57 | // Downstream group 1 58 | if( RegionBaseUSVerifyFrequencyGroup( freq, CN470_B26_FIRST_RX_CHANNEL, 59 | CN470_B26_LAST_RX_CHANNEL, 60 | CN470_B26_STEPWIDTH_RX_CHANNEL ) == false ) 61 | { 62 | return false; 63 | } 64 | return true; 65 | } 66 | 67 | void RegionCN470B26InitializeChannels( ChannelParams_t* channels ) 68 | { 69 | // Upstream group 1 70 | for( uint8_t i = 0; i < 48; i++ ) 71 | { 72 | channels[i].Frequency = CN470_B26_FIRST_TX_CHANNEL + i * CN470_B26_STEPWIDTH_RX_CHANNEL; 73 | channels[i].DrRange.Value = ( CN470_TX_MAX_DATARATE << 4 ) | CN470_TX_MIN_DATARATE; 74 | channels[i].Band = 0; 75 | } 76 | } 77 | 78 | void RegionCN470B26InitializeChannelsMask( uint16_t* channelsDefaultMask ) 79 | { 80 | RegionCN470A26InitializeChannelsMask( channelsDefaultMask ); 81 | } 82 | 83 | uint32_t RegionCN470B26GetRx1Frequency( uint8_t channel ) 84 | { 85 | return ( CN470_B26_FIRST_RX_CHANNEL + ( ( channel % 24 ) * CN470_B26_STEPWIDTH_RX_CHANNEL ) ); 86 | } 87 | 88 | uint32_t RegionCN470B26GetRx2Frequency( uint8_t joinChannelIndex, bool isOtaaDevice ) 89 | { 90 | return CN470_B26_RX_WND_2_FREQ; 91 | } 92 | 93 | /*! \} defgroup LORAMACCLASSB */ 94 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionNvm.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file RegionNvm.h 3 | * 4 | * \brief Region independent non-volatile data. 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2017 Semtech 16 | * 17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 | * embedded.connectivity.solutions=============== 22 | * 23 | * \endcode 24 | * 25 | * \author Miguel Luis ( Semtech ) 26 | * 27 | * \author Daniel Jaeckle ( STACKFORCE ) 28 | * 29 | * \addtogroup REGIONCOMMON 30 | * 31 | * \{ 32 | */ 33 | #ifndef __REGIONNVM_H__ 34 | #define __REGIONNVM_H__ 35 | 36 | #ifdef __cplusplus 37 | extern "C" 38 | { 39 | #endif 40 | 41 | #include "lorawan_conf.h" 42 | #include "LoRaMacTypes.h" 43 | #include "RegionVersion.h" 44 | 45 | #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) 46 | /*! 47 | * Channel plan for region CN470 48 | */ 49 | typedef enum eRegionCN470ChannelPlan 50 | { 51 | CHANNEL_PLAN_UNKNOWN, 52 | CHANNEL_PLAN_20MHZ_TYPE_A, 53 | CHANNEL_PLAN_20MHZ_TYPE_B, 54 | CHANNEL_PLAN_26MHZ_TYPE_A, 55 | CHANNEL_PLAN_26MHZ_TYPE_B 56 | }RegionCN470ChannelPlan_t; 57 | 58 | // Selection of REGION_NVM_MAX_NB_CHANNELS ( MAX = REGION_US915 | REGION_AU915 ) 59 | #define REGION_NVM_MAX_NB_CHANNELS 72 60 | 61 | #else 62 | // Selection of REGION_NVM_MAX_NB_CHANNELS ( MAX = REGION_CN470 ) 63 | #define REGION_NVM_MAX_NB_CHANNELS 96 64 | 65 | #endif /* REGION_VERSION */ 66 | 67 | // Selection of REGION_NVM_MAX_NB_BANDS 68 | #define REGION_NVM_MAX_NB_BANDS 6 69 | 70 | // Selection of REGION_NVM_CHANNELS_MASK_SIZE 71 | #define REGION_NVM_CHANNELS_MASK_SIZE 6 72 | 73 | /*! 74 | * Region specific data which must be stored in the NVM. 75 | */ 76 | typedef struct sRegionNvmDataGroup1 77 | { 78 | #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x01010003 )) 79 | /*! 80 | * LoRaMac bands 81 | */ 82 | Band_t Bands[ REGION_NVM_MAX_NB_BANDS ]; 83 | #endif /* REGION_VERSION */ 84 | #if defined( REGION_US915 ) || defined( REGION_AU915 ) || defined( REGION_CN470 ) 85 | /*! 86 | * LoRaMac channels remaining 87 | */ 88 | uint16_t ChannelsMaskRemaining[ REGION_NVM_CHANNELS_MASK_SIZE ]; 89 | #endif 90 | #if defined( REGION_US915 ) || defined( REGION_AU915 ) 91 | /*! 92 | * Index of current in use 8 bit group (0: bit 0 - 7, 1: bit 8 - 15, ..., 93 | * 7: bit 56 - 63) 94 | */ 95 | uint8_t JoinChannelGroupsCurrentIndex; 96 | /*! 97 | * Counter of join trials needed to alternate between datarates. 98 | */ 99 | uint8_t JoinTrialsCounter; 100 | #endif 101 | /*! 102 | * CRC32 value of the Region data structure. 103 | */ 104 | uint32_t Crc32; 105 | }RegionNvmDataGroup1_t; 106 | 107 | /*! 108 | * Region specific data which must be stored in the NVM. 109 | * Parameters which do not change very frequently. 110 | */ 111 | typedef struct sRegionNvmDataGroup2 112 | { 113 | /*! 114 | * LoRaMAC channels 115 | */ 116 | ChannelParams_t Channels[ REGION_NVM_MAX_NB_CHANNELS ]; 117 | /*! 118 | * LoRaMac channels mask 119 | */ 120 | uint16_t ChannelsMask[ REGION_NVM_CHANNELS_MASK_SIZE ]; 121 | /*! 122 | * LoRaMac channels default mask 123 | */ 124 | uint16_t ChannelsDefaultMask[ REGION_NVM_CHANNELS_MASK_SIZE ]; 125 | #if (defined( REGION_VERSION ) && ( REGION_VERSION == 0x02010001 )) 126 | #if defined( REGION_CN470 ) 127 | /*! 128 | * Holds the channel plan. 129 | */ 130 | RegionCN470ChannelPlan_t ChannelPlan; 131 | /*! 132 | * Holds the common join channel, if its an OTAA device, otherwise 133 | * this value is 0. 134 | */ 135 | uint8_t CommonJoinChannelIndex; 136 | /*! 137 | * Identifier which specifies if the device is an OTAA device. Set 138 | * to true, if its an OTAA device. 139 | */ 140 | bool IsOtaaDevice; 141 | #endif 142 | #endif /* REGION_VERSION */ 143 | /*! 144 | * CRC32 value of the Region data structure. 145 | */ 146 | uint32_t Crc32; 147 | }RegionNvmDataGroup2_t; 148 | 149 | /*! \} addtogroup REGIONCOMMON */ 150 | 151 | #ifdef __cplusplus 152 | } 153 | #endif 154 | 155 | #endif // __REGIONNVM_H__ 156 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/Mac/Region/RegionVersion.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file RegionVersion.h 4 | * @author MCD Application Team 5 | * @brief Identifies the version of Regional Parameters 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2020(-2021) STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | #ifndef __REGION_VERSION_H__ 19 | #define __REGION_VERSION_H__ 20 | 21 | #ifdef __cplusplus 22 | extern "C" 23 | { 24 | #endif 25 | 26 | #include "LoRaMacVersion.h" 27 | 28 | #ifndef REGION_VERSION 29 | #if (defined(LORAMAC_VERSION) && (LORAMAC_VERSION == 0x01000300)) 30 | /*! 31 | * @brief Regional parameters version definition. 32 | * @note RP001-1.0.3 : 33 | */ 34 | #define REGION_VERSION 0x01010003 35 | #elif (defined(LORAMAC_VERSION) && (LORAMAC_VERSION == 0x01000400)) 36 | /*! 37 | * @brief Regional parameters version definition. 38 | * @note RP002-1.0.1 : https://lora-alliance.org/resource_hub/rp2-101-lorawan-regional-parameters-2/ 39 | */ 40 | #define REGION_VERSION 0x02010001 41 | #endif /* LORAMAC_VERSION */ 42 | #endif 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif // __REGION_VERSION_H__ 49 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/Mac/secure-element-nvm.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file secure-element-nvm.h 3 | * 4 | * \brief Secure Element non-volatile data. 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013 Semtech 16 | * 17 | * ___ _____ _ ___ _ _____ ___ ___ ___ ___ 18 | * / __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __| 19 | * \__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _| 20 | * |___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___| 21 | * embedded.connectivity.solutions=============== 22 | * 23 | * \endcode 24 | * 25 | * \author Miguel Luis ( Semtech ) 26 | * 27 | * \author Daniel Jaeckle ( STACKFORCE ) 28 | * 29 | * \addtogroup SECUREELEMENT 30 | * 31 | * \{ 32 | * 33 | */ 34 | /** 35 | ****************************************************************************** 36 | * 37 | * Portions COPYRIGHT 2020 STMicroelectronics 38 | * 39 | * @file secure-element-nvm.h 40 | * @author MCD Application Team 41 | * @brief Secure Element non-volatile data. 42 | ****************************************************************************** 43 | */ 44 | #ifndef __SECURE_ELEMENT_NVM_H__ 45 | #define __SECURE_ELEMENT_NVM_H__ 46 | 47 | #ifdef __cplusplus 48 | extern "C" 49 | { 50 | #endif 51 | 52 | #include "LoRaMacTypes.h" 53 | #include "lorawan_conf.h" /* LORAWAN_KMS */ 54 | #if (!defined (LORAWAN_KMS) || (LORAWAN_KMS == 0)) 55 | #else /* LORAWAN_KMS == 1 */ 56 | #include "kms_if.h" 57 | #endif /* LORAWAN_KMS */ 58 | 59 | /*! 60 | * Secure-element keys size in bytes 61 | */ 62 | #define SE_KEY_SIZE 16 63 | 64 | /*! 65 | * Secure-element EUI size in bytes 66 | */ 67 | #define SE_EUI_SIZE 8 68 | 69 | /* ST_WORKAROUND_BEGIN: Dynamic number of keys definition */ 70 | /*! 71 | * Number of supported crypto keys for the soft-se 72 | */ 73 | #if ( USE_LRWAN_1_1_X_CRYPTO == 1 ) 74 | #if ( LORAMAC_MAX_MC_CTX > 3 ) 75 | #define NUM_OF_KEYS 23UL 76 | #elif ( LORAMAC_MAX_MC_CTX > 2 ) 77 | #define NUM_OF_KEYS 20UL 78 | #elif ( LORAMAC_MAX_MC_CTX > 1 ) 79 | #define NUM_OF_KEYS 17UL 80 | #else /* LORAMAC_MAX_MC_CTX == 0 */ 81 | #define NUM_OF_KEYS 14UL 82 | #endif /* LORAMAC_MAX_MC_CTX */ 83 | #else /* USE_LRWAN_1_1_X_CRYPTO == 0 */ 84 | #if ( LORAMAC_MAX_MC_CTX > 3 ) 85 | #define NUM_OF_KEYS 19UL 86 | #elif ( LORAMAC_MAX_MC_CTX > 2 ) 87 | #define NUM_OF_KEYS 16UL 88 | #elif ( LORAMAC_MAX_MC_CTX > 1 ) 89 | #define NUM_OF_KEYS 13UL 90 | #else /* LORAMAC_MAX_MC_CTX == 0 */ 91 | #define NUM_OF_KEYS 10UL 92 | #endif /* LORAMAC_MAX_MC_CTX */ 93 | #endif /* USE_LRWAN_1_1_X_CRYPTO */ 94 | /* ST_WORKAROUND_END */ 95 | 96 | /*! 97 | * Key structure definition for the soft-se 98 | */ 99 | typedef struct sKey 100 | { 101 | /*! 102 | * Key identifier 103 | */ 104 | KeyIdentifier_t KeyID; 105 | #if (!defined (LORAWAN_KMS) || (LORAWAN_KMS == 0)) 106 | /*! 107 | * Key value 108 | */ 109 | uint8_t KeyValue[SE_KEY_SIZE]; 110 | #else /* LORAWAN_KMS == 1 */ 111 | /*! 112 | * Key object index in the above list 113 | */ 114 | CK_OBJECT_HANDLE Object_Index; 115 | #endif /* LORAWAN_KMS */ 116 | } Key_t; 117 | 118 | typedef struct sSecureElementNvCtx 119 | { 120 | /*! 121 | * DevEUI storage 122 | */ 123 | uint8_t DevEui[SE_EUI_SIZE]; 124 | /*! 125 | * Join EUI storage 126 | */ 127 | uint8_t JoinEui[SE_EUI_SIZE]; 128 | /*! 129 | * The key list is required for the soft-se only. All other secure-elements 130 | * handle the storage on their own. 131 | */ 132 | Key_t KeyList[NUM_OF_KEYS]; 133 | /*! 134 | * CRC32 value of the SecureElement data structure. 135 | */ 136 | uint32_t Crc32; 137 | } SecureElementNvmData_t; 138 | 139 | /*! \} addtogroup SECUREELEMENT */ 140 | 141 | #ifdef __cplusplus 142 | } 143 | #endif 144 | 145 | #endif // __SECURE_ELEMENT_NVM_H__ 146 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/LoRaWAN/Utilities/utilities.c: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file utilities.c 3 | * 4 | * \brief Helper functions implementation 5 | * 6 | * \copyright Revised BSD License, see section \ref LICENSE. 7 | * 8 | * \code 9 | * ______ _ 10 | * / _____) _ | | 11 | * ( (____ _____ ____ _| |_ _____ ____| |__ 12 | * \____ \| ___ | (_ _) ___ |/ ___) _ \ 13 | * _____) ) ____| | | || |_| ____( (___| | | | 14 | * (______/|_____)_|_|_| \__)_____)\____)_| |_| 15 | * (C)2013-2017 Semtech 16 | * 17 | * \endcode 18 | * 19 | * \author Miguel Luis ( Semtech ) 20 | * 21 | * \author Gregory Cristian ( Semtech ) 22 | */ 23 | /** 24 | ****************************************************************************** 25 | * 26 | * Portions COPYRIGHT 2020 STMicroelectronics 27 | * 28 | * @file utilities.c 29 | * @author MCD Application Team 30 | * @brief Helper functions implementation 31 | ****************************************************************************** 32 | */ 33 | 34 | #include "utilities.h" 35 | 36 | /*! 37 | * Redefinition of rand() and srand() standard C functions. 38 | * These functions are redefined in order to get the same behavior across 39 | * different compiler toolchains implementations. 40 | */ 41 | // Standard random functions redefinition start 42 | #define RAND_LOCAL_MAX 2147483647L 43 | 44 | // CRC32 reversed polynomial 0xEDB88320 45 | static const uint32_t reversedPolynom = 0xEDB88320; 46 | 47 | static uint32_t next = 1; 48 | 49 | static int32_t rand1( void ); 50 | 51 | static int32_t rand1( void ) 52 | { 53 | return ( ( next = next * 1103515245L + 12345L ) % RAND_LOCAL_MAX ); 54 | } 55 | 56 | void srand1( uint32_t seed ) 57 | { 58 | next = seed; 59 | } 60 | // Standard random functions redefinition end 61 | 62 | int32_t randr( int32_t min, int32_t max ) 63 | { 64 | return ( int32_t )rand1( ) % ( max - min + 1 ) + min; 65 | } 66 | 67 | void memcpy1( uint8_t *dst, const uint8_t *src, uint16_t size ) 68 | { 69 | while( size-- ) 70 | { 71 | *dst++ = *src++; 72 | } 73 | } 74 | 75 | void memcpyr( uint8_t *dst, const uint8_t *src, uint16_t size ) 76 | { 77 | dst = dst + ( size - 1 ); 78 | while( size-- ) 79 | { 80 | *dst-- = *src++; 81 | } 82 | } 83 | 84 | void memset1( uint8_t *dst, uint8_t value, uint16_t size ) 85 | { 86 | while( size-- ) 87 | { 88 | *dst++ = value; 89 | } 90 | } 91 | 92 | int8_t Nibble2HexChar( uint8_t a ) 93 | { 94 | if( a < 10 ) 95 | { 96 | return '0' + a; 97 | } 98 | else if( a < 16 ) 99 | { 100 | return 'A' + ( a - 10 ); 101 | } 102 | else 103 | { 104 | return '?'; 105 | } 106 | } 107 | 108 | uint32_t Crc32( uint8_t *buffer, uint16_t length ) 109 | { 110 | // CRC initial value 111 | uint32_t crc = 0xFFFFFFFF; 112 | 113 | if( buffer == NULL ) 114 | { 115 | return 0; 116 | } 117 | 118 | for( uint16_t i = 0; i < length; ++i ) 119 | { 120 | crc ^= ( uint32_t )buffer[i]; 121 | for( uint16_t i = 0; i < 8; i++ ) 122 | { 123 | crc = ( crc >> 1 ) ^ ( reversedPolynom & ~( ( crc & 0x01 ) - 1 ) ); 124 | } 125 | } 126 | 127 | return ~crc; 128 | } 129 | 130 | uint32_t Crc32Init( void ) 131 | { 132 | return 0xFFFFFFFF; 133 | } 134 | 135 | uint32_t Crc32Update( uint32_t crcInit, uint8_t *buffer, uint16_t length ) 136 | { 137 | // CRC initial value 138 | uint32_t crc = crcInit; 139 | 140 | if( buffer == NULL ) 141 | { 142 | return 0; 143 | } 144 | 145 | for( uint16_t i = 0; i < length; ++i ) 146 | { 147 | crc ^= ( uint32_t )buffer[i]; 148 | for( uint16_t i = 0; i < 8; i++ ) 149 | { 150 | crc = ( crc >> 1 ) ^ ( reversedPolynom & ~( ( crc & 0x01 ) - 1 ) ); 151 | } 152 | } 153 | return crc; 154 | } 155 | 156 | uint32_t Crc32Finalize( uint32_t crc ) 157 | { 158 | return ~crc; 159 | } 160 | -------------------------------------------------------------------------------- /Middlewares/Third_Party/SubGHz_Phy/LICENSE: -------------------------------------------------------------------------------- 1 | The Clear BSD License 2 | Copyright Semtech Corporation 2021. All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted (subject to the limitations in the disclaimer 6 | below) provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Semtech corporation nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY 17 | THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 18 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT 19 | NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 20 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE 21 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 22 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 23 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 24 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 25 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 26 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 27 | POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /Middlewares/Third_Party/SubGHz_Phy/stm32_radio_driver/subghz_phy_version.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * @file subghz_phy_version.h 3 | * @author MCD Application Team 4 | * @brief defines the radio driver version 5 | ****************************************************************************** 6 | * @attention 7 | * 8 | * Copyright (c) 2020(-2021) STMicroelectronics. 9 | * All rights reserved. 10 | * 11 | * This software is licensed under terms that can be found in the LICENSE file 12 | * in the root directory of this software component. 13 | * If no LICENSE file comes with this software, it is provided AS-IS. 14 | * 15 | ****************************************************************************** 16 | */ 17 | 18 | /* Define to prevent recursive inclusion -------------------------------------*/ 19 | 20 | #ifndef __SUBGHZ_PHY_VERSION_H__ 21 | #define __SUBGHZ_PHY_VERSION_H__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | 27 | /* Includes ------------------------------------------------------------------*/ 28 | /* Exported constants --------------------------------------------------------*/ 29 | 30 | /* __SUBGHZ_PHY_TYPE: 0x01 STM32WL 31 | 0x61 SX126X 32 | 0x72 SX1272 33 | 0x76 SX1276 */ 34 | 35 | #define SUBGHZ_PHY_VERSION_MAIN (0x01U) /*!< [31:24] main version */ 36 | #define SUBGHZ_PHY_VERSION_SUB1 (0x02U) /*!< [23:16] sub1 version */ 37 | #define SUBGHZ_PHY_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */ 38 | #define SUBGHZ_PHY_TYPE (0x01U) /*!< [7:0] type version */ 39 | #define SUBGHZ_PHY_VERSION ((SUBGHZ_PHY_VERSION_MAIN << 24) \ 40 | |(SUBGHZ_PHY_VERSION_SUB1 << 16) \ 41 | |(SUBGHZ_PHY_VERSION_SUB2 << 8) \ 42 | |(SUBGHZ_PHY_TYPE)) 43 | 44 | /* Exported types ------------------------------------------------------------*/ 45 | /* External variables --------------------------------------------------------*/ 46 | /* Exported macros -----------------------------------------------------------*/ 47 | /* Exported functions ------------------------------------------------------- */ 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif 52 | 53 | #endif /*__SUBGHZ_PHY_VERSION_H__*/ 54 | -------------------------------------------------------------------------------- /RAK3172.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/danak6jq/RAK3172/64451933eb391dd716d6133b3f072ecf05dd8c3d/RAK3172.pdf -------------------------------------------------------------------------------- /RAK3172.txt: -------------------------------------------------------------------------------- 1 | Configuration RAK3172 2 | STM32CubeMX 6.6.0 3 | Date 07/06/2022 4 | MCU STM32WLE5CCUx 5 | 6 | 7 | 8 | PERIPHERALS MODES FUNCTIONS PINS 9 | ADC IN2 ADC_IN2 PB3 10 | ADC Single-ended ADC_TempSens_Input VP_ADC_TempSens_Input 11 | ADC Vrefint Channel ADC_Vref_Input VP_ADC_Vref_Input 12 | DEBUG Serial Wire DEBUG_JTCK-SWCLK PA14 13 | DEBUG Serial Wire DEBUG_JTMS-SWDIO PA13 14 | RCC Crystal/Ceramic Resonator RCC_OSC_IN OSC_IN 15 | RCC Crystal/Ceramic Resonator RCC_OSC_OUT OSC_OUT 16 | RCC Crystal/Ceramic Resonator RCC_OSC32_IN PC14-OSC32_IN 17 | RCC Crystal/Ceramic Resonator RCC_OSC32_OUT PC15-OSC32_OUT 18 | RTC Activate RTC Clock Source RTC_VS_RTC_Activate VP_RTC_VS_RTC_Activate 19 | RTC RTC Enabled RTC_VS_RTC_Calendar VP_RTC_VS_RTC_Calendar 20 | RTC Internal Alarm A RTC_VS_RTC_Alarm_A_Intern VP_RTC_VS_RTC_Alarm_A_Intern 21 | SUBGHZ Activated SUBGHZ_VS_SUBGHZ VP_SUBGHZ_VS_SUBGHZ 22 | SYS None SYS_VS_None VP_SYS_VS_None 23 | USART2 Asynchronous USART2_RX PA3 24 | USART2 Asynchronous USART2_TX PA2 25 | 26 | 27 | 28 | Pin Nb PINs FUNCTIONs LABELs 29 | 1 PB3 ADC_IN2 30 | 6 PB8 GPIO_Output RF_CTRL1 31 | 7 PA0 GPIO_Output LED1 32 | 8 PA1 GPIO_Output LED2 33 | 9 PA2 USART2_TX 34 | 10 PA3 USART2_RX 35 | 26 OSC_IN RCC_OSC_IN 36 | 27 OSC_OUT RCC_OSC_OUT 37 | 32 PB12 GPIO_Input FREQ_HIGH 38 | 36 PA13 DEBUG_JTMS-SWDIO 39 | 38 PC13 GPIO_Output RF_CTRL2 40 | 39 PC14-OSC32_IN RCC_OSC32_IN 41 | 40 PC15-OSC32_OUT RCC_OSC32_OUT 42 | 42 PA14 DEBUG_JTCK-SWCLK 43 | PERIPHERALS MODES FUNCTIONS PINS 44 | ADC IN2 ADC_IN2 PB3 45 | ADC Single-ended ADC_TempSens_Input VP_ADC_TempSens_Input 46 | ADC Vrefint Channel ADC_Vref_Input VP_ADC_Vref_Input 47 | DEBUG Serial Wire DEBUG_JTCK-SWCLK PA14 48 | DEBUG Serial Wire DEBUG_JTMS-SWDIO PA13 49 | RCC Crystal/Ceramic Resonator RCC_OSC_IN OSC_IN 50 | RCC Crystal/Ceramic Resonator RCC_OSC_OUT OSC_OUT 51 | RCC Crystal/Ceramic Resonator RCC_OSC32_IN PC14-OSC32_IN 52 | RCC Crystal/Ceramic Resonator RCC_OSC32_OUT PC15-OSC32_OUT 53 | RTC Activate RTC Clock Source RTC_VS_RTC_Activate VP_RTC_VS_RTC_Activate 54 | RTC RTC Enabled RTC_VS_RTC_Calendar VP_RTC_VS_RTC_Calendar 55 | RTC Internal Alarm A RTC_VS_RTC_Alarm_A_Intern VP_RTC_VS_RTC_Alarm_A_Intern 56 | SUBGHZ Activated SUBGHZ_VS_SUBGHZ VP_SUBGHZ_VS_SUBGHZ 57 | SYS None SYS_VS_None VP_SYS_VS_None 58 | USART2 Asynchronous USART2_RX PA3 59 | USART2 Asynchronous USART2_TX PA2 60 | 61 | 62 | 63 | Pin Nb PINs FUNCTIONs LABELs 64 | 1 PB3 ADC_IN2 65 | 6 PB8 GPIO_Output RF_CTRL1 66 | 7 PA0 GPIO_Output LED1 67 | 8 PA1 GPIO_Output LED2 68 | 9 PA2 USART2_TX 69 | 10 PA3 USART2_RX 70 | 26 OSC_IN RCC_OSC_IN 71 | 27 OSC_OUT RCC_OSC_OUT 72 | 32 PB12 GPIO_Input FREQ_HIGH 73 | 36 PA13 DEBUG_JTMS-SWDIO 74 | 38 PC13 GPIO_Output RF_CTRL2 75 | 39 PC14-OSC32_IN RCC_OSC32_IN 76 | 40 PC15-OSC32_OUT RCC_OSC32_OUT 77 | 42 PA14 DEBUG_JTCK-SWCLK 78 | 79 | 80 | 81 | SOFTWARE PROJECT 82 | 83 | Project Settings : 84 | Project Name : RAK3172 85 | Project Folder : C:\Users\danam\STM32CubeIDE\workspace_1.7.0\RAK3172 86 | Toolchain / IDE : STM32CubeIDE 87 | Firmware Package Name and Version : STM32Cube FW_WL V1.2.0 88 | 89 | 90 | Code Generation Settings : 91 | STM32Cube MCU packages and embedded software packs : Copy only the necessary library files 92 | Generate peripheral initialization as a pair of '.c/.h' files per peripheral : Yes 93 | Backup previously generated files when re-generating : Yes 94 | Delete previously generated files when not re-generated : Yes 95 | Set all free pins as analog (to optimize the power consumption) : No 96 | 97 | 98 | Toolchains Settings : 99 | Compiler Optimizations : 100 | 101 | 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # RAK3172 2 | Port of STM32WLxx example for RAK3172 3 | 4 | UPDATE 9 May 2023: the FW1.3 branch is the result of letting STM32CubeIDE update to FW V1.3. It hasn't been tested yet but initial review suggests it'll work fine. If you test this before I do, please let me know I'll merge it to master. 5 | 6 | Quick update to V1.2 of ST firmware package; unit tested as a Class C mote 7 | 8 | Update 14 July 2022: 9 | Reviewed merge of V1.2 ST FW and found a number of issues, mostly in the lora_app.c merge. I think I've fixed battery level reporting. Cleaned-up LED control code (though LEDs don't have a clear functionality, this could use some more app-specific attention). Added implementation of v1.0.4. Moved GPIO initialization to match ST LoRa_End_Node example. Unit-tested in Class C and Class A. Changed some defaults in the IOC file (use ST-provided EUI, v1.0.4, Class A, debugger disabled). 10 | I'm happy to merge PRs with different defaults when there's enough user request. 11 | 12 | NOTE: ********* bug in ST firmware requires workaround 13 | 14 | Note there's an issue with: 15 | ``` 16 | /** 17 | * @brief Perform an ADC automatic self-calibration 18 | * Calibration prerequisite: ADC must be disabled (execute this 19 | * function before HAL_ADC_Start() or after HAL_ADC_Stop() ). 20 | * @note Calibration factor can be read after calibration, using function 21 | * HAL_ADC_GetValue() (value on 7 bits: from DR[6;0]). 22 | * @param hadc ADC handle 23 | * @retval HAL status 24 | */ 25 | HAL_StatusTypeDef HAL_ADCEx_Calibration_Start(ADC_HandleTypeDef *hadc) 26 | ``` 27 | 28 | right now - add the lines with stars below after every Cube regen. ST HAL bug. 29 | ``` 30 | /* Compute average */ 31 | calibration_factor_accumulated /= calibration_index; 32 | /* Apply calibration factor */ 33 | LL_ADC_Enable(hadc->Instance); 34 | 35 | /* add this block of code */ 36 | while (!LL_ADC_IsActiveFlag_ADRDY(hadc->Instance)) // *** 37 | /* spin */; // *** 38 | LL_ADC_ClearFlag_ADRDY(hadc->Instance); // *** 39 | 40 | LL_ADC_SetCalibrationFactor(hadc->Instance, calibration_factor_accumulated); 41 | LL_ADC_Disable(hadc->Instance); 42 | ``` 43 | 44 | As usual, this is provided with zero warranty for usefulness or reliability. 45 | -------------------------------------------------------------------------------- /Utilities/misc/stm32_mem.c: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32_mem.c 4 | * @author MCD Application Team 5 | * @brief standard memory operation 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2019 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Includes ------------------------------------------------------------------*/ 20 | #include "stdint.h" 21 | #include "stm32_mem.h" 22 | 23 | /* Private typedef -----------------------------------------------------------*/ 24 | /* Private defines -----------------------------------------------------------*/ 25 | /* Private macros ------------------------------------------------------------*/ 26 | /* Private variables ---------------------------------------------------------*/ 27 | /* Global variables ----------------------------------------------------------*/ 28 | /* Private function prototypes -----------------------------------------------*/ 29 | /* Functions Definition ------------------------------------------------------*/ 30 | 31 | void UTIL_MEM_cpy_8( void *dst, const void *src, uint16_t size ) 32 | { 33 | uint8_t* dst8= (uint8_t *) dst; 34 | uint8_t* src8= (uint8_t *) src; 35 | 36 | while( size-- ) 37 | { 38 | *dst8++ = *src8++; 39 | } 40 | } 41 | 42 | void UTIL_MEM_cpyr_8( void *dst, const void *src, uint16_t size ) 43 | { 44 | uint8_t* dst8= (uint8_t *) dst; 45 | uint8_t* src8= (uint8_t *) src; 46 | 47 | dst8 = dst8 + ( size - 1 ); 48 | while( size-- ) 49 | { 50 | *dst8-- = *src8++; 51 | } 52 | } 53 | 54 | void UTIL_MEM_set_8( void *dst, uint8_t value, uint16_t size ) 55 | { 56 | uint8_t* dst8= (uint8_t *) dst; 57 | while( size-- ) 58 | { 59 | *dst8++ = value; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Utilities/misc/stm32_mem.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32_mem.h 4 | * @author MCD Application Team 5 | * @brief standard memory operation 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2019 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __STM32_MEM_H__ 21 | #define __STM32_MEM_H__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" 25 | { 26 | #endif 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include 29 | #include "utilities_conf.h" 30 | 31 | /* Exported types ------------------------------------------------------------*/ 32 | /* Exported constants --------------------------------------------------------*/ 33 | /* Exported macro ------------------------------------------------------------*/ 34 | /* ---- Memory mapping macros ----------------------------------------------- */ 35 | #define UTIL_MEM_PLACE_IN_SECTION( __x__ ) UTIL_PLACE_IN_SECTION( __x__ ) 36 | #define UTIL_MEM_ALIGN ALIGN 37 | 38 | /* Exported functions ------------------------------------------------------- */ 39 | /** 40 | * @brief This API copies one buffer to another 41 | * @param dst: output buffer to be filled 42 | * @param src: input buffer 43 | * @param size: size of 8b data 44 | * @retval None 45 | */ 46 | void UTIL_MEM_cpy_8( void *dst, const void *src, uint16_t size ); 47 | 48 | /** 49 | * @brief This API copies one buffer to another in reverse 50 | * @param dst: output buffer to be filled 51 | * @param src: input buffer 52 | * @param size: size of 8b data 53 | * @retval None 54 | */ 55 | void UTIL_MEM_cpyr_8( void *dst, const void *src, uint16_t size ); 56 | 57 | /** 58 | * @brief This API fills a buffer with value 59 | * @param dst: output buffer to be filled 60 | * @param value: value 61 | * @param size: size of 8b data 62 | * @retval None 63 | */ 64 | void UTIL_MEM_set_8( void *dst, uint8_t value, uint16_t size ); 65 | 66 | #ifdef __cplusplus 67 | } 68 | #endif 69 | 70 | #endif /* __STM32_MEM_H__ */ 71 | -------------------------------------------------------------------------------- /Utilities/misc/stm32_tiny_sscanf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32_tiny_sscanf.h 4 | * @author MCD Application Team 5 | * @brief Header for driver tiny_sscanf.c module 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2019 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __STM32_TINY_SSCANF_H__ 21 | #define __STM32_TINY_SSCANF_H__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" 25 | { 26 | #endif 27 | /* Includes ------------------------------------------------------------------*/ 28 | /* Exported types ------------------------------------------------------------*/ 29 | /* Exported constants --------------------------------------------------------*/ 30 | /* External variables --------------------------------------------------------*/ 31 | /* Exported macros -----------------------------------------------------------*/ 32 | /* Exported functions ------------------------------------------------------- */ 33 | 34 | /** 35 | * @brief Read formatted data from string 36 | * 37 | * Reads data from s and stores them according to parameter format into the 38 | * locations given by the additional arguments, as if scanf was used, but 39 | * reading from s instead of the standard input (stdin). 40 | * 41 | * The additional arguments should point to already allocated objects of the 42 | * type specified by their corresponding format specifier within the format string. 43 | * 44 | * @param C string that the function processes as its source to retrieve the data. 45 | * @param C string that contains a format string that follows the same specifications 46 | * as format in scanf (see scanf for details). 47 | * @param Depending on the format string, the function may expect a sequence of 48 | * additional arguments, each containing a pointer to allocated storage 49 | * where the interpretation of the extracted characters is stored with 50 | * the appropriate type. 51 | * There should be at least as many of these arguments as the number of 52 | * values stored by the format specifiers. Additional arguments are 53 | * ignored by the function. 54 | * @retval The number of items in the argument list successfully filled. This 55 | * count can match the expected number of items or be less (even zero) 56 | * in the case of a matching failure 57 | * @note Current supported formats are %hx, %hhx, %ul, %d,... 58 | */ 59 | int tiny_sscanf(const char *str, const char *fmt, ...); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif /* __STM32_TINY_SSCANF_H__ */ 66 | -------------------------------------------------------------------------------- /Utilities/misc/stm32_tiny_vsnprintf.h: -------------------------------------------------------------------------------- 1 | /** 2 | ****************************************************************************** 3 | * @file stm32_tiny_vsnprintf.h 4 | * @author MCD Application Team 5 | * @brief Header for tiny_vsnprintf.c module 6 | ****************************************************************************** 7 | * @attention 8 | * 9 | * Copyright (c) 2019 STMicroelectronics. 10 | * All rights reserved. 11 | * 12 | * This software is licensed under terms that can be found in the LICENSE file 13 | * in the root directory of this software component. 14 | * If no LICENSE file comes with this software, it is provided AS-IS. 15 | * 16 | ****************************************************************************** 17 | */ 18 | 19 | /* Define to prevent recursive inclusion -------------------------------------*/ 20 | #ifndef __STM32_TINY_VSNPRINTF_H__ 21 | #define __STM32_TINY_VSNPRINTF_H__ 22 | 23 | #ifdef __cplusplus 24 | extern "C" 25 | { 26 | #endif 27 | /* Includes ------------------------------------------------------------------*/ 28 | #include 29 | #include 30 | /* Exported types ------------------------------------------------------------*/ 31 | /* Exported constants --------------------------------------------------------*/ 32 | /* External variables --------------------------------------------------------*/ 33 | /* Exported functions ------------------------------------------------------- */ 34 | 35 | /** 36 | * @brief Tiny implementation of vsnprintf() like function 37 | * 38 | * It has been adapted so that: 39 | * - Tiny implementation, when defining TINY_PRINTF, is available. In such as case, 40 | * not all the format are available. Instead, only %02X, %x, %d, %u, %s and %c are available. 41 | * %f,, %+, %#, %- and others are excluded 42 | * - Provide a snprintf like implementation. The size of the buffer is provided, 43 | * and the length of the filled buffer is returned (not including the final '\0' char). 44 | * The string may be truncated 45 | * @param Pointer to a buffer where the resulting C-string is stored. The buffer should have a size of 46 | * at least n characters. 47 | * @param Maximum number of bytes to be used in the buffer. The generated string has a length of at 48 | * most n-1, leaving space for the additional terminating null character. 49 | * @param C string that contains a format string that follows the same specifications as format 50 | * in printf (see printf for details). 51 | * @param A value identifying a variable arguments list initialized with va_start. 52 | * @retval The number of written char (note that this is different from vsnprintf() 53 | */ 54 | int tiny_vsnprintf_like(char *buf, const int size, const char *fmt, va_list args); 55 | 56 | #ifdef __cplusplus 57 | } 58 | #endif 59 | 60 | #endif /* __STM32_TINY_VSNPRINTF_H__ */ 61 | --------------------------------------------------------------------------------