Modern embedded framework, using Rust and async.
f2ac14b86f
This commit adds two constants which are intended to be used for setting the `Word Length` and `High Speed` fields in the gSPR register (address: 0x0000, bit: 0 and bit 4). Currently, this field is being set by the following line: ```rust // 32bit, little endian. self.write32_swapped(REG_BUS_CTRL, 0x00010031).await; ``` Assuming that we are sending these bits using the gSPI write protocol and using 16-bit word operation in little endian (which I think might be the default) then the data bytes should be packed like this: ``` +--+--+--+--+ |D1|D0|D3|D2| +--+--+--+--+ val (hex): 0x00010031 val (bin): 00000000000000010000000000110001 rotated(16): 00000000001100010000000000000001 ``` If we split val into bytes and rotated the bits we get: ``` Split into bytes: D3 D2 D1 D0 00000000 00000001 00000000 00110001 Rotate 16 and split into bytes: D1 D0 D3 D2 00000000 00110001 00000000 00000001 ``` Looking at the write procotol it seems to me that the above will indeed set the `Word Length` to 1 but will also set other values. ``` Status enable (1=default) D1 D0 D3 D2 ↓ 00000000 00110001 00000000 00000001 ↑↑ ↑↑ ↑ || |Word Length (1=32-bit) || | || Endianess (0=Little) || |High-speed mode (1=High speed (default)) | Interrupt polarity (1=high (default)) ``` This commit suggests adding the above mentioned constants for setting the only the word length field and the high speed field. |
||
---|---|---|
.vscode | ||
examples/rpi-pico-w | ||
firmware | ||
src | ||
.gitignore | ||
Cargo.toml | ||
LICENSE-APACHE | ||
LICENSE-MIT | ||
README.md | ||
rust-toolchain.toml | ||
rustfmt.toml |
cyw43
WIP driver for the CYW43439 wifi chip, used in the Raspberry Pi Pico W. Implementation based on Infineon/wifi-host-driver.
Current status
Working:
- Station mode (joining an AP).
- Sending and receiving Ethernet frames.
- Using the default MAC address.
embassy-net
integration.
TODO:
- AP mode (creating an AP)
- GPIO support (used for the Pico W LED)
- Scanning
- Setting a custom MAC address.
- RP2040 PIO driver for the nonstandard half-duplex SPI used in the Pico W. Probably porting this. (Currently bitbanging is used).
- Using the IRQ pin instead of polling the bus.
- Bus sleep (unclear what the benefit is. Is it needed for IRQs? or is it just power consumption optimization?)
Running the example
cargo install probe-run
cd examples/rpi-pico-w
WIFI_NETWORK=MyWifiNetwork WIFI_PASSWORD=MyWifiPassword cargo run --release
After a few seconds, you should see that DHCP picks up an IP address like this
11.944489 DEBUG Acquired IP configuration:
11.944517 DEBUG IP address: 192.168.0.250/24
11.944620 DEBUG Default gateway: 192.168.0.33
11.944722 DEBUG DNS server 0: 192.168.0.33
The example implements a TCP echo server on port 1234. You can try connecting to it with:
nc 192.168.0.250 1234
Send it some data, you should see it echoed back and printed in the firmware's logs.
License
This work is licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.