This commit is contained in:
2025-03-19 11:06:57 +08:00
commit 49f5db3a10
1343 changed files with 599230 additions and 0 deletions

View File

@ -0,0 +1,27 @@
The Clear BSD License
Copyright Semtech Corporation 2021. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted (subject to the limitations in the disclaimer
below) provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the Semtech corporation nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY
THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SEMTECH CORPORATION BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1,6 @@
This software component is provided to you as part of a software package and
applicable license terms are in the Package_license file. If you received this
software component outside of a package or without applicable license terms,
the terms of the BSD-3-Clause license shall apply.
You may obtain a copy of the BSD-3-Clause at:
https://opensource.org/licenses/BSD-3-Clause

View File

@ -0,0 +1,488 @@
/*!
* \file radio.h
*
* \brief Radio driver API definition
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2017 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*
* \author Gregory Cristian ( Semtech )
*/
/**
******************************************************************************
*
* Portions COPYRIGHT 2020 STMicroelectronics
*
* @file radio.h
* @author MCD Application Team
* @brief Radio driver API definition
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __RADIO_H__
#define __RADIO_H__
#ifdef __cplusplus
extern "C"
{
#endif
/* Includes ------------------------------------------------------------------*/
#include <stdint.h>
#include <stdbool.h>
/* Private typedef -----------------------------------------------------------*/
/*!
* Radio driver supported modems
*/
typedef enum
{
MODEM_FSK = 0,
MODEM_LORA,
MODEM_MSK,
/* ST_WORKAROUND_BEGIN: Upgraded modulations list */
MODEM_BPSK,
MODEM_SIGFOX_TX,
MODEM_SIGFOX_RX,
/* ST_WORKAROUND_END */
}RadioModems_t;
/*!
* Radio driver internal state machine states definition
*/
typedef enum
{
RF_IDLE = 0, //!< The radio is idle
RF_RX_RUNNING, //!< The radio is in reception state
RF_TX_RUNNING, //!< The radio is in transmission state
RF_CAD, //!< The radio is doing channel activity detection
}RadioState_t;
/*!
* \brief Radio driver callback functions
*/
typedef struct
{
/*!
* \brief Tx Done callback prototype.
*/
void ( *TxDone )( void );
/*!
* \brief Tx Timeout callback prototype.
*/
void ( *TxTimeout )( void );
/*!
* \brief Rx Done callback prototype.
*
* \param [in] payload Received buffer pointer
* \param [in] size Received buffer size
* \param [in] rssi RSSI value computed while receiving the frame [dBm]
* \param [in] LoraSnr_FskCfo
* FSK : Carrier Frequency Offset in kHz
* LoRa: SNR value in dB
*/
void ( *RxDone )( uint8_t *payload, uint16_t size, int16_t rssi, int8_t LoraSnr_FskCfo );
/*!
* \brief Rx Timeout callback prototype.
*/
void ( *RxTimeout )( void );
/*!
* \brief Rx Error callback prototype.
*/
void ( *RxError )( void );
/*!
* \brief FHSS Change Channel callback prototype.
*
* \param [in] currentChannel Index number of the current channel
*/
void ( *FhssChangeChannel )( uint8_t currentChannel );
/*!
* \brief CAD Done callback prototype.
*
* \param [in] channelDetected Channel Activity detected during the CAD
*/
void ( *CadDone ) ( bool channelActivityDetected );
}RadioEvents_t;
#include "radio_ex.h" /* ST_WORKAROUND: extended radio functions */
/*!
* \brief Radio driver definition
*/
struct Radio_s
{
/*!
* \brief Initializes the radio
*
* \param [in] events Structure containing the driver callback functions
*/
void ( *Init )( RadioEvents_t *events );
/*!
* Return current radio status
*
* \return status Radio status.[RF_IDLE, RF_RX_RUNNING, RF_TX_RUNNING]
*/
RadioState_t ( *GetStatus )( void );
/*!
* \brief Configures the radio with the given modem
*
* \param [in] modem Modem to be used [0: FSK, 1: LoRa]
*/
void ( *SetModem )( RadioModems_t modem );
/*!
* \brief Sets the channel frequency
*
* \param [in] freq Channel RF frequency
*/
void ( *SetChannel )( uint32_t freq );
/*!
* \brief Checks if the channel is free for the given time
*
* \remark The FSK modem is always used for this task as we can select the Rx bandwidth at will.
*
* \param [in] freq Channel RF frequency in Hertz
* \param [in] rxBandwidth Rx bandwidth in Hertz
* \param [in] rssiThresh RSSI threshold in dBm
* \param [in] maxCarrierSenseTime Max time in milliseconds while the RSSI is measured
*
* \retval isFree [true: Channel is free, false: Channel is not free]
*/
bool ( *IsChannelFree )( uint32_t freq, uint32_t rxBandwidth, int16_t rssiThresh, uint32_t maxCarrierSenseTime );
/*!
* \brief Generates a 32 bits random value based on the RSSI readings
*
* \remark This function sets the radio in LoRa modem mode and disables
* all interrupts.
* After calling this function either Radio.SetRxConfig or
* Radio.SetTxConfig functions must be called.
*
* \retval randomValue 32 bits random value
*/
uint32_t ( *Random )( void );
/*!
* \brief Sets the reception parameters
*
* \param [in] modem Radio modem to be used [0: FSK, 1: LoRa]
* \param [in] bandwidth Sets the bandwidth
* FSK : >= 2600 and <= 250000 Hz
* LoRa: [0: 125 kHz, 1: 250 kHz,
* 2: 500 kHz, 3: Reserved]
* \param [in] datarate Sets the Datarate
* FSK : 600..300000 bits/s
* LoRa: [6: 64, 7: 128, 8: 256, 9: 512,
* 10: 1024, 11: 2048, 12: 4096 chips]
* \param [in] coderate Sets the coding rate (LoRa only)
* FSK : N/A ( set to 0 )
* LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
* \param [in] bandwidthAfc Sets the AFC Bandwidth (FSK only)
* FSK : >= 2600 and <= 250000 Hz
* LoRa: N/A ( set to 0 )
* \param [in] preambleLen Sets the Preamble length
* FSK : Number of bytes
* LoRa: Length in symbols (the hardware adds 4 more symbols)
* \param [in] symbTimeout Sets the RxSingle timeout value
* FSK : timeout in number of bytes
* LoRa: timeout in symbols
* \param [in] fixLen Fixed length packets [0: variable, 1: fixed]
* \param [in] payloadLen Sets payload length when fixed length is used
* \param [in] crcOn Enables/Disables the CRC [0: OFF, 1: ON]
* \param [in] freqHopOn Enables disables the intra-packet frequency hopping
* FSK : N/A ( set to 0 )
* LoRa: [0: OFF, 1: ON]
* \param [in] hopPeriod Number of symbols between each hop
* FSK : N/A ( set to 0 )
* LoRa: Number of symbols
* \param [in] iqInverted Inverts IQ signals (LoRa only)
* FSK : N/A ( set to 0 )
* LoRa: [0: not inverted, 1: inverted]
* \param [in] rxContinuous Sets the reception in continuous mode
* [false: single mode, true: continuous mode]
*/
void ( *SetRxConfig )( RadioModems_t modem, uint32_t bandwidth,
uint32_t datarate, uint8_t coderate,
uint32_t bandwidthAfc, uint16_t preambleLen,
uint16_t symbTimeout, bool fixLen,
uint8_t payloadLen,
bool crcOn, bool freqHopOn, uint8_t hopPeriod,
bool iqInverted, bool rxContinuous );
/*!
* \brief Sets the transmission parameters
*
* \param [in] modem Radio modem to be used [0: FSK, 1: LoRa]
* \param [in] power Sets the output power [dBm]
* \param [in] fdev Sets the frequency deviation (FSK only)
* FSK : [Hz]
* LoRa: 0
* \param [in] bandwidth Sets the bandwidth (LoRa only)
* FSK : 0
* LoRa: [0: 125 kHz, 1: 250 kHz,
* 2: 500 kHz, 3: Reserved]
* \param [in] datarate Sets the Datarate
* FSK : 600..300000 bits/s
* LoRa: [6: 64, 7: 128, 8: 256, 9: 512,
* 10: 1024, 11: 2048, 12: 4096 chips]
* \param [in] coderate Sets the coding rate (LoRa only)
* FSK : N/A ( set to 0 )
* LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
* \param [in] preambleLen Sets the preamble length
* FSK : Number of bytes
* LoRa: Length in symbols (the hardware adds 4 more symbols)
* \param [in] fixLen Fixed length packets [0: variable, 1: fixed]
* \param [in] crcOn Enables disables the CRC [0: OFF, 1: ON]
* \param [in] freqHopOn Enables disables the intra-packet frequency hopping
* FSK : N/A ( set to 0 )
* LoRa: [0: OFF, 1: ON]
* \param [in] hopPeriod Number of symbols between each hop
* FSK : N/A ( set to 0 )
* LoRa: Number of symbols
* \param [in] iqInverted Inverts IQ signals (LoRa only)
* FSK : N/A ( set to 0 )
* LoRa: [0: not inverted, 1: inverted]
* \param [in] timeout Transmission timeout [ms]
*/
void ( *SetTxConfig )( RadioModems_t modem, int8_t power, uint32_t fdev,
uint32_t bandwidth, uint32_t datarate,
uint8_t coderate, uint16_t preambleLen,
bool fixLen, bool crcOn, bool freqHopOn,
uint8_t hopPeriod, bool iqInverted, uint32_t timeout );
/*!
* \brief Checks if the given RF frequency is supported by the hardware
*
* \param [in] frequency RF frequency to be checked
* \retval isSupported [true: supported, false: unsupported]
*/
bool ( *CheckRfFrequency )( uint32_t frequency );
/*!
* \brief Computes the packet time on air in ms for the given payload
*
* \remark Can only be called once SetRxConfig or SetTxConfig have been called
*
* \param [in] modem Radio modem to be used [0: FSK, 1: LoRa]
* \param [in] bandwidth Sets the bandwidth
* FSK : >= 2600 and <= 250000 Hz
* LoRa: [0: 125 kHz, 1: 250 kHz,
* 2: 500 kHz, 3: Reserved]
* \param [in] datarate Sets the Datarate
* FSK : 600..300000 bits/s
* LoRa: [6: 64, 7: 128, 8: 256, 9: 512,
* 10: 1024, 11: 2048, 12: 4096 chips]
* \param [in] coderate Sets the coding rate (LoRa only)
* FSK : N/A ( set to 0 )
* LoRa: [1: 4/5, 2: 4/6, 3: 4/7, 4: 4/8]
* \param [in] preambleLen Sets the Preamble length
* FSK : Number of bytes
* LoRa: Length in symbols (the hardware adds 4 more symbols)
* \param [in] fixLen Fixed length packets [0: variable, 1: fixed]
* \param [in] payloadLen Sets payload length when fixed length is used
* \param [in] crcOn Enables/Disables the CRC [0: OFF, 1: ON]
*
* \retval airTime Computed airTime (ms) for the given packet payload length
*/
uint32_t ( *TimeOnAir )( RadioModems_t modem, uint32_t bandwidth,
uint32_t datarate, uint8_t coderate,
uint16_t preambleLen, bool fixLen, uint8_t payloadLen,
bool crcOn );
/*!
* \brief Sends the buffer of size. Prepares the packet to be sent and sets
* the radio in transmission
*
* \param [in] buffer Buffer pointer
* \param [in] size Buffer size
*/
void ( *Send )( uint8_t *buffer, uint8_t size );
/*!
* \brief Sets the radio in sleep mode
*/
void ( *Sleep )( void );
/*!
* \brief Sets the radio in standby mode
*/
void ( *Standby )( void );
/*!
* \brief Sets the radio in reception mode for the given time
* \param [in] timeout Reception timeout [ms]
* [0: continuous, others timeout]
*/
void ( *Rx )( uint32_t timeout );
/*!
* \brief Start a Channel Activity Detection
*/
void ( *StartCad )( void );
/*!
* \brief Sets the radio in continuous wave transmission mode
*
* \param [in] freq Channel RF frequency
* \param [in] power Sets the output power [dBm]
* \param [in] time Transmission mode timeout [s]
*/
void ( *SetTxContinuousWave )( uint32_t freq, int8_t power, uint16_t time );
/*!
* \brief Reads the current RSSI value
*
* \retval rssiValue Current RSSI value in [dBm]
*/
int16_t ( *Rssi )( RadioModems_t modem );
/* ST_WORKAROUND_BEGIN: Force register addr to uint16_t */
/*!
* \brief Writes the radio register at the specified address
*
* \param [in] addr Register address
* \param [in] data New register value
*/
void ( *Write )( uint16_t addr, uint8_t data );
/*!
* \brief Reads the radio register at the specified address
*
* \param [in] addr Register address
* \retval data Register value
*/
uint8_t ( *Read )( uint16_t addr );
/*!
* \brief Writes multiple radio registers starting at address
*
* \param [in] addr First Radio register address
* \param [in] buffer Buffer containing the new register's values
* \param [in] size Number of registers to be written
*/
void ( *WriteRegisters )( uint16_t addr, uint8_t *buffer, uint8_t size );
/*!
* \brief Reads multiple radio registers starting at address
*
* \param [in] addr First Radio register address
* \param [out] buffer Buffer where to copy the registers data
* \param [in] size Number of registers to be read
*/
void ( *ReadRegisters )( uint16_t addr, uint8_t *buffer, uint8_t size );
/* ST_WORKAROUND_END */
/*!
* \brief Sets the maximum payload length.
*
* \param [in] modem Radio modem to be used [0: FSK, 1: LoRa]
* \param [in] max Maximum payload length in bytes
*/
void ( *SetMaxPayloadLength )( RadioModems_t modem, uint8_t max );
/*!
* \brief Sets the network to public or private. Updates the sync byte.
*
* \remark Applies to LoRa modem only
*
* \param [in] enable if true, it enables a public network
*/
void ( *SetPublicNetwork )( bool enable );
/*!
* \brief Gets the time required for the board plus radio to get out of sleep.[ms]
*
* \retval time Radio plus board wakeup time in ms.
*/
uint32_t ( *GetWakeupTime )( void );
/*!
* \brief Process radio irq
*/
void ( *IrqProcess )( void );
/*!
* \brief Sets the radio in reception mode with Max LNA gain for the given time
*
* \param [in] timeout Reception timeout [ms]
* [0: continuous, others timeout]
*/
void ( *RxBoosted )( uint32_t timeout );
/*!
* \brief Sets the Rx duty cycle management parameters
*
* \param [in] rxTime Structure describing reception timeout value
* \param [in] sleepTime Structure describing sleep timeout value
*/
void ( *SetRxDutyCycle )( uint32_t rxTime, uint32_t sleepTime );
/* ST_WORKAROUND_BEGIN: extended radio functions */
/*!
* @brief Sets the Transmitter in continuous PRBS mode
*
* \remark power and datarate shall be configured prior calling TxPrbs
*/
void ( *TxPrbs )( void );
/*!
* \brief Sets the Transmitter in continuous un-modulated Carrier mode at power dBm
*
* \param [in] power Tx power in dBm
*/
void ( *TxCw )( int8_t power );
/*!
* \brief Sets the reception parameters
*
* \param [in] modem Radio modem to be used [GENERIC_FSK or GENERIC_FSK]
* \param [in] config configuration of receiver
* fsk field to be used if modem =GENERIC_FSK
* lora field to be used if modem =GENERIC_LORA
* \param [in] rxContinuous Sets the reception in continuous mode
* [0: single mode, otherwise continuous mode]
* \param [in] symbTimeout Sets the RxSingle timeout value
* FSK : timeout in number of bytes
* LoRa: timeout in symbols
* \return 0 when no parameters error, -1 otherwise
*/
int32_t ( *RadioSetRxGenericConfig )( GenericModems_t modem, RxConfigGeneric_t* config, uint32_t rxContinuous, uint32_t symbTimeout );
/*!
* \brief Sets the transmission parameters
*
* \param [in] modem Radio modem to be used [GENERIC_FSK or GENERIC_FSK or GENERIC_BPSK]
* \param [in] config configuration of receiver
* fsk field to be used if modem =GENERIC_FSK
* lora field to be used if modem =GENERIC_LORA
* bpsk field to be used if modem =GENERIC_BPSK
* \param [in] power Sets the output power [dBm]
* \param [in] timeout Reception timeout [ms]
* \return 0 when no parameters error, -1 otherwise
*/
int32_t ( *RadioSetTxGenericConfig )( GenericModems_t modem, TxConfigGeneric_t* config, int8_t power, uint32_t timeout );
/*!
* \brief Starts sending long Packet, packet maybe short
*
* \param [in] payload_size total payload size to be sent
* \param [in] timeout in ms
* \param [in] TxLongPacketGetNextChunkCb callback to be implemented on user side to feed partial chunk
* buffer: source buffer allocated by the app
* size: size in bytes to feed
* \return 0 when no parameters error, -1 otherwise
*/
int32_t ( *TransmitLongPacket )( uint16_t payload_size, uint32_t timeout,void (*TxLongPacketGetNextChunkCb) ( uint8_t** buffer, uint8_t buffer_size ) );
/*!
* \brief Starts receiving long Packet, packet maybe short
*
* \param [in] boosted_mode boosted_mode: 0 normal Rx, 1:improved sensitivity
* \param [in] timeout Reception timeout [ms]
* \param [in] RxLongStorePacketChunkCb callback to be implemented on user side to record partial chunk in the application
* buffer: source buffer allocated in the radio driver
* size: size in bytes to record
* \return 0 when no parameters error, -1 otherwise
*/
int32_t ( *ReceiveLongPacket )( uint8_t boosted_mode, uint32_t timeout, void (*RxLongStorePacketChunkCb) ( uint8_t* buffer, uint8_t chunk_size ) );
/* ST_WORKAROUND_END */
};
/*!
* \brief Radio driver
*
* \remark This variable is defined and initialized in the specific radio
* board implementation
*/
extern const struct Radio_s Radio;
#ifdef __cplusplus
}
#endif
#endif // __RADIO_H__

