Commit Graph

60 Commits

Author SHA1 Message Date
kbleeke
0ff606dfc1 Add pio transport to pico w example 2023-03-19 16:58:22 +01:00
kbleeke
d57fe0de86 Custom Bus Trait to support PIO 2023-03-19 16:57:54 +01:00
Dario Nieuwenhuis
a2bae33d84 Add separate function to set power management mode. 2023-01-02 21:36:51 +01:00
Lukas Krejci
001610f0d0 Be able to specify the power management mode at init time. 2023-01-02 21:34:13 +01:00
mattiasgronlund
c1fa46bd36
Merge branch 'master' into wlan_read_fix 2022-12-31 16:40:22 +01:00
Mattias Grönlund
871700f05d Fixed length for wlan_read.
The length provided in command word for FUNC_WLAN READ, should
describe the actual bytes requested, not the size of the buffer
which is sized in u32.
2022-12-31 16:25:37 +01:00
Dario Nieuwenhuis
2548bbdd65 Update Embassy. 2022-12-27 01:19:26 +01:00
Dario Nieuwenhuis
1b6799d93f split bus, consts into separate mods. 2022-12-26 23:34:27 +01:00
Dario Nieuwenhuis
076ada4c02 Add feature to display console logs from the wifi firmware. 2022-12-25 22:50:59 +01:00
Dario Nieuwenhuis
42cc0c6d73 print ioctl error as signed. 2022-12-25 22:50:59 +01:00
Dario Nieuwenhuis
56b50f8b62 fix bp_read.
It was broken since the switch from u8 to u32.
2022-12-25 22:50:59 +01:00
Dario Nieuwenhuis
0d84533bcb Use async spi transaction helper macro. 2022-10-02 21:30:43 +02:00
Dario Nieuwenhuis
c385bbf07d Update embassy, embedded-hal. 2022-10-02 21:28:34 +02:00
Daniel Bevenius
3b04ef265c Add constants for BDC_VERSION
This commit adds two constants intended to be used with the
bdc_header.flags field. I believe these are the correct values after
looking at following lines in `whd_cdc_bdc.c`:

40a7ec2273/WiFi_Host_Driver/src/whd_cdc_bdc.c (L34-L35)
40a7ec2273/WiFi_Host_Driver/src/whd_cdc_bdc.c (L447)
2022-09-26 14:53:37 +02:00
Daniel Bevenius
9962db4ecf Suppress compiler warnings
This commit adds the allow(unused) attribute to functions and constants
that are not currently used. There is one warning remaining but
https://github.com/embassy-rs/cyw43/pull/23 attempts to address that
one. The constants have been moved into a module to allow the attribute
to be applied to the module as a whole.

The motivation for this is that it will hopefully make it easier to
spot new warnings that might be introduced by new, or updated code.
2022-09-26 14:08:50 +02:00
Dario Nieuwenhuis
79a9a4eb98
Merge pull request #20 from danbev/glom_comment
Add comment about bus:txglom iovar
2022-09-25 23:39:08 +02:00
Dario Nieuwenhuis
270c4d2476
Merge pull request #21 from danbev/extra-time-waits
Comment out extra Timer:after calls
2022-09-25 23:38:36 +02:00
Dario Nieuwenhuis
6b35f654ba
Merge pull request #22 from danbev/antdiv-const
Add const for IOCTL ANTDIV
2022-09-25 23:37:54 +02:00
Dario Nieuwenhuis
11387c3b03
Merge pull request #23 from danbev/ioctl_set_u32-iface
Update ioctl_set_u32 to pass through iface param
2022-09-25 23:37:35 +02:00
Daniel Bevenius
9aaefa6e71 Add constants for cmd_word arguments
This commit adds constants intended to be used with the `cmd_word`
function.

The motivation for this to (hopefully) improve the readability of the
code.
2022-09-23 15:06:26 +02:00
Daniel Bevenius
281cbcb1e8 Update ioctl_set_u32 to pass through iface param
This commit updates ioctl_set_u32 to pass through the `iface` parameter
to self.iotcl.
2022-09-23 09:39:29 +02:00
Daniel Bevenius
28bf4b7b6d Add const for IOCTL ANTDIV 2022-09-23 09:35:54 +02:00
Daniel Bevenius
3ba0b3ef3b Comment out extra Timer:after calls
This commit comments out two Timer::after calls which look like they
go together with previous instructions, but those instructions are
currently commented out, so it looks like these calls are not
currently needed.
2022-09-23 09:04:59 +02:00
Daniel Bevenius
8f21a5b116 Add comment about bus:txglom iovar
This commit adds a comment to the setting of the iovar `bus:txglom`.

