PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
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.

365 lines
11KB

  1. /* Copyright (c) 2010 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. * $LastChangedRevision$
  12. */
  13. /**
  14. * @file
  15. *
  16. * @ingroup aci
  17. *
  18. * @brief Definitions for the ACI (Application Control Interface) events
  19. */
  20. #ifndef ACI_EVTS_H__
  21. #define ACI_EVTS_H__
  22. #include "aci.h"
  23. /**
  24. * @enum aci_evt_opcode_t
  25. * @brief ACI event opcodes
  26. */
  27. typedef enum
  28. {
  29. /**
  30. * Invalid event code
  31. */
  32. ACI_EVT_INVALID = 0x00,
  33. /**
  34. * Sent every time the device starts
  35. */
  36. ACI_EVT_DEVICE_STARTED = 0x81,
  37. /**
  38. * Mirrors the ACI_CMD_ECHO
  39. */
  40. ACI_EVT_ECHO = 0x82,
  41. /**
  42. * Asynchronous hardware error event
  43. */
  44. ACI_EVT_HW_ERROR = 0x83,
  45. /**
  46. * Event opcode used as a event response for all commands
  47. */
  48. ACI_EVT_CMD_RSP = 0x84,
  49. /**
  50. * Link connected
  51. */
  52. ACI_EVT_CONNECTED = 0x85,
  53. /**
  54. * Link disconnected
  55. */
  56. ACI_EVT_DISCONNECTED = 0x86,
  57. /**
  58. * Bond completion result
  59. */
  60. ACI_EVT_BOND_STATUS = 0x87,
  61. /**
  62. * Pipe bitmap for available pipes
  63. */
  64. ACI_EVT_PIPE_STATUS = 0x88,
  65. /**
  66. * Sent to the application when the radio enters a connected state
  67. * or when the timing of the radio connection changes
  68. */
  69. ACI_EVT_TIMING = 0x89,
  70. /**
  71. * Notification to the application that transmit credits are
  72. * available
  73. */
  74. ACI_EVT_DATA_CREDIT = 0x8A,
  75. /**
  76. * Data acknowledgement event
  77. */
  78. ACI_EVT_DATA_ACK = 0x8B,
  79. /**
  80. * Data received notification event
  81. */
  82. ACI_EVT_DATA_RECEIVED = 0x8C,
  83. /**
  84. * Error notification event
  85. */
  86. ACI_EVT_PIPE_ERROR = 0x8D,
  87. /**
  88. * Display Passkey Event
  89. */
  90. ACI_EVT_DISPLAY_PASSKEY = 0x8E,
  91. /**
  92. * Security Key request
  93. */
  94. ACI_EVT_KEY_REQUEST = 0x8F
  95. } __attribute__((packed)) aci_evt_opcode_t;
  96. /**
  97. * @struct aci_evt_params_device_started_t
  98. * @brief Structure for the ACI_EVT_DEVICE_STARTED event return parameters
  99. */
  100. typedef struct
  101. {
  102. uint8_t device_mode; /**< enum aci_device_operation_mode_t -> Mode in which the device is being started */
  103. uint8_t hw_error; /**< enum aci_hw_error_t -> Hardware Error if available for the start */
  104. uint8_t credit_available; /**< Flow control credit available for this specific FW build */
  105. } __attribute__((packed)) aci_evt_params_device_started_t;
  106. /**
  107. * @struct aci_evt_params_hw_error_t
  108. * @brief Structure for the ACI_EVT_HW_ERROR event return parameters
  109. */
  110. typedef struct
  111. {
  112. uint16_t line_num;
  113. uint8_t file_name[20];
  114. } __attribute__((packed)) aci_evt_params_hw_error_t;
  115. /**
  116. * @struct aci_evt_cmd_rsp_params_dtm_cmd_t
  117. * @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_DTM_CMD event return parameters
  118. */
  119. typedef struct
  120. {
  121. uint8_t evt_msb;
  122. uint8_t evt_lsb;
  123. } __attribute__((packed)) aci_evt_cmd_rsp_params_dtm_cmd_t;
  124. /**
  125. * @struct aci_evt_cmd_rsp_read_dynamic_data_t
  126. * @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_READ_DYNAMIC_DATA event return parameters
  127. * @note Dynamic data chunk size in this event is defined to go up to ACI_PACKET_MAX_LEN - 5
  128. */
  129. typedef struct
  130. {
  131. uint8_t seq_no;
  132. uint8_t dynamic_data[1];
  133. } __attribute__((packed)) aci_evt_cmd_rsp_read_dynamic_data_t;
  134. /**
  135. * @struct aci_evt_cmd_rsp_params_get_device_version_t
  136. * @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_GET_DEVICE_VERSION event return parameters
  137. */
  138. typedef struct
  139. {
  140. uint16_t configuration_id;
  141. uint8_t aci_version;
  142. uint8_t setup_format;
  143. uint32_t setup_id;
  144. uint8_t setup_status;
  145. } __attribute__((packed)) aci_evt_cmd_rsp_params_get_device_version_t;
  146. /**
  147. * @struct aci_evt_cmd_rsp_params_get_device_address_t
  148. * @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_GET_DEVICE_ADDRESS event return parameters
  149. */
  150. typedef struct
  151. {
  152. uint8_t bd_addr_own[BTLE_DEVICE_ADDRESS_SIZE];
  153. uint8_t bd_addr_type; /**< enum aci_bd_addr_type_t */
  154. } __attribute__((packed)) aci_evt_cmd_rsp_params_get_device_address_t;
  155. /**
  156. * @struct aci_evt_cmd_rsp_params_get_battery_level_t
  157. * @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_GET_BATTERY_LEVEL event return parameters
  158. */
  159. typedef struct
  160. {
  161. uint16_t battery_level;
  162. } __attribute__((packed)) aci_evt_cmd_rsp_params_get_battery_level_t;
  163. /**
  164. * @struct aci_evt_cmd_rsp_params_get_temperature_t
  165. * @brief Structure for the ACI_EVT_CMD_RSP event with opcode=ACI_CMD_GET_TEMPERATURE event return parameters
  166. */
  167. typedef struct
  168. {
  169. int16_t temperature_value;
  170. } __attribute__((packed)) aci_evt_cmd_rsp_params_get_temperature_t;
  171. /**
  172. * @struct aci_evt_params_cmd_rsp_t
  173. * @brief Structure for the ACI_EVT_CMD_RSP event return parameters
  174. */
  175. typedef struct
  176. {
  177. uint8_t cmd_opcode; /**< enum aci_cmd_opcode_t -> Command opcode for which the event response is being sent */
  178. uint8_t cmd_status; /**< enum aci_status_code_t -> Status of the command that was sent. Used in the context of the command. */
  179. union
  180. {
  181. aci_evt_cmd_rsp_params_dtm_cmd_t dtm_cmd;
  182. aci_evt_cmd_rsp_read_dynamic_data_t read_dynamic_data;
  183. aci_evt_cmd_rsp_params_get_device_version_t get_device_version;
  184. aci_evt_cmd_rsp_params_get_device_address_t get_device_address;
  185. aci_evt_cmd_rsp_params_get_battery_level_t get_battery_level;
  186. aci_evt_cmd_rsp_params_get_temperature_t get_temperature;
  187. uint8_t padding[29];
  188. } params;
  189. } __attribute__((packed)) aci_evt_params_cmd_rsp_t;
  190. /**
  191. * @struct aci_evt_params_connected_t
  192. * @brief Structure for the ACI_EVT_CONNECTED event return parameters
  193. */
  194. typedef struct
  195. {
  196. aci_bd_addr_type_t dev_addr_type;
  197. uint8_t dev_addr[BTLE_DEVICE_ADDRESS_SIZE];
  198. uint16_t conn_rf_interval; /**< rf_interval = conn_rf_interval * 1.25 ms Range:0x0006 to 0x0C80 */
  199. uint16_t conn_slave_rf_latency; /**< Number of RF events the slave can skip */
  200. uint16_t conn_rf_timeout; /**< Timeout as a multiple of 10ms i.e timeout = conn_rf_timeout * 10ms Range: 0x000A to 0x0C80 */
  201. uint8_t master_clock_accuracy; /**< enum aci_clock_accuracy_t -> Clock accuracy of Bluetooth master: Enumerated list of values from 500 ppm to 20 ppm */
  202. } __attribute__((packed)) aci_evt_params_connected_t;
  203. /**
  204. * @struct aci_evt_params_disconnected_t
  205. * @brief Structure for the ACI_EVT_DISCONNECTED event return parameters
  206. */
  207. typedef struct
  208. {
  209. uint8_t aci_status; /**< enum aci_status_code_t */
  210. uint8_t btle_status;
  211. } __attribute__((packed)) aci_evt_params_disconnected_t;
  212. /**
  213. * @struct aci_evt_params_bond_status_t
  214. * @brief Structure for the ACI_EVT_BOND_STATUS event return parameters
  215. */
  216. typedef struct
  217. {
  218. uint8_t status_code;
  219. uint8_t status_source; /**< enum aci_bond_status_source_t */
  220. uint8_t secmode1_bitmap;
  221. uint8_t secmode2_bitmap;
  222. uint8_t keys_exchanged_slave;
  223. uint8_t keys_exchanged_master;
  224. } __attribute__((packed)) aci_evt_params_bond_status_t;
  225. /**
  226. * @struct aci_evt_params_pipe_status_t
  227. * @brief Structure for the ACI_EVT_PIPE_STATUS event return parameters
  228. */
  229. typedef struct
  230. {
  231. uint8_t pipes_open_bitmap[8];
  232. uint8_t pipes_closed_bitmap[8];
  233. } __attribute__((packed)) aci_evt_params_pipe_status_t;
  234. /**
  235. * @struct aci_evt_params_timing_t
  236. * @brief Structure for the ACI_EVT_TIMING event return parameters
  237. */
  238. typedef struct
  239. {
  240. uint16_t conn_rf_interval; /**< rf_interval = conn_rf_interval * 1.25 ms Range:0x0006 to 0x0C80 */
  241. uint16_t conn_slave_rf_latency; /**< Number of RF events the slave can skip */
  242. uint16_t conn_rf_timeout; /**< Timeout as a multiple of 10ms i.e timeout = conn_rf_timeout * 10ms Range: 0x000A to 0x0C80 */
  243. } __attribute__((packed)) aci_evt_params_timing_t;
  244. /**
  245. * @struct aci_evt_params_data_credit_t
  246. * @brief Structure for the ACI_EVT_DATA_CREDIT event return parameters
  247. */
  248. typedef struct
  249. {
  250. uint8_t credit;
  251. } __attribute__((packed)) aci_evt_params_data_credit_t;
  252. /**
  253. * @struct aci_evt_params_data_ack_t
  254. * @brief Structure for the ACI_EVT_DATA_ACK event return parameters
  255. */
  256. typedef struct
  257. {
  258. uint8_t pipe_number;
  259. } __attribute__((packed)) aci_evt_params_data_ack_t;
  260. /**
  261. * @struct aci_evt_params_data_received_t
  262. * @brief Structure for the ACI_EVT_DATA_RECEIVED event return parameters
  263. */
  264. typedef struct
  265. {
  266. aci_rx_data_t rx_data;
  267. } __attribute__((packed)) aci_evt_params_data_received_t;
  268. typedef struct
  269. {
  270. uint8_t content[1];
  271. } __attribute__((packed)) error_data_t;
  272. /**
  273. * @struct aci_evt_params_pipe_error_t
  274. * @brief Structure for the ACI_EVT_PIPE_ERROR event return parameters
  275. */
  276. typedef struct
  277. {
  278. uint8_t pipe_number;
  279. uint8_t error_code;
  280. union
  281. {
  282. error_data_t error_data;
  283. } params;
  284. } __attribute__((packed)) aci_evt_params_pipe_error_t;
  285. /**
  286. * @struct aci_evt_params_display_passkey_t
  287. * @brief Structure for the ACI_EVT_DISPLAY_PASSKEY event return parameters
  288. */
  289. typedef struct
  290. {
  291. uint8_t passkey[6];
  292. } __attribute__((packed)) aci_evt_params_display_passkey_t;
  293. /**
  294. * @struct aci_evt_params_key_request_t
  295. * @brief Structure for the ACI_EVT_KEY_REQUEST event return parameters
  296. */
  297. typedef struct
  298. {
  299. uint8_t key_type; /**< enum aci_key_type_t */
  300. } __attribute__((packed)) aci_evt_params_key_request_t;
  301. /**
  302. * @struct aci_event_params_echo_t
  303. * @brief Structure for the ACI_EVT_ECHO ACI event parameters
  304. */
  305. typedef struct
  306. {
  307. uint8_t echo_data[ACI_ECHO_DATA_MAX_LEN];
  308. } __attribute__((packed)) aci_evt_params_echo_t;
  309. /**
  310. * @struct aci_evt_t
  311. * @brief Encapsulates a generic ACI event
  312. */
  313. typedef struct
  314. {
  315. uint8_t len;
  316. uint8_t evt_opcode; /** enum aci_evt_opcode_t */
  317. union
  318. {
  319. aci_evt_params_device_started_t device_started;
  320. aci_evt_params_echo_t echo;
  321. aci_evt_params_hw_error_t hw_error;
  322. aci_evt_params_cmd_rsp_t cmd_rsp;
  323. aci_evt_params_connected_t connected;
  324. aci_evt_params_disconnected_t disconnected;
  325. aci_evt_params_bond_status_t bond_status;
  326. aci_evt_params_pipe_status_t pipe_status;
  327. aci_evt_params_timing_t timing;
  328. aci_evt_params_data_credit_t data_credit;
  329. aci_evt_params_data_ack_t data_ack;
  330. aci_evt_params_data_received_t data_received;
  331. aci_evt_params_pipe_error_t pipe_error;
  332. aci_evt_params_display_passkey_t display_passkey;
  333. aci_evt_params_key_request_t key_request;
  334. } params;
  335. } __attribute__((packed)) aci_evt_t;
  336. #endif // ACI_EVTS_H__