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.

405 lines
10KB

  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) commands
  19. * @remarks
  20. *
  21. */
  22. #ifndef ACI_CMDS_H__
  23. #define ACI_CMDS_H__
  24. /**
  25. * @enum aci_cmd_opcode_t
  26. * @brief ACI command opcodes
  27. */
  28. typedef enum
  29. {
  30. /**
  31. * Enter test mode
  32. */
  33. ACI_CMD_TEST = 0x01,
  34. /**
  35. * Echo (loopback) test command
  36. */
  37. ACI_CMD_ECHO = 0x02,
  38. /**
  39. * Send a BTLE DTM command to the radio
  40. */
  41. ACI_CMD_DTM_CMD = 0x03,
  42. /**
  43. * Put the device to sleep
  44. */
  45. ACI_CMD_SLEEP = 0x04,
  46. /**
  47. * Wakeup the device from deep sleep
  48. */
  49. ACI_CMD_WAKEUP = 0x05,
  50. /**
  51. * Replace the contents of the internal database with
  52. * user provided data
  53. */
  54. ACI_CMD_SETUP = 0x06,
  55. /**
  56. * Read the portions of memory required to be restored after a power cycle
  57. */
  58. ACI_CMD_READ_DYNAMIC_DATA = 0x07,
  59. /**
  60. * Write back the data retrieved using ACI_CMD_READ_DYNAMIC_DATA
  61. */
  62. ACI_CMD_WRITE_DYNAMIC_DATA = 0x08,
  63. /**
  64. * Retrieve the device's version information
  65. */
  66. ACI_CMD_GET_DEVICE_VERSION = 0x09,
  67. /**
  68. * Request the Bluetooth address and its type
  69. */
  70. ACI_CMD_GET_DEVICE_ADDRESS = 0x0A,
  71. /**
  72. * Request the battery level measured by nRF8001
  73. */
  74. ACI_CMD_GET_BATTERY_LEVEL = 0x0B,
  75. /**
  76. * Request the temperature value measured by nRF8001
  77. */
  78. ACI_CMD_GET_TEMPERATURE = 0x0C,
  79. /**
  80. * Write to the local Attribute Database
  81. */
  82. ACI_CMD_SET_LOCAL_DATA = 0x0D,
  83. /**
  84. * Reset the baseband and radio and go back to idle
  85. */
  86. ACI_CMD_RADIO_RESET = 0x0E,
  87. /**
  88. * Start advertising and wait for a master connection
  89. */
  90. ACI_CMD_CONNECT = 0x0F,
  91. /**
  92. * Start advertising and wait for a master connection
  93. */
  94. ACI_CMD_BOND = 0x10,
  95. /**
  96. * Start advertising and wait for a master connection
  97. */
  98. ACI_CMD_DISCONNECT = 0x11,
  99. /**
  100. * Throttles the Radio transmit power
  101. */
  102. ACI_CMD_SET_TX_POWER = 0x12,
  103. /**
  104. * Trigger a connection parameter update
  105. */
  106. ACI_CMD_CHANGE_TIMING = 0x13,
  107. /**
  108. * Open a remote pipe for data reception
  109. */
  110. ACI_CMD_OPEN_REMOTE_PIPE = 0x14,
  111. /**
  112. * Transmit data over an open pipe
  113. */
  114. ACI_CMD_SEND_DATA = 0x15,
  115. /**
  116. * Send an acknowledgment of received data
  117. */
  118. ACI_CMD_SEND_DATA_ACK = 0x16,
  119. /**
  120. * Request data over an open pipe
  121. */
  122. ACI_CMD_REQUEST_DATA = 0x17,
  123. /**
  124. * NACK a data reception
  125. */
  126. ACI_CMD_SEND_DATA_NACK = 0x18,
  127. /**
  128. * Set application latency
  129. */
  130. ACI_CMD_SET_APP_LATENCY = 0x19,
  131. /**
  132. * Set a security key
  133. */
  134. ACI_CMD_SET_KEY = 0x1A,
  135. /**
  136. * Open Advertising Pipes
  137. */
  138. ACI_CMD_OPEN_ADV_PIPE = 0x1B,
  139. /**
  140. * Start non-connectable advertising
  141. */
  142. ACI_CMD_BROADCAST = 0x1C,
  143. /**
  144. * Start a security request in bonding mode
  145. */
  146. ACI_CMD_BOND_SECURITY_REQUEST = 0x1D,
  147. /**
  148. * Start Directed advertising towards a Bonded Peer
  149. */
  150. ACI_CMD_CONNECT_DIRECT = 0x1E,
  151. /**
  152. * Close a previously opened remote pipe
  153. */
  154. ACI_CMD_CLOSE_REMOTE_PIPE = 0x1F,
  155. /**
  156. * Invalid ACI command opcode
  157. */
  158. ACI_CMD_INVALID = 0xFF
  159. } aci_cmd_opcode_t;
  160. /**
  161. * @struct aci_cmd_params_test_t
  162. * @brief Structure for the ACI_CMD_TEST ACI command parameters
  163. */
  164. typedef struct
  165. {
  166. uint8_t test_mode_change; /**< enum aci_test_mode_change_t */
  167. } aci_cmd_params_test_t;
  168. /**
  169. * @struct aci_cmd_params_echo_t
  170. * @brief Structure for the ACI_CMD_ECHO ACI command parameters
  171. */
  172. typedef struct
  173. {
  174. uint8_t echo_data[ACI_ECHO_DATA_MAX_LEN];
  175. } aci_cmd_params_echo_t;
  176. /**
  177. * @struct aci_cmd_params_dtm_cmd_t
  178. * @brief Structure for the ACI_CMD_DTM_CMD ACI command parameters
  179. */
  180. typedef struct
  181. {
  182. uint8_t cmd_msb;
  183. uint8_t cmd_lsb;
  184. } aci_cmd_params_dtm_cmd_t;
  185. /**
  186. * @struct aci_cmd_params_setup_t
  187. * @brief Structure for the ACI_CMD_SETUP ACI command parameters
  188. */
  189. typedef struct
  190. {
  191. uint8_t setup_data[1];
  192. } aci_cmd_params_setup_t;
  193. /**
  194. * @struct aci_cmd_params_write_dynamic_data_t
  195. * @brief Structure for the ACI_CMD_WRITE_DYNAMIC_DATA ACI command parameters
  196. * @note Dynamic data chunk size in this command is defined to go up to ACI_PACKET_MAX_LEN - 3
  197. */
  198. typedef struct
  199. {
  200. uint8_t seq_no;
  201. uint8_t dynamic_data[1];
  202. } aci_cmd_params_write_dynamic_data_t;
  203. /**
  204. * @define aci_cmd_params_set_local_data_t
  205. * @brief Structure for the ACI_CMD_SET_LOCAL_DATA ACI command parameters
  206. */
  207. typedef struct
  208. {
  209. aci_tx_data_t tx_data;
  210. } aci_cmd_params_set_local_data_t;
  211. /**
  212. * @struct aci_cmd_params_connect_t
  213. * @brief Structure for the ACI_CMD_CONNECT ACI command parameters
  214. */
  215. typedef struct
  216. {
  217. uint16_t timeout; /**< 0x0000 (no timeout) to 0x3FFF */
  218. uint16_t adv_interval; /**< 16 bits of advertising interval for general discovery */
  219. } aci_cmd_params_connect_t;
  220. /**
  221. * @define aci_cmd_params_bond_t
  222. * @brief Structure for the ACI_CMD_BOND ACI command parameters
  223. */
  224. typedef struct
  225. {
  226. uint16_t timeout; /**< 0x0000 (no timeout) to 0x3FFF */
  227. uint16_t adv_interval; /**< 16 bits of advertising interval for general discovery */
  228. } aci_cmd_params_bond_t;
  229. /**
  230. * @struct aci_cmd_params_disconnect_t
  231. * @brief Structure for the ACI_CMD_DISCONNECT ACI command parameters
  232. */
  233. typedef struct
  234. {
  235. uint8_t reason; /**< enum aci_disconnect_reason_t */
  236. } aci_cmd_params_disconnect_t;
  237. /**
  238. * @struct aci_cmd_params_set_tx_power_t
  239. * @brief Structure for the ACI_CMD_SET_TX_POWER ACI command parameters
  240. */
  241. typedef struct
  242. {
  243. uint8_t device_power; /**< enum aci_device_output_power_t */
  244. } aci_cmd_params_set_tx_power_t;
  245. /**
  246. * @struct aci_cmd_params_change_timing_t
  247. * @brief Structure for the ACI_CMD_CHANGE_TIMING ACI command parameters
  248. */
  249. typedef struct
  250. {
  251. aci_ll_conn_params_t conn_params;
  252. } aci_cmd_params_change_timing_t;
  253. /**
  254. * @struct aci_cmd_params_open_remote_pipe_t
  255. * @brief Structure for the ACI_CMD_OPEN_REMOTE_PIPE ACI command parameters
  256. */
  257. typedef struct
  258. {
  259. uint8_t pipe_number;
  260. } aci_cmd_params_open_remote_pipe_t;
  261. /**
  262. * @struct aci_cmd_params_send_data_t
  263. * @brief Structure for the ACI_CMD_SEND_DATA ACI command parameters
  264. */
  265. typedef struct
  266. {
  267. aci_tx_data_t tx_data;
  268. } aci_cmd_params_send_data_t;
  269. /**
  270. * @define aci_cmd_params_send_data_ack_t
  271. * @brief Structure for the ACI_CMD_SEND_DATA_ACK ACI command parameters
  272. */
  273. typedef struct
  274. {
  275. uint8_t pipe_number;
  276. } aci_cmd_params_send_data_ack_t;
  277. /**
  278. * @struct aci_cmd_params_send_data_t
  279. * @brief Structure for the ACI_CMD_SEND_DATA ACI command parameters
  280. */
  281. typedef struct
  282. {
  283. uint8_t pipe_number;
  284. } aci_cmd_params_request_data_t;
  285. /**
  286. * @define aci_cmd_params_send_data_nack_t
  287. * @brief Structure for the ACI_CMD_SEND_DATA_NACK ACI command parameters
  288. */
  289. typedef struct
  290. {
  291. uint8_t pipe_number;
  292. uint8_t error_code;
  293. } aci_cmd_params_send_data_nack_t;
  294. /**
  295. * @define aci_cmd_params_set_app_latency_t
  296. * @brief Structure for the ACI_CMD_SET_APP_LATENCY ACI command parameters
  297. */
  298. typedef struct
  299. {
  300. aci_app_latency_mode_t mode;
  301. uint16_t latency;
  302. } aci_cmd_params_set_app_latency_t;
  303. /**
  304. * @define aci_cmd_params_set_key_t
  305. * @brief Structure for the ACI_CMD_SET_KEY ACI command parameters
  306. */
  307. typedef struct
  308. {
  309. aci_key_type_t key_type;
  310. union
  311. {
  312. uint8_t passkey[6];
  313. uint8_t oob_key[16];
  314. } key;
  315. } aci_cmd_params_set_key_t;
  316. /**
  317. * @define aci_cmd_params_open_adv_pipe_t
  318. * @brief Structure for the ACI_CMD_OPEN_ADV_PIPE ACI command parameters
  319. */
  320. typedef struct
  321. {
  322. uint8_t pipes[8];
  323. } aci_cmd_params_open_adv_pipe_t;
  324. /**
  325. * @define aci_cmd_params_broadcast_t
  326. * @brief Structure for the ACI_CMD_BROADCAST ACI command parameters
  327. */
  328. typedef struct
  329. {
  330. uint16_t timeout; /**< 0x0000 (no timeout) to 0x3FFF */
  331. uint16_t adv_interval; /**< 16 bits of advertising interval for general discovery */
  332. } aci_cmd_params_broadcast_t;
  333. /**
  334. * @struct aci_cmd_params_close_remote_pipe_t
  335. * @brief Structure for the ACI_CMD_CLOSE_REMOTE_PIPE ACI command parameters
  336. */
  337. typedef struct
  338. {
  339. uint8_t pipe_number;
  340. } aci_cmd_params_close_remote_pipe_t;
  341. /**
  342. * @struct aci_cmd_t
  343. * @brief Encapsulates a generic ACI command
  344. */
  345. typedef struct
  346. {
  347. uint8_t len; /**< Length of the ACI command */
  348. uint8_t cmd_opcode; /**< enum aci_cmd_opcode_t -> Opcode of the ACI command */
  349. union
  350. {
  351. aci_cmd_params_test_t test;
  352. aci_cmd_params_echo_t echo;
  353. aci_cmd_params_dtm_cmd_t dtm_cmd;
  354. aci_cmd_params_setup_t setup;
  355. aci_cmd_params_write_dynamic_data_t write_dynamic_data;
  356. aci_cmd_params_set_local_data_t set_local_data;
  357. aci_cmd_params_connect_t connect;
  358. aci_cmd_params_bond_t bond;
  359. aci_cmd_params_disconnect_t disconnect;
  360. aci_cmd_params_set_tx_power_t set_tx_power;
  361. aci_cmd_params_change_timing_t change_timing;
  362. aci_cmd_params_open_remote_pipe_t open_remote_pipe;
  363. aci_cmd_params_send_data_t send_data;
  364. aci_cmd_params_send_data_ack_t send_data_ack;
  365. aci_cmd_params_request_data_t request_data;
  366. aci_cmd_params_send_data_nack_t send_data_nack;
  367. aci_cmd_params_set_app_latency_t set_app_latency;
  368. aci_cmd_params_set_key_t set_key;
  369. aci_cmd_params_open_adv_pipe_t open_adv_pipe;
  370. aci_cmd_params_broadcast_t broadcast;
  371. aci_cmd_params_close_remote_pipe_t close_remote_pipe;
  372. } params;
  373. } aci_cmd_t;
  374. #endif // ACI_CMDS_H__