diff options
Diffstat (limited to 'keyboards/helix/serial.h')
-rw-r--r-- | keyboards/helix/serial.h | 63 |
1 files changed, 58 insertions, 5 deletions
diff --git a/keyboards/helix/serial.h b/keyboards/helix/serial.h index c3c9569b2..d2b7fd8e6 100644 --- a/keyboards/helix/serial.h +++ b/keyboards/helix/serial.h | |||
@@ -3,25 +3,78 @@ | |||
3 | 3 | ||
4 | #include <stdbool.h> | 4 | #include <stdbool.h> |
5 | 5 | ||
6 | // //////////////////////////////////////////// | 6 | // ///////////////////////////////////////////////////////////////// |
7 | // Need Soft Serial defines in serial_config.h | 7 | // Need Soft Serial defines in serial_config.h |
8 | // //////////////////////////////////////////// | 8 | // ///////////////////////////////////////////////////////////////// |
9 | // ex. | 9 | // ex. |
10 | // #define SERIAL_PIN_DDR DDRD | 10 | // #define SERIAL_PIN_DDR DDRD |
11 | // #define SERIAL_PIN_PORT PORTD | 11 | // #define SERIAL_PIN_PORT PORTD |
12 | // #define SERIAL_PIN_INPUT PIND | 12 | // #define SERIAL_PIN_INPUT PIND |
13 | // #define SERIAL_PIN_MASK _BV(PD?) ?=0,2 | 13 | // #define SERIAL_PIN_MASK _BV(PD?) ?=0,2 |
14 | // #define SERIAL_PIN_INTERRUPT INT?_vect ?=0,2 | 14 | // #define SERIAL_PIN_INTERRUPT INT?_vect ?=0,2 |
15 | // | ||
16 | // //// USE Simple API (OLD API, compatible with let's split serial.c) | ||
17 | // ex. | ||
15 | // #define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2 | 18 | // #define SERIAL_SLAVE_BUFFER_LENGTH MATRIX_ROWS/2 |
16 | // #define SERIAL_MASTER_BUFFER_LENGTH MATRIX_ROWS/2 | 19 | // #define SERIAL_MASTER_BUFFER_LENGTH 1 |
20 | // | ||
21 | // //// USE flexible API (using multi-type transaction function) | ||
22 | // #define SERIAL_USE_MULTI_TRANSACTION | ||
23 | // | ||
24 | // ///////////////////////////////////////////////////////////////// | ||
25 | |||
17 | 26 | ||
18 | // Buffers for master - slave communication | 27 | #ifndef SERIAL_USE_MULTI_TRANSACTION |
28 | /* --- USE Simple API (OLD API, compatible with let's split serial.c) */ | ||
29 | #if SERIAL_SLAVE_BUFFER_LENGTH > 0 | ||
19 | extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH]; | 30 | extern volatile uint8_t serial_slave_buffer[SERIAL_SLAVE_BUFFER_LENGTH]; |
31 | #endif | ||
32 | #if SERIAL_MASTER_BUFFER_LENGTH > 0 | ||
20 | extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH]; | 33 | extern volatile uint8_t serial_master_buffer[SERIAL_MASTER_BUFFER_LENGTH]; |
34 | #endif | ||
21 | 35 | ||
22 | void serial_master_init(void); | 36 | void serial_master_init(void); |
23 | void serial_slave_init(void); | 37 | void serial_slave_init(void); |
24 | int serial_update_buffers(void); | 38 | int serial_update_buffers(void); |
25 | bool serial_slave_data_corrupt(void); | 39 | |
40 | #endif // USE Simple API | ||
41 | |||
42 | // Soft Serial Transaction Descriptor | ||
43 | typedef struct _SSTD_t { | ||
44 | uint8_t *status; | ||
45 | uint8_t initiator2target_buffer_size; | ||
46 | uint8_t *initiator2target_buffer; | ||
47 | uint8_t target2initiator_buffer_size; | ||
48 | uint8_t *target2initiator_buffer; | ||
49 | } SSTD_t; | ||
50 | |||
51 | // initiator is transaction start side | ||
52 | void soft_serial_initiator_init(SSTD_t *sstd_table); | ||
53 | // target is interrupt accept side | ||
54 | void soft_serial_target_init(SSTD_t *sstd_table); | ||
55 | |||
56 | // initiator resullt | ||
57 | #define TRANSACTION_END 0 | ||
58 | #define TRANSACTION_NO_RESPONSE 0x1 | ||
59 | #define TRANSACTION_DATA_ERROR 0x2 | ||
60 | #ifndef SERIAL_USE_MULTI_TRANSACTION | ||
61 | int soft_serial_transaction(void); | ||
62 | #else | ||
63 | int soft_serial_transaction(int sstd_index); | ||
64 | #endif | ||
65 | |||
66 | // target status | ||
67 | // *SSTD_t.status has | ||
68 | // initiator: | ||
69 | // TRANSACTION_END | ||
70 | // or TRANSACTION_NO_RESPONSE | ||
71 | // or TRANSACTION_DATA_ERROR | ||
72 | // target: | ||
73 | // TRANSACTION_DATA_ERROR | ||
74 | // or TRANSACTION_ACCEPTED | ||
75 | #define TRANSACTION_ACCEPTED 0x4 | ||
76 | #ifdef SERIAL_USE_MULTI_TRANSACTION | ||
77 | int soft_serial_get_and_clean_status(int sstd_index); | ||
78 | #endif | ||
26 | 79 | ||
27 | #endif /* SOFT_SERIAL_H */ | 80 | #endif /* SOFT_SERIAL_H */ |