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
13extern "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_PICO_CYW43_ARCH, Enable/disable assertions in the pico_cyw43_arch module, type=bool, default=0, group=pico_cyw43_arch
134#ifndef PARAM_ASSERTIONS_ENABLED_PICO_CYW43_ARCH
135#ifdef PARAM_ASSERTIONS_ENABLED_CYW43_ARCH // backwards compatibility with SDK < 2.0.0
136#define PARAM_ASSERTIONS_ENABLED_PICO_CYW43_ARCH PARAM_ASSERTIONS_ENABLED_CYW43_ARCH
137#else
138#define PARAM_ASSERTIONS_ENABLED_PICO_CYW43_ARCH 0
139#endif
140#endif
141
142// 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
143#ifndef PICO_CYW43_ARCH_DEBUG_ENABLED
144#ifndef NDEBUG
145#define PICO_CYW43_ARCH_DEBUG_ENABLED 1
146#else
147#define PICO_CYW43_ARCH_DEBUG_ENABLED 0
148#endif
149#endif
150
151// PICO_CONFIG: PICO_CYW43_ARCH_DEFAULT_COUNTRY_CODE, Default country code for the cyw43 wireless driver, default=CYW43_COUNTRY_WORLDWIDE, group=pico_cyw43_arch
152#ifndef PICO_CYW43_ARCH_DEFAULT_COUNTRY_CODE
153#define PICO_CYW43_ARCH_DEFAULT_COUNTRY_CODE CYW43_COUNTRY_WORLDWIDE
154#endif
155
175
191int cyw43_arch_init_with_country(uint32_t country);
192
204
212
223
235
244void cyw43_arch_poll(void);
245
257
277static inline void cyw43_arch_lwip_begin(void) {
278 cyw43_thread_enter();
279}
280
300static inline void cyw43_arch_lwip_end(void) {
301 cyw43_thread_exit();
302}
303
320static inline int cyw43_arch_lwip_protect(int (*func)(void *param), void *param) {
322 int rc = func(param);
324 return rc;
325}
326
354uint32_t cyw43_arch_get_country_code(void);
355
363
372
383void cyw43_arch_enable_ap_mode(const char *ssid, const char *password, uint32_t auth);
384
392
404int cyw43_arch_wifi_connect_blocking(const char *ssid, const char *pw, uint32_t auth);
405
418int cyw43_arch_wifi_connect_bssid_blocking(const char *ssid, const uint8_t *bssid, const char *pw, uint32_t auth);
419
432int cyw43_arch_wifi_connect_timeout_ms(const char *ssid, const char *pw, uint32_t auth, uint32_t timeout);
433
447int cyw43_arch_wifi_connect_bssid_timeout_ms(const char *ssid, const uint8_t *bssid, const char *pw, uint32_t auth, uint32_t timeout);
448
463int cyw43_arch_wifi_connect_async(const char *ssid, const char *pw, uint32_t auth);
464
480int cyw43_arch_wifi_connect_bssid_async(const char *ssid, const uint8_t *bssid, const char *pw, uint32_t auth);
481
491void cyw43_arch_gpio_put(uint wl_gpio, bool value);
492
502bool cyw43_arch_gpio_get(uint wl_gpio);
503
504#ifdef __cplusplus
505}
506#endif
507
508#endif
CYW43 driver interface.
CYW43 country codes.
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:177
void cyw43_arch_enable_ap_mode(const char *ssid, const char *password, uint32_t auth)
Enables Wi-Fi AP (Access point) mode.
Definition: cyw43_arch.c:47
static int cyw43_arch_lwip_protect(int(*func)(void *param), void *param)
sad Release any locks required for calling into lwIP
Definition: cyw43_arch.h:320
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:165
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 BSSID.
Definition: cyw43_arch.c:90
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
uint32_t cyw43_arch_get_country_code(void)
Return the country code used to initialize cyw43_arch.
Definition: cyw43_arch.c:156
int cyw43_arch_wifi_connect_async(const char *ssid, const char *pw, uint32_t auth)
Start attempting to connect to a wireless access point.
Definition: cyw43_arch.c:96
void cyw43_arch_enable_sta_mode(void)
Enables Wi-Fi STA (Station) mode.
Definition: cyw43_arch.c:31
static void cyw43_arch_lwip_begin(void)
Acquire any locks required to call into lwIP.
Definition: cyw43_arch.h:277
int cyw43_arch_init(void)
Initialize the CYW43 architecture.
void cyw43_arch_disable_ap_mode(void)
Disables Wi-Fi AP (Access point) mode.
Definition: cyw43_arch.c:59
async_context_t * cyw43_arch_init_default_async_context(void)
Initialize the default async_context for the current cyw43_arch type.
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:140
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:144
void cyw43_arch_disable_sta_mode(void)
Disables Wi-Fi STA (Station) mode.
Definition: cyw43_arch.c:36
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:152
bool cyw43_arch_gpio_get(uint wl_gpio)
Read the value of a GPIO pin on the wireless chip.
Definition: cyw43_arch.c:170
void cyw43_arch_poll(void)
Perform any processing required by the cyw43_driver or the TCP/IP stack.
Definition: cyw43_arch.c:181
void cyw43_arch_wait_for_work_until(absolute_time_t until)
Sleep until there is cyw43_driver work to be done.
Definition: cyw43_arch.c:186
static void cyw43_arch_lwip_end(void)
Release any locks required for calling into lwIP.
Definition: cyw43_arch.h:300
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,...
Definition: cyw43_arch.c:148
void cyw43_arch_deinit(void)
De-initialize the CYW43 architecture.
int cyw43_arch_init_with_country(uint32_t country)
Initialize the CYW43 architecture for use in a specific country.
Definition: cyw43_arch.c:160
uint64_t absolute_time_t
An opaque 64 bit timestamp in microseconds.
Definition: types.h:43
Base structure type of all async_contexts. For details about its use, see pico_async_context.
Definition: async_context.h:179