Mercurial > louis > kiibohd-controller
comparison Scan/UARTConnect/connect_scan.h @ 307:ecd2ae35d25c
Initial commit for UARTConnect module
* Keyboard interconnect using two uarts
* Supports daisy chain addressing using a master/slave direction communication scheme
- Still needs more testing
- Functions have been tested alone to be generally working
author | Jacob Alexander <haata@kiibohd.com> |
---|---|
date | Sun, 15 Mar 2015 16:58:01 -0700 |
parents | |
children | 66eccdd9ced5 |
comparison
equal
deleted
inserted
replaced
306:f158dfa0fa85 | 307:ecd2ae35d25c |
---|---|
1 /* Copyright (C) 2014-2015 by Jacob Alexander | |
2 * | |
3 * This file is free software: you can redistribute it and/or modify | |
4 * it under the terms of the GNU General Public License as published by | |
5 * the Free Software Foundation, either version 3 of the License, or | |
6 * (at your option) any later version. | |
7 * | |
8 * This file is distributed in the hope that it will be useful, | |
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
11 * GNU General Public License for more details. | |
12 * | |
13 * You should have received a copy of the GNU General Public License | |
14 * along with this file. If not, see <http://www.gnu.org/licenses/>. | |
15 */ | |
16 | |
17 #ifndef __CONNECT_SCAN_H | |
18 #define __CONNECT_SCAN_H | |
19 | |
20 // ----- Includes ----- | |
21 | |
22 // Project Includes | |
23 #include <kll.h> | |
24 | |
25 | |
26 | |
27 // ----- Enums ----- | |
28 | |
29 // Functions | |
30 typedef enum Command { | |
31 CableCheck = 0, // Comm check | |
32 IdRequest = 1, // Slave initialization (request id from master) | |
33 IdEnumeration = 2, // Slave initialization (begin enumeration from master) | |
34 IdReport = 3, // Slave initialization complete, report id to master | |
35 ScanCode = 4, // ScanCode event status change | |
36 Animation = 5, // Master trigger animation event (same command is sent back to master when ready) | |
37 } Command; | |
38 | |
39 // UART Rx/Tx Status | |
40 typedef enum UARTStatus { | |
41 UARTStatus_Wait = 0, // Waiting Rx: for SYN Tx: for current command copy to finish | |
42 UARTStatus_SYN = 1, // Rx: SYN Received, waiting for SOH | |
43 UARTStatus_SOH = 2, // Rx: SOH Received, waiting for Command | |
44 UARTStatus_Command = 3, // Rx: Command Received, waiting for data | |
45 UARTStatus_Ready = 4, // Tx: Ready to receive commands | |
46 } UARTStatus; | |
47 | |
48 | |
49 | |
50 // ----- Structs ----- | |
51 | |
52 // UART Connect Commands | |
53 | |
54 // Cable Check Command | |
55 // Called on each UART every few seconds to make sure there is a connection | |
56 // Also used to make sure there aren't any serious problems with the cable with data corruption | |
57 // This command must pass before sending any other commands on the particular UART | |
58 // Each argument is always 0xD2 (11010010) | |
59 typedef struct CableCheckCommand { | |
60 Command command; | |
61 uint8_t numArgs; | |
62 uint8_t firstArg[0]; | |
63 } CableCheckCommand; | |
64 | |
65 // Id Request Command | |
66 // Issued by the slave device (non-master) whenever it is powered up | |
67 // Do not issue any commands until given an Id | |
68 // (Except for Cable Check and IdRequestCommand) | |
69 typedef struct IdRequestCommand { | |
70 Command command; | |
71 } IdRequestCommand; | |
72 | |
73 // Id Enumeration Command | |
74 // Issued by the master whenever an Id Request is received | |
75 // XXX Future work may include an "external capabilities" list in this command | |
76 typedef struct IdEnumerationCommand { | |
77 Command command; | |
78 uint8_t id; | |
79 } IdEnumerationCommand; | |
80 | |
81 // Id Report Command | |
82 // Issued by each slave to the master when assigned an Id | |
83 // XXX Future work will include an "external capabilities" list in this command | |
84 typedef struct IdReportCommand { | |
85 Command command; | |
86 uint8_t id; | |
87 } IdReportCommand; | |
88 | |
89 // Scan Code Command | |
90 // Sent from the slave to the master whenever there is a scan code state change | |
91 typedef struct ScanCodeCommand { | |
92 Command command; | |
93 uint8_t id; | |
94 uint8_t numScanCodes; | |
95 TriggerGuide firstScanCode[0]; | |
96 } ScanCodeCommand; | |
97 | |
98 // Animation Command | |
99 // Initiated by the master whenever an animation id should modify it's state | |
100 // Then after the leaf slave node receives the command, send it back to the master | |
101 // On the way back, each device can begin the animation adjustment | |
102 // | |
103 // The master->leaf command should indicate to each device that it should finish sending the | |
104 // current slave->master data and wait for the leaf->master command | |
105 // This allows for a tighter synchronization of animation events | |
106 typedef struct AnimationCommand { | |
107 Command command; | |
108 uint8_t animationId; | |
109 uint8_t numParams; | |
110 uint8_t firstParam[0]; | |
111 } AnimationCommand; | |
112 | |
113 | |
114 | |
115 // ----- Functions ----- | |
116 | |
117 void Connect_setup( uint8_t master ); | |
118 void Connect_scan(); | |
119 | |
120 | |
121 #endif // __CONNECT_SCAN_H | |
122 |