HT32SX Generic Push Button
Generic Push Button application for HT32SX
monarch_api.h
Go to the documentation of this file.
1 
32 /********************************************************
33 * External API dependencies to link with this library.
34 *
35 * Error codes of the MCU MONARCH API functions are described below.
36 * The Manufacturer can add more error code taking care of the limits defined.
37 *
38 ********************************************************/
39 
52 #include "sigfox_types.h"
53 #include "sigfox_monarch_api.h"
54 
55 /*
56  * ----------------------------------------------------------------
57  * Bytes reserved for MCU API ERROR CODES : From 0x10 to 0x2F
58  * ----------------------------------------------------------------
59  */
60 
61 /*
62  * ----------------------------------------------------------------
63  * Bytes reserved for RF API ERROR CODES : From 0x30 to 0x3F
64  * ----------------------------------------------------------------
65  */
66 
67 /*
68  * ----------------------------------------------------------------
69  * Bytes reserved for SE API ERROR CODES : From 0x40 to 0x5F
70  * ----------------------------------------------------------------
71  */
72 
73 /*
74  * ----------------------------------------------------------------
75  * Bytes reserved for REPEATER API ERROR CODES : From 0x60 to 0x7F
76  * ----------------------------------------------------------------
77  */
78 
79 /*
80  * ----------------------------------------------------------------
81  * Bytes reserved for MONARCH API ERROR CODES : From 0x80 to 0x8F
82  * ----------------------------------------------------------------
83  */
84 #define MONARCH_ERR_API_MALLOC (sfx_u8)(0x80)
85 #define MONARCH_ERR_API_FREE (sfx_u8)(0x81)
86 #define MONARCH_ERR_API_TIMER_START (sfx_u8)(0x82)
87 #define MONARCH_ERR_API_TIMER_STOP (sfx_u8)(0x83)
88 #define MONARCH_ERR_API_CONFIGURE_SEARCH_PATTERN (sfx_u8)(0x84)
89 #define MONARCH_ERR_API_STOP_SEARCH_PATTERN (sfx_u8)(0x85)
90 #define MONARCH_ERR_API_GET_VERSION (sfx_u8)(0x86)
94 /*!******************************************************************
95  * \fn sfx_u8 MONARCH_API_malloc(sfx_u16 size, sfx_u8 **returned_pointer)
96  * \brief Allocate memory for MONARCH library usage (Memory usage = size (Bytes))
97  * This function is only called once at RC Scan.
98  *
99  * IMPORTANT NOTE:
100  * --------------
101  * The address reported need to be aligned with architecture of the microprocessor used.
102  * For a Microprocessor of:
103  * - 8 bits => any address is allowed
104  * - 16 bits => only address multiple of 2 are allowed
105  * - 32 bits => only address multiple of 4 are allowed
106  *
107  * \param[in] sfx_u16 size size of buffer to allocate in bytes
108  * \param[out] sfx_u8 **returned_pointer pointer to buffer (can be static)
109  *
110  * \retval SFX_ERR_NONE: No error
111  * \retval MONARCH_ERR_API_MALLOC Malloc error
112  *******************************************************************/
113 sfx_u8 MONARCH_API_malloc(sfx_u16 size, sfx_u8** returned_pointer);
114 
115 /*!******************************************************************
116  * \fn sfx_u8 MONARCH_API_free(sfx_u8 *ptr)
117  * \brief Free memory allocated to library with the MONARCH_API_malloc
118  *
119  * \param[in] sfx_u8 *ptr pointer to buffer
120  * \param[out] none
121  *
122  * \retval SFX_ERR_NONE: No error
123  * \retval MONARCH_ERR_API_FREE: Free error
124  *******************************************************************/
125 sfx_u8 MONARCH_API_free(sfx_u8* ptr);
126 
127 /*!******************************************************************
128  * \fn sfx_u8 MONARCH_API_timer_start (sfx_u16 timer_value, sfx_timer_unit_enum_t unit, sfx_error_t (* sigfox_callback_timeout_handler ) ( void ) )
129  * \brief This function starts a timer based on timer_value and the units. When the timer expires
130  * the manufacturer has to call the timer callback function (sigfox_callback_timeout_handler)
131  *
132  * \param[in] sfx_u16 timer_value Scan duration value ( with the unit parameter information )
133  * \param[in] sfx_timer_unit_enum_t unit Unit to be considered for the scan time computation
134  * \param[in] timeout_callback_handler This is the function that needs to be called when the timer expires
135  * ( either when RC Found or when Timeout )
136  *
137  * \retval SFX_ERR_NONE: No error
138  * \retval MONARCH_ERR_API_TIMER_START: Timer Start error
139  *******************************************************************/
140 sfx_u8 MONARCH_API_timer_start(sfx_u16 timer_value, sfx_timer_unit_enum_t unit, sfx_error_t (* timeout_callback_handler)(void));
141 
142 /*!******************************************************************
143  * \fn sfx_u8 MONARCH_API_timer_stop (void)
144  * \brief This function stops the timer
145  *
146  * \retval SFX_ERR_NONE: No error
147  * \retval MONARCH_ERR_API_TIMER_STOP: Stop Timer error
148  *******************************************************************/
149 sfx_u8 MONARCH_API_timer_stop(void);
150 
151 /*!******************************************************************
152  * \fn sfx_u8 MONARCH_API_configure_search_pattern ( sfx_monarch_pattern_search_t list_freq_pattern[], sfx_u8 size, sfx_monarch_listening_mode_t mode, sfx_error_t (* monarch_pattern_freq_result_callback_handler ) (sfx_u32 freq, sfx_pattern_enum_t pattern, sfx_s16 rssi));
153  *
154  * \brief This function is used to configure a search pattern action from on the MCU/RF side.
155  * The list of frequencies to scan and associated pattern is given as parameter.
156  * When a pattern is found or the timeout ( set with MONARCH_API_timer_start ) occurs,
157  * the callback function has to be called.
158  *
159  * There are 2 modes that can be used : LISTENING_SWEEP and LISTENING_WINDOW modes.
160  * They are detailed in the sfx_monarch_listening_mode_t description
161  *
162  * \param[in] sfx_monarch_pattern_search_t list_freq_pattern[] Tab of the frequencies / patterns to check
163  * \param[in] sfx_u8 size Size of the list (list_freq_pattern)
164  * \param[in] sfx_monarch_listening_mode_t mode Mode of the scan
165  * \param[in] monarch_pattern_freq_result_callback_handler Callback function when a pattern is found or when the timer expires
166  * with the following parameters :
167  * \param[in] sfx_u32 freq Report the Frequency on which the pattern has been found
168  * \param[in] sfx_pattern_enum_t pattern Pattern which has been found
169  * \param[in] sfx_s16 rssi RSSI level of the found pattern
170  *
171  *
172  * \retval SFX_ERR_NONE: No error
173  * \retval MONARCH_ERR_API_CONFIGURE_SEARCH_PATTERN: Search pattern error
174  *******************************************************************/
176  sfx_u8 size,
178  sfx_error_t (* monarch_pattern_freq_result_callback_handler)(sfx_u32 freq, sfx_pattern_enum_t pattern, sfx_s16 rssi));
179 
180 /*!******************************************************************
181  * \fn sfx_u8 MONARCH_API_stop_search_pattern (void)
182  * \brief This function stops the scan
183  *
184  * \retval SFX_ERR_NONE: No error
185  * \retval MONARCH_ERR_API_STOP_SEARCH_PATTERN: Stop seach pattern error
186  *******************************************************************/
188 
189 /*!******************************************************************
190  * \fn sfx_u8 MONARCH_API_get_version(sfx_u8 **version, sfx_u8 *size)
191  * \brief This function returns current MONARCH API version
192  *
193  * \param[out] sfx_u8 **version Pointer to Byte array (ASCII format) containing library version
194  * \param[out] sfx_u8 *size Size of the byte array pointed by *version
195  *
196  * \retval SFX_ERR_NONE: No error
197  * \retval MONARCH_ERR_API_GET_VERSION: Get Version error
198  *******************************************************************/
199 sfx_u8 MONARCH_API_get_version(sfx_u8** version, sfx_u8* size);
200 
MONARCH_API_timer_stop
sfx_u8 MONARCH_API_timer_stop(void)
This function stops the timer.
Definition: rf_api.c:2006
sfx_monarch_pattern_search_t
Definition: sigfox_monarch_api.h:90
MONARCH_API_stop_search_pattern
sfx_u8 MONARCH_API_stop_search_pattern(void)
This function stops the scan.
Definition: rf_api.c:2013
sigfox_monarch_api.h
Sigfox user functions.
sfx_pattern_enum_t
sfx_pattern_enum_t
Definition: sigfox_monarch_api.h:72
MONARCH_API_malloc
sfx_u8 MONARCH_API_malloc(sfx_u16 size, sfx_u8 **returned_pointer)
Allocate memory for MONARCH library usage (Memory usage = size (Bytes)) This function is only called ...
Definition: rf_api.c:2000
MONARCH_API_get_version
sfx_u8 MONARCH_API_get_version(sfx_u8 **version, sfx_u8 *size)
This function returns current MONARCH API version.
Definition: rf_api.c:2015
sfx_monarch_listening_mode_t
sfx_monarch_listening_mode_t
Definition: sigfox_monarch_api.h:100
MONARCH_API_free
sfx_u8 MONARCH_API_free(sfx_u8 *ptr)
Free memory allocated to library with the MONARCH_API_malloc.
Definition: rf_api.c:2002
sfx_timer_unit_enum_t
sfx_timer_unit_enum_t
Definition: sigfox_monarch_api.h:39
MONARCH_API_configure_search_pattern
sfx_u8 MONARCH_API_configure_search_pattern(sfx_monarch_pattern_search_t list_freq_pattern[], sfx_u8 size, sfx_monarch_listening_mode_t mode, sfx_error_t(*monarch_pattern_freq_result_callback_handler)(sfx_u32 freq, sfx_pattern_enum_t pattern, sfx_s16 rssi))
This function is used to configure a search pattern action from on the MCU/RF side....
Definition: rf_api.c:2008
sigfox_types.h
Sigfox types definition.
MONARCH_API_timer_start
sfx_u8 MONARCH_API_timer_start(sfx_u16 timer_value, sfx_timer_unit_enum_t unit, sfx_error_t(*timeout_callback_handler)(void))
This function starts a timer based on timer_value and the units. When the timer expires the manufactu...
Definition: rf_api.c:2004