diff options
| author | Daniel Bevenius <[email protected]> | 2022-08-24 13:35:48 +0200 |
|---|---|---|
| committer | Daniel Bevenius <[email protected]> | 2022-08-25 15:40:14 +0200 |
| commit | f2ac14b86f21c31221bba1e1653e2a9020d60d8e (patch) | |
| tree | 4a2db095e2d3f4e2b0be55213fef6886fe24f670 /src/structs.rs | |
| parent | f76815d642064b5ed5b1673e4a386e2747813f20 (diff) | |
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.
Diffstat (limited to 'src/structs.rs')
0 files changed, 0 insertions, 0 deletions
