This repository has been archived on 2023-06-05. You can view files and clone it, but cannot push or open issues or pull requests.
xx_retired_Yunhorn_STS_MM/readme.txt

575 lines
24 KiB
Plaintext

=====2022 - 09 18 night ==== pending changes
lora-app.c
onRx
case LORAWAN_USER_APP_CTRL_PORT:
if (appData->BufferSize == 1)
{
// AppLedStateOn = appData->Buffer[0] & 0x01;
//
// if (AppLedStateOn == RESET)
// {
// APP_LOG(TS_OFF, VLEVEL_H, "LED OFF\r\n");
// BSP_LED_Off(LED_RED) ;
// }
// else
// {
// APP_LOG(TS_OFF, VLEVEL_H, "LED ON\r\n");
// BSP_LED_On(LED_RED) ;
// }
// for ascii translate, '0' --> 0x30, '1' --> 0x31
APP_LOG(TS_OFF, VLEVEL_M, "_______STS E4 fport=2 Testing APP CTRL PORT:%d CMD:%d\r\n",
appData->Port, (uint8_t)(appData->Buffer[0] -0x30));
cmd_cycle_time_level = (uint8_t)(appData->Buffer[0] - 0x30); //ASCII code TRANSLATE '0', '1','2' =0x30, 0x31, 0x32
if (cmd_cycle_time_level > TX_DUTY_CYCLE_LEVEL_8 )
{
cmd_cycle_time_level = TX_DUTY_CYCLE_LEVEL_8;
}
else
if (cmd_cycle_time_level < TX_DUTY_CYCLE_LEVEL_0)
{
cmd_cycle_time_level = TX_DUTY_CYCLE_LEVEL_0;
}
// update sensorData.dutycycletime value
//sts_e4_sensorData.dutycycletimelevel = (uint8_t)cmd_cycle_time_level;
// Write the configuratin to RW flash
flash_code_duty_cycle_level = cmd_cycle_time_level;
//save_config_to_flash((uint32_t)cmd_cycle_time_level);
// CHANGE SEND DATA INTERVAL BY RECEIVING TX_APP_DUTY_CYCLE_TIME
// IN LORA_APP.H LINE 55
// #define APP_TX_DUTYCYCLE 10000 // uint32_t for interval
/* send every time timer elapses */
UTIL_TIMER_Create(&TxTimer, 0xFFFFFFFFU, UTIL_TIMER_ONESHOT, OnTxTimerEvent, NULL);
APP_LOG(TS_OFF, VLEVEL_M, "**STS E4 CMD TO CONFIG APP_TX_DUTYCYCLE time =%d seconds\r\n",(uint16_t)(5*Level_DutyCycleTime[cmd_cycle_time_level]));
UTIL_TIMER_SetPeriod(&TxTimer, (uint32_t)(5*Level_DutyCycleTime[(uint8_t)cmd_cycle_time_level]*1000));
// set period interval to APP_TX_DUTYCYCLE ms
UTIL_TIMER_Start(&TxTimer);
// and sendTxData immediately with new effected duty cycle time
SendTxData();
}
break;
============================================
============ STM32WL 55 ========================================
BUT1_PIN PA.0 CN10 Pin nbr 1 [PC.13 CN7 Pin nbr 23]
BUT2_PIN PA.1 CN10 Pin nbr 36
BUT3_PIN PC.6 CN10 Pin nbr 12 //// ADXL345-INT2
#define BUT1_Pin GPIO_PIN_0
#define BUT1_GPIO_Port GPIOA
#define BUT1_EXTI_IRQn EXTI0_IRQn
#define BUT3_Pin GPIO_PIN_6
#define BUT3_GPIO_Port GPIOC
#define BUT3_EXTI_IRQn EXTI9_5_IRQn
#define BUT2_Pin GPIO_PIN_1
#define BUT2_GPIO_Port GPIOA
#define BUT2_EXTI_IRQn EXTI1_IRQn
============ STM32WL 55 ========================================
==================================
STM32WL55JC confirmed =============
===================================
GNG GND=== CN7 PIN 20
VCC 3.3 ====CN7 PIN 16
===================================
SSD 1306 STM32WL55JC
----- I2C1 --------------------------------------
SCL PB.08 === CN10 pin 27
SDA PB.07 === CN10 pin 37
----- I2C2 --------------------------------------
SCL PA.12 === CN10 pin 3
SDA PA.15 === CN7 pin 17
----- I2C3 --------------------------------------
SCL PB.13 === CN7 pin 38
SDA PB.4 === CN7 pin 34
--------------------SPI STM32WL55JC
--------------------SPI1 -------------------------------
CLK PA.05 ==== CN10 pin 11
MISO PA.06 ====- CN10 pin 13
MOSI PA.07 ==== CN10 pin 15
=======================================
===================================
===================================
/*!
* LoRaWAN Adaptive Data Rate
* @note Please note that when ADR is enabled the end-device should be static
*/
#define LORAWAN_ADR_STATE LORAMAC_HANDLER_ADR_OFF //LORAMAC_HANDLER_ADR_ON
/** @addtogroup STM32WLXX_NUCLEO_LOW_LEVEL_BUTTON_Functions
* @{
*/
/**
* @brief Configures Yunhorn GPIO INT1/INT2 or Sensor with EXTI Line.
* @param DryContactSensor: Specifies the Dry Contact Sensors to be configured.
* This parameter can be one of following parameters:
* @arg DRY_CONTACT_S1 // REED SWITCH OR WATER LEAKAGE
* @arg DRY_CONTACT_S2
* @arg DRY_CONTACT_S3
* @param DRY_CONTACT_Mode: Specifies Button mode.
* This parameter can be one of following parameters:
* @arg DRY_CONTACT_MODE_GPIO: DRY_CONTACT will be used as simple IO
* @arg DRY_CONTACT_MODE_EXTI: DRY_CONTACT will be connected to EXTI line with interrupt
* generation capability
* @retval BSP status
*/
int32_t BSP_PB_Init(Button_TypeDef Button, ButtonMode_TypeDef ButtonMode)
{
GPIO_InitTypeDef gpio_init_structure = {0};
static BSP_EXTI_LineCallback button_callback[BUTTONn] = {BUTTON_SW1_EXTI_Callback, BUTTON_SW2_EXTI_Callback, BUTTON_SW3_EXTI_Callback};
static uint32_t button_interrupt_priority[BUTTONn] = {BSP_BUTTON_USER_IT_PRIORITY, BSP_BUTTON_USER_IT_PRIORITY, BSP_BUTTON_USER_IT_PRIORITY};
static const uint32_t button_exti_line[BUTTONn] = {BUTTON_SW1_EXTI_LINE, BUTTON_SW2_EXTI_LINE, BUTTON_SW3_EXTI_LINE};
/* Enable the BUTTON Clock */
BUTTONx_GPIO_CLK_ENABLE(Button);
gpio_init_structure.Pin = BUTTON_PIN[Button];
gpio_init_structure.Pull = GPIO_PULLUP;
gpio_init_structure.Speed = GPIO_SPEED_FREQ_HIGH;
if(ButtonMode == BUTTON_MODE_GPIO)
{
/* Configure Button pin as input */
gpio_init_structure.Mode = GPIO_MODE_INPUT;
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
}
else /* (ButtonMode == BUTTON_MODE_EXTI) */
{
/* Configure Button pin as input with External interrupt */
gpio_init_structure.Mode = GPIO_MODE_IT_FALLING;
HAL_GPIO_Init(BUTTON_PORT[Button], &gpio_init_structure);
(void)HAL_EXTI_GetHandle(&hpb_exti[Button], button_exti_line[Button]);
(void)HAL_EXTI_RegisterCallback(&hpb_exti[Button], HAL_EXTI_COMMON_CB_ID, button_callback[Button]);
/* Enable and set Button EXTI Interrupt to the lowest priority */
HAL_NVIC_SetPriority((BUTTON_IRQn[Button]), button_interrupt_priority[Button], 0x00);
HAL_NVIC_EnableIRQ((BUTTON_IRQn[Button]));
}
return BSP_ERROR_NONE;
}
/**
* @brief Push Button DeInit.
* @param Button: Button to be configured
* This parameter can be one of following parameters:
* @arg BUTTON_SW1
* @arg BUTTON_SW2
* @arg BUTTON_SW3
* @note PB DeInit does not disable the GPIO clock
* @retval BSP status
*/
int32_t BSP_PB_DeInit(Button_TypeDef Button)
{
HAL_NVIC_DisableIRQ((BUTTON_IRQn[Button]));
HAL_GPIO_DeInit(BUTTON_PORT[Button], BUTTON_PIN[Button]);
return BSP_ERROR_NONE;
}
/**
* @brief Returns the selected Button state.
* @param Button: Specifies the Button to be checked.
* This parameter can be one of following parameters:
* @arg BUTTON_SW1
* @arg BUTTON_SW2
* @arg BUTTON_SW3
* @retval The Button GPIO pin value.
*/
int32_t BSP_PB_GetState(Button_TypeDef Button)
{
return (int32_t)HAL_GPIO_ReadPin(BUTTON_PORT[Button], BUTTON_PIN[Button]);
}
/**
* @brief This function handles Push-Button interrupt requests.
* @param Button Specifies the pin connected EXTI line
* @retval None
*/
void BSP_PB_IRQHandler(Button_TypeDef Button)
{
HAL_EXTI_IRQHandler(&hpb_exti[Button]);
}
/**
* @brief BSP Push Button callback
* @param Button: Specifies the Button to be checked.
* This parameter can be one of following parameters:
* @arg BUTTON_SW1
* @arg BUTTON_SW2
* @arg BUTTON_SW3
* @retval None.
*/
__weak void BSP_PB_Callback(Button_TypeDef Button)
{
/* Prevent unused argument(s) compilation warning */
UNUSED(Button);
/* This function should be implemented by the user application.
It is called into this driver when an event on Button is triggered. */
}
===================================
===========================================================================================================
sys_sensor.c
Application/User/LoRaWAN/App
===========================================================================================================
LORA_APP.H
===/* Region ------------------------------------*/
//#define ACTIVE_REGION LORAMAC_REGION_EU868
#define ACTIVE_REGION LORAMAC_REGION_AS923
//#define LORAWAN_USER_APP_PORT 2
#define LORAWAN_USER_APP_PORT 11
/*!
* Defines the application data transmission duty cycle. 10s, value in [ms].
*/
#define APP_TX_DUTYCYCLE 60000
===========================================================================================================
/LoRaWAN/App/lora_info.c
lorawan_conf.h
===========================================================================================================
/* Region ------------------------------------*/
/* the region listed here will be linked in the MW code */
/* the application (on sys_conf.h) shall just configure one region at the time */
/*#define REGION_AS923*/
/*#define REGION_AU915*/
/*#define REGION_CN470*/
/*#define REGION_CN779*/
/*#define REGION_EU433*/
#define REGION_EU868
/*#define REGION_KR920*/
/*#define REGION_IN865*/
#define REGION_US915
/*#define REGION_RU864*/
===========================================================================================================
===================================
STM32WL55JC
confirmed =============
===================================
GNG GND=== CN7 PIN 20
VCC 3.3 ====CN7 PIN 16
===================================
SSD 1306 STM32WL55JC
----- I2C1 --------------------------------------
SCL PB.08 === CN10 pin 27
SDA PB.07 === CN10 pin 37
----- I2C2 --------------------------------------
SCL PA.12 === CN10 pin 3
SDA PA.15 === CN7 pin 17
----- I2C3 --------------------------------------
SCL PB.13 === CN7 pin 38
SDA PB.4 === CN7 pin 34
=======================================
SPI STM32WL55JC
--------------------SPI1 -------------------------------
CLK PA.05 ==== CN10 pin 11
MISO PA.06 ====- CN10 pin 13
MOSI PA.07 ==== CN10 pin 15
===================================
/**
@page LoRaWAN_End_Node Readme file
@verbatim
******************************************************************************
* @file Applications/LoRaWAN/LoRaWAN_End_Node/readme.txt
* @author MCD Application Team
* @brief This application is a simple demo application software of a LoRa
* modem connecting to Network server. Data sent can be checked on
* Network server for eg Loriot. Traces are displayed over UART
******************************************************************************
*
* Copyright (c) 2020-2021 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
@endverbatim
@par Description
This directory contains a set of source files that implements a LoRa application
device sending sensors data to LoRa Network server.
Data are sent periodically on timer event or on "user button 1" depending on the configuration.
This application is targeting the STM32WLxx Nucleo board embedding the STM32WLxx.
******************************************************************************
@par Keywords
Applications, SubGHz_Phy, LoRaWAN, End_Node, SingleCore
@par Directory contents
- LoRaWAN_End_Node/Core/Inc/adc.h This file contains all the function prototypes for
the adc.c file
- LoRaWAN_End_Node/Core/Inc/adc_if.h Header for ADC interface configuration
- LoRaWAN_End_Node/Core/Inc/dma.h This file contains all the function prototypes for
the dma.c file
- LoRaWAN_End_Node/Core/Inc/flash_if.h This file contains definitions for FLASH Interface functionalities.
- LoRaWAN_End_Node/Core/Inc/gpio.h This file contains all the function prototypes for
the gpio.c file
- LoRaWAN_End_Node/Core/Inc/main.h : Header for main.c file.
This file contains the common defines of the application.
- LoRaWAN_End_Node/Core/Inc/platform.h Header for General HW instances configuration
- LoRaWAN_End_Node/Core/Inc/rtc.h This file contains all the function prototypes for
the rtc.c file
- LoRaWAN_End_Node/Core/Inc/stm32wlxx_hal_conf.h HAL configuration file.
- LoRaWAN_End_Node/Core/Inc/stm32wlxx_it.h This file contains the headers of the interrupt handlers.
- LoRaWAN_End_Node/Core/Inc/stm32wlxx_nucleo_conf.h STM32WLxx_Nucleo board configuration file.
- LoRaWAN_End_Node/Core/Inc/stm32_lpm_if.h Header for Low Power Manager interface configuration
- LoRaWAN_End_Node/Core/Inc/subghz.h This file contains all the function prototypes for
the subghz.c file
- LoRaWAN_End_Node/Core/Inc/sys_app.h Function prototypes for sys_app.c file
- LoRaWAN_End_Node/Core/Inc/sys_conf.h Applicative configuration, e.g. : debug, trace, low power, sensors
- LoRaWAN_End_Node/Core/Inc/sys_debug.h Configuration of the debug.c instances
- LoRaWAN_End_Node/Core/Inc/sys_sensors.h Header for sensors application
- LoRaWAN_End_Node/Core/Inc/timer_if.h configuration of the timer_if.c instances
- LoRaWAN_End_Node/Core/Inc/usart.h This file contains all the function prototypes for
the usart.c file
- LoRaWAN_End_Node/Core/Inc/usart_if.h Header for USART interface configuration
- LoRaWAN_End_Node/Core/Inc/utilities_conf.h Header for configuration file to utilities
- LoRaWAN_End_Node/Core/Inc/utilities_def.h Definitions for modules requiring utilities
- LoRaWAN_End_Node/LoRaWAN/App/app_lorawan.h Header of application of the LRWAN Middleware
- LoRaWAN_End_Node/LoRaWAN/App/CayenneLpp.h Implements the Cayenne Low Power Protocol
- LoRaWAN_End_Node/LoRaWAN/App/Commissioning.h End-device commissioning parameters
- LoRaWAN_End_Node/LoRaWAN/App/lora_app.h Header of application of the LRWAN Middleware
- LoRaWAN_End_Node/LoRaWAN/App/lora_app_version.h Definition the version of the application
- LoRaWAN_End_Node/LoRaWAN/App/lora_info.h To give info to the application about LoRaWAN configuration
- LoRaWAN_End_Node/LoRaWAN/App/se-identity.h Secure Element identity and keys
- LoRaWAN_End_Node/LoRaWAN/Target/lorawan_conf.h Header for LoRaWAN middleware instances
- LoRaWAN_End_Node/LoRaWAN/Target/mw_log_conf.h Configure (enable/disable) traces for CM0
- LoRaWAN_End_Node/LoRaWAN/Target/radio_board_if.h Header for Radio interface configuration
- LoRaWAN_End_Node/LoRaWAN/Target/radio_conf.h Header of Radio configuration
- LoRaWAN_End_Node/LoRaWAN/Target/systime.h Map middleware systime
- LoRaWAN_End_Node/LoRaWAN/Target/timer.h Wrapper to timer server
- LoRaWAN_End_Node/Core/Src/adc.c This file provides code for the configuration
of the ADC instances.
- LoRaWAN_End_Node/Core/Src/adc_if.c Read status related to the chip (battery level, VREF, chip temperature)
- LoRaWAN_End_Node/Core/Src/dma.c This file provides code for the configuration
of all the requested memory to memory DMA transfers.
- LoRaWAN_End_Node/Core/Src/flash_if.c This file provides set of firmware functions to manage Flash
Interface functionalities.
- LoRaWAN_End_Node/Core/Src/gpio.c This file provides code for the configuration
of all used GPIO pins.
- LoRaWAN_End_Node/Core/Src/main.c : Main program body
- LoRaWAN_End_Node/Core/Src/rtc.c This file provides code for the configuration
of the RTC instances.
- LoRaWAN_End_Node/Core/Src/stm32wlxx_hal_msp.c This file provides code for the MSP Initialization
and de-Initialization codes.
- LoRaWAN_End_Node/Core/Src/stm32wlxx_it.c Interrupt Service Routines.
- LoRaWAN_End_Node/Core/Src/stm32_lpm_if.c Low layer function to enter/exit low power modes (stop, sleep)
- LoRaWAN_End_Node/Core/Src/subghz.c This file provides code for the configuration
of the SUBGHZ instances.
- LoRaWAN_End_Node/Core/Src/system_stm32wlxx.c CMSIS Cortex Device Peripheral Access Layer System Source File
- LoRaWAN_End_Node/Core/Src/sys_app.c Initializes HW and SW system entities (not related to the radio)
- LoRaWAN_End_Node/Core/Src/sys_debug.c Configure probes pins RealTime debugging and JTAG/SerialWires for LowPower
- LoRaWAN_End_Node/Core/Src/sys_sensors.c Manages the sensors on the application
- LoRaWAN_End_Node/Core/Src/timer_if.c Configure RTC Alarm, Tick and Calendar manager
- LoRaWAN_End_Node/Core/Src/usart.c This file provides code for the configuration
of the USART instances.
- LoRaWAN_End_Node/Core/Src/usart_if.c Configuration of UART driver interface for hyperterminal communication
- LoRaWAN_End_Node/LoRaWAN/App/app_lorawan.c Application of the LRWAN Middleware
- LoRaWAN_End_Node/LoRaWAN/App/CayenneLpp.c Implements the Cayenne Low Power Protocol
- LoRaWAN_End_Node/LoRaWAN/App/lora_app.c Application of the LRWAN Middleware
- LoRaWAN_End_Node/LoRaWAN/App/lora_info.c To give info to the application about LoRaWAN configuration
- LoRaWAN_End_Node/LoRaWAN/Target/radio_board_if.c This file provides an interface layer between MW and Radio Board
- LoRaWAN_End_Node/STM32CubeIDE/Application/User/Core/syscalls.c STM32CubeIDE Minimal System calls file
- LoRaWAN_End_Node/STM32CubeIDE/Application/User/Core/sysmem.c STM32CubeIDE System Memory calls file
@par Hardware and Software environment
- This example runs on the STM32WLxx Nucleo board.
- STM32WLxx Nucleo board Set-up
- Connect the Nucleo board to your PC with a USB cable type A to micro-B
to ST-LINK connector.
- Please ensure that the ST-LINK connector jumpers are fitted.
- Configure the software via the configuration files:
- sys_conf.h, radio_conf.h, lorawan_conf.h, lora_app.c, lora_app.h, Commissioning.h, se-identity.h, mw_log_conf.h, main.h, etc
- Careful:
- the region and class chosen on LoRaWAN/App/lora_app.h shall be compatible with LoRaWAN/Target/lorawan_conf.h list
-Set Up:
-------------------------- V V --------------------------
| LoRa Object | | | | LoRa Network |
| | | | | |
ComPort<--| |--| |--| |-->Web Server
| | | |
-------------------------- --------------------------
@par How to use it ?
In order to make the program work, you must do the following :
- Open your preferred toolchain
- Rebuild all files and load your image into target memory
- Run the example
- Open a Terminal, connected the LoRa Object
- UART Config = 115200, 8b, 1 stopbit, no parity, no flow control
@par How to debug ?
- make sure the flag DEBUGGER_ENABLED to 1 in sys_conf.h
- simpler to define the flag LOW_POWER_DISABLE to 1 as well
- compile, download and attach
@par How to use MX to modify some RF middleware and application settings
This example is compatible (with some problems/limitations) with STM32CubeMX
and the RF application and middleware configuration can be modified via GUI. Few warnings and guidelines:
- ioc file is provided in the project directory and can be opened with STM32CubeMX v6.5.0 or higher.
- warning: when regenerating with the provided ioc file,
the IDE projects are regenerated and paths to HAL and MWs files from STM32Cube/Repository location are erroneously added; to avoid that,
user shall uncheck the "Use Default Firmware Location" in the GUI "Project-Manager" panel
and shall replace "Firmware Relative Path" with the root directory of the STM32CubeWL firmware package (e.g. C:\myDir\STM32Cube_FW_WL_V1.2.0\);
problem will be fixed in next STM32CubeMX version.
- .extSettings file allows to add to the generated IDE projects additional files not generated natively by MX (e.g. BSP files).
- when regenerating on existing code and existing linker files:
- STM32CubeMX updates the existing project content and preserves linker files.
- STM32CubeMX does not update the USER CODE sections (lines between /* USER CODE BEGIN Xxx */ and /* USER CODE END Xxx */).
- when regenerating after copying only the ioc file in an empty directory:
- STM32CubeMX generates default project files and default linker files. (Please check original linker file from project directory)
- it is up to the user to to fill the USER CODE sections with his application code.
@par How to use it with Azure ThreadX RTOS?
This example can be combined with Azure ThreadX RTOS via STM32CubeMX. The video tutorial:
"STM32WL - How to port an existing RF application on Azure ThreadX RTOS"
is available on https://www.youtube.com/playlist?list=PLnMKNibPkDnE2eaR-ZGM3ZJXadyQLtTpX
* <h3><center>&copy; COPYRIGHT STMicroelectronics</center></h3>
*/