HT32SX Monarch Scan
Monarch Scan application for HT32SX
st_mcu_api.h
Go to the documentation of this file.
1 
13 #include "sigfox_types.h"
14 
15 #ifdef MONARCH_REF_DES
16 /*Structure to manage External PA from MCU*/
17 typedef enum
18 {
19  SHUTDOWN = 0x00,
20  TX_BYPASS = 0x01,
21  TX = 0x02,
22  RX = 0x03,
23 }ExtPaStatus;
24 #endif
25 /********************************************************
26  * External API dependencies to link with this library.
27  *
28  * Error codes of the MCU API functions are described below.
29  * The Manufacturer can add more error code taking care of the limits defined.
30  *
31  ********************************************************/
32 
33 
34 /*!******************************************************************
35  * \fn void ST_MCU_API_SpiRaw(sfx_u8 n_bytes, sfx_u8* in_buffer, sfx_u8* out_buffer, sfx_u8 can_return_bef_tx)
36  * \brief Performs a SPI transaction with the S2-LP SPI slave.
37  * \param[in] uint8_t bytes: The number of bytes involved in the SPI transaction.
38  * \param[in] uint8_t* in_buffer: pointer to the buffer to be sent to the slave.
39  * \param[in] uint8_t* out_buffer: pointer to the buffer where the received bytes should be stored.
40  * \param[in] uint8_t can_return_bef_tx: flag specifying if the function should be blocking (0) or not (1).
41  * This can be useful if the SPI is aided with DMA support.
42  * \note This is a function that is not required by the SIGFOX_API nor by the RF_API library.
43  * \retval None
44  *******************************************************************/
45 void ST_MCU_API_SpiRaw(sfx_u8 n_bytes, sfx_u8* in_buffer, sfx_u8* out_buffer, sfx_u8 can_return_bef_tx);
46 
47 /*!******************************************************************
48  * \fn void ST_MCU_API_GpioIRQ(sfx_u8 pin, sfx_u8 new_state, sfx_u8 trigger)
49  * \brief Enables or Disables the external interrupt on the microcontroller side. The interrupt must be set on the rising or falling edge of the input signal according to the trigger_flag.
50  * The pin number passed represents the GPIO number of the S2-LP.
51  * \param[in] uint8_t pin: the GPIO pin of the S2-LP (integer from 0 to 3).
52  * \param[in] uint8_t new_state: enable or disable the EXTI (can be 0 or 1).
53  * \param[in] uint8_t trigger: trigger_flag:
54  * 1: rising edge
55  * 0: falling edge
56  * \note This is a function that is not required by the SIGFOX_API nor by the RF_API library.
57  * \retval None
58  *******************************************************************/
59 void ST_MCU_API_GpioIRQ(sfx_u8 pin, sfx_u8 new_state, sfx_u8 trigger);
60 
61 /*!******************************************************************
62  * \fn void ST_MCU_API_Shutdown(sfx_u8 value)
63  * \brief Set on or off the S2-LP by GPIO.
64  * \param[in] sfx_u8 value:
65  * if 1, the device should enter shutdown (OFF).
66  * if 0, the device should exit from shutdown (ON).
67  * \retval None
68  *******************************************************************/
69 void ST_MCU_API_Shutdown(sfx_u8 value);
70 
71 /*!******************************************************************
72  * \fn void ST_MCU_API_LowPower(sfx_u8 low_power_flag)
73  * \brief This function instructs the mcu_api to send the microcontroller in sleep or not
74  * during the protocol operations.
75  * It is mainly used for debugging purposes.
76  * \param[in] uint8_t low_power_flag : enable the low power (1, default setting) or not (0).
77  * \note This is a function that is not required by the SIGFOX_API nor by the RF_API library.
78  * \retval None.
79  *******************************************************************/
80 void ST_MCU_API_LowPower(sfx_u8 low_power_flag);
81 
82 /*!******************************************************************
83  * \fn void ST_MCU_API_WaitForInterrupt(void)
84  * \brief Microcontroller waits for interrupt.
85  * This function is continously called by the library each time it waits for an event.
86  * This is useful if the application must trigger a state machine and not block the CPU waiting for an event from the library.
87  * For example, this can be a null implementation or can activate a low power mode of the microcontroller, tick a stack for
88  * dual radio applications or other type of state machines.
89  * \param[in] None.
90  * \note This is a function that is not required by the SIGFOX_API nor by the RF_API library.
91  * \retval None.
92  *******************************************************************/
94 
95 /*!******************************************************************
96  * \fn void ST_MCU_API_SetSysClock(void)
97  * \brief This function is used to confgure the system clock when the STM32 exits
98  * the low power or at beginning of the application.
99  * \param[in] None.
100  * \note This is a function that is not required by the SIGFOX_API nor by the RF_API library.
101  * \retval None.
102  *******************************************************************/
103 void ST_MCU_API_SetSysClock(void);
104 
105 /*!******************************************************************
106  * \fn void ST_MCU_API_TimerCalibration(sfx_u16 duration_ms)
107  * \brief This function calibrates the RTC that is used by the st_lowlevel when the
108  * device goes in sleep.
109  * \param[in] sfx_u16 duration_ms : duration of the calibration process in ms.
110  * \note This is a function that is not required by the SIGFOX_API nor by the RF_API library.
111  * \retval None.
112  *******************************************************************/
113 void ST_MCU_API_TimerCalibration(sfx_u16 duration_ms);
114 
115 /*!******************************************************************
116  * \fn void ST_MCU_API_SetEncryptionPayload(uint8_t ePayloads)
117  * \brief This function toggles the payload encryption option.
118  * \param[in] sfx_u8 ePayload : set to 1 to enable encryption, 0 to disable.
119  * \retval None.
120  *******************************************************************/
121 void ST_MCU_API_SetEncryptionPayload(sfx_u8 ePayload);
122 
123 /************************************************************************/
124 //
125 // MONARCH REF DES APIs
126 //
127 /************************************************************************/
128 #ifdef MONARCH_REF_DES //Only for the reference Module with Skyworks FE driven by MCU
129 void ST_MCU_API_SetExtPAStatus(ExtPaStatus pa_status);
130 #endif
131 
132 #ifdef MONARCH_GPIO_SAMPLING
133 sfx_u32 ST_MCU_API_CaptureGPIO(sfx_u8 pin);
134 void ST_MCU_API_InitOOKGpio(sfx_u8 pin);
135 void ST_MCU_API_Enable16KHzSamplingTimer(void);
136 void ST_MCU_API_Disable16KHzSamplingTimer(void);
137 #endif
138 
ST_MCU_API_SetEncryptionPayload
void ST_MCU_API_SetEncryptionPayload(uint8_t ePayload)
This function toggles the payload encryption option.
Definition: mcu_api_stm32.c:31
ST_MCU_API_LowPower
void ST_MCU_API_LowPower(sfx_u8 low_power_flag)
This function instructs the mcu_api to send the microcontroller in sleep or not during the protocol o...
Definition: gpio.c:261
ST_MCU_API_TimerCalibration
void ST_MCU_API_TimerCalibration(sfx_u16 duration_ms)
This function calibrates the RTC that is used by the st_lowlevel when the device goes in sleep.
ST_MCU_API_WaitForInterrupt
void ST_MCU_API_WaitForInterrupt(void)
Microcontroller waits for interrupt. This function is continously called by the library each time it ...
Definition: tim.c:365
ST_MCU_API_Shutdown
void ST_MCU_API_Shutdown(sfx_u8 value)
Set on or off the S2-LP by GPIO.
Definition: gpio.c:187
ST_MCU_API_GpioIRQ
void ST_MCU_API_GpioIRQ(sfx_u8 pin, sfx_u8 new_state, sfx_u8 trigger)
Enables or Disables the external interrupt on the microcontroller side. The interrupt must be set on ...
Definition: gpio.c:253
ST_MCU_API_SetSysClock
void ST_MCU_API_SetSysClock(void)
This function is used to confgure the system clock when the STM32 exits the low power or at beginning...
sigfox_types.h
Sigfox types definition.
ST_MCU_API_SpiRaw
void ST_MCU_API_SpiRaw(sfx_u8 n_bytes, sfx_u8 *in_buffer, sfx_u8 *out_buffer, sfx_u8 can_return_bef_tx)
Performs a SPI transaction with the S2-LP SPI slave.