first
This commit is contained in:
96
SubGHz_Phy/App/app_subghz_phy.c
Normal file
96
SubGHz_Phy/App/app_subghz_phy.c
Normal file
@ -0,0 +1,96 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file app_subghz_phy.c
|
||||
* @author MCD Application Team
|
||||
* @brief Application of the SubGHz_Phy Middleware
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2022 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "app_subghz_phy.h"
|
||||
#include "subghz_phy_app.h"
|
||||
#include "sys_app.h"
|
||||
#include "stm32_seq.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* External variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PTD */
|
||||
|
||||
/* USER CODE END PTD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PD */
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PM */
|
||||
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
|
||||
void MX_SubGHz_Phy_Init(void)
|
||||
{
|
||||
/* USER CODE BEGIN MX_SubGHz_Phy_Init_1 */
|
||||
|
||||
/* USER CODE END MX_SubGHz_Phy_Init_1 */
|
||||
SystemApp_Init();
|
||||
/* USER CODE BEGIN MX_SubGHz_Phy_Init_1_1 */
|
||||
|
||||
/* USER CODE END MX_SubGHz_Phy_Init_1_1 */
|
||||
SubghzApp_Init();
|
||||
/* USER CODE BEGIN MX_SubGHz_Phy_Init_2 */
|
||||
|
||||
/* USER CODE END MX_SubGHz_Phy_Init_2 */
|
||||
}
|
||||
|
||||
void MX_SubGHz_Phy_Process(void)
|
||||
{
|
||||
/* USER CODE BEGIN MX_SubGHz_Phy_Process_1 */
|
||||
|
||||
/* USER CODE END MX_SubGHz_Phy_Process_1 */
|
||||
UTIL_SEQ_Run(UTIL_SEQ_DEFAULT);
|
||||
/* USER CODE BEGIN MX_SubGHz_Phy_Process_2 */
|
||||
|
||||
/* USER CODE END MX_SubGHz_Phy_Process_2 */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN EF */
|
||||
|
||||
/* USER CODE END EF */
|
||||
|
||||
/* Private Functions Definition -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PrFD */
|
||||
|
||||
/* USER CODE END PrFD */
|
||||
73
SubGHz_Phy/App/app_subghz_phy.h
Normal file
73
SubGHz_Phy/App/app_subghz_phy.h
Normal file
@ -0,0 +1,73 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file app_subghz_phy.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header of application of the SubGHz_Phy Middleware
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2022 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __APP_SUBGHZ_PHY_H__
|
||||
#define __APP_SUBGHZ_PHY_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported Functions Prototypes ---------------------------------------------*/
|
||||
/**
|
||||
* @brief Init SubGHz Radio Application
|
||||
*/
|
||||
void MX_SubGHz_Phy_Init(void);
|
||||
|
||||
/**
|
||||
* @brief SubGHz Radio Application Process
|
||||
*/
|
||||
void MX_SubGHz_Phy_Process(void);
|
||||
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__APP_SUBGHZ_PHY_H__*/
|
||||
82
SubGHz_Phy/App/app_version.h
Normal file
82
SubGHz_Phy/App/app_version.h
Normal file
@ -0,0 +1,82 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file app_version.h
|
||||
* @author MCD Application Team
|
||||
* @brief Definition the version of the application
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2022 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __APP_VERSION_H__
|
||||
#define __APP_VERSION_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define APP_VERSION_MAIN (0x01U) /*!< [31:24] main version */
|
||||
#define APP_VERSION_SUB1 (0x02U) /*!< [23:16] sub1 version */
|
||||
#define APP_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */
|
||||
#define APP_VERSION_RC (0x00U) /*!< [7:0] release candidate */
|
||||
|
||||
#define APP_VERSION_MAIN_SHIFT 24 /*!< main byte shift */
|
||||
#define APP_VERSION_SUB1_SHIFT 16 /*!< sub1 byte shift */
|
||||
#define APP_VERSION_SUB2_SHIFT 8 /*!< sub2 byte shift */
|
||||
#define APP_VERSION_RC_SHIFT 0 /*!< release candidate byte shift */
|
||||
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Application version
|
||||
*/
|
||||
#define APP_VERSION ((APP_VERSION_MAIN << APP_VERSION_MAIN_SHIFT)\
|
||||
|(APP_VERSION_SUB1 << APP_VERSION_SUB1_SHIFT)\
|
||||
|(APP_VERSION_SUB2 << APP_VERSION_SUB2_SHIFT)\
|
||||
|(APP_VERSION_RC << APP_VERSION_RC_SHIFT))
|
||||
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__APP_VERSION_H__*/
|
||||
485
SubGHz_Phy/App/subghz_phy_app.c
Normal file
485
SubGHz_Phy/App/subghz_phy_app.c
Normal file
@ -0,0 +1,485 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file subghz_phy_app.c
|
||||
* @author MCD Application Team
|
||||
* @brief Application of the SubGHz_Phy Middleware
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "platform.h"
|
||||
#include "sys_app.h"
|
||||
#include "subghz_phy_app.h"
|
||||
#include "radio.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
#include "stm32_timer.h"
|
||||
#include "stm32_seq.h"
|
||||
#include "utilities_def.h"
|
||||
#include "app_version.h"
|
||||
#include "subghz_phy_version.h"
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* External variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
|
||||
/* USER CODE BEGIN PTD */
|
||||
typedef enum
|
||||
{
|
||||
RX,
|
||||
RX_TIMEOUT,
|
||||
RX_ERROR,
|
||||
TX,
|
||||
TX_TIMEOUT,
|
||||
} States_t;
|
||||
/* USER CODE END PTD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PD */
|
||||
/* Configurations */
|
||||
/*Timeout*/
|
||||
#define RX_TIMEOUT_VALUE 3000
|
||||
#define TX_TIMEOUT_VALUE 3000
|
||||
/* PING string*/
|
||||
#define PING "PING"
|
||||
/* PONG string*/
|
||||
#define PONG "PONG"
|
||||
/*Size of the payload to be sent*/
|
||||
/* Size must be greater of equal the PING and PONG*/
|
||||
#define MAX_APP_BUFFER_SIZE 255
|
||||
#if (PAYLOAD_LEN > MAX_APP_BUFFER_SIZE)
|
||||
#error PAYLOAD_LEN must be less or equal than MAX_APP_BUFFER_SIZE
|
||||
#endif /* (PAYLOAD_LEN > MAX_APP_BUFFER_SIZE) */
|
||||
/* wait for remote to be in Rx, before sending a Tx frame*/
|
||||
#define RX_TIME_MARGIN 200
|
||||
/* Afc bandwidth in Hz */
|
||||
#define FSK_AFC_BANDWIDTH 83333
|
||||
/* LED blink Period*/
|
||||
#define LED_PERIOD_MS 1000
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PM */
|
||||
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* Radio events function pointer */
|
||||
static RadioEvents_t RadioEvents;
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/*Ping Pong FSM states */
|
||||
static States_t State = RX;
|
||||
/* App Rx Buffer*/
|
||||
static uint8_t BufferRx[MAX_APP_BUFFER_SIZE];
|
||||
/* App Tx Buffer*/
|
||||
static uint8_t BufferTx[MAX_APP_BUFFER_SIZE];
|
||||
/* Last Received Buffer Size*/
|
||||
uint16_t RxBufferSize = 0;
|
||||
/* Last Received packer Rssi*/
|
||||
int8_t RssiValue = 0;
|
||||
/* Last Received packer SNR (in Lora modulation)*/
|
||||
int8_t SnrValue = 0;
|
||||
/* Led Timers objects*/
|
||||
static UTIL_TIMER_Object_t timerLed;
|
||||
/* device state. Master: true, Slave: false*/
|
||||
bool isMaster = true;
|
||||
/* random delay to make sure 2 devices will sync*/
|
||||
/* the closest the random delays are, the longer it will
|
||||
take for the devices to sync when started simultaneously*/
|
||||
static int32_t random_delay;
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/*!
|
||||
* @brief Function to be executed on Radio Tx Done event
|
||||
*/
|
||||
static void OnTxDone(void);
|
||||
|
||||
/**
|
||||
* @brief Function to be executed on Radio Rx Done event
|
||||
* @param payload ptr of buffer received
|
||||
* @param size buffer size
|
||||
* @param rssi
|
||||
* @param LoraSnr_FskCfo
|
||||
*/
|
||||
static void OnRxDone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t LoraSnr_FskCfo);
|
||||
|
||||
/**
|
||||
* @brief Function executed on Radio Tx Timeout event
|
||||
*/
|
||||
static void OnTxTimeout(void);
|
||||
|
||||
/**
|
||||
* @brief Function executed on Radio Rx Timeout event
|
||||
*/
|
||||
static void OnRxTimeout(void);
|
||||
|
||||
/**
|
||||
* @brief Function executed on Radio Rx Error event
|
||||
*/
|
||||
static void OnRxError(void);
|
||||
|
||||
/* USER CODE BEGIN PFP */
|
||||
/**
|
||||
* @brief Function executed on when led timer elapses
|
||||
* @param context ptr of LED context
|
||||
*/
|
||||
static void OnledEvent(void *context);
|
||||
|
||||
/**
|
||||
* @brief PingPong state machine implementation
|
||||
*/
|
||||
static void PingPong_Process(void);
|
||||
/* USER CODE END PFP */
|
||||
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
|
||||
{
|
||||
switch (GPIO_Pin)
|
||||
{
|
||||
case BUTTON_SW1_PIN:
|
||||
BSP_LED_Toggle(LED_BLUE) ;
|
||||
HAL_Delay(20);
|
||||
BSP_LED_Toggle(LED_BLUE) ;
|
||||
APP_PRINTF("BUTTON SW1\r\n");
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
APP_PRINTF("Unkonw Button\r\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
/* Exported functions ---------------------------------------------------------*/
|
||||
void SubghzApp_Init(void)
|
||||
{
|
||||
/* USER CODE BEGIN SubghzApp_Init_1 */
|
||||
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "\n\rPING PONG\n\r");
|
||||
/* Get SubGHY_Phy APP version*/
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "APPLICATION_VERSION: V%X.%X.%X\r\n",
|
||||
(uint8_t)(APP_VERSION_MAIN),
|
||||
(uint8_t)(APP_VERSION_SUB1),
|
||||
(uint8_t)(APP_VERSION_SUB2));
|
||||
|
||||
/* Get MW SubGhz_Phy info */
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "MW_RADIO_VERSION: V%X.%X.%X\r\n",
|
||||
(uint8_t)(SUBGHZ_PHY_VERSION_MAIN),
|
||||
(uint8_t)(SUBGHZ_PHY_VERSION_SUB1),
|
||||
(uint8_t)(SUBGHZ_PHY_VERSION_SUB2));
|
||||
|
||||
/* Led Timers*/
|
||||
UTIL_TIMER_Create(&timerLed, LED_PERIOD_MS, UTIL_TIMER_ONESHOT, OnledEvent, NULL);
|
||||
UTIL_TIMER_Start(&timerLed);
|
||||
/* USER CODE END SubghzApp_Init_1 */
|
||||
|
||||
/* Radio initialization */
|
||||
RadioEvents.TxDone = OnTxDone;
|
||||
RadioEvents.RxDone = OnRxDone;
|
||||
RadioEvents.TxTimeout = OnTxTimeout;
|
||||
RadioEvents.RxTimeout = OnRxTimeout;
|
||||
RadioEvents.RxError = OnRxError;
|
||||
|
||||
Radio.Init(&RadioEvents);
|
||||
|
||||
/* USER CODE BEGIN SubghzApp_Init_2 */
|
||||
/*calculate random delay for synchronization*/
|
||||
random_delay = (Radio.Random()) >> 22; /*10bits random e.g. from 0 to 1023 ms*/
|
||||
|
||||
/* Radio Set frequency */
|
||||
Radio.SetChannel(RF_FREQUENCY);
|
||||
|
||||
/* Radio configuration */
|
||||
#if ((USE_MODEM_LORA == 1) && (USE_MODEM_FSK == 0))
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "---------------\n\r");
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "LORA_MODULATION\n\r");
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "LORA_BW=%d kHz\n\r", (1 << LORA_BANDWIDTH) * 125);
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "LORA_SF=%d\n\r", LORA_SPREADING_FACTOR);
|
||||
|
||||
Radio.SetTxConfig(MODEM_LORA, TX_OUTPUT_POWER, 0, LORA_BANDWIDTH,
|
||||
LORA_SPREADING_FACTOR, LORA_CODINGRATE,
|
||||
LORA_PREAMBLE_LENGTH, LORA_FIX_LENGTH_PAYLOAD_ON,
|
||||
true, 0, 0, LORA_IQ_INVERSION_ON, TX_TIMEOUT_VALUE);
|
||||
|
||||
Radio.SetRxConfig(MODEM_LORA, LORA_BANDWIDTH, LORA_SPREADING_FACTOR,
|
||||
LORA_CODINGRATE, 0, LORA_PREAMBLE_LENGTH,
|
||||
LORA_SYMBOL_TIMEOUT, LORA_FIX_LENGTH_PAYLOAD_ON,
|
||||
0, true, 0, 0, LORA_IQ_INVERSION_ON, true);
|
||||
|
||||
Radio.SetMaxPayloadLength(MODEM_LORA, MAX_APP_BUFFER_SIZE);
|
||||
|
||||
#elif ((USE_MODEM_LORA == 0) && (USE_MODEM_FSK == 1))
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "---------------\n\r");
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "FSK_MODULATION\n\r");
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "FSK_BW=%d Hz\n\r", FSK_BANDWIDTH);
|
||||
APP_LOG(TS_OFF, VLEVEL_M, "FSK_DR=%d bits/s\n\r", FSK_DATARATE);
|
||||
|
||||
Radio.SetTxConfig(MODEM_FSK, TX_OUTPUT_POWER, FSK_FDEV, 0,
|
||||
FSK_DATARATE, 0,
|
||||
FSK_PREAMBLE_LENGTH, FSK_FIX_LENGTH_PAYLOAD_ON,
|
||||
true, 0, 0, 0, TX_TIMEOUT_VALUE);
|
||||
|
||||
Radio.SetRxConfig(MODEM_FSK, FSK_BANDWIDTH, FSK_DATARATE,
|
||||
0, FSK_AFC_BANDWIDTH, FSK_PREAMBLE_LENGTH,
|
||||
0, FSK_FIX_LENGTH_PAYLOAD_ON, 0, true,
|
||||
0, 0, false, true);
|
||||
|
||||
Radio.SetMaxPayloadLength(MODEM_FSK, MAX_APP_BUFFER_SIZE);
|
||||
|
||||
#else
|
||||
#error "Please define a modulation in the subghz_phy_app.h file."
|
||||
#endif /* USE_MODEM_LORA | USE_MODEM_FSK */
|
||||
/* LED initialization*/
|
||||
BSP_LED_Init(LED_GREEN);
|
||||
BSP_LED_Init(LED_RED);
|
||||
BSP_LED_Init(LED_BLUE);
|
||||
BSP_PB_Init(BUTTON_SW1, BUTTON_MODE_EXTI);
|
||||
/*fills tx buffer*/
|
||||
memset(BufferTx, 0x0, MAX_APP_BUFFER_SIZE);
|
||||
|
||||
APP_LOG(TS_ON, VLEVEL_L, "rand=%d\n\r", random_delay);
|
||||
/*starts reception*/
|
||||
Radio.Rx(RX_TIMEOUT_VALUE + random_delay);
|
||||
|
||||
/*register task to to be run in while(1) after Radio IT*/
|
||||
UTIL_SEQ_RegTask((1 << CFG_SEQ_Task_SubGHz_Phy_App_Process), UTIL_SEQ_RFU, PingPong_Process);
|
||||
/* USER CODE END SubghzApp_Init_2 */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN EF */
|
||||
|
||||
/* USER CODE END EF */
|
||||
|
||||
/* Private functions ---------------------------------------------------------*/
|
||||
static void OnTxDone(void)
|
||||
{
|
||||
/* USER CODE BEGIN OnTxDone */
|
||||
APP_LOG(TS_ON, VLEVEL_L, "OnTxDone\n\r");
|
||||
/* Update the State of the FSM*/
|
||||
State = TX;
|
||||
/* Run PingPong process in background*/
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_SubGHz_Phy_App_Process), CFG_SEQ_Prio_0);
|
||||
/* USER CODE END OnTxDone */
|
||||
}
|
||||
|
||||
static void OnRxDone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t LoraSnr_FskCfo)
|
||||
{
|
||||
/* USER CODE BEGIN OnRxDone */
|
||||
APP_LOG(TS_ON, VLEVEL_L, "OnRxDone\n\r");
|
||||
#if ((USE_MODEM_LORA == 1) && (USE_MODEM_FSK == 0))
|
||||
APP_LOG(TS_ON, VLEVEL_L, "RssiValue=%d dBm, SnrValue=%ddB\n\r", rssi, LoraSnr_FskCfo);
|
||||
/* Record payload Signal to noise ratio in Lora*/
|
||||
SnrValue = LoraSnr_FskCfo;
|
||||
#endif /* USE_MODEM_LORA | USE_MODEM_FSK */
|
||||
#if ((USE_MODEM_LORA == 0) && (USE_MODEM_FSK == 1))
|
||||
APP_LOG(TS_ON, VLEVEL_L, "RssiValue=%d dBm, Cfo=%dkHz\n\r", rssi, LoraSnr_FskCfo);
|
||||
SnrValue = 0; /*not applicable in GFSK*/
|
||||
#endif /* USE_MODEM_LORA | USE_MODEM_FSK */
|
||||
/* Update the State of the FSM*/
|
||||
State = RX;
|
||||
/* Clear BufferRx*/
|
||||
memset(BufferRx, 0, MAX_APP_BUFFER_SIZE);
|
||||
/* Record payload size*/
|
||||
RxBufferSize = size;
|
||||
if (RxBufferSize <= MAX_APP_BUFFER_SIZE)
|
||||
{
|
||||
memcpy(BufferRx, payload, RxBufferSize);
|
||||
}
|
||||
/* Record Received Signal Strength*/
|
||||
RssiValue = rssi;
|
||||
/* Record payload content*/
|
||||
APP_LOG(TS_ON, VLEVEL_H, "payload. size=%d \n\r", size);
|
||||
for (int i = 0; i < PAYLOAD_LEN; i++)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "%02X", BufferRx[i]);
|
||||
if (i % 16 == 15)
|
||||
{
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "\n\r");
|
||||
}
|
||||
}
|
||||
APP_LOG(TS_OFF, VLEVEL_H, "\n\r");
|
||||
/* Run PingPong process in background*/
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_SubGHz_Phy_App_Process), CFG_SEQ_Prio_0);
|
||||
/* USER CODE END OnRxDone */
|
||||
}
|
||||
|
||||
static void OnTxTimeout(void)
|
||||
{
|
||||
/* USER CODE BEGIN OnTxTimeout */
|
||||
APP_LOG(TS_ON, VLEVEL_L, "OnTxTimeout\n\r");
|
||||
/* Update the State of the FSM*/
|
||||
State = TX_TIMEOUT;
|
||||
/* Run PingPong process in background*/
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_SubGHz_Phy_App_Process), CFG_SEQ_Prio_0);
|
||||
/* USER CODE END OnTxTimeout */
|
||||
}
|
||||
|
||||
static void OnRxTimeout(void)
|
||||
{
|
||||
/* USER CODE BEGIN OnRxTimeout */
|
||||
APP_LOG(TS_ON, VLEVEL_L, "OnRxTimeout\n\r");
|
||||
/* Update the State of the FSM*/
|
||||
State = RX_TIMEOUT;
|
||||
/* Run PingPong process in background*/
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_SubGHz_Phy_App_Process), CFG_SEQ_Prio_0);
|
||||
/* USER CODE END OnRxTimeout */
|
||||
}
|
||||
|
||||
static void OnRxError(void)
|
||||
{
|
||||
/* USER CODE BEGIN OnRxError */
|
||||
APP_LOG(TS_ON, VLEVEL_L, "OnRxError\n\r");
|
||||
/* Update the State of the FSM*/
|
||||
State = RX_ERROR;
|
||||
/* Run PingPong process in background*/
|
||||
UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_SubGHz_Phy_App_Process), CFG_SEQ_Prio_0);
|
||||
/* USER CODE END OnRxError */
|
||||
}
|
||||
|
||||
/* USER CODE BEGIN PrFD */
|
||||
static void PingPong_Process(void)
|
||||
{
|
||||
Radio.Sleep();
|
||||
|
||||
switch (State)
|
||||
{
|
||||
case RX:
|
||||
|
||||
if (isMaster == true)
|
||||
{
|
||||
if (RxBufferSize > 0)
|
||||
{
|
||||
if (strncmp((const char *)BufferRx, PONG, sizeof(PONG) - 1) == 0)
|
||||
{
|
||||
UTIL_TIMER_Stop(&timerLed);
|
||||
/* switch off green led */
|
||||
HAL_GPIO_WritePin(LED2_GPIO_Port, LED2_Pin, GPIO_PIN_RESET); /* LED_GREEN */
|
||||
/* master toggles red led */
|
||||
HAL_GPIO_TogglePin(LED3_GPIO_Port, LED3_Pin); /* LED_RED */
|
||||
/* Add delay between RX and TX */
|
||||
HAL_Delay(Radio.GetWakeupTime() + RX_TIME_MARGIN);
|
||||
/* master sends PING*/
|
||||
APP_LOG(TS_ON, VLEVEL_L, "..."
|
||||
"PING"
|
||||
"\n\r");
|
||||
APP_LOG(TS_ON, VLEVEL_L, "Master Tx start\n\r");
|
||||
memcpy(BufferTx, PING, sizeof(PING) - 1);
|
||||
Radio.Send(BufferTx, PAYLOAD_LEN);
|
||||
}
|
||||
else if (strncmp((const char *)BufferRx, PING, sizeof(PING) - 1) == 0)
|
||||
{
|
||||
/* A master already exists then become a slave */
|
||||
isMaster = false;
|
||||
APP_LOG(TS_ON, VLEVEL_L, "Slave Rx start\n\r");
|
||||
Radio.Rx(RX_TIMEOUT_VALUE);
|
||||
}
|
||||
else /* valid reception but neither a PING or a PONG message */
|
||||
{
|
||||
/* Set device as master and start again */
|
||||
isMaster = true;
|
||||
APP_LOG(TS_ON, VLEVEL_L, "Master Rx start\n\r");
|
||||
Radio.Rx(RX_TIMEOUT_VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (RxBufferSize > 0)
|
||||
{
|
||||
if (strncmp((const char *)BufferRx, PING, sizeof(PING) - 1) == 0)
|
||||
{
|
||||
UTIL_TIMER_Stop(&timerLed);
|
||||
/* switch off red led */
|
||||
HAL_GPIO_WritePin(LED3_GPIO_Port, LED3_Pin, GPIO_PIN_RESET); /* LED_RED */
|
||||
/* slave toggles green led */
|
||||
HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin); /* LED_GREEN */
|
||||
/* Add delay between RX and TX */
|
||||
HAL_Delay(Radio.GetWakeupTime() + RX_TIME_MARGIN);
|
||||
/*slave sends PONG*/
|
||||
APP_LOG(TS_ON, VLEVEL_L, "..."
|
||||
"PONG"
|
||||
"\n\r");
|
||||
APP_LOG(TS_ON, VLEVEL_L, "Slave Tx start\n\r");
|
||||
memcpy(BufferTx, PONG, sizeof(PONG) - 1);
|
||||
Radio.Send(BufferTx, PAYLOAD_LEN);
|
||||
}
|
||||
else /* valid reception but not a PING as expected */
|
||||
{
|
||||
/* Set device as master and start again */
|
||||
isMaster = true;
|
||||
APP_LOG(TS_ON, VLEVEL_L, "Master Rx start\n\r");
|
||||
Radio.Rx(RX_TIMEOUT_VALUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TX:
|
||||
APP_LOG(TS_ON, VLEVEL_L, "Rx start\n\r");
|
||||
Radio.Rx(RX_TIMEOUT_VALUE);
|
||||
break;
|
||||
case RX_TIMEOUT:
|
||||
#if defined (LOW_POWER_DISABLE) && (LOW_POWER_DISABLE == 0)
|
||||
//UTIL_TIMER_SetPeriod(&timerLed, LED_PERIOD_MS*20);
|
||||
UTIL_TIMER_Stop(&timerLed);
|
||||
BSP_LED_Off(LED_RED) ;
|
||||
BSP_LED_Off(LED_GREEN) ;
|
||||
|
||||
Radio.Sleep();
|
||||
break;
|
||||
#endif
|
||||
case RX_ERROR:
|
||||
if (isMaster == true)
|
||||
{
|
||||
/* Send the next PING frame */
|
||||
/* Add delay between RX and TX*/
|
||||
/* add random_delay to force sync between boards after some trials*/
|
||||
HAL_Delay(Radio.GetWakeupTime() + RX_TIME_MARGIN + random_delay);
|
||||
APP_LOG(TS_ON, VLEVEL_L, "Master Tx start\n\r");
|
||||
/* master sends PING*/
|
||||
memcpy(BufferTx, PING, sizeof(PING) - 1);
|
||||
Radio.Send(BufferTx, PAYLOAD_LEN);
|
||||
}
|
||||
else
|
||||
{
|
||||
APP_LOG(TS_ON, VLEVEL_L, "Slave Rx start\n\r");
|
||||
Radio.Rx(RX_TIMEOUT_VALUE);
|
||||
}
|
||||
break;
|
||||
case TX_TIMEOUT:
|
||||
APP_LOG(TS_ON, VLEVEL_L, "Slave Rx start\n\r");
|
||||
Radio.Rx(RX_TIMEOUT_VALUE);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void OnledEvent(void *context)
|
||||
{
|
||||
HAL_GPIO_TogglePin(LED2_GPIO_Port, LED2_Pin); /* LED_GREEN */
|
||||
HAL_GPIO_TogglePin(LED3_GPIO_Port, LED3_Pin); /* LED_RED */
|
||||
APP_LOG(TS_ON, VLEVEL_L, "..."
|
||||
"PONG"
|
||||
"\n\r");
|
||||
APP_LOG(TS_ON, VLEVEL_L, "Slave Tx start\n\r");
|
||||
memcpy(BufferTx, PONG, sizeof(PONG) - 1);
|
||||
Radio.Send(BufferTx, PAYLOAD_LEN);
|
||||
UTIL_TIMER_Start(&timerLed);
|
||||
}
|
||||
|
||||
/* USER CODE END PrFD */
|
||||
142
SubGHz_Phy/App/subghz_phy_app.h
Normal file
142
SubGHz_Phy/App/subghz_phy_app.h
Normal file
@ -0,0 +1,142 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file subghz_phy_app.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header of application of the SubGHz_Phy Middleware
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2022 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __SUBGHZ_PHY_APP_H__
|
||||
#define __SUBGHZ_PHY_APP_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* MODEM type: one shall be 1 the other shall be 0 */
|
||||
#define USE_MODEM_LORA 1
|
||||
#define USE_MODEM_FSK 0
|
||||
|
||||
#define REGION_US915
|
||||
//#define REGION_CN470
|
||||
#if defined( REGION_AS923 )
|
||||
|
||||
#define RF_FREQUENCY 923000000 /* Hz */
|
||||
#elif defined( REGION_AU915 )
|
||||
|
||||
#define RF_FREQUENCY 915000000 /* Hz */
|
||||
|
||||
#elif defined( REGION_CN470 )
|
||||
|
||||
#define RF_FREQUENCY 470000000 /* Hz */
|
||||
|
||||
#elif defined( REGION_CN779 )
|
||||
|
||||
#define RF_FREQUENCY 779000000 /* Hz */
|
||||
|
||||
#elif defined( REGION_EU433 )
|
||||
|
||||
#define RF_FREQUENCY 433000000 /* Hz */
|
||||
|
||||
#elif defined( REGION_EU868 )
|
||||
|
||||
#define RF_FREQUENCY 868000000 /* Hz */
|
||||
|
||||
#elif defined( REGION_KR920 )
|
||||
|
||||
#define RF_FREQUENCY 920000000 /* Hz */
|
||||
|
||||
#elif defined( REGION_IN865 )
|
||||
|
||||
#define RF_FREQUENCY 865000000 /* Hz */
|
||||
|
||||
#elif defined( REGION_US915 )
|
||||
|
||||
#define RF_FREQUENCY 915000000 /* Hz */
|
||||
|
||||
#elif defined( REGION_RU864 )
|
||||
|
||||
#define RF_FREQUENCY 864000000 /* Hz */
|
||||
|
||||
#else
|
||||
#error "Please define a frequency band in the compiler options."
|
||||
#endif /* REGION_XXxxx */
|
||||
|
||||
#define TX_OUTPUT_POWER 22 /* dBm */
|
||||
|
||||
#if (( USE_MODEM_LORA == 1 ) && ( USE_MODEM_FSK == 0 ))
|
||||
#define LORA_BANDWIDTH 0 /* [0: 125 kHz, 1: 250 kHz, 2: 500 kHz, 3: Reserved] */
|
||||
#define LORA_SPREADING_FACTOR 10 /* [SF7..SF12] */
|
||||
#define LORA_CODINGRATE 1 /* [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8] */
|
||||
#define LORA_PREAMBLE_LENGTH 8 /* Same for Tx and Rx */
|
||||
#define LORA_SYMBOL_TIMEOUT 5 /* Symbols */
|
||||
#define LORA_FIX_LENGTH_PAYLOAD_ON false
|
||||
#define LORA_IQ_INVERSION_ON false
|
||||
|
||||
#elif (( USE_MODEM_LORA == 0 ) && ( USE_MODEM_FSK == 1 ))
|
||||
|
||||
#define FSK_FDEV 25000 /* Hz */
|
||||
#define FSK_DATARATE 50000 /* bps */
|
||||
#define FSK_BANDWIDTH 50000 /* Hz */
|
||||
#define FSK_PREAMBLE_LENGTH 5 /* Same for Tx and Rx */
|
||||
#define FSK_FIX_LENGTH_PAYLOAD_ON false
|
||||
|
||||
#else
|
||||
#error "Please define a modem in the compiler subghz_phy_app.h."
|
||||
#endif /* USE_MODEM_LORA | USE_MODEM_FSK */
|
||||
|
||||
#define PAYLOAD_LEN 32
|
||||
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/**
|
||||
* @brief Init Subghz Application
|
||||
*/
|
||||
void SubghzApp_Init(void);
|
||||
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__SUBGHZ_PHY_APP_H__*/
|
||||
72
SubGHz_Phy/Target/mw_log_conf.h
Normal file
72
SubGHz_Phy/Target/mw_log_conf.h
Normal file
@ -0,0 +1,72 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file mw_log_conf.h
|
||||
* @author MCD Application Team
|
||||
* @brief Configure (enable/disable) traces for CM0
|
||||
*******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2022 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __MW_LOG_CONF_H__
|
||||
#define __MW_LOG_CONF_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32_adv_trace.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
#define MW_LOG_ENABLED
|
||||
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
#ifdef MW_LOG_ENABLED
|
||||
#define MW_LOG(TS,VL, ...) do{ {UTIL_ADV_TRACE_COND_FSend(VL, T_REG_OFF, TS, __VA_ARGS__);} }while(0)
|
||||
#else /* MW_LOG_ENABLED */
|
||||
#define MW_LOG(TS,VL, ...)
|
||||
#endif /* MW_LOG_ENABLED */
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /*__MW_LOG_CONF_H__ */
|
||||
256
SubGHz_Phy/Target/radio_board_if.c
Normal file
256
SubGHz_Phy/Target/radio_board_if.c
Normal file
@ -0,0 +1,256 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file radio_board_if.c
|
||||
* @author MCD Application Team
|
||||
* @brief This file provides an interface layer between MW and Radio Board
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2022 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "radio_board_if.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* External variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Private typedef -----------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PTD */
|
||||
|
||||
/* USER CODE END PTD */
|
||||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PD */
|
||||
|
||||
/* USER CODE END PD */
|
||||
|
||||
/* Private macro -------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PM */
|
||||
|
||||
/* USER CODE END PM */
|
||||
|
||||
/* Private variables ---------------------------------------------------------*/
|
||||
/* USER CODE BEGIN PV */
|
||||
|
||||
/* USER CODE END PV */
|
||||
|
||||
/* Private function prototypes -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PFP */
|
||||
|
||||
/* USER CODE END PFP */
|
||||
|
||||
/* Exported functions --------------------------------------------------------*/
|
||||
int32_t RBI_Init(void)
|
||||
{
|
||||
/* USER CODE BEGIN RBI_Init_1 */
|
||||
|
||||
/* USER CODE END RBI_Init_1 */
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* Important note: BSP code is board dependent
|
||||
* STM32WL_Nucleo code can be found
|
||||
* either in STM32CubeWL package under Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* or at https://github.com/STMicroelectronics/STM32CubeWL/tree/main/Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* 1/ For User boards, the BSP/STM32WLxx_Nucleo/ directory can be copied and replaced in the project. The copy must then be updated depending:
|
||||
* on board RF switch configuration (pin control, number of port etc)
|
||||
* on TCXO configuration
|
||||
* on DC/DC configuration
|
||||
* on maximum output power that the board can deliver*/
|
||||
return BSP_RADIO_Init();
|
||||
#else
|
||||
/* 2/ Or implement RBI_Init here */
|
||||
int32_t retcode = 0;
|
||||
/* USER CODE BEGIN RBI_Init_2 */
|
||||
#warning user to provide its board code or to call his board driver functions
|
||||
/* USER CODE END RBI_Init_2 */
|
||||
return retcode;
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
}
|
||||
|
||||
int32_t RBI_DeInit(void)
|
||||
{
|
||||
/* USER CODE BEGIN RBI_DeInit_1 */
|
||||
|
||||
/* USER CODE END RBI_DeInit_1 */
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* Important note: BSP code is board dependent
|
||||
* STM32WL_Nucleo code can be found
|
||||
* either in STM32CubeWL package under Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* or at https://github.com/STMicroelectronics/STM32CubeWL/tree/main/Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* 1/ For User boards, the BSP/STM32WLxx_Nucleo/ directory can be copied and replaced in the project. The copy must then be updated depending:
|
||||
* on board RF switch configuration (pin control, number of port etc)
|
||||
* on TCXO configuration
|
||||
* on DC/DC configuration
|
||||
* on maximum output power that the board can deliver*/
|
||||
return BSP_RADIO_DeInit();
|
||||
#else
|
||||
/* 2/ Or implement RBI_DeInit here */
|
||||
int32_t retcode = 0;
|
||||
/* USER CODE BEGIN RBI_DeInit_2 */
|
||||
#warning user to provide its board code or to call his board driver functions
|
||||
/* USER CODE END RBI_DeInit_2 */
|
||||
return retcode;
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
}
|
||||
|
||||
int32_t RBI_ConfigRFSwitch(RBI_Switch_TypeDef Config)
|
||||
{
|
||||
/* USER CODE BEGIN RBI_ConfigRFSwitch_1 */
|
||||
|
||||
/* USER CODE END RBI_ConfigRFSwitch_1 */
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
|
||||
/* Important note: BSP code is board dependent
|
||||
* STM32WL_Nucleo code can be found
|
||||
* either in STM32CubeWL package under Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* or at https://github.com/STMicroelectronics/STM32CubeWL/tree/main/Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* 1/ For User boards, the BSP/STM32WLxx_Nucleo/ directory can be copied and replaced in the project. The copy must then be updated depending:
|
||||
* on board RF switch configuration (pin control, number of port etc)
|
||||
* on TCXO configuration
|
||||
* on DC/DC configuration
|
||||
* on maximum output power that the board can deliver*/
|
||||
return BSP_RADIO_ConfigRFSwitch((BSP_RADIO_Switch_TypeDef) Config);
|
||||
#else
|
||||
/* 2/ Or implement RBI_ConfigRFSwitch here */
|
||||
int32_t retcode = 0;
|
||||
/* USER CODE BEGIN RBI_ConfigRFSwitch_2 */
|
||||
#warning user to provide its board code or to call his board driver functions
|
||||
/* USER CODE END RBI_ConfigRFSwitch_2 */
|
||||
return retcode;
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
}
|
||||
|
||||
int32_t RBI_GetTxConfig(void)
|
||||
{
|
||||
/* USER CODE BEGIN RBI_GetTxConfig_1 */
|
||||
|
||||
/* USER CODE END RBI_GetTxConfig_1 */
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* Important note: BSP code is board dependent
|
||||
* STM32WL_Nucleo code can be found
|
||||
* either in STM32CubeWL package under Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* or at https://github.com/STMicroelectronics/STM32CubeWL/tree/main/Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* 1/ For User boards, the BSP/STM32WLxx_Nucleo/ directory can be copied and replaced in the project. The copy must then be updated depending:
|
||||
* on board RF switch configuration (pin control, number of port etc)
|
||||
* on TCXO configuration
|
||||
* on DC/DC configuration
|
||||
* on maximum output power that the board can deliver*/
|
||||
return BSP_RADIO_GetTxConfig();
|
||||
#else
|
||||
/* 2/ Or implement RBI_GetTxConfig here */
|
||||
int32_t retcode = RBI_CONF_RFO;
|
||||
/* USER CODE BEGIN RBI_GetTxConfig_2 */
|
||||
#warning user to provide its board code or to call his board driver functions
|
||||
/* USER CODE END RBI_GetTxConfig_2 */
|
||||
return retcode;
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
}
|
||||
|
||||
int32_t RBI_IsTCXO(void)
|
||||
{
|
||||
/* USER CODE BEGIN RBI_IsTCXO_1 */
|
||||
|
||||
/* USER CODE END RBI_IsTCXO_1 */
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* Important note: BSP code is board dependent
|
||||
* STM32WL_Nucleo code can be found
|
||||
* either in STM32CubeWL package under Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* or at https://github.com/STMicroelectronics/STM32CubeWL/tree/main/Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* 1/ For User boards, the BSP/STM32WLxx_Nucleo/ directory can be copied and replaced in the project. The copy must then be updated depending:
|
||||
* on board RF switch configuration (pin control, number of port etc)
|
||||
* on TCXO configuration
|
||||
* on DC/DC configuration
|
||||
* on maximum output power that the board can deliver*/
|
||||
return BSP_RADIO_IsTCXO();
|
||||
#else
|
||||
/* 2/ Or implement RBI_IsTCXO here */
|
||||
int32_t retcode = IS_TCXO_SUPPORTED;
|
||||
/* USER CODE BEGIN RBI_IsTCXO_2 */
|
||||
#warning user to provide its board code or to call his board driver functions
|
||||
/* USER CODE END RBI_IsTCXO_2 */
|
||||
return retcode;
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
}
|
||||
|
||||
int32_t RBI_IsDCDC(void)
|
||||
{
|
||||
/* USER CODE BEGIN RBI_IsDCDC_1 */
|
||||
|
||||
/* USER CODE END RBI_IsDCDC_1 */
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* Important note: BSP code is board dependent
|
||||
* STM32WL_Nucleo code can be found
|
||||
* either in STM32CubeWL package under Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* or at https://github.com/STMicroelectronics/STM32CubeWL/tree/main/Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* 1/ For User boards, the BSP/STM32WLxx_Nucleo/ directory can be copied and replaced in the project. The copy must then be updated depending:
|
||||
* on board RF switch configuration (pin control, number of port etc)
|
||||
* on TCXO configuration
|
||||
* on DC/DC configuration
|
||||
* on maximum output power that the board can deliver*/
|
||||
return BSP_RADIO_IsDCDC();
|
||||
#else
|
||||
/* 2/ Or implement RBI_IsDCDC here */
|
||||
int32_t retcode = IS_DCDC_SUPPORTED;
|
||||
/* USER CODE BEGIN RBI_IsDCDC_2 */
|
||||
#warning user to provide its board code or to call his board driver functions
|
||||
/* USER CODE END RBI_IsDCDC_2 */
|
||||
return retcode;
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
}
|
||||
|
||||
int32_t RBI_GetRFOMaxPowerConfig(RBI_RFOMaxPowerConfig_TypeDef Config)
|
||||
{
|
||||
/* USER CODE BEGIN RBI_GetRFOMaxPowerConfig_1 */
|
||||
|
||||
/* USER CODE END RBI_GetRFOMaxPowerConfig_1 */
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* Important note: BSP code is board dependent
|
||||
* STM32WL_Nucleo code can be found
|
||||
* either in STM32CubeWL package under Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* or at https://github.com/STMicroelectronics/STM32CubeWL/tree/main/Drivers/BSP/STM32WLxx_Nucleo/
|
||||
* 1/ For User boards, the BSP/STM32WLxx_Nucleo/ directory can be copied and replaced in the project. The copy must then be updated depending:
|
||||
* on board RF switch configuration (pin control, number of port etc)
|
||||
* on TCXO configuration
|
||||
* on DC/DC configuration
|
||||
* on maximum output power that the board can deliver*/
|
||||
return BSP_RADIO_GetRFOMaxPowerConfig((BSP_RADIO_RFOMaxPowerConfig_TypeDef) Config);
|
||||
#else
|
||||
/* 2/ Or implement RBI_RBI_GetRFOMaxPowerConfig here */
|
||||
int32_t ret = 0;
|
||||
/* USER CODE BEGIN RBI_GetRFOMaxPowerConfig_2 */
|
||||
#warning user to provide its board code or to call his board driver functions
|
||||
if (Config == RBI_RFO_LP_MAXPOWER)
|
||||
{
|
||||
ret = 15; /*dBm*/
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = 22; /*dBm*/
|
||||
}
|
||||
/* USER CODE END RBI_GetRFOMaxPowerConfig_2 */
|
||||
return ret;
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
}
|
||||
/* USER CODE BEGIN EF */
|
||||
|
||||
/* USER CODE END EF */
|
||||
|
||||
/* Private Functions Definition -----------------------------------------------*/
|
||||
/* USER CODE BEGIN PrFD */
|
||||
|
||||
/* USER CODE END PrFD */
|
||||
223
SubGHz_Phy/Target/radio_board_if.h
Normal file
223
SubGHz_Phy/Target/radio_board_if.h
Normal file
@ -0,0 +1,223 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file radio_board_if.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header for Radio interface configuration
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2022 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef RADIO_BOARD_IF_H
|
||||
#define RADIO_BOARD_IF_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "platform.h"
|
||||
/* USER CODE BEGIN include */
|
||||
|
||||
/* USER CODE END include */
|
||||
|
||||
/* Exported defines ----------------------------------------------------------*/
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* code generated by STM32CubeMX does not support BSP */
|
||||
/* In order to use BSP driver, add the correspondent files in the IDE workspace */
|
||||
/* and define USE_BSP_DRIVER in the preprocessor definitions or in platform.h */
|
||||
#define RBI_CONF_RFO_LP_HP RADIO_CONF_RFO_LP_HP
|
||||
#define RBI_CONF_RFO_LP RADIO_CONF_RFO_LP
|
||||
#define RBI_CONF_RFO_HP RADIO_CONF_RFO_HP
|
||||
#else
|
||||
/* USER CODE BEGIN Board Definition */
|
||||
|
||||
/* USER CODE END Board Definition */
|
||||
#define RBI_CONF_RFO_LP_HP 0
|
||||
#define RBI_CONF_RFO_LP 1
|
||||
#define RBI_CONF_RFO_HP 2
|
||||
/* USER CODE BEGIN Board Definition_2 */
|
||||
|
||||
/* USER CODE END Board Definition_2 */
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* code generated by STM32CubeMX does not support BSP */
|
||||
/* In order to use BSP driver, add the correspondent files in the IDE workspace */
|
||||
/* and define USE_BSP_DRIVER in the preprocessor definitions or in platform.h */
|
||||
|
||||
#else
|
||||
/* USER CODE BEGIN Exported Parameters */
|
||||
|
||||
/* USER CODE END Exported Parameters */
|
||||
/* Indicates the type of switch between the ones proposed by CONFIG Constants
|
||||
*/
|
||||
#define RBI_CONF_RFO RBI_CONF_RFO_LP_HP
|
||||
|
||||
/* Indicates whether or not TCXO is supported by the board
|
||||
* 0: TCXO not supported
|
||||
* 1: TCXO supported
|
||||
*/
|
||||
#define IS_TCXO_SUPPORTED 1U
|
||||
|
||||
/* Indicates whether or not DCDC is supported by the board
|
||||
* 0: DCDC not supported
|
||||
* 1: DCDC supported
|
||||
*/
|
||||
#define IS_DCDC_SUPPORTED 1U
|
||||
|
||||
/* USER CODE BEGIN Exported Parameters_2 */
|
||||
|
||||
/* USER CODE END Exported Parameters_2 */
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* code generated by STM32CubeMX does not support BSP */
|
||||
/* In order to use BSP driver, add the correspondent files in the IDE workspace */
|
||||
/* and define USE_BSP_DRIVER in the preprocessor definitions or in platform.h */
|
||||
|
||||
#else
|
||||
/* USER CODE BEGIN Exported PinMapping */
|
||||
#warning user to provide its board definitions pins
|
||||
/* USER CODE END Exported PinMapping */
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
|
||||
/* USER CODE BEGIN ED */
|
||||
|
||||
/* USER CODE END ED */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
|
||||
#if defined(USE_BSP_DRIVER)
|
||||
/* code generated by STM32CubeMX does not support BSP */
|
||||
/* In order to use BSP driver, add the correspondent files in the IDE workspace */
|
||||
/* and define USE_BSP_DRIVER in the preprocessor definitions or in platform.h */
|
||||
typedef enum
|
||||
{
|
||||
RBI_SWITCH_OFF = RADIO_SWITCH_OFF,
|
||||
RBI_SWITCH_RX = RADIO_SWITCH_RX,
|
||||
RBI_SWITCH_RFO_LP = RADIO_SWITCH_RFO_LP,
|
||||
RBI_SWITCH_RFO_HP = RADIO_SWITCH_RFO_HP,
|
||||
} RBI_Switch_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
RBI_RFO_LP_MAXPOWER = RADIO_RFO_LP_MAXPOWER,
|
||||
RBI_RFO_HP_MAXPOWER = RADIO_RFO_HP_MAXPOWER,
|
||||
} RBI_RFOMaxPowerConfig_TypeDef;
|
||||
|
||||
#else
|
||||
/* USER CODE BEGIN Exported Types */
|
||||
|
||||
/* USER CODE END Exported Types */
|
||||
typedef enum
|
||||
{
|
||||
RBI_SWITCH_OFF = 0,
|
||||
RBI_SWITCH_RX = 1,
|
||||
RBI_SWITCH_RFO_LP = 2,
|
||||
RBI_SWITCH_RFO_HP = 3,
|
||||
} RBI_Switch_TypeDef;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
RBI_RFO_LP_MAXPOWER = 0,
|
||||
RBI_RFO_HP_MAXPOWER = 1,
|
||||
} RBI_RFOMaxPowerConfig_TypeDef;
|
||||
/* USER CODE BEGIN Exported Types_2 */
|
||||
|
||||
/* USER CODE END Exported Types_2 */
|
||||
#endif /* USE_BSP_DRIVER */
|
||||
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions ------------------------------------------------------- */
|
||||
/**
|
||||
* @brief Init Radio Switch
|
||||
* @return BSP status
|
||||
*/
|
||||
int32_t RBI_Init(void);
|
||||
|
||||
/**
|
||||
* @brief DeInit Radio Switch
|
||||
* @return BSP status
|
||||
*/
|
||||
int32_t RBI_DeInit(void);
|
||||
|
||||
/**
|
||||
* @brief Configure Radio Switch.
|
||||
* @param Config: Specifies the Radio RF switch path to be set.
|
||||
* This parameter can be one of following parameters:
|
||||
* @arg RADIO_SWITCH_OFF
|
||||
* @arg RADIO_SWITCH_RX
|
||||
* @arg RADIO_SWITCH_RFO_LP
|
||||
* @arg RADIO_SWITCH_RFO_HP
|
||||
* @return BSP status
|
||||
*/
|
||||
int32_t RBI_ConfigRFSwitch(RBI_Switch_TypeDef Config);
|
||||
|
||||
/**
|
||||
* @brief Return Board Configuration
|
||||
* @retval RBI_CONF_RFO_LP_HP
|
||||
* @retval RBI_CONF_RFO_LP
|
||||
* @retval RBI_CONF_RFO_HP
|
||||
*/
|
||||
int32_t RBI_GetTxConfig(void);
|
||||
|
||||
/**
|
||||
* @brief Get If TCXO is to be present on board
|
||||
* @note never remove called by MW,
|
||||
* @retval return 1 if present, 0 if not present
|
||||
*/
|
||||
int32_t RBI_IsTCXO(void);
|
||||
|
||||
/**
|
||||
* @brief Get If DCDC is to be present on board
|
||||
* @note never remove called by MW,
|
||||
* @retval return 1 if present, 0 if not present
|
||||
*/
|
||||
int32_t RBI_IsDCDC(void);
|
||||
|
||||
/**
|
||||
* @brief Return RF Output Max Power Configuration of matching circuit
|
||||
* @note never remove called by MW,
|
||||
* @retval return Max Power configuration of matching circuit for Low Power or High Power mode in dBm
|
||||
*/
|
||||
int32_t RBI_GetRFOMaxPowerConfig(RBI_RFOMaxPowerConfig_TypeDef Config);
|
||||
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* RADIO_BOARD_IF_H */
|
||||
151
SubGHz_Phy/Target/radio_conf.h
Normal file
151
SubGHz_Phy/Target/radio_conf.h
Normal file
@ -0,0 +1,151 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file radio_conf.h
|
||||
* @author MCD Application Team
|
||||
* @brief Header of Radio configuration
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2022 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __RADIO_CONF_H__
|
||||
#define __RADIO_CONF_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "platform.h"
|
||||
#include "subghz.h"
|
||||
#include "stm32_mem.h" /* RADIO_MEMSET8 def in this file */
|
||||
#include "mw_log_conf.h" /* mw trace conf */
|
||||
#include "radio_board_if.h" /* low layer api (bsp) */
|
||||
#include "utilities_def.h" /* low layer api (bsp) */
|
||||
#include "sys_debug.h"
|
||||
/* USER CODE BEGIN include */
|
||||
|
||||
/* USER CODE END include */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* @brief drive value used anytime radio is NOT in TX low power mode
|
||||
* @note override the default configuration of radio_driver.c
|
||||
*/
|
||||
#define SMPS_DRIVE_SETTING_DEFAULT SMPS_DRV_40
|
||||
|
||||
/**
|
||||
* @brief drive value used anytime radio is in TX low power mode
|
||||
* TX low power mode is the worst case because the PA sinks from SMPS
|
||||
* while in high power mode, current is sunk directly from the battery
|
||||
* @note override the default configuration of radio_driver.c
|
||||
*/
|
||||
#define SMPS_DRIVE_SETTING_MAX SMPS_DRV_60
|
||||
|
||||
/**
|
||||
* @brief Provides the frequency of the chip running on the radio and the frequency step
|
||||
* @remark These defines are used for computing the frequency divider to set the RF frequency
|
||||
* @note override the default configuration of radio_driver.c
|
||||
*/
|
||||
#define XTAL_FREQ ( 32000000UL )
|
||||
|
||||
/**
|
||||
* @brief in XO mode, set internal capacitor (from 0x00 to 0x2F starting 11.2pF with 0.47pF steps)
|
||||
* @note override the default configuration of radio_driver.c
|
||||
*/
|
||||
#define XTAL_DEFAULT_CAP_VALUE ( 0x20UL )
|
||||
|
||||
/**
|
||||
* @brief voltage of vdd tcxo.
|
||||
* @note override the default configuration of radio_driver.c
|
||||
*/
|
||||
#define TCXO_CTRL_VOLTAGE TCXO_CTRL_1_7V
|
||||
|
||||
/**
|
||||
* @brief Radio maximum wakeup time (in ms)
|
||||
* @note override the default configuration of radio_driver.c
|
||||
*/
|
||||
#define RF_WAKEUP_TIME ( 1UL )
|
||||
|
||||
/**
|
||||
* @brief DCDC is enabled
|
||||
* @remark this define is only used if the DCDC is present on the board
|
||||
* @note override the default configuration of radio_driver.c
|
||||
*/
|
||||
#define DCDC_ENABLE ( 1UL )
|
||||
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macros -----------------------------------------------------------*/
|
||||
#ifndef CRITICAL_SECTION_BEGIN
|
||||
/**
|
||||
* @brief macro used to enter the critical section
|
||||
*/
|
||||
#define CRITICAL_SECTION_BEGIN( ) UTILS_ENTER_CRITICAL_SECTION( )
|
||||
#endif /* !CRITICAL_SECTION_BEGIN */
|
||||
#ifndef CRITICAL_SECTION_END
|
||||
/**
|
||||
* @brief macro used to exit the critical section
|
||||
*/
|
||||
#define CRITICAL_SECTION_END( ) UTILS_EXIT_CRITICAL_SECTION( )
|
||||
#endif /* !CRITICAL_SECTION_END */
|
||||
|
||||
/* Function mapping */
|
||||
/**
|
||||
* @brief SUBGHZ interface init to radio Middleware
|
||||
*/
|
||||
#define RADIO_INIT MX_SUBGHZ_Init
|
||||
|
||||
/**
|
||||
* @brief Delay interface to radio Middleware
|
||||
*/
|
||||
#define RADIO_DELAY_MS HAL_Delay
|
||||
|
||||
/**
|
||||
* @brief Memset utilities interface to radio Middleware
|
||||
*/
|
||||
#define RADIO_MEMSET8( dest, value, size ) UTIL_MEM_set_8( dest, value, size )
|
||||
|
||||
/**
|
||||
* @brief Memcpy utilities interface to radio Middleware
|
||||
*/
|
||||
#define RADIO_MEMCPY8( dest, src, size ) UTIL_MEM_cpy_8( dest, src, size )
|
||||
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __RADIO_CONF_H__*/
|
||||
117
SubGHz_Phy/Target/timer.h
Normal file
117
SubGHz_Phy/Target/timer.h
Normal file
@ -0,0 +1,117 @@
|
||||
/* USER CODE BEGIN Header */
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file timer.h
|
||||
* @author MCD Application Team
|
||||
* @brief Wrapper to timer server
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* Copyright (c) 2022 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.
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
/* USER CODE END Header */
|
||||
|
||||
/* Define to prevent recursive inclusion -------------------------------------*/
|
||||
#ifndef __TIMER_H__
|
||||
#define __TIMER_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "stm32_timer.h"
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
||||
/* USER CODE END Includes */
|
||||
|
||||
/* Exported types ------------------------------------------------------------*/
|
||||
/* USER CODE BEGIN ET */
|
||||
|
||||
/* USER CODE END ET */
|
||||
|
||||
/* Exported constants --------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Max timer mask
|
||||
*/
|
||||
#define TIMERTIME_T_MAX ( ( uint32_t )~0 )
|
||||
|
||||
/* USER CODE BEGIN EC */
|
||||
|
||||
/* USER CODE END EC */
|
||||
|
||||
/* External variables --------------------------------------------------------*/
|
||||
/* USER CODE BEGIN EV */
|
||||
|
||||
/* USER CODE END EV */
|
||||
|
||||
/* Exported macro ------------------------------------------------------------*/
|
||||
/**
|
||||
* @brief Timer value on 32 bits
|
||||
*/
|
||||
#define TimerTime_t UTIL_TIMER_Time_t
|
||||
|
||||
/**
|
||||
* @brief Timer object description
|
||||
*/
|
||||
#define TimerEvent_t UTIL_TIMER_Object_t
|
||||
|
||||
/**
|
||||
* @brief Create the timer object
|
||||
*/
|
||||
#define TimerInit(HANDLE, CB) do {\
|
||||
UTIL_TIMER_Create( HANDLE, TIMERTIME_T_MAX, UTIL_TIMER_ONESHOT, CB, NULL);\
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief update the period and start the timer
|
||||
*/
|
||||
#define TimerSetValue(HANDLE, TIMEOUT) do{ \
|
||||
UTIL_TIMER_SetPeriod(HANDLE, TIMEOUT);\
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief Start and adds the timer object to the list of timer events
|
||||
*/
|
||||
#define TimerStart(HANDLE) do {\
|
||||
UTIL_TIMER_Start(HANDLE);\
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief Stop and removes the timer object from the list of timer events
|
||||
*/
|
||||
#define TimerStop(HANDLE) do {\
|
||||
UTIL_TIMER_Stop(HANDLE);\
|
||||
} while(0)
|
||||
|
||||
/**
|
||||
* @brief return the current time
|
||||
*/
|
||||
#define TimerGetCurrentTime UTIL_TIMER_GetCurrentTime
|
||||
|
||||
/**
|
||||
* @brief return the elapsed time
|
||||
*/
|
||||
#define TimerGetElapsedTime UTIL_TIMER_GetElapsedTime
|
||||
|
||||
/* USER CODE BEGIN EM */
|
||||
|
||||
/* USER CODE END EM */
|
||||
|
||||
/* Exported functions prototypes ---------------------------------------------*/
|
||||
/* USER CODE BEGIN EFP */
|
||||
|
||||
/* USER CODE END EFP */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __TIMER_H__*/
|
||||
Reference in New Issue
Block a user