View File

@ -0,0 +1,311 @@
/**
******************************************************************************
* @file radio_ex.h
* @author MCD Application Team
* @brief Extends radio capabilities (whitening, long packet)
******************************************************************************
* @attention
*
* 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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __RADIO_EX_H__
#define __RADIO_EX_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
/*******************************************Radio LORA enum*****************************************/
typedef enum
{
GENERIC_FSK = 0,
GENERIC_LORA,
GENERIC_BPSK, /*Tx only. In this mode, only payload is generated at the antenna (e.g. preamble nor syncword is generated and must be placed into the payload*/
GENERIC_MSK, /*Tx only. For Rx, FSK must be used*/
}GenericModems_t;
/*!
* @brief Represents the possible spreading factor values in LoRa packet types
*/
typedef enum
{
RADIO_LORA_SF5 = 0x05,
RADIO_LORA_SF6 = 0x06,
RADIO_LORA_SF7 = 0x07,
RADIO_LORA_SF8 = 0x08,
RADIO_LORA_SF9 = 0x09,
RADIO_LORA_SF10 = 0x0A,
RADIO_LORA_SF11 = 0x0B,
RADIO_LORA_SF12 = 0x0C,
}RADIO_LoRaSpreadingFactors_t;
/*!
* @brief Represents the coding rate values for LoRa packet type
*/
typedef enum
{
RADIO_LORA_CR_4_5 = 0x01,
RADIO_LORA_CR_4_6 = 0x02,
RADIO_LORA_CR_4_7 = 0x03,
RADIO_LORA_CR_4_8 = 0x04,
}RADIO_LoRaCodingRates_t;
/*!
* @brief Represents the bandwidth values for LoRa packet type
*/
typedef enum
{
RADIO_LORA_BW_500 = 6,
RADIO_LORA_BW_250 = 5,
RADIO_LORA_BW_125 = 4,
RADIO_LORA_BW_062 = 3,
RADIO_LORA_BW_041 = 10,
RADIO_LORA_BW_031 = 2,
RADIO_LORA_BW_020 = 9,
RADIO_LORA_BW_015 = 1,
RADIO_LORA_BW_010 = 8,
RADIO_LORA_BW_007 = 0,
}RADIO_LoRaBandwidths_t;
/*!
* @brief Holds the lengths mode of a LoRa packet type
*/
typedef enum
{
RADIO_LORA_PACKET_VARIABLE_LENGTH = 0x00, //!< The packet is on variable size, header included
RADIO_LORA_PACKET_FIXED_LENGTH = 0x01, //!< The packet is known on both sides, no header included in the packet
RADIO_LORA_PACKET_EXPLICIT = RADIO_LORA_PACKET_VARIABLE_LENGTH,
RADIO_LORA_PACKET_IMPLICIT = RADIO_LORA_PACKET_FIXED_LENGTH,
}RADIO_LoRaPacketLengthsMode_t;
/*!
* @brief Represents the CRC mode for LoRa packet type
*/
typedef enum
{
RADIO_LORA_CRC_ON = 0x01, //!< CRC activated
RADIO_LORA_CRC_OFF = 0x00, //!< CRC not used
}RADIO_LoRaCrcModes_t;
/*!
* @brief Represents the IQ mode for LoRa packet type
*/
typedef enum
{
RADIO_LORA_IQ_NORMAL = 0x00,
RADIO_LORA_IQ_INVERTED = 0x01,
}RADIO_LoRaIQModes_t;
/*!
* @brief Represents the IQ mode for LoRa packet type
*/
typedef enum
{
RADIO_LORA_LOWDR_OPT_OFF = 0x00, /*Forced to 0*/
RADIO_LORA_LOWDR_OPT_ON = 0x01, /*Forced to 1*/
RADIO_LORA_LOWDR_OPT_AUTO = 0x02, /*Forced to 1 when SF11 or SF12, 0 otherwise*/
}RADIO_Ld_Opt_t;
/*******************************************Radio FSK enum*****************************************/
/*!
* @brief Represents the modulation shaping parameter
*/
typedef enum
{
RADIO_FSK_MOD_SHAPING_OFF = 0x00,
RADIO_FSK_MOD_SHAPING_G_BT_03 = 0x08,
RADIO_FSK_MOD_SHAPING_G_BT_05 = 0x09,
RADIO_FSK_MOD_SHAPING_G_BT_07 = 0x0A,
RADIO_FSK_MOD_SHAPING_G_BT_1 = 0x0B,
}RADIO_FSK_ModShapings_t;
/*!
* @brief Represents the preamble length used to detect the packet on Rx side
*/
typedef enum
{
RADIO_FSK_PREAMBLE_DETECTOR_OFF = 0x00, //!< Preamble detection length off
RADIO_FSK_PREAMBLE_DETECTOR_08_BITS = 0x04, //!< Preamble detection length 8 bits
RADIO_FSK_PREAMBLE_DETECTOR_16_BITS = 0x05, //!< Preamble detection length 16 bits
RADIO_FSK_PREAMBLE_DETECTOR_24_BITS = 0x06, //!< Preamble detection length 24 bits
RADIO_FSK_PREAMBLE_DETECTOR_32_BITS = 0x07, //!< Preamble detection length 32 bit
}RADIO_FSK_PreambleDetection_t;
/*!
* @brief Represents the possible combinations of SyncWord correlators activated
*/
typedef enum
{
RADIO_FSK_ADDRESSCOMP_FILT_OFF = 0x00, //!< No correlator turned on, i.e. do not search for SyncWord
RADIO_FSK_ADDRESSCOMP_FILT_NODE = 0x01,
RADIO_FSK_ADDRESSCOMP_FILT_NODE_BROAD = 0x02,
}RADIO_FSK_AddressComp_t;
/*!
* @brief Radio packet length mode
*/
typedef enum
{
RADIO_FSK_PACKET_FIXED_LENGTH = 0x00, //!< The packet is known on both sides, no header included in the packet
RADIO_FSK_PACKET_VARIABLE_LENGTH = 0x01, //!< 1 byte packet length field inserted after the sync word*/
RADIO_FSK_PACKET_2BYTES_LENGTH = 0x02 //!< 2 bytes packet length field inserted after the sync word, payload size greater than 255 bytes */
}RADIO_FSK_PacketLengthModes_t;
/*!
* @brief Represents the CRC length
*/
typedef enum
{
RADIO_FSK_CRC_OFF = 0x01, //!< No CRC in use
RADIO_FSK_CRC_1_BYTES = 0x00,
RADIO_FSK_CRC_2_BYTES = 0x02,
RADIO_FSK_CRC_1_BYTES_INV = 0x04,
RADIO_FSK_CRC_2_BYTES_INV = 0x06,
RADIO_FSK_CRC_2_BYTES_IBM = 0xF1,
RADIO_FSK_CRC_2_BYTES_CCIT = 0xF2,
}RADIO_FSK_CrcTypes_t;
/*!
* @brief Radio whitening mode Off, CCIT or ibm
*/
typedef enum
{
RADIO_FSK_DC_FREE_OFF = 0x00, /*whitening Off*/
RADIO_FSK_DC_FREEWHITENING = 0x01, /*whitening CCIT*/
RADIO_FSK_DC_IBM_WHITENING = 0x02, /*whitening IBM*/
}RADIO_FSK_DcFree_t;
/*!
* @brief Radio Lora generic Rx parameters
*/
typedef struct
{
uint32_t StopTimerOnPreambleDetect; /*0 inactive, otherwise active*/
RADIO_LoRaSpreadingFactors_t SpreadingFactor;
RADIO_LoRaBandwidths_t Bandwidth;
RADIO_LoRaCodingRates_t Coderate;
RADIO_Ld_Opt_t LowDatarateOptimize;/*0 inactive, 1 active, otherwise auto (active for SF11 and SF12)*/
uint16_t PreambleLen;
RADIO_LoRaPacketLengthsMode_t LengthMode;
uint8_t MaxPayloadLength;
RADIO_LoRaCrcModes_t CrcMode;
RADIO_LoRaIQModes_t IqInverted;
} generic_param_rx_lora_t;
/*!
* @brief Radio FSK generic Rx parameters
*/
typedef struct
{
uint32_t StopTimerOnPreambleDetect;
uint32_t Bandwidth;
uint32_t BitRate; /* BitRate */
uint32_t PreambleLen; /* Preamble length in Byte */
uint8_t* SyncWord; /* SyncWord Buffer, 8 bytes max */
uint32_t MaxPayloadLength; /* maximum Payload length to listen */
uint16_t CrcPolynomial; /* Polynomial of the Crc*/
uint16_t CrcSeed; /* Seed of the Crc*/
uint16_t whiteSeed; /* WhiteningSeed, whitening can also be disabled by setting this field to 0 */
uint8_t SyncWordLength; /* SyncWord Buffer length in Byte*/
RADIO_FSK_PreambleDetection_t PreambleMinDetect;
RADIO_FSK_ModShapings_t ModulationShaping;
RADIO_FSK_AddressComp_t AddrComp;
RADIO_FSK_PacketLengthModes_t LengthMode; /* If the header is explicit, it will be transmitted in the GFSK packet. If the header is implicit, it will not be transmitted */
RADIO_FSK_CrcTypes_t CrcLength; /* Size of the CRC block in the GFSK packet */
RADIO_FSK_DcFree_t Whitening; /* whitening type*/
} generic_param_rx_fsk_t;
/*!
* @brief Radio generic Rx Configuration
*/
typedef struct
{
generic_param_rx_fsk_t fsk;
generic_param_rx_lora_t lora;
} RxConfigGeneric_t;
/*!
* @brief Radio BPSK generic Tx parameters
*/
typedef struct
{
uint32_t BitRate; /*BitRate*/
} generic_param_tx_bpsk_t;
/*!
* @brief Radio Lora generic Tx parameters
*/
typedef struct
{
RADIO_LoRaSpreadingFactors_t SpreadingFactor;
RADIO_LoRaBandwidths_t Bandwidth;
RADIO_LoRaCodingRates_t Coderate;
RADIO_Ld_Opt_t LowDatarateOptimize; /*0 inactive, otherwise active*/
uint16_t PreambleLen;
RADIO_LoRaPacketLengthsMode_t LengthMode;
RADIO_LoRaCrcModes_t CrcMode;
RADIO_LoRaIQModes_t IqInverted;
} generic_param_tx_lora_t;
/*!
* @brief Radio FSK generic Tx parameters
*/
typedef struct
{
uint32_t BitRate; /* BitRate */
uint32_t PreambleLen; /* in Byte */
uint8_t* SyncWord; /* SyncWord Buffer, 8 bytes max */
uint16_t CrcPolynomial;
uint16_t CrcSeed;
uint16_t whiteSeed; /* Whitening seed, whitening can be disabled by setting this field to 0 */
uint8_t SyncWordLength; /* in Byte */
RADIO_FSK_ModShapings_t ModulationShaping;
RADIO_FSK_PacketLengthModes_t HeaderType; /* If the header is explicit, it will be transmitted in the GFSK packet. If the header is implicit, it will not be transmitted */
RADIO_FSK_CrcTypes_t CrcLength; /* Size of the CRC block in the GFSK packet */
RADIO_FSK_DcFree_t Whitening;
uint32_t FrequencyDeviation; /* FrequencyDeviation */
} generic_param_tx_fsk_t;
/*!
* @brief Radio MSK generic Tx parameters
*/
typedef struct
{
uint32_t BitRate; /* BitRate */
uint32_t PreambleLen; /* in Byte */
uint8_t* SyncWord; /* SyncWord Buffer, 8 bytes max */
uint16_t CrcPolynomial;
uint16_t CrcSeed;
uint16_t whiteSeed; /* Whitening seed, whitening can be disabled by setting this field to 0 */
uint8_t SyncWordLength; /* in Byte */
RADIO_FSK_ModShapings_t ModulationShaping;
RADIO_FSK_PacketLengthModes_t HeaderType; /* If the header is explicit, it will be transmitted in the GFSK packet. If the header is implicit, it will not be transmitted */
RADIO_FSK_CrcTypes_t CrcLength; /* Size of the CRC block in the GFSK packet */
RADIO_FSK_DcFree_t Whitening;
} generic_param_tx_msk_t;
/*!
* @brief Radio generic Tx Configuration
*/
typedef union
{
generic_param_tx_fsk_t fsk;
generic_param_tx_lora_t lora;
generic_param_tx_bpsk_t bpsk;
generic_param_tx_msk_t msk;
} TxConfigGeneric_t;
#ifdef __cplusplus
}
#endif
#endif // __RADIO_EX_H__

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,150 @@
/**
******************************************************************************
* @file radio_fw.h
* @author MCD Application Team
* @brief Extends radio capabilities (whitening, long packet)
******************************************************************************
* @attention
*
* 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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __RADIO_FW_H__
#define __RADIO_FW_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
/*reserved for SubGHz_Phy internal MW communication*/
typedef enum
{
CONFIG_RX = 0,
CONFIG_TX,
}ConfigGenericRTx_t;
typedef struct{
TxConfigGeneric_t* TxConfig;
RxConfigGeneric_t* RxConfig;
ConfigGenericRTx_t rtx;
} ConfigGeneric_t;
/* Exported constants --------------------------------------------------------*/
/* External variables --------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
/* Exported functions prototypes ---------------------------------------------*/
/*!
* @brief Initialise the RFW module and enables custom whithing, optionally long packet feature
*
* @param [in] config rx or tx config from the application
* @param [in] RadioEvents from the radio
* @param [in] TimeoutTimerEvent Timer for Rx or Tx timeout event
* @return 0 when no parameters error, -1 otherwise
*/
int32_t RFW_Init( ConfigGeneric_t* config, RadioEvents_t* RadioEvents, TimerEvent_t* TimeoutTimerEvent);
/*!
* @brief Return whether the RFW module is enabled
*
* @return 0 when not initialised, -1 otherwise
*/
uint8_t RFW_Is_Init( void);
/*!
* @brief Return whether the RFW module long packet is enabled
*
* @return 0 when not initialised, -1 otherwise
*/
uint8_t RFW_Is_LongPacketModeEnabled( void);
/*!
* @brief Return whether the RFW module long packet is enabled
*
* @param [in] Modem set in the radio
*/
void RFW_SetRadioModem(RadioModems_t Modem);
/*!
* @brief DeInitialise the RFW module and enable custom whithing and optionally long packet feature
*
*/
void RFW_DeInit( void);
/*!
* @brief DeInitialise the TxLongPacket
*
*/
void RFW_DeInit_TxLongPacket(void);
/*!
* @brief Set antenna switch output to be used in Tx
*
* @param [in] AntSwitch RFO_LP or FRO_HP
*
*/
void RFW_SetAntSwitch( uint8_t AntSwitch);
/*!
* @brief Initialise reception for IBM whitening case
*
* @return 0 when RFW_ENABLE exists, -1 otherwise
*/
int32_t RFW_ReceiveInit( void );
/*!
* @brief Initialise transmission for IBM whitening case
*
* @param [in,out] inOutBuffer pointer of exchange buffer to send or receive data
* @param [in] size input buffer size
* @param [out] outSize output buffer size
*
*/
int32_t RFW_TransmitInit(uint8_t* inOutBuffer, uint8_t size, uint8_t* outSize);
/*!
* @brief Starts receiving payload. Called at Rx Sync IRQ
*
*/
void RFW_ReceivePayload(void );
/*!
* @brief Starts transmitting long Packet, note packet length may be on 1 bytes depending on config
*
* @param [in] payload_size total payload size to be sent
* @param [in] timeout Reception timeout [ms]
* @param [in] TxLongPacketGetNextChunkCb callback to be implemented on user side to feed partial chunk
* buffer: source buffer allocated by the app
* size: size in bytes to feed. User to implement the offset based on previous chunk request
* @return 0 when no parameters error, -1 otherwise
*/
int32_t RFW_TransmitLongPacket( uint16_t payload_size, uint32_t timeout, void (*TxLongPacketGetNextChunkCb) (uint8_t** buffer, uint8_t buffer_size) );
/*!
* @brief Starts receiving long Packet, packet maybe short
*
* @param [in] boosted_mode boosted_mode: 0 normal Rx, 1:improved sensitivity
* @param [in] timeout Reception timeout [ms]
* @param [in] RxLongStorePacketChunkCb callback to be implemented on user side to record partial chunk in the application
* buffer: source buffer allocated in the radio driver
* size: size in bytes to record
* @return 0 when no parameters error, -1 otherwise
*/
int32_t RFW_ReceiveLongPacket( uint8_t boosted_mode, uint32_t timeout, void (*RxLongStorePacketChunkCb) (uint8_t* buffer, uint8_t chunk_size) );
#ifdef __cplusplus
}
#endif
#endif /*__RADIO_FW_H__*/

