Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document serial protocol ADC commands #64

Merged
merged 1 commit into from Apr 12, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
60 changes: 40 additions & 20 deletions docs/CommunicationProtocol.md
Expand Up @@ -8,27 +8,47 @@

## Commands

The acknowledge byte is `254`.
| Function Descriptor | Main Cmd | Sub Cmd | Arguments | Arg Type | Return Data Stream | Type | Number of bytes |
| --------------------- | -------- | ------- | ---------------------- | -------------- | ---------------------- | ----------- | ------------------ |
| | | | | | | | |
| `GET_VERSION` | `11` | `5` | | | version string | string | terminated by `\n` |
| | | | | | | | |
| `CAPTURE_ONE` | `2` | `1` | channel mux no. | byte (0-136) | | | |
| | | | no. samples to capture | Int (1-10000) | | | |
| | | | timegap | Int (6-65535) | acknowledge | byte | 1 |
| | | | | | | | |
| `CAPTURE_TWO` | `2` | `2` | channel mux no. | byte (0-136) | | | |
| | | | no. samples to capture | Int (1-5000) | | | |
| | | | timegap | Int (7-65535) | acknowledge | byte | 1 |
| | | | | | | | |
| `CAPTURE_DMASPEED` | `2` | `3` | channel mux no. | byte (0-136) | | | |
| | | | no. samples to capture | Int (1-10000) | | | |
| | | | timegap | Int (4-65535) | acknowledge | byte | 1 |
| | | | | | | | |
| `CAPTURE_FOUR` | `2` | `4` | channel mux no. | byte (0-136) | | | |
| | | | no. samples to capture | Int (1-2500) | | | |
| | | | timegap | Int (14-65535) | acknowledge | byte | 1 |
| | | | | | | | |
| `CONFIGURE_TRIGGER` | `2` | `5` | trigger channel | byte (0-3) | | | |
| | | | trigger voltage | Int (0-4095) | acknowledge | byte | 1 |
| | | | | | | | |
| `GET_CAPTURE_STATUS` | `2` | `6` | | | conversion done | byte | 1 |
| | | | | | no. of samples | Int | 2 |
| | | | | | acknowledge | byte | 1 |
| | | | | | | | |
| `SET_PGA_GAIN` | `2` | `8` | pga | byte (1-2) | | | |
| | | | gain index | byte (0-7) | acknowledge | byte | 1 |
| | | | | | | | |
| `GET_VOLTAGE_SUMMED` | `2` | `10` | channel mux no. | byte (0-8) | sum of 16 samples | Int | 2 |
| | | | | | acknowledge | byte | 1 |
| | | | | | | | |
| `SET_PGA_GAIN` | `2` | `7` | pga | byte (1-2) | | | |
| | | | gain index | byte (0-7) | acknowledge | byte | 1 |
| | | | | | | | |
| `SET_CAP` | `2` | `21` | state | byte (0-1) | | | |
| | | | charge time | Int (0-65535) | acknowledge | byte | 1 |
| | | | | | | | |

| Function Descriptor | Main Cmd | Sub Cmd | Arguments | Arg Type | Return Data Stream | Type | Number of bytes |
| --------------------- | -------- | ------- | --------------------- | ------------ | ---------------------- | ----------- | ------------------ |
| `READ_BULK_FLASH` | `1` | `4` | no. of bytes to read | Int (0-2048) | values stored in flash | byte stream | N |
| | | | page number | byte (0-19) | acknowledge | byte | 1 |
| | | | | | | | |
| `WRITE_BULK_FLASH` | `1` | `3` | no. of bytes to write | Int (0-2048) | | byte stream | N |
| | | | page number | byte (0-19) | acknowledge | byte | 1 |
| | | | | | | | |
| `get_version` | `11` | `5` | | | version string | string | terminated by `\n` |

## Example `read_bulk_flash`

1) Send `chr(1),chr(4)` (i.e., `0x14`?)
2) Send number of bytes to read `chr(N&0xFF),chr((N>>8)&0xFF)`
(so `N`'s low byte's compliment to `0xFF`, followed by high byte's compliment
to `0xFF`, i.e. binary compliment of swapped bytes?)
3) Send Page Number `chr(0-19)` (i.e. `0x01`..`0x13`?)
4) read `N` bytes (TODO: how?)
5) Read 1 byte and check if equals `254` (so that is a parity byte?)

## Example `get version`

Expand Down