pico_cyw43_arch

Modules

 cyw43_driver
 Driver used for Pico W wireless.
 

Macros

#define cyw43_arch_lwip_check()   cyw43_thread_lock_check()
 Checks the caller has any locks required for calling into lwIP. More...
 

Functions

int cyw43_arch_init (void)
 Initialize the CYW43 architecture. More...
 
int cyw43_arch_init_with_country (uint32_t country)
 Initialize the CYW43 architecture for use in a specific country. More...
 
void cyw43_arch_enable_sta_mode (void)
 Enables Wi-Fi STA (Station) mode. More...
 
void cyw43_arch_enable_ap_mode (const char *ssid, const char *password, uint32_t auth)
 Enables Wi-Fi AP (Access point) mode. More...
 
void cyw43_arch_deinit (void)
 De-initialize the CYW43 architecture. More...
 
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 detected. More...
 
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. More...
 
int cyw43_arch_wifi_connect_async (const char *ssid, const char *pw, uint32_t auth)
 Start attempting to connect to a wireless access point. More...
 
uint32_t cyw43_arch_get_country_code (void)
 Return the country code used to initialize cyw43_arch. More...
 
void cyw43_arch_gpio_put (uint wl_gpio, bool value)
 Set a GPIO pin on the wireless chip to a given value. More...
 
bool cyw43_arch_gpio_get (uint wl_gpio)
 Read the value of a GPIO pin on the wireless chip. More...
 
void cyw43_arch_poll (void)
 Perform any processing required by the cyw43_driver or the TCP/IP stack. More...
 

Detailed Description

Architecture for integrating the CYW43 driver (for the wireless on Pico W) and lwIP (for TCP/IP stack) into the SDK. It is also necessary for accessing the on-board LED on Pico W

Both the low level cyw43_driver and the lwIP stack require periodic servicing, and have limitations on whether they can be called from multiple cores/threads.

pico_cyw43_arch attempts to abstract these complications into several behavioral groups:

As of right now, lwIP is the only supported TCP/IP stack, however the use of pico_cyw43_arch is intended to be independent of the particular TCP/IP stack used (and possibly Bluetooth stack used) in the future. For this reason, the integration of lwIP is handled in the base (pico_cyw43_arch) library based on the #define CYW43_LWIP used by the cyw43_driver.

Whilst you can use the pico_cyw43_arch library directly and specify CYW$#_LWIP (and other defines) yourself, several other libraries are made available to the build which aggregate the defines and other dependencies for you:

Macro Definition Documentation

◆ cyw43_arch_lwip_check

void cyw43_arch_lwip_check (   void)    cyw43_thread_lock_check()

Checks the caller has any locks required for calling into lwIP.

The lwIP API is not thread safe. You should surround calls into the lwIP API with calls to cyw43_arch_lwip_begin and this method. Note these calls are not necessary (but harmless) when you are calling back into the lwIP API from an lwIP callback.

This method will assert in debug mode, if the above conditions are not met (i.e. it is not safe to call into the lwIP API)

See also
cyw43_arch_lwip_begin
cyw43_arch_lwip_protect

Function Documentation

◆ cyw43_arch_deinit()

void cyw43_arch_deinit ( void  )

De-initialize the CYW43 architecture.

This method de-initializes the cyw43_driver code and de-initializes the lwIP stack (if it was enabled at build time). Note this method should always be called from the same core (or RTOS task, depending on the environment) as cyw43_arch_init.

◆ cyw43_arch_enable_ap_mode()

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 connections can be made to the device by other Wi-Fi clients

Parameters
ssidthe name for the access point
passwordthe password to use or NULL for no password.
auththe authorization type to use when the password is enabled. Values are CYW43_AUTH_WPA_TKIP_PSK, CYW43_AUTH_WPA2_AES_PSK, or CYW43_AUTH_WPA2_MIXED_PSK (see CYW43_AUTH_)

◆ cyw43_arch_enable_sta_mode()

void cyw43_arch_enable_sta_mode ( void  )

Enables Wi-Fi STA (Station) mode.

This enables the Wi-Fi in \emStation mode such that connections can be made to other Wi-Fi Access Points

◆ cyw43_arch_get_country_code()

uint32_t cyw43_arch_get_country_code ( void  )

Return the country code used to initialize cyw43_arch.

