Move more code from pico_cyw43_arch to pico_cyw43_driver (#1201)
Basically the integration code (cyw43_config.h and related implementations) are now in the driver. cyw43_arch now just has * async_context creation per CYW43_ARCH_TYPE * pre-existing cyw43_arch methods for connect etc.
This commit is contained in:
@ -119,30 +119,6 @@ int cyw43_arch_wifi_connect_timeout_ms(const char *ssid, const char *pw, uint32_
|
||||
return cyw43_arch_wifi_connect_until(ssid, pw, auth, make_timeout_time_ms(timeout_ms));
|
||||
}
|
||||
|
||||
// todo maybe add an #ifdef in cyw43_driver
|
||||
uint32_t storage_read_blocks(__unused uint8_t *dest, __unused uint32_t block_num, __unused uint32_t num_blocks) {
|
||||
// shouldn't be used
|
||||
panic_unsupported();
|
||||
}
|
||||
|
||||
// Generate a mac address if one is not set in otp
|
||||
void cyw43_hal_generate_laa_mac(__unused int idx, uint8_t buf[6]) {
|
||||
CYW43_DEBUG("Warning. No mac in otp. Generating mac from board id\n");
|
||||
pico_unique_board_id_t board_id;
|
||||
pico_get_unique_board_id(&board_id);
|
||||
memcpy(buf, &board_id.id[2], 6);
|
||||
buf[0] &= (uint8_t)~0x1; // unicast
|
||||
buf[0] |= 0x2; // locally administered
|
||||
}
|
||||
|
||||
// Return mac address
|
||||
void cyw43_hal_get_mac(__unused int idx, uint8_t buf[6]) {
|
||||
// The mac should come from cyw43 otp.
|
||||
// This is loaded into the state after the driver is initialised
|
||||
// cyw43_hal_generate_laa_mac is called by the driver to generate a mac if otp is not set
|
||||
memcpy(buf, cyw43_state.mac, 6);
|
||||
}
|
||||
|
||||
uint32_t cyw43_arch_get_country_code(void) {
|
||||
return country_code;
|
||||
}
|
||||
@ -175,52 +151,4 @@ void cyw43_arch_poll(void)
|
||||
|
||||
void cyw43_arch_wait_for_work_until(absolute_time_t until) {
|
||||
async_context_wait_for_work_until(async_context, until);
|
||||
}
|
||||
|
||||
// Prevent background processing in pensv and access by the other core
|
||||
// These methods are called in pensv context and on either core
|
||||
// They can be called recursively
|
||||
void cyw43_thread_enter(void) {
|
||||
async_context_acquire_lock_blocking(async_context);
|
||||
}
|
||||
|
||||
void cyw43_thread_exit(void) {
|
||||
async_context_release_lock(async_context);
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
void cyw43_thread_lock_check(void) {
|
||||
async_context_lock_check(async_context);
|
||||
}
|
||||
#endif
|
||||
|
||||
void cyw43_await_background_or_timeout_us(uint32_t timeout_us) {
|
||||
async_context_wait_for_work_until(async_context, make_timeout_time_us(timeout_us));
|
||||
}
|
||||
|
||||
void cyw43_delay_ms(uint32_t ms) {
|
||||
async_context_wait_until(async_context, make_timeout_time_ms(ms));
|
||||
}
|
||||
|
||||
void cyw43_delay_us(uint32_t us) {
|
||||
async_context_wait_until(async_context, make_timeout_time_us(us));
|
||||
}
|
||||
|
||||
#if !CYW43_LWIP
|
||||
static void no_lwip_fail() {
|
||||
panic("cyw43 has no ethernet interface");
|
||||
}
|
||||
void __attribute__((weak)) cyw43_cb_tcpip_init(cyw43_t *self, int itf) {
|
||||
}
|
||||
void __attribute__((weak)) cyw43_cb_tcpip_deinit(cyw43_t *self, int itf) {
|
||||
}
|
||||
void __attribute__((weak)) cyw43_cb_tcpip_set_link_up(cyw43_t *self, int itf) {
|
||||
no_lwip_fail();
|
||||
}
|
||||
void __attribute__((weak)) cyw43_cb_tcpip_set_link_down(cyw43_t *self, int itf) {
|
||||
no_lwip_fail();
|
||||
}
|
||||
void __attribute__((weak)) cyw43_cb_process_ethernet(void *cb_data, int itf, size_t len, const uint8_t *buf) {
|
||||
no_lwip_fail();
|
||||
}
|
||||
#endif
|
||||
}
|
Reference in New Issue
Block a user