The motivation for this is that I had not heard of 'glom/glomming'
before and having a comment might help others that are not familar with
the term.
2022-09-23 08:37:16 +02:00
Daniel Bevenius
483edf694b Introduce IoctlType enum for IOCTL types
This commit introduces an enum to represent the IOCTL command types
available, the direction of the data transfer (Get and Set).
2022-09-22 14:12:07 +02:00
Daniel Bevenius
520860622b Make self parameter to has_credit non-mutable 2022-09-17 09:06:23 +02:00
Dario Nieuwenhuis
e727fe8675
Merge pull request #16 from danbev/alp
Add contants and update comment about ALP
2022-09-15 13:26:31 +02:00
Daniel Bevenius
96214f9db6 Add constants for channel types 2022-09-15 09:58:44 +02:00
Daniel Bevenius
be20512f17 Add contants and update comment about ALP
This commit add two constants and updates the comment about ALP.

It was not easy to find the definition of ALP but after searching I
found what I believe is the correct definition in section 3.3 "Clocks"
in the referenced document below.

Active Low Power (ALP):
Supplied by an internal or external oscillator. This clock is
requested by cores when accessing backplane registers in other cores
or when performing minor computations. When an external crystal is
used to provide reference clock, ALP clock frequency is determined by
the frequency of the external oscillator. A 37.4 MHz reference clock
 is recommended.

Refs:
https://www.infineon.com/dgdl/Infineon-AN214828_Power_Consumption_Measurements-ApplicationNotes-v03_00-EN.pdf?fileId=8ac78c8c7cdc391c017d0d2803a4630d
2022-09-12 11:49:09 +02:00
Dario Nieuwenhuis
a19bcb69d1
Merge pull request #14 from danbev/ioctl_set_get_consts
Add constants for ioctl commands
2022-09-09 22:11:55 +02:00
Daniel Bevenius
f0b7f43c41 Use wrapping_sub in update_credit
This commit uses wrapping_sub for subtraction in update_credit.

The motivation for this is that currently the rpi-pico-w example panics
(at least for me) with the following error:

3.825277 INFO  init done
└─ cyw43::{impl#4}::init::{async_fn#0} @ /embassy/cyw43/src/fmt.rs:138
3.825486 INFO  Downloading CLM...
└─ cyw43::{impl#2}::init::{async_fn#0} @ /embassy/cyw43/src/fmt.rs:138
3.841328 WARN  TX stalled
└─ cyw43::{impl#4}::run::{async_fn#0} @ /embassy/cyw43/src/fmt.rs:151
3.845549 ERROR panicked at 'attempt to subtract with overflow', /embassy/cyw43/src/lib.rs:919:16
└─ panic_probe::print_defmt::print @ .cargo/registry/src/github.com-1ecc6299db9ec823/panic-probe-0.3.0/src/lib.rs:91
────────────────────────────────────────────────────────────────────────────────
stack backtrace:
   0: HardFaultTrampoline
      <exception entry>
   1: lib::inline::__udf
        at ./asm/inline.rs:181:5
   2: __udf
        at ./asm/lib.rs:51:17
   3: cortex_m::asm::udf
        at .cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-0.7.6/src/asm.rs:43:5
   4: rust_begin_unwind
        at .cargo/registry/src/github.com-1ecc6299db9ec823/panic-probe-0.3.0/src/lib.rs:72:9
   5: core::panicking::panic_fmt
        at rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/core/src/panicking.rs:142:14
   6: core::panicking::panic
        at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/core/src/panicking.rs:48:5
   7: cyw43::Runner<PWR,SPI>::update_credit
        at /embassy/cyw43/src/lib.rs:919:16
   8: cyw43::Runner<PWR,SPI>::rx
        at /embassy/cyw43/src/lib.rs:808:9
   9: cyw43::Runner<PWR,SPI>::run::{{closure}}
        at /embassy/cyw43/src/lib.rs:727:21
  10: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
        at /rustc/1c7b36d4db582cb47513a6c7176baaec1c3346ab/library/core/src/future/mod.rs:91:19
  11: cyw43_example_rpi_pico_w::__wifi_task_task::{{closure}}
        at src/main.rs:32:17
2022-09-09 15:09:54 +02:00
Daniel Bevenius
fe5229670f Add constants for ioctl commands
This commit adds contants for the IOCTL commands that are currently
used in cyw43::Control.
2022-09-09 14:31:00 +02:00
Jan Niehusmann
ea0738c485 Add gpio_set
Example: Blink LED

```
    loop {
        info!("on");
        control.gpio_set(0, true).await;
        Timer::after(Duration::from_millis(200)).await;

        info!("off");
        control.gpio_set(0, false).await;
        Timer::after(Duration::from_millis(200)).await;
    }
```
2022-09-06 21:08:04 +00:00
Jan Niehusmann
5c4d6232ae Fixes after review
- rename tx_seq_max to sdpcm_seq_max
- make sure we have credit for each packet we send
2022-09-06 20:50:27 +00:00
Jan Niehusmann
95f3484b87 Implement minimal tx flow control
The credit update code uses constants from
https://github.com/Infineon/wifi-host-driver/blob/master/WiFi_Host_Driver/src/whd_sdpcm.c#L307-L317
2022-09-06 12:40:22 +00:00
Jan Niehusmann
acaa8b3e8b Fix calculation of slice index
total_len is already rounded up, so the `+ 3` is not needed.
And even if it was, the calculation should have been `((total_len + 3) / 4)`.

`(total_len + 3 / 4)` is equivalent to `total_len` and can overflow
the slice, leading to a panic which can easily be triggered by sending
large ICMP ECHO packets to the device.
2022-08-30 20:37:02 +00:00
Dario Nieuwenhuis
69e92e5639
Merge pull request #6 from danbev/add-word-length-constants
Add WORD_LENGTH_32 constant
2022-08-25 15:52:10 +02:00
Daniel Bevenius
f2ac14b86f Add WORD_LENGTH_32/HIGH_SPEED constants
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.
2022-08-25 15:40:14 +02:00
Dario Nieuwenhuis
193124bed1
Merge pull request #8 from danbev/test-ro-rw-constants
Rename REG_BUS_FEEDBEAD to REG_BUS_TEST_RO
2022-08-25 14:16:16 +02:00
Daniel Bevenius
3826b4f713 Rename REG_BUS_FEEDBEAD to REG_BUS_TEST_RO
This commit renames the REG_BUS_FEEDBEAD to REG_BUS_TEST_RO
(Read-Only) which is the name used in the specification, section 4.2.3
Table 6.

It also adds a constant named REG_BUS_TEST_RW (Read-Write) to represent
the dummy register which the host can use to write data and read back
to check that the gSPI interface is working properly.
2022-08-25 09:13:26 +02:00
Daniel Bevenius
bb76a29ff1 Add comment for AI constants
This commit adds a comment about the AI_* constants.

The motivation for using this definition is from looking in the
following file:
https://github.com/seemoo-lab/bcm-public/blob/master/firmware_patching/examples/ioctl/bcmdhd/include/aidmp.h#L2
https://github.com/seemoo-lab/bcm-public/blob/master/firmware_patching/examples/ioctl/bcmdhd/include/aidmp.h#L307-L361
2022-08-24 15:58:44 +02:00
Dario Nieuwenhuis
9218aff498 Update Embassy. 2022-08-23 01:06:14 +02:00
Dario Nieuwenhuis
945449b10f Update Embassy. 2022-08-22 17:26:05 +02:00
Dario Nieuwenhuis
f76815d642 Update Embassy. 2022-08-13 15:37:30 +02:00
Mattias Grönlund
3388b5cecf Improve data checks for VHD events
For some reason I got strange events on channel 1 (ASYNCEVENT_HEADER):

0.647329 WARN  unexpected ehternet type 0x0508, expected Qualcom ether type 0x886c

This patch improves the validation of BCD WHD events to minimize the
risk for panic.
2022-08-13 15:25:34 +02:00
Dario Nieuwenhuis
ddfbfa0132 move ioctl_id from State to Runner. 2022-08-13 15:11:17 +02:00
Dario Nieuwenhuis
5ef40acd1d Fix set iovar buffer length. 2022-07-22 00:05:39 +02:00
Dario Nieuwenhuis
13c88a9ca3 Obtain the firmware blobs from the user instead of hardcoding magic flash addrs. 2022-07-17 00:33:30 +02:00
Dario Nieuwenhuis
4205eef3ec Fix iovar_get, unhardcode MAC addr. 2022-07-16 19:25:35 +02:00
Dario Nieuwenhuis
931e3d7ee0 Switch to 32bit SPI. 2022-07-16 18:06:57 +02:00