Returns
the country code (see CYW43_COUNTRY_)

◆ cyw43_arch_gpio_get()

bool cyw43_arch_gpio_get ( uint  wl_gpio)

Read the value of a GPIO pin on the wireless chip.

Note
this method does not check for errors setting the GPIO. You can use the lower level cyw43_gpio_get instead if you wish to check for errors.
Parameters
wl_gpiothe GPIO number on the wireless chip
Returns
true if the GPIO is high, false otherwise

◆ cyw43_arch_gpio_put()

void cyw43_arch_gpio_put ( uint  wl_gpio,
bool  value 
)

Set a GPIO pin on the wireless chip to a given value.

Note
this method does not check for errors setting the GPIO. You can use the lower level cyw43_gpio_set instead if you wish to check for errors.
Parameters
wl_gpiothe GPIO number on the wireless chip
valuetrue to set the GPIO, false to clear it.

◆ cyw43_arch_init()

int cyw43_arch_init ( void  )

Initialize the CYW43 architecture.

This method initializes the cyw43_driver code and initializes the lwIP stack (if it was enabled at build time). This method must be called prior to using any other pico_cyw43_arch, \cyw43_driver or lwIP functions.

Note
this method initializes wireless with a country code of PICO_CYW43_ARCH_DEFAULT_COUNTRY_CODE which defaults to CYW43_COUNTRY_WORLDWIDE. Worldwide settings may not give the best performance; consider setting PICO_CYW43_ARCH_DEFAULT_COUNTRY_CODE to a different value or calling cyw43_arch_init_with_country
Returns
0 if the initialization is successful, an error code otherwise
See also
pico_error_codes

◆ cyw43_arch_init_with_country()

int cyw43_arch_init_with_country ( uint32_t  country)

Initialize the CYW43 architecture for use in a specific country.

This method initializes the cyw43_driver code and initializes the lwIP stack (if it was enabled at build time). This method must be called prior to using any other pico_cyw43_arch, \cyw43_driver or lwIP functions.

Parameters
countrythe country code to use (see CYW43_COUNTRY_)
Returns
0 if the initialization is successful, an error code otherwise
See also
pico_error_codes

◆ cyw43_arch_poll()

void cyw43_arch_poll ( void  )

Perform any processing required by the cyw43_driver or the TCP/IP stack.

This method must be called periodically from the main loop when using a polling style pico_cyw43_arch (e.g. pico_cyw43_arch_lwip_poll ). It may be called in other styles, but it is unnecessary to do so.

◆ cyw43_arch_wifi_connect_async()

int cyw43_arch_wifi_connect_async ( const char *  ssid,
const char *  pw,
uint32_t  auth 
)

Start attempting to connect to a wireless access point.

This method tells the CYW43 driver to start connecting to an access point. You should subsequently check the status by calling cyw43_wifi_link_status.

Parameters
ssidthe network name to connect to
passwordthe network password or NULL if there is no password required
auththe authorization type to use when the password is enabled. Values are CYW43_AUTH_WPA_TKIP_PSK, CYW43_AUTH_WPA2_AES_PSK, or CYW43_AUTH_WPA2_MIXED_PSK (see CYW43_AUTH_)
Returns
0 if the scan was started successfully, an error code otherwise
See also
pico_error_codes

◆ cyw43_arch_wifi_connect_blocking()

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 detected.

Parameters
ssidthe network name to connect to
passwordthe network password or NULL if there is no password required
auththe authorization type to use when the password is enabled. Values are CYW43_AUTH_WPA_TKIP_PSK, CYW43_AUTH_WPA2_AES_PSK, or CYW43_AUTH_WPA2_MIXED_PSK (see CYW43_AUTH_)
Returns
0 if the initialization is successful, an error code otherwise
See also
pico_error_codes

◆ cyw43_arch_wifi_connect_timeout_ms()

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.

Parameters
ssidthe network name to connect to
passwordthe network password or NULL if there is no password required
auththe authorization type to use when the password is enabled. Values are CYW43_AUTH_WPA_TKIP_PSK, CYW43_AUTH_WPA2_AES_PSK, or CYW43_AUTH_WPA2_MIXED_PSK (see CYW43_AUTH_)
Returns
0 if the initialization is successful, an error code otherwise
See also
pico_error_codes