Commit Graph

28 Commits

Author SHA1 Message Date
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
Dario Nieuwenhuis
7dfdea8797 Switch to embedded-hal SPI, GPIO traits. 2022-07-16 08:26:54 +02:00
Dario Nieuwenhuis
ce7353fba4 Hook up embassy-net. IT WORKS. 2022-07-12 07:52:16 +02:00
Dario Nieuwenhuis
f60407feb3 ITS DOING SOMETHING 2022-07-12 05:06:29 +02:00
Dario Nieuwenhuis
e1fd7dfc40 wpa2 join... still nothing. 2022-07-12 04:17:07 +02:00
Dario Nieuwenhuis
18b11e7417 check clmload_status. 2022-07-12 03:34:27 +02:00
Dario Nieuwenhuis
3ffdbd2ca3 stuff 2022-07-11 22:44:42 +02:00
Dario Nieuwenhuis
30b7800f9a add event printing, add join but not working yet. 2022-07-11 05:19:31 +02:00
Dario Nieuwenhuis
7ddcacac7b clm download, country config. 2022-07-11 03:07:39 +02:00
Dario Nieuwenhuis
069a57fcf8 async ioctls working. 2022-07-11 00:25:35 +02:00
Dario Nieuwenhuis
e560415fde 🌈 2022-07-10 19:45:26 +02:00