diff options
author | Joel Challis <git@zvecr.com> | 2020-05-21 18:00:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-05-21 18:00:21 +0100 |
commit | 65150984bd1f9c301b080652fe60b181765bb9be (patch) | |
tree | 7f714fa864ba58a7c89a97170bad94319c39ff98 /drivers/chibios/serial.h | |
parent | 205321c37740caaffbca69e626a8432fd369d20c (diff) | |
download | qmk_firmware-65150984bd1f9c301b080652fe60b181765bb9be.tar.gz qmk_firmware-65150984bd1f9c301b080652fe60b181765bb9be.zip |
ARM split - Add uart half duplex transport support (#7987)
* ARM split - Add uart half duplex transport support
* Fix for f103
* initial full duplex pass
* partially remove full duplex
* Correct speeds within driver docs
Co-authored-by: Nick Brassel <nick@tzarc.org>
Co-authored-by: Nick Brassel <nick@tzarc.org>
Diffstat (limited to 'drivers/chibios/serial.h')
-rw-r--r-- | drivers/chibios/serial.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/drivers/chibios/serial.h b/drivers/chibios/serial.h new file mode 100644 index 000000000..0c1857d52 --- /dev/null +++ b/drivers/chibios/serial.h | |||
@@ -0,0 +1,62 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include <stdbool.h> | ||
4 | |||
5 | // ///////////////////////////////////////////////////////////////// | ||
6 | // Need Soft Serial defines in config.h | ||
7 | // ///////////////////////////////////////////////////////////////// | ||
8 | // ex. | ||
9 | // #define SOFT_SERIAL_PIN ?? // ?? = D0,D1,D2,D3,E6 | ||
10 | // OPTIONAL: #define SELECT_SOFT_SERIAL_SPEED ? // ? = 1,2,3,4,5 | ||
11 | // // 1: about 137kbps (default) | ||
12 | // // 2: about 75kbps | ||
13 | // // 3: about 39kbps | ||
14 | // // 4: about 26kbps | ||
15 | // // 5: about 20kbps | ||
16 | // | ||
17 | // //// USE simple API (using signle-type transaction function) | ||
18 | // /* nothing */ | ||
19 | // //// USE flexible API (using multi-type transaction function) | ||
20 | // #define SERIAL_USE_MULTI_TRANSACTION | ||
21 | // | ||
22 | // ///////////////////////////////////////////////////////////////// | ||
23 | |||
24 | // Soft Serial Transaction Descriptor | ||
25 | typedef struct _SSTD_t { | ||
26 | uint8_t *status; | ||
27 | uint8_t initiator2target_buffer_size; | ||
28 | uint8_t *initiator2target_buffer; | ||
29 | uint8_t target2initiator_buffer_size; | ||
30 | uint8_t *target2initiator_buffer; | ||
31 | } SSTD_t; | ||
32 | #define TID_LIMIT(table) (sizeof(table) / sizeof(SSTD_t)) | ||
33 | |||
34 | // initiator is transaction start side | ||
35 | void soft_serial_initiator_init(SSTD_t *sstd_table, int sstd_table_size); | ||
36 | // target is interrupt accept side | ||
37 | void soft_serial_target_init(SSTD_t *sstd_table, int sstd_table_size); | ||
38 | |||
39 | // initiator result | ||
40 | #define TRANSACTION_END 0 | ||
41 | #define TRANSACTION_NO_RESPONSE 0x1 | ||
42 | #define TRANSACTION_DATA_ERROR 0x2 | ||
43 | #define TRANSACTION_TYPE_ERROR 0x4 | ||
44 | #ifndef SERIAL_USE_MULTI_TRANSACTION | ||
45 | int soft_serial_transaction(void); | ||
46 | #else | ||
47 | int soft_serial_transaction(int sstd_index); | ||
48 | #endif | ||
49 | |||
50 | // target status | ||
51 | // *SSTD_t.status has | ||
52 | // initiator: | ||
53 | // TRANSACTION_END | ||
54 | // or TRANSACTION_NO_RESPONSE | ||
55 | // or TRANSACTION_DATA_ERROR | ||
56 | // target: | ||
57 | // TRANSACTION_DATA_ERROR | ||
58 | // or TRANSACTION_ACCEPTED | ||
59 | #define TRANSACTION_ACCEPTED 0x8 | ||
60 | #ifdef SERIAL_USE_MULTI_TRANSACTION | ||
61 | int soft_serial_get_and_clean_status(int sstd_index); | ||
62 | #endif | ||