Kiibohd Controller
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

connect_scan.h 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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. #ifndef __CONNECT_SCAN_H
  17. #define __CONNECT_SCAN_H
  18. // ----- Includes -----
  19. // Project Includes
  20. #include <kll.h>
  21. // ----- Enums -----
  22. // Functions
  23. typedef enum Command {
  24. CableCheck = 0, // Comm check
  25. IdRequest = 1, // Slave initialization (request id from master)
  26. IdEnumeration = 2, // Slave initialization (begin enumeration from master)
  27. IdReport = 3, // Slave initialization complete, report id to master
  28. ScanCode = 4, // ScanCode event status change
  29. Animation = 5, // Master trigger animation event (same command is sent back to master when ready)
  30. } Command;
  31. // UART Rx/Tx Status
  32. typedef enum UARTStatus {
  33. UARTStatus_Wait = 0, // Waiting Rx: for SYN Tx: for current command copy to finish
  34. UARTStatus_SYN = 1, // Rx: SYN Received, waiting for SOH
  35. UARTStatus_SOH = 2, // Rx: SOH Received, waiting for Command
  36. UARTStatus_Command = 3, // Rx: Command Received, waiting for data
  37. UARTStatus_Ready = 4, // Tx: Ready to receive commands
  38. } UARTStatus;
  39. // ----- Structs -----
  40. // UART Connect Commands
  41. // Cable Check Command
  42. // Called on each UART every few seconds to make sure there is a connection
  43. // Also used to make sure there aren't any serious problems with the cable with data corruption
  44. // This command must pass before sending any other commands on the particular UART
  45. // Each argument is always 0xD2 (11010010)
  46. typedef struct CableCheckCommand {
  47. Command command;
  48. uint8_t numArgs;
  49. uint8_t firstArg[0];
  50. } CableCheckCommand;
  51. // Id Request Command
  52. // Issued by the slave device (non-master) whenever it is powered up
  53. // Do not issue any commands until given an Id
  54. // (Except for Cable Check and IdRequestCommand)
  55. typedef struct IdRequestCommand {
  56. Command command;
  57. } IdRequestCommand;
  58. // Id Enumeration Command
  59. // Issued by the master whenever an Id Request is received
  60. // XXX Future work may include an "external capabilities" list in this command
  61. typedef struct IdEnumerationCommand {
  62. Command command;
  63. uint8_t id;
  64. } IdEnumerationCommand;
  65. // Id Report Command
  66. // Issued by each slave to the master when assigned an Id
  67. // XXX Future work will include an "external capabilities" list in this command
  68. typedef struct IdReportCommand {
  69. Command command;
  70. uint8_t id;
  71. } IdReportCommand;
  72. // Scan Code Command
  73. // Sent from the slave to the master whenever there is a scan code state change
  74. typedef struct ScanCodeCommand {
  75. Command command;
  76. uint8_t id;
  77. uint8_t numScanCodes;
  78. TriggerGuide firstScanCode[0];
  79. } ScanCodeCommand;
  80. // Animation Command
  81. // Initiated by the master whenever an animation id should modify it's state
  82. // Then after the leaf slave node receives the command, send it back to the master
  83. // On the way back, each device can begin the animation adjustment
  84. //
  85. // The master->leaf command should indicate to each device that it should finish sending the
  86. // current slave->master data and wait for the leaf->master command
  87. // This allows for a tighter synchronization of animation events
  88. typedef struct AnimationCommand {
  89. Command command;
  90. uint8_t animationId;
  91. uint8_t numParams;
  92. uint8_t firstParam[0];
  93. } AnimationCommand;
  94. // ----- Functions -----
  95. void Connect_setup( uint8_t master );
  96. void Connect_scan();
  97. #endif // __CONNECT_SCAN_H