Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit038f261

Browse files
committed
rp2: Move cyw43 code from main.
The "init" code can now be added to rp2_network_cyw43_make_new.Signed-off-by: Peter Harper <peter.harper@raspberrypi.com>
1 parent5f18e53 commit038f261

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

‎ports/rp2/main.c

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,11 @@
4949

5050
#include"pico/stdlib.h"
5151
#include"pico/binary_info.h"
52-
#include"pico/unique_id.h"
5352
#include"hardware/structs/rosc.h"
5453
#ifMICROPY_PY_LWIP
5554
#include"lwip/init.h"
5655
#include"lwip/apps/mdns.h"
5756
#endif
58-
#ifMICROPY_PY_NETWORK_CYW43
59-
#include"lib/cyw43-driver/src/cyw43.h"
60-
#endif
6157
#ifPICO_RP2040
6258
#include"RP2040.h"// cmsis, for PendSV_IRQn and SCB/SCB_SCR_SEVONPEND_Msk
6359
#elifPICO_RP2350&&PICO_ARM
@@ -131,28 +127,6 @@ int main(int argc, char **argv) {
131127
#endif
132128
#endif
133129

134-
#ifMICROPY_PY_NETWORK_CYW43||MICROPY_PY_BLUETOOTH_CYW43
135-
{
136-
cyw43_init(&cyw43_state);
137-
cyw43_irq_init();
138-
cyw43_post_poll_hook();// enable the irq
139-
uint8_tbuf[8];
140-
memcpy(&buf[0],"PICO",4);
141-
142-
// MAC isn't loaded from OTP yet, so use unique id to generate the default AP ssid.
143-
constcharhexchr[16]="0123456789ABCDEF";
144-
pico_unique_board_id_tpid;
145-
pico_get_unique_board_id(&pid);
146-
buf[4]=hexchr[pid.id[7] >>4];
147-
buf[5]=hexchr[pid.id[6]&0xf];
148-
buf[6]=hexchr[pid.id[5] >>4];
149-
buf[7]=hexchr[pid.id[4]&0xf];
150-
cyw43_wifi_ap_set_ssid(&cyw43_state,8,buf);
151-
cyw43_wifi_ap_set_auth(&cyw43_state,CYW43_AUTH_WPA2_AES_PSK);
152-
cyw43_wifi_ap_set_password(&cyw43_state,8, (constuint8_t*)"picoW123");
153-
}
154-
#endif
155-
156130
// Hook for setting up anything that can wait until after other hardware features are initialised.
157131
MICROPY_BOARD_EARLY_INIT();
158132

‎ports/rp2/rp2_network_cyw43.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include"extmod/network_cyw43.h"
33
#include"extmod/modnetwork.h"
44
#include"lib/cyw43-driver/src/cyw43.h"
5+
#include"pico/unique_id.h"
56

67
voidcyw43_irq_deinit(void);
78
voidcyw43_irq_init(void);
@@ -16,6 +17,30 @@ extern int cyw43_set_pins_wl(uint pins[CYW43_PIN_INDEX_WL_COUNT]);
1617
externvoidcyw43_set_pio_clock_divisor(uint16_tclock_div_int,uint8_tclock_div_frac);
1718
#endif
1819

20+
staticvoidrp2_network_cyw43_init(void) {
21+
staticboolcyw43_init_done;
22+
if (!cyw43_init_done) {
23+
cyw43_init(&cyw43_state);
24+
cyw43_irq_init();
25+
cyw43_post_poll_hook();// enable the irq
26+
cyw43_init_done= true;
27+
}
28+
uint8_tbuf[8];
29+
memcpy(&buf[0],"PICO",4);
30+
31+
// Use unique id to generate the default AP ssid.
32+
constcharhexchr[16]="0123456789ABCDEF";
33+
pico_unique_board_id_tpid;
34+
pico_get_unique_board_id(&pid);
35+
buf[4]=hexchr[pid.id[7] >>4];
36+
buf[5]=hexchr[pid.id[6]&0xf];
37+
buf[6]=hexchr[pid.id[5] >>4];
38+
buf[7]=hexchr[pid.id[4]&0xf];
39+
cyw43_wifi_ap_set_ssid(&cyw43_state,8,buf);
40+
cyw43_wifi_ap_set_auth(&cyw43_state,CYW43_AUTH_WPA2_AES_PSK);
41+
cyw43_wifi_ap_set_password(&cyw43_state,8, (constuint8_t*)"picoW123");
42+
}
43+
1944
mp_obj_trp2_network_cyw43_make_new(constmp_obj_type_t*type,size_tn_args,size_tn_kw,constmp_obj_t*all_args) {
2045
enum {ARG_interface,ARG_pin_on,ARG_pin_out,ARG_pin_in,ARG_pin_wake,ARG_pin_clock,ARG_pin_cs,ARG_pin_dat,ARG_div_int,ARG_div_frac };
2146
staticconstmp_arg_tallowed_args[]= {
@@ -36,6 +61,7 @@ mp_obj_t rp2_network_cyw43_make_new(const mp_obj_type_t *type, size_t n_args, si
3661
};
3762
mp_arg_val_targs[MP_ARRAY_SIZE(allowed_args)];
3863
mp_arg_parse_all_kw_array(n_args,n_kw,all_args,MP_ARRAY_SIZE(allowed_args),allowed_args,args);
64+
rp2_network_cyw43_init();
3965

4066
// Set the pins
4167
#ifCYW43_PIN_WL_DYNAMIC

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp