XCORE SDK
XCORE Software Development Kit
sl_wfx_host_api.h
1 /**************************************************************************/
17 #ifndef SL_WFX_HOST_API_H
18 #define SL_WFX_HOST_API_H
19 
20 #include "sl_wfx_api.h"
21 #include "sl_wfx_constants.h"
22 
23 /******************************************************
24 * Enumerations
25 ******************************************************/
26 
27 /******************************************************
28 * Variables
29 ******************************************************/
30 
31 extern sl_wfx_context_t *sl_wfx_context;
32 
33 /**************************************************************************/
38 #ifdef __cplusplus
39 extern "C"
40 {
41 #endif
42 
43 /* Initialization phase*/
44 /**************************************************************************/
50 sl_status_t sl_wfx_host_init(void);
51 
52 /**************************************************************************/
61 sl_status_t sl_wfx_host_get_firmware_data(const uint8_t **data, uint32_t data_size);
62 
63 /**************************************************************************/
71 sl_status_t sl_wfx_host_get_firmware_size(uint32_t *firmware_size);
72 
73 /**************************************************************************/
82 sl_status_t sl_wfx_host_get_pds_data(const char **pds_data, uint16_t index);
83 
84 /**************************************************************************/
92 sl_status_t sl_wfx_host_get_pds_size(uint16_t *pds_size);
93 
94 /**************************************************************************/
100 sl_status_t sl_wfx_host_deinit(void);
101 
102 /* GPIO interface */
103 /**************************************************************************/
110 sl_status_t sl_wfx_host_reset_chip(void);
111 
112 /**************************************************************************/
120 sl_status_t sl_wfx_host_set_wake_up_pin(uint8_t state);
121 
122 /**************************************************************************/
129 sl_status_t sl_wfx_host_wait_for_wake_up(void);
130 
131 /**************************************************************************/
146  uint32_t length);
147 
148 /**************************************************************************/
154 sl_status_t sl_wfx_host_hold_in_reset(void);
155 
156 /**************************************************************************/
164 sl_status_t sl_wfx_host_setup_waited_event(uint8_t event_id);
165 
166 /**************************************************************************/
177 sl_status_t sl_wfx_host_wait_for_confirmation(uint8_t confirmation_id,
178  uint32_t timeout_ms,
179  void **event_payload_out);
180 
181 /**************************************************************************/
189 sl_status_t sl_wfx_host_wait(uint32_t wait_ms);
190 
191 /**************************************************************************/
199 sl_status_t sl_wfx_host_post_event(sl_wfx_generic_message_t *event_payload);
200 
201 /* Memory management */
202 /**************************************************************************/
212 sl_status_t sl_wfx_host_allocate_buffer(void **buffer,
214  uint32_t buffer_size);
215 
216 /**************************************************************************/
223 sl_status_t sl_wfx_host_free_buffer(void *buffer, sl_wfx_buffer_type_t type);
224 
225 /* Frame hook */
226 /**************************************************************************/
233 sl_status_t sl_wfx_host_transmit_frame(void *frame, uint32_t frame_len);
234 
235 /**************************************************************************/
241 sl_status_t sl_wfx_host_lock(void);
242 
243 /**************************************************************************/
248 sl_status_t sl_wfx_host_unlock(void);
249 
250 /* WF200 host bus API */
251 /**************************************************************************/
257 sl_status_t sl_wfx_host_init_bus(void);
258 
259 /**************************************************************************/
265 sl_status_t sl_wfx_host_deinit_bus(void);
266 
267 /**************************************************************************/
271 sl_status_t sl_wfx_host_enable_platform_interrupt(void);
272 
273 /**************************************************************************/
278 
279 /* WF200 host SPI bus API */
280 /**************************************************************************/
284 sl_status_t sl_wfx_host_spi_cs_assert(void);
285 
286 /**************************************************************************/
290 sl_status_t sl_wfx_host_spi_cs_deassert(void);
291 
292 /**************************************************************************/
303  uint8_t *header,
304  uint16_t header_length,
305  uint8_t *buffer,
306  uint16_t buffer_length);
307 
308 /* WF200 host SDIO bus API */
309 /**************************************************************************/
319  uint8_t function,
320  uint32_t address,
321  uint8_t *buffer);
322 
323 /**************************************************************************/
334  uint8_t function,
335  uint32_t address,
336  uint8_t *buffer,
337  uint16_t buffer_length);
338 
339 /**************************************************************************/
344 
345 #ifdef SL_WFX_USE_SECURE_LINK
346 /* WFX host SecureLink API */
347 
348 /**************************************************************************/
355 sl_status_t sl_wfx_host_get_secure_link_mac_key(uint8_t *sl_mac_key);
356 
357 /**************************************************************************/
364 sl_status_t sl_wfx_host_compute_pub_key(sl_wfx_securelink_exchange_pub_keys_req_body_t *request, const uint8_t *sl_mac_key);
365 
366 /**************************************************************************/
375 sl_status_t sl_wfx_host_verify_pub_key(sl_wfx_securelink_exchange_pub_keys_ind_t *response_packet,
376  const uint8_t *sl_mac_key,
377  uint8_t *sl_host_pub_key);
378 
379 /**************************************************************************/
384 sl_status_t sl_wfx_host_free_crypto_context(void);
385 
386 /**************************************************************************/
394 sl_status_t sl_wfx_host_decode_secure_link_data(uint8_t *buffer,
395  uint32_t length,
396  uint8_t *session_key);
397 
398 /**************************************************************************/
407 sl_status_t sl_wfx_host_encode_secure_link_data(sl_wfx_generic_message_t *buffer,
408  uint32_t data_length,
409  uint8_t *session_key,
410  uint8_t *nonce);
411 
412 /**************************************************************************/
417 sl_status_t sl_wfx_host_schedule_secure_link_renegotiation(void);
418 #endif //SL_WFX_USE_SECURE_LINK
419 
420 /* WF200 host debug API */
421 /**************************************************************************/
427 #if SL_WFX_DEBUG_MASK
428 extern void sl_wfx_host_log(const char *string, ...);
429 #endif
430 
431 #ifdef __cplusplus
432 } /*extern "C" */
433 #endif
434 
437 #endif // SL_WFX_HOST_API_H
sl_wfx_buffer_type_t
Enumerates the different types of buffer.
Definition: sl_wfx_constants.h:314
sl_wfx_register_address_t
Enum listing the registers of the WFx solution.
Definition: sl_wfx_constants.h:251
sl_wfx_host_bus_transfer_type_t
Enumerates the different types of bus transfers.
Definition: sl_wfx_constants.h:324
sl_status_t sl_wfx_host_disable_platform_interrupt(void)
Disable the bus interrupt.
Definition: sl_wfx_host_spi.c:153
sl_status_t sl_wfx_host_wait_for_confirmation(uint8_t confirmation_id, uint32_t timeout_ms, void **event_payload_out)
Called when the driver is waiting for a confirmation.
Definition: sl_wfx_host.c:226
sl_status_t sl_wfx_host_enable_platform_interrupt(void)
Enable the bus interrupt.
Definition: sl_wfx_host_spi.c:143
sl_status_t sl_wfx_host_init_bus(void)
Initialize the host bus.
Definition: sl_wfx_host_spi.c:107
sl_status_t sl_wfx_host_wait_for_wake_up(void)
Called once the WFx chip is waking up.
Definition: sl_wfx_host.c:191
sl_status_t sl_wfx_host_get_pds_size(uint16_t *pds_size)
Driver hook to get the number of lines of the PDS.
Definition: sl_wfx_host.c:146
sl_status_t sl_wfx_host_sleep_grant(sl_wfx_host_bus_transfer_type_t type, sl_wfx_register_address_t address, uint32_t length)
Called when the driver is considering putting the WFx in sleep mode.
Definition: sl_wfx_host.c:206
sl_status_t sl_wfx_host_get_pds_data(const char **pds_data, uint16_t index)
Driver hook to retrieve a PDS line.
Definition: sl_wfx_host.c:136
sl_status_t sl_wfx_host_wait(uint32_t wait_ms)
Called when the FMAC driver wants to add a delay.
Definition: sl_wfx_host.c:254
sl_status_t sl_wfx_host_allocate_buffer(void **buffer, sl_wfx_buffer_type_t type, uint32_t buffer_size)
Called when the driver wants to allocate memory.
Definition: sl_wfx_host.c:380
sl_status_t sl_wfx_host_unlock(void)
Called when the driver needs to unlock its access.
Definition: sl_wfx_host.c:451
sl_status_t sl_wfx_host_transmit_frame(void *frame, uint32_t frame_len)
Called when the driver sends a frame to the WFx chip.
Definition: sl_wfx_host.c:432
sl_status_t sl_wfx_host_sdio_enable_high_speed_mode(void)
Enable the SDIO high-speed mode.
sl_status_t sl_wfx_host_post_event(sl_wfx_generic_message_t *event_payload)
Called when a message is received from the WFx chip.
Definition: sl_wfx_host.c:260
sl_status_t sl_wfx_host_sdio_transfer_cmd52(sl_wfx_host_bus_transfer_type_t type, uint8_t function, uint32_t address, uint8_t *buffer)
Send command 52 on the SDIO bus.
sl_status_t sl_wfx_host_spi_transfer_no_cs_assert(sl_wfx_host_bus_transfer_type_t type, uint8_t *header, uint16_t header_length, uint8_t *buffer, uint16_t buffer_length)
Send data on the SPI bus.
Definition: sl_wfx_host_spi.c:184
sl_status_t sl_wfx_host_deinit_bus(void)
Deinitialize the host bus.
Definition: sl_wfx_host_spi.c:163
sl_status_t sl_wfx_host_free_buffer(void *buffer, sl_wfx_buffer_type_t type)
Called when the driver wants to free memory.
Definition: sl_wfx_host.c:423
sl_status_t sl_wfx_host_deinit(void)
Driver hook to deinitialize the host resources.
Definition: sl_wfx_host.c:156
sl_status_t sl_wfx_host_set_wake_up_pin(uint8_t state)
Drive the wake up pin in the requested state.
Definition: sl_wfx_host.c:173
sl_status_t sl_wfx_host_reset_chip(void)
Implement the reset of the WFx chip.
Definition: sl_wfx_host.c:161
sl_status_t sl_wfx_host_init(void)
Driver hook to initialize the host resources.
Definition: sl_wfx_host.c:101
sl_status_t sl_wfx_host_get_firmware_size(uint32_t *firmware_size)
Driver hook to retrieve the firmware size.
Definition: sl_wfx_host.c:126
sl_status_t sl_wfx_host_hold_in_reset(void)
Hold the WFx chip in reset mode.
Definition: sl_wfx_host.c:213
sl_status_t sl_wfx_host_get_firmware_data(const uint8_t **data, uint32_t data_size)
Driver hook to retrieve a firmware chunk.
Definition: sl_wfx_host.c:111
sl_status_t sl_wfx_host_setup_waited_event(uint8_t event_id)
Set up the next event that the driver will wait.
Definition: sl_wfx_host.c:219
sl_status_t sl_wfx_host_spi_cs_assert(void)
Assert the SPI Chip Select pin.
Definition: sl_wfx_host_spi.c:172
sl_status_t sl_wfx_host_sdio_transfer_cmd53(sl_wfx_host_bus_transfer_type_t type, uint8_t function, uint32_t address, uint8_t *buffer, uint16_t buffer_length)
Send command 53 on the SDIO bus.
sl_status_t sl_wfx_host_lock(void)
Called when the driver needs to lock its access.
Definition: sl_wfx_host.c:437
sl_status_t sl_wfx_host_spi_cs_deassert(void)
Deassert the SPI Chip Select pin.
Definition: sl_wfx_host_spi.c:178
Structure used to maintain the Wi-Fi solution context on the host side.
Definition: sl_wfx_constants.h:400
Generic message structure for all requests, confirmations and indications.
Definition: sl_wfx_general_api.h:124