cyw43_arch.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022 Raspberry Pi (Trading) Ltd.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef _PICO_CYW43_ARCH_H
8 #define _PICO_CYW43_ARCH_H
9 
10 #include "pico.h"
11 
12 #ifdef __cplusplus
13 extern "C" {
14 #endif
15 
16 #include "cyw43.h"
17 #include "cyw43_country.h"
18 #include "pico/async_context.h"
19 
20 #ifdef PICO_CYW43_ARCH_HEADER
21 #include __XSTRING(PICO_CYW43_ARCH_HEADER)
22 #else
23 #if PICO_CYW43_ARCH_POLL
24 #include "pico/cyw43_arch/arch_poll.h"
25 #elif PICO_CYW43_ARCH_THREADSAFE_BACKGROUND
26 #include "pico/cyw43_arch/arch_threadsafe_background.h"
27 #elif PICO_CYW43_ARCH_FREERTOS
28 #include "pico/cyw43_arch/arch_freertos.h"
29 #else
30 #error must specify support pico_cyw43_arch architecture type or set PICO_CYW43_ARCH_HEADER
31 #endif
32 #endif
33 
133 // PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_CYW43_ARCH, Enable/disable assertions in the pico_cyw43_arch module, type=bool, default=0, group=pico_cyw43_arch
134 #ifndef PARAM_ASSERTIONS_ENABLED_CYW43_ARCH
135 #define PARAM_ASSERTIONS_ENABLED_CYW43_ARCH 0
136 #endif
137 
138 // PICO_CONFIG: PICO_CYW43_ARCH_DEBUG_ENABLED, Enable/disable some debugging output in the pico_cyw43_arch module, type=bool, default=1 in debug builds, group=pico_cyw43_arch
139 #ifndef PICO_CYW43_ARCH_DEBUG_ENABLED
140 #ifndef NDEBUG
141 #define PICO_CYW43_ARCH_DEBUG_ENABLED 1
142 #else
143 #define PICO_CYW43_ARCH_DEBUG_ENABLED 0
144 #endif
145 #endif
146 
147 // PICO_CONFIG: PICO_CYW43_ARCH_DEFAULT_COUNTRY_CODE, Default country code for the cyw43 wireless driver, default=CYW43_COUNTRY_WORLDWIDE, group=pico_cyw43_arch
148 #ifndef PICO_CYW43_ARCH_DEFAULT_COUNTRY_CODE
149 #define PICO_CYW43_ARCH_DEFAULT_COUNTRY_CODE CYW43_COUNTRY_WORLDWIDE
150 #endif
151 
170 int cyw43_arch_init(void);
171 
187 int cyw43_arch_init_with_country(uint32_t country);
188 
199 void cyw43_arch_deinit(void);
200 
208 
219 
231 
240 void cyw43_arch_poll(void);
241 
253 
273 static inline void cyw43_arch_lwip_begin(void) {
274  cyw43_thread_enter();
275 }
276 
296 static inline void cyw43_arch_lwip_end(void) {
297  cyw43_thread_exit();
298 }
299 
316 static inline int cyw43_arch_lwip_protect(int (*func)(void *param), void *param) {
318  int rc = func(param);
320  return rc;
321 }
322 
350 uint32_t cyw43_arch_get_country_code(void);
351 
358 void cyw43_arch_enable_sta_mode(void);
359 
370 void cyw43_arch_enable_ap_mode(const char *ssid, const char *password, uint32_t auth);
371 
383 int cyw43_arch_wifi_connect_blocking(const char *ssid, const char *pw, uint32_t auth);
384 
397 int cyw43_arch_wifi_connect_bssid_blocking(const char *ssid, const uint8_t *bssid, const char *pw, uint32_t auth);
398 
410 int cyw43_arch_wifi_connect_timeout_ms(const char *ssid, const char *pw, uint32_t auth, uint32_t timeout);
411 
424 int cyw43_arch_wifi_connect_bssid_timeout_ms(const char *ssid, const uint8_t *bssid, const char *pw, uint32_t auth, uint32_t timeout);
425 
440 int cyw43_arch_wifi_connect_async(const char *ssid, const char *pw, uint32_t auth);
441 
457 int cyw43_arch_wifi_connect_bssid_async(const char *ssid, const uint8_t *bssid, const char *pw, uint32_t auth);
458 
468 void cyw43_arch_gpio_put(uint wl_gpio, bool value);
469 
479 bool cyw43_arch_gpio_get(uint wl_gpio);
480 
481 #ifdef __cplusplus
482 }
483 #endif
484 
485 #endif
int cyw43_arch_init_with_country(uint32_t country)
Initialize the CYW43 architecture for use in a specific countryThis method initializes the cyw43_driv...
Definition: cyw43_arch.c:143
int cyw43_arch_init(void)
Initialize the CYW43 architectureThis method initializes the cyw43_driver code and initializes the lw...
CYW43 country codes.
void cyw43_arch_deinit(void)
De-initialize the CYW43 architectureThis method de-initializes the cyw43_driver code and de-initializ...
static int cyw43_arch_lwip_protect(int(*func)(void *param), void *param)
sad Release any locks required for calling into lwIPThe lwIP API is not thread safe. You can use this method to wrap a function with any locking required to call into the lwIP API. If you are using single-core polling only (pico_cyw43_arch_poll) then there are no locks to required, but it is still good practice to use this function.
Definition: cyw43_arch.h:316
Definition: types.h:33
uint32_t cyw43_arch_get_country_code(void)
Return the country code used to initialize cyw43_arch.
Definition: cyw43_arch.c:139
int cyw43_arch_wifi_connect_timeout_ms(const char *ssid, const char *pw, uint32_t auth, uint32_t timeout)
Attempt to connect to a wireless access point, blocking until the network is joined, a failure is detected or a timeout occurs.
Definition: cyw43_arch.c:131
CYW43 driver interface.
void cyw43_arch_gpio_put(uint wl_gpio, bool value)
Set a GPIO pin on the wireless chip to a given value.
Definition: cyw43_arch.c:148
static void cyw43_arch_lwip_begin(void)
Acquire any locks required to call into lwIPThe lwIP API is not thread safe. You should surround call...
Definition: cyw43_arch.h:273
int cyw43_arch_wifi_connect_bssid_timeout_ms(const char *ssid, const uint8_t *bssid, const char *pw, uint32_t auth, uint32_t timeout)
Attempt to connect to a wireless access point specified by SSID and BSSID, blocking until the network...
Definition: cyw43_arch.c:135
async_context_t * cyw43_arch_async_context(void)
Return the current async_context currently in use by the cyw43_arch code.
Definition: cyw43_arch.c:160
async_context_t * cyw43_arch_init_default_async_context(void)
Initialize the default async_context for the current cyw43_arch typeThis method initializes and retur...
int cyw43_arch_wifi_connect_blocking(const char *ssid, const char *pw, uint32_t auth)
Attempt to connect to a wireless access point, blocking until the network is joined or a failure is d...
Definition: cyw43_arch.c:123
Base structure type of all async_contexts. For details about its use, see pico_async_context.Individual async_context_types with additional state, should contain this structure at the start.
Definition: async_context.h:175
void cyw43_arch_enable_sta_mode(void)
Enables Wi-Fi STA (Station) mode.This enables the Wi-Fi in mode such that connections can be made to...
Definition: cyw43_arch.c:31
int cyw43_arch_wifi_connect_bssid_async(const char *ssid, const uint8_t *bssid, const char *pw, uint32_t auth)
Start attempting to connect to a wireless access point specified by SSID and BSSIDThis method tells t...
Definition: cyw43_arch.c:73
int cyw43_arch_wifi_connect_async(const char *ssid, const char *pw, uint32_t auth)
Start attempting to connect to a wireless access pointThis method tells the CYW43 driver to start con...
Definition: cyw43_arch.c:79
void cyw43_arch_poll(void)
Perform any processing required by the cyw43_driver or the TCP/IP stackThis method must be called per...
Definition: cyw43_arch.c:164
bool cyw43_arch_gpio_get(uint wl_gpio)
Read the value of a GPIO pin on the wireless chip.
Definition: cyw43_arch.c:153
int cyw43_arch_wifi_connect_bssid_blocking(const char *ssid, const uint8_t *bssid, const char *pw, uint32_t auth)
Attempt to connect to a wireless access point specified by SSID and BSSID, blocking until the network...
Definition: cyw43_arch.c:127
static void cyw43_arch_lwip_end(void)
Release any locks required for calling into lwIPThe lwIP API is not thread safe. You should surround ...
Definition: cyw43_arch.h:296
void cyw43_arch_set_async_context(async_context_t *context)
Set the async_context to be used by the cyw43_arch_init.
Definition: cyw43_arch.c:27
void cyw43_arch_enable_ap_mode(const char *ssid, const char *password, uint32_t auth)
Enables Wi-Fi AP (Access point) mode.This enables the Wi-Fi in Access Point mode such that connection...
Definition: cyw43_arch.c:36
void cyw43_arch_wait_for_work_until(absolute_time_t until)
Sleep until there is cyw43_driver work to be doneThis method may be called by code that is waiting fo...
Definition: cyw43_arch.c:169