Skip to content

Commit

Permalink
v1.1 release.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludovic-Lesur committed Jun 28, 2023
1 parent 53e181a commit 6c30198
Show file tree
Hide file tree
Showing 6 changed files with 196 additions and 52 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [v1.1](https://github.com/sigfox-tech-radio/sigfox-ep-rf-api-st-s2lp/releases/tag/v1.1) - 28 Jun 2023

### Added

* Add signal parameter to HW API GPIO get function for future use.

### Fixed

* Replace RF API redirecting macros by inline fonctions to solve linking issues.

### Known limitations

* **LBT** not implemented.
* **External radio front-end** not supported.

## [v1.0](https://github.com/sigfox-tech-radio/sigfox-ep-rf-api-st-s2lp/releases/tag/v1.0) - 19 Jun 2023

### General
Expand All @@ -16,3 +31,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Known limitations

* **LBT** not implemented.
* **External radio front-end** not supported.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ This **S2LP RF API** is a low level implementation example of the [Sigfox EP lib

The table below shows the version compatibility with the SIGFOX_EP_LIB version.

| **S2LP_RF_API** | **SIGFOX_EP_LIB** |
|:----------------------------------------------------------------------------------:|:----------------------------------------------------------------------------:|
| [v1.0](https://github.com/sigfox-tech-radio/sigfox-ep-rf-api-st-s2lp/releases/tag/v1.0) | [v3.2](https://github.com/sigfox-tech-radio/sigfox-ep-lib/releases/tag/v3.2) |
| **S2LP_RF_API** | **SIGFOX_EP_LIB** |
|:---------------------------------------------------------------------------------------:|:-------------------------------------------------------------------------------:|
| [v1.1](https://github.com/sigfox-tech-radio/sigfox-ep-rf-api-st-s2lp/releases/tag/v1.1) | >= [v3.2](https://github.com/sigfox-tech-radio/sigfox-ep-lib/releases/tag/v3.2) |
| [v1.0](https://github.com/sigfox-tech-radio/sigfox-ep-rf-api-st-s2lp/releases/tag/v1.0) | >= [v3.2](https://github.com/sigfox-tech-radio/sigfox-ep-lib/releases/tag/v3.2) |

**Note:** the resulting radio performances of your device strongly depends on your hardware design (schematic, PCB routing, crystal oscillator placement, good RF practices, etc...). **Sigfox certification remains mandatory** whatever the software embedded in your device (including the Sigfox End-Point library and its implementation examples).

Expand Down
15 changes: 12 additions & 3 deletions inc/board/s2lp_hw_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,15 @@ typedef enum {
S2LP_HW_API_OSCILLATOR_TYPE_LAST
} S2LP_HW_API_oscillator_type_t;

/*!******************************************************************
* \enum S2LP_HW_API_signal_t
* \brief S2LP external signals list.
*******************************************************************/
typedef enum {
S2LP_HW_API_SIGNAL_IRQ = 0,
S2LP_HW_API_SIGNAL_LAST
} S2LP_HW_API_signal_t;

/*!******************************************************************
* \enum S2LP_HW_API_gpio_t
* \brief S2LP GPIO pins list.
Expand Down Expand Up @@ -134,11 +143,11 @@ S2LP_HW_API_status_t S2LP_HW_API_get_oscillator(S2LP_HW_API_oscillator_type_t *x
/*!******************************************************************
* \fn S2LP_HW_API_status_t S2LP_HW_API_get_gpio(sfx_u8 *s2lp_gpio)
* \brief Returns the S2LP GPIO attached to the MCU.
* \param[in] none
* \param[out] s2lp_gpio_pin: Pointer to the S2LP GPIO pin number used as external interrupt.
* \param[in] signal: External S2LP signal.
* \param[out] s2lp_gpio: Pointer to the S2LP GPIO pin number connected to the signal.
* \retval Function execution status.
*******************************************************************/
S2LP_HW_API_status_t S2LP_HW_API_get_gpio(S2LP_HW_API_gpio_t *s2lp_gpio);
S2LP_HW_API_status_t S2LP_HW_API_get_gpio(S2LP_HW_API_signal_t signal, S2LP_HW_API_gpio_t *s2lp_gpio);

#if (defined TIMER_REQUIRED) && (defined LATENCY_COMPENSATION)
/*!******************************************************************
Expand Down
40 changes: 2 additions & 38 deletions inc/manuf/s2lp_rf_api.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!*****************************************************************
* \file s2lp_rf_api.h
* \brief Sigfox s2lp RF api.
* \brief Sigfox S2LP RF API implementation.
*******************************************************************
* \copyright
*
Expand Down Expand Up @@ -56,6 +56,7 @@ typedef enum {
S2LP_RF_API_ERROR_MODE,
S2LP_RF_API_ERROR_FREQUENCY,
S2LP_RF_API_ERROR_MODULATION,
S2LP_RF_API_ERROR_GPIO,
S2LP_RF_API_ERROR_TX_POWER,
S2LP_RF_API_ERROR_SYMBOL_TABLE,
S2LP_RF_API_ERROR_LATENCY_TYPE,
Expand Down Expand Up @@ -224,43 +225,6 @@ RF_API_status_t S2LP_RF_API_get_version(sfx_u8 **version, sfx_u8 *version_size_c
void S2LP_RF_API_error(void);
#endif

/*** S2LP RF API functions mapping ***/

#ifndef DYNAMIC_RF_API

#if (defined ASYNCHRONOUS) || (defined LOW_LEVEL_OPEN_CLOSE)
#define RF_API_open S2LP_RF_API_open
#endif
#ifdef LOW_LEVEL_OPEN_CLOSE
#define RF_API_close S2LP_RF_API_close
#endif
#ifdef ASYNCHRONOUS
#define RF_API_process S2LP_RF_API_process
#endif
#define RF_API_wake_up S2LP_RF_API_wake_up
#define RF_API_sleep S2LP_RF_API_sleep
#define RF_API_init S2LP_RF_API_init
#define RF_API_de_init S2LP_RF_API_de_init
#define RF_API_send S2LP_RF_API_send
#ifdef BIDIRECTIONAL
#define RF_API_receive S2LP_RF_API_receive
#define RF_API_get_dl_phy_content_and_rssi S2LP_RF_API_get_dl_phy_content_and_rssi
#endif
#if (defined REGULATORY) && (defined SPECTRUM_ACCESS_LBT)
#define RF_API_carrier_sense S2LP_RF_API_carrier_sense
#endif
#if (defined TIMER_REQUIRED) && (defined LATENCY_COMPENSATION)
#define RF_API_get_latency S2LP_RF_API_get_latency
#endif
#ifdef VERBOSE
#define RF_API_get_version S2LP_RF_API_get_version
#endif
#ifdef ERROR_CODES
#define RF_API_error S2LP_RF_API_error
#endif

#endif /* DYNAMIC_RF_API */

/*** Unwanted flag combinations and values ***/

#ifndef LOW_LEVEL_OPEN_CLOSE
Expand Down
33 changes: 32 additions & 1 deletion src/board/s2lp_hw_api.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,37 @@
/*!*****************************************************************
* \file s2lp_hw_api.c
* \brief Sigfox S2LP HW interface.
*******************************************************************
* \copyright
*
* Copyright (c) 2022, UnaBiz SAS
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1 Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2 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.
* 3 Neither the name of UnaBiz SAS 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 THE COPYRIGHT HOLDER OR
* CONTRIBUTORS 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.
*
*******************************************************************/

#include "board/s2lp_hw_api.h"
Expand Down Expand Up @@ -55,7 +86,7 @@ S2LP_HW_API_status_t S2LP_HW_API_get_oscillator(S2LP_HW_API_oscillator_type_t *x
}

/*******************************************************************/
S2LP_HW_API_status_t S2LP_HW_API_get_gpio(S2LP_HW_API_gpio_t *s2lp_gpio) {
S2LP_HW_API_status_t S2LP_HW_API_get_gpio(S2LP_HW_API_signal_t signal, S2LP_HW_API_gpio_t *s2lp_gpio) {
/* To be implemented by the device manufacturer */
#ifdef ERROR_CODES
S2LP_HW_API_status_t status = S2LP_HW_API_SUCCESS;
Expand Down
137 changes: 130 additions & 7 deletions src/manuf/s2lp_rf_api.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*!*****************************************************************
* \file s2lp_rf_api.c
* \brief Sigfox s2lp RF api.
* \brief Sigfox S2LP RF API implementation.
*******************************************************************
* \copyright
*
Expand Down Expand Up @@ -82,7 +82,7 @@
#define S2LP_FIFO_SIZE_BYTES 128

#ifdef VERBOSE
static const sfx_u8 S2LP_RF_API_VERSION[] = "v1.0";
static const sfx_u8 S2LP_RF_API_VERSION[] = "v1.1";
#endif

// Ramp profile table is written for ramp-down direction (reverse table for ramp up).
Expand Down Expand Up @@ -226,6 +226,33 @@ static void _wait_for_s2lp_state_switch(S2LPState new_state) {
}
}

/*******************************************************************/
static RF_API_status_t _convert_gpio(S2LP_HW_API_gpio_t hw_api_gpio, S2LPGpioPin* s2lp_gpio) {
#ifdef ERROR_CODES
// Local variables.
RF_API_status_t status = S2LP_RF_API_SUCCESS;
#endif
switch (hw_api_gpio) {
case S2LP_HW_API_GPIO_0:
(*s2lp_gpio) = S2LP_GPIO_0;
break;
case S2LP_HW_API_GPIO_1:
(*s2lp_gpio) = S2LP_GPIO_1;
break;
case S2LP_HW_API_GPIO_2:
(*s2lp_gpio) = S2LP_GPIO_2;
break;
case S2LP_HW_API_GPIO_3:
(*s2lp_gpio) = S2LP_GPIO_3;
break;
default:
EXIT_ERROR(S2LP_RF_API_ERROR_GPIO);
break;
}
errors:
RETURN();
}

/*******************************************************************/
static void _s2lp_gpio_irq_callback(void) {
// Set flag if IRQ is enabled.
Expand Down Expand Up @@ -517,7 +544,7 @@ RF_API_status_t S2LP_RF_API_init(RF_API_radio_parameters_t *radio_parameters) {
ModulationSelect s2lp_modulation = MOD_NO_MOD;
sfx_u32 s2lp_datarate = 0;
sfx_u32 s2lp_deviation = 0;
S2LP_HW_API_gpio_t s2lp_gpio = 0;
S2LP_HW_API_gpio_t hw_api_gpio = 0;
SGpioInit s2lp_gpio_init;
sfx_u8 reg_value = 0;
#ifdef BIDIRECTIONAL
Expand Down Expand Up @@ -570,14 +597,16 @@ RF_API_status_t S2LP_RF_API_init(RF_API_radio_parameters_t *radio_parameters) {
S2LPRadioSetFrequencyDev(s2lp_deviation);
// Disable all IRQ.
S2LPGpioIrqDeInit(NULL);
// Configure GPIO.
// Configure IRQ GPIO.
#ifdef ERROR_CODES
s2lp_hw_api_status = S2LP_HW_API_get_gpio(&s2lp_gpio);
s2lp_hw_api_status = S2LP_HW_API_get_gpio(S2LP_HW_API_SIGNAL_IRQ, &hw_api_gpio);
S2LP_HW_API_check_status(S2LP_RF_API_ERROR_DRIVER_S2LP_HW_API);
status = _convert_gpio(hw_api_gpio, &(s2lp_gpio_init.xS2LPGpioPin));
CHECK_STATUS(RF_API_SUCCESS);
#else
S2LP_HW_API_get_gpio(&s2lp_gpio);
S2LP_HW_API_get_gpio(S2LP_HW_API_SIGNAL_IRQ, &hw_api_gpio);
_convert_gpio(hw_api_gpio, &(s2lp_gpio_init.xS2LPGpioPin));
#endif
s2lp_gpio_init.xS2LPGpioPin = (S2LPGpioPin) s2lp_gpio; // Note: value mapping is the same.
s2lp_gpio_init.xS2LPGpioMode = S2LP_GPIO_MODE_DIGITAL_OUTPUT_LP;
s2lp_gpio_init.xS2LPGpioIO = S2LP_GPIO_DIG_OUT_IRQ;
S2LPGpioInit(&s2lp_gpio_init);
Expand Down Expand Up @@ -931,3 +960,97 @@ void S2LP_RF_API_error(void) {
#endif
}
#endif

/*** S2LP RF API functions mapping ***/

#ifndef DYNAMIC_RF_API

#if (defined ASYNCHRONOUS) || (defined LOW_LEVEL_OPEN_CLOSE)
/*******************************************************************/
inline RF_API_status_t RF_API_open(RF_API_config_t *rf_api_config) {
return S2LP_RF_API_open(rf_api_config);
}
#endif

#ifdef LOW_LEVEL_OPEN_CLOSE
/*******************************************************************/
inline RF_API_status_t RF_API_close(void) {
return S2LP_RF_API_close();
}
#endif

#ifdef ASYNCHRONOUS
/*******************************************************************/
inline RF_API_status_t RF_API_process(void) {
return S2LP_RF_API_process();
}
#endif

/*******************************************************************/
inline RF_API_status_t RF_API_wake_up(void) {
return S2LP_RF_API_wake_up();
}

/*******************************************************************/
inline RF_API_status_t RF_API_sleep(void) {
return S2LP_RF_API_sleep();
}

/*******************************************************************/
inline RF_API_status_t RF_API_init(RF_API_radio_parameters_t *radio_parameters) {
return S2LP_RF_API_init(radio_parameters);
}

/*******************************************************************/
inline RF_API_status_t RF_API_de_init(void) {
return S2LP_RF_API_de_init();
}

/*******************************************************************/
inline RF_API_status_t RF_API_send(RF_API_tx_data_t *tx_data) {
return S2LP_RF_API_send(tx_data);
}

#ifdef BIDIRECTIONAL
/*******************************************************************/
inline RF_API_status_t RF_API_receive(RF_API_rx_data_t *rx_data) {
return S2LP_RF_API_receive(rx_data);
}
#endif

#ifdef BIDIRECTIONAL
/*******************************************************************/
inline RF_API_status_t RF_API_get_dl_phy_content_and_rssi(sfx_u8 *dl_phy_content, sfx_u8 dl_phy_content_size, sfx_s16 *dl_rssi_dbm) {
return S2LP_RF_API_get_dl_phy_content_and_rssi(dl_phy_content, dl_phy_content_size, dl_rssi_dbm);
}
#endif

#if (defined REGULATORY) && (defined SPECTRUM_ACCESS_LBT)
/*******************************************************************/
inline RF_API_status_t RF_API_carrier_sense(RF_API_carrier_sense_parameters_t *carrier_sense_params) {
return S2LP_RF_API_carrier_sense(carrier_sense_params);
}
#endif

#if (defined TIMER_REQUIRED) && (defined LATENCY_COMPENSATION)
/*******************************************************************/
inline RF_API_status_t RF_API_get_latency(RF_API_latency_t latency_type, sfx_u32 *latency_ms) {
return S2LP_RF_API_get_latency(latency_type, latency_ms);
}
#endif

#ifdef VERBOSE
/*******************************************************************/
inline RF_API_status_t RF_API_get_version(sfx_u8 **version, sfx_u8 *version_size_char) {
return S2LP_RF_API_get_version(version, version_size_char);
}
#endif

#ifdef ERROR_CODES
/*******************************************************************/
inline void RF_API_error(void) {
S2LP_RF_API_error();
}
#endif

#endif /* DYNAMIC_RF_API */

0 comments on commit 6c30198

Please sign in to comment.