View File

@ -0,0 +1,53 @@
/******************************************************************************
* @file subghz_phy_version.h
* @author MCD Application Team
* @brief defines the radio driver version
******************************************************************************
* @attention
*
* 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.
*
******************************************************************************
*/
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __SUBGHZ_PHY_VERSION_H__
#define __SUBGHZ_PHY_VERSION_H__
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* __SUBGHZ_PHY_TYPE: 0x01 STM32WL
0x61 SX126X
0x72 SX1272
0x76 SX1276 */
#define SUBGHZ_PHY_VERSION_MAIN (0x01U) /*!< [31:24] main version */
#define SUBGHZ_PHY_VERSION_SUB1 (0x02U) /*!< [23:16] sub1 version */
#define SUBGHZ_PHY_VERSION_SUB2 (0x00U) /*!< [15:8] sub2 version */
#define SUBGHZ_PHY_TYPE (0x01U) /*!< [7:0] type version */
#define SUBGHZ_PHY_VERSION ((SUBGHZ_PHY_VERSION_MAIN << 24) \
|(SUBGHZ_PHY_VERSION_SUB1 << 16) \
|(SUBGHZ_PHY_VERSION_SUB2 << 8) \
|(SUBGHZ_PHY_TYPE))
/* Exported types ------------------------------------------------------------*/
/* External variables --------------------------------------------------------*/
/* Exported macros -----------------------------------------------------------*/
/* Exported functions ------------------------------------------------------- */
#ifdef __cplusplus
}
#endif
#endif /*__SUBGHZ_PHY_VERSION_H__*/