1 /***************************************************************************//** 2 * \file cy_ipc_bt.h 3 * \version 1.130 4 * 5 * \brief 6 * Provides an API declaration for the BT IPC driver. 7 * 8 ******************************************************************************** 9 * \copyright 10 * Copyright (c) (2020-2022), Cypress Semiconductor Corporation (an Infineon company) or 11 * an affiliate of Cypress Semiconductor Corporation. 12 * SPDX-License-Identifier: Apache-2.0 13 * 14 * Licensed under the Apache License, Version 2.0 (the "License"); 15 * you may not use this file except in compliance with the License. 16 * You may obtain a copy of the License at 17 * 18 * http://www.apache.org/licenses/LICENSE-2.0 19 * 20 * Unless required by applicable law or agreed to in writing, software 21 * distributed under the License is distributed on an "AS IS" BASIS, 22 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 23 * See the License for the specific language governing permissions and 24 * limitations under the License. 25 *******************************************************************************/ 26 27 #ifndef CY_IPC_BT_H 28 #define CY_IPC_BT_H 29 30 /******************************************************************************/ 31 /* Include files */ 32 /******************************************************************************/ 33 34 #include "cy_device.h" 35 36 #if defined (CY_IP_MXIPC) 37 38 #include "cy_ipc_drv.h" 39 #include "cy_syslib.h" 40 #include "cy_sysint.h" 41 42 /** 43 * \addtogroup group_ipc_bt IPC Bluetooth sub-system layer (IPC_BTSS) 44 * \{ 45 * All the HCI APIs are intended to be called by the stack interface layer, and 46 * not meant to be called by the application developers. 47 * 48 * The BT IPC functions provide a method to transfer Host Controller Interface (HCI) 49 * and High Priority Controller (HPC) messages between the MCU and BT SS. 50 * 51 * Include cy_ipc_bt.h. Alternatively include cy_pdl.h 52 * to get access to all functions and declarations in the PDL. 53 * 54 * The data needs to be provided in an array along with the payload type indicator. 55 * Depending on the payload length, the message gets formatted in to short or long 56 * message. If the payload length is less than 7 bytes, then it is considered as a short 57 * message. Short messages are packed and sent using IPC channel DATA0 and DATA1 58 * registers. Any payload length greater than 7 bytes will be sent using the buffers in 59 * the shared memory. 60 * 61 * It supports callback function for notification on receiving the HCI messages from the BT SS 62 * HCI notification callback function is registered during the initialization of the driver. 63 * It also supports multiple callback registration for notification on receiving the 64 * HPC messages. 65 * 66 * \defgroup group_ipc_bt_macros Macros 67 * Macro definitions are used in the driver 68 * 69 * \defgroup group_ipc_bt_functions Functions 70 * Functions are used in the driver 71 * 72 * \defgroup group_ipc_bt_data_structures Data Structures 73 * Data structures are used in the driver 74 * 75 * \defgroup group_ipc_bt_enums Enumerated Types 76 * Enumerations are used in the driver 77 * \} 78 * 79 */ 80 81 //#define BT_OLD_INIT 82 /* Enable below macro to get BT IPC statistics */ 83 #define CY_BTIPC_STATS 84 85 /** 86 * \addtogroup group_ipc_bt_macros 87 * \{ 88 */ 89 90 /** Software PDL driver ID for IPC BT functions */ 91 #define CY_BT_IPC_ID CY_IPC_ID 92 93 /** Return prefix for BT IPC driver function status codes */ 94 #define CY_BT_IPC_ID_INFO (uint32_t)( CY_BT_IPC_ID | CY_PDL_STATUS_INFO ) 95 96 /** Return prefix for BT IPC driver function warning return values */ 97 #define CY_BT_IPC_ID_WARNING (uint32_t)( CY_BT_IPC_ID | CY_PDL_STATUS_WARNING) 98 99 /** Return prefix for BT IPC driver function error return values */ 100 #define CY_BT_IPC_ID_ERROR (uint32_t)( CY_BT_IPC_ID | CY_PDL_STATUS_ERROR) 101 102 /** Maximum HPC callback supported */ 103 #define MAX_BT_IPC_HPC_CB 10 104 105 /** Maximum number of buffers in the pool */ 106 #define MAX_BUF_COUNT 4 107 108 /** Maximum number of buffers to be released */ 109 #define MAX_TO_FREE_BUF_COUNT 5 110 111 /** Maximum size of IPC FIFO */ 112 #define MAX_IPC_FIFO_SIZE 5 113 114 /** \} group_ipc_bt_macros */ 115 116 117 /** Maximum length of short message */ 118 #define MAX_SHORT_MESG_LENGTH 7 119 120 /** Buffer descriptor length in init message */ 121 #define BUFFER_DESCRIPTION_LEN 7 122 123 /** size of cy_stc_ipc_msg_subheader_t structure */ 124 #define SUB_HEADER_SIZE 4 125 126 /** 127 * \addtogroup group_ipc_bt_enums 128 * \{ 129 */ 130 /** 131 * This is a list of ENUMs used for function return status. 132 */ 133 typedef enum 134 { 135 CY_BT_IPC_DRV_SUCCESS =(uint32_t)(0x00u), /**< BT IPC API return for no error */ 136 CY_BT_IPC_DRV_ERROR =(uint32_t)(CY_BT_IPC_ID_ERROR | 1UL), /**< BT IPC API return for general error */ 137 CY_BT_IPC_DRV_ERROR_BAD_HANDLE =(uint32_t)(CY_BT_IPC_ID_ERROR | 2UL), /**< BT IPC API return for bad handle */ 138 CY_BT_IPC_DRV_ERROR_CH_BUSY =(uint32_t)(CY_BT_IPC_ID_ERROR | 3UL), /**< BT IPC API return for channel busy */ 139 CY_BT_IPC_DRV_ERROR_LOCK_REL =(uint32_t)(CY_BT_IPC_ID_ERROR | 4UL), /**< BT IPCAPI return for channel release error */ 140 CY_BT_IPC_DRV_ERROR_LOCK_ACQUIRE =(uint32_t)(CY_BT_IPC_ID_ERROR | 5UL), /**< BT IPC API return for channel release error */ 141 CY_BT_IPC_DRV_ERROR_BUF_GET =(uint32_t)(CY_BT_IPC_ID_ERROR | 6UL), /**< BT IPC API return for get buffer error */ 142 CY_BT_IPC_DRV_ERROR_BUF_FULL =(uint32_t)(CY_BT_IPC_ID_ERROR | 7UL), /**< BT IPC API return for buffer full error */ 143 CY_BT_IPC_DRV_ERROR_BUF_EMPTY =(uint32_t)(CY_BT_IPC_ID_ERROR | 8UL), /**< BT IPC API return for buffer empty error */ 144 CY_BT_IPC_DRV_ERROR_BUF_PRESENT =(uint32_t)(CY_BT_IPC_ID_ERROR | 9UL), /**< BT IPC API return for buffer already present error */ 145 CY_BT_IPC_DRV_ERROR_BUF_SIZE =(uint32_t)(CY_BT_IPC_ID_ERROR | 10UL), /**< BT IPC API return for buffer of size not available error */ 146 CY_BT_IPC_DRV_ERROR_PARAM =(uint32_t)(CY_BT_IPC_ID_ERROR | 11UL), /**< BT IPC API return for bad parameter error */ 147 } cy_en_btipcdrv_status_t; 148 149 /** 150 * This is a list of ENUMs used for buffer types. 151 */ 152 typedef enum 153 { 154 CY_BT_IPC_CTRL_BUF = (0x00u), /**< Control buffer type */ 155 CY_BT_IPC_HCI_CMD_BUF = (0x01u), /**< Command buffer type */ 156 CY_BT_IPC_HCI_BREDR_BUF = (0x02u), /**< BR/EDR buffer type */ 157 CY_BT_IPC_HCI_BLE_BUF = (0x03u), /**< BLE buffer type */ 158 CY_BT_IPC_HCI_ISOC_BUF = (0x04u), /**< ISOC buffer type */ 159 CY_BT_IPC_HCI_INVALID_BUF = (0xFFu), /**< Invalid buffer type */ 160 } cy_en_btipc_buftype_t; 161 162 /** 163 * This is a list of ENUMs used for HCI packet type. 164 */ 165 typedef enum 166 { 167 CY_BT_IPC_HCI_IGNORE = (0x00u), /**< HCI payload type ignore */ 168 CY_BT_IPC_HCI_CMD = (0x01u), /**< HCI payload type command */ 169 CY_BT_IPC_HCI_ACL = (0x02u), /**< HCI payload type ACL */ 170 CY_BT_IPC_HCI_SCO = (0x03u), /**< HCI payload type SCO */ 171 CY_BT_IPC_HCI_EVT = (0x04u), /**< HCI payload type Event */ 172 CY_BT_IPC_HCI_ISO = (0x05u), /**< HCI payload type ISO */ 173 CY_BT_IPC_HCI_DIAG = (0x07u), /**< HCI payload type Diagnostics */ 174 CY_BT_IPC_HCI_MPAF = (0x0Au), /**< HCI payload type MPAF */ 175 CY_BT_IPC_HCI_SLIPH5 = (0xC0u), /**< HCI payload type SLIPH5 */ 176 CY_BT_IPC_HCI_LONG = (0xFFu), /**< HCI payload type long message */ 177 } cy_en_btipc_hcipti_t; 178 179 /** 180 * This is a list of ENUMs used for HPC packet type. 181 */ 182 typedef enum 183 { 184 CY_BT_IPC_HPC_RESERVED = (0x00u), /**<..Reserved (not used) */ 185 CY_BT_IPC_HPC_BUFRELEASE = (0x01u), /**< HPC payload type buffer release, sent from MCU only */ 186 CY_BT_IPC_HPC_REQTRNG = (0x02u), /**< HPC payload type request TRNG */ 187 CY_BT_IPC_HPC_BUFPROVIDE = (0x03u), /**< HPC payload type provide buffer, sent from BT only */ 188 CY_BT_IPC_HPC_PM = (0x04u), /**< HPC payload type PM control */ 189 CY_BT_IPC_HPC_RESACCESS = (0x05u), /**< HPC payload type Resource Access */ 190 CY_BT_IPC_HPC_LPO_SWITCH = (0x06u), /**< HPC payload type LPO Clk switch */ 191 CY_BT_IPC_HPC_INRUSH_MODE = (0x07u), /**< HPC payload type inrush mode select */ 192 CY_BT_IPC_HPC_BUFFER_REMOVE = (0x08u), /**< HPC payload type buffer remove, sent from BT only */ 193 CY_BT_IPC_HPC_LONG = (0xFFu), /**< HPC payload type long message */ 194 } cy_en_btipc_hpcpti_t; 195 196 /** 197 * This is a list of ENUMs used for HPC long message type. 198 */ 199 typedef enum 200 { 201 CY_BT_IPC_HPC_INIT = (0x01u), /**<..Init message */ 202 CY_BT_IPC_HPC_HADM = (0x02u), /**< HADM data message from BTSS to MCU */ 203 CY_BT_IPC_HPC_DUMMY = (0x10u), /**< DUMMY data message from MCU to BTSS */ 204 } cy_en_btipc_hpcmsgid_t; 205 206 /** 207 * This is a list of ENUMs used for bt boot type. 208 */ 209 typedef enum 210 { 211 #ifdef BT_OLD_INIT 212 CY_BT_IPC_COLD_BOOT = (0x00u), /**< BTSS was reset and is in colds boot */ 213 #endif 214 CY_BT_IPC_BOOT_CONFIG_WAIT = (0x00u), /**< BTSS is reset and is in boot waiting for a config from the MCU. If certificate error indicates any error processing certificates */ 215 CY_BT_IPC_BOOT_FULLY_UP = (0x01u), /**< BTSS is fully up. It either processed a config from the MCU, or the MCU did not send a config. If the certificate error value is non-zero, there was an error processing certificates after getting the config, but the boot continued anyway. */ 216 } cy_en_btipc_boottype_t; 217 218 /** 219 * This is a list of ENUMs used in PM command from MCU to BTSS 220 */ 221 typedef enum 222 { 223 CY_BT_IPC_PM_HIBERNATE_CMD = (0x01u), /**< Command for Hibernate state */ 224 } cy_en_btipc_pm_cmd_t; 225 226 /** 227 * This is a list of ENUMs used in PM response from BTSS to MCU 228 */ 229 typedef enum 230 { 231 CY_BT_IPC_PM_ACCEPTED = (0x00u), /**< PM command accepted */ 232 CY_BT_IPC_PM_REJECTED = (0x01u), /**< PM command rejected */ 233 } cy_en_btipc_pm_resp_t; 234 235 /** 236 * This is a list of ENUMs used in resource access request from BTSS to MCU 237 */ 238 typedef enum 239 { 240 CY_BT_IPC_RESACC_DI = (0x00u), /**< Resource access disable request */ 241 CY_BT_IPC_RESACC_EN = (0x01u), /**< Resource access enable request */ 242 } cy_en_btipc_recacc_req_t; 243 244 /** 245 * This is a list of ENUMs used as response from MCCU to BTSS for resource access request 246 */ 247 typedef enum 248 { 249 CY_BT_IPC_RESACC_ACCEPTED = (0x00u), /**< Resource access request accepted */ 250 CY_BT_IPC_RESACC_REJECTED = (0x01u), /**< Resource access request rejected */ 251 }cy_en_btipc_recacc_resp_t; 252 253 /** 254 * This is a list of ENUMs used for LPO change indication from MCUSS to BTSS 255 */ 256 typedef enum 257 { 258 CY_BT_IPC_LPO_PILO = (0x00u), /**< LPO clk type PILO */ 259 CY_BT_IPC_LPO_WCO = (0x01u), /**< LPO clk type WCO */ 260 CY_BT_IPC_LPO_WCO_BYPASS = (0x02u), /**< LPO clk type WCO BYPASS */ 261 }cy_en_btipc_lpo_cmd_t; 262 263 /** 264 * This is a list of ENUMs used for cbuk inrush mode indication from MCUSS to BTSS 265 */ 266 typedef enum 267 { 268 CY_BT_IPC_INRUSH_LOW = (0x00u), /**< Inrush limit low */ 269 CY_BT_IPC_INRUSH_HIGH = (0x01u), /**< Inrush limit high */ 270 }cy_en_btipc_inrush_mode_t; 271 272 /** 273 * This is a list of ENUMs used for HCI DAIG packet type. 274 */ 275 typedef enum 276 { 277 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_NOP = (0x00U), 278 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_ALIVE_IND = (0x02U), 279 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_CPU_LOAD = (0x10U), 280 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_RESET_STATS = (0xB9U), 281 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_LMP_LOG = (0xF0U), 282 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_MEM_PEEK = (0xF1U), 283 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_MEM_POKE = (0xF2U), 284 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_MEM_HEXDUMP = (0xF3U), 285 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_SEND_STATS = (0xF4U), 286 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_BB_PKT_TEST = (0xF6U), 287 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_PICO_TEST = (0xF7U), 288 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_HCI_LOG = (0xF8U), 289 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_PICO_STATS = (0xF9U), 290 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_AUX_STATS = (0xFAU), 291 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_SEND_RSSI = (0xFBU), 292 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_BAD_EVENT_LOG = (0xFCU), 293 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_READ_2040_GPIO = (0xFDU), 294 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_SEND_BASIC_RATE_ACL_STATS = (0xC1U), 295 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_SEND_EDR_ACL_STATS = (0xC2U), 296 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_2045_AUX_STATS = (0xC3U), 297 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_SEND_BASIC_RATE_SCO_STATS = (0xC5U), 298 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_SEND_EDR_SCO_STATS = (0xC6U), 299 CY_BT_IPC_HCI_DIAG_IN_PKT_ID_BLE_CONN_STATS = (0xCFU), 300 }cy_en_btipc_hci_diag_msg_type_t; 301 302 303 /** \} group_ipc_bt_enums */ 304 305 /* 306 * This section defines the system level constants required to define 307 * callback arrays for the Cypress pipe and the user pipe. These defines 308 * are used for both the max callback count and maximum clients. 309 */ 310 311 /** Typedef for bt ipc callback function pointer */ 312 typedef void (* cy_ipc_bt_callback_ptr_t)(uint32_t * msgPtr); 313 314 /** Typedef for bt ipc channel release callback function pointer */ 315 typedef void (* cy_ipc_bt_relcallback_ptr_t)(void); 316 317 /** Typedef for bt ipc buffer available callback function pointer */ 318 typedef void (* cy_ipc_bt_bufcallback_ptr_t)(cy_en_btipc_buftype_t bufType); 319 320 /** Typedef for bt ipc irq function pointer */ 321 typedef void (* cy_ipc_bt_irq_handler_t)(void); 322 323 /** 324 * \addtogroup group_ipc_bt_data_structures 325 * \{ 326 */ 327 328 /** 329 * This is the definition of an allocation msg structure. 330 */ 331 typedef struct cy_stc_ipc_msg_alloc_t 332 { 333 uint8_t pti; /**< Payload type indicator */ 334 uint8_t bufType; /**< Buffer type indicator */ 335 uint16_t bufSize; /**< Buffer size */ 336 uint8_t *bufAddr; /**< Pointer to the buffer */ 337 } cy_stc_ipc_msg_alloc_t; 338 339 /** 340 * This is the definition of a long message structure. 341 */ 342 typedef struct cy_stc_ipc_msg_buff_t 343 { 344 uint8_t pti; /**< Payload type indicator */ 345 uint8_t actualPti; /**< Actual PTI for the long messages */ 346 uint16_t bufSize; /**< Buffer size */ 347 uint8_t *bufAddr; /**< Pointer to the buffer */ 348 } cy_stc_ipc_msg_buff_t; 349 350 /** 351 * This is the definition of a short msg structure. 352 */ 353 typedef struct cy_stc_ipc_msg_short_t 354 { 355 uint8_t pti; /**< Payload type indicator */ 356 uint8_t db0; /**< Payload byte 0 for short message */ 357 uint8_t db1; /**< Payload byte 1 for short message */ 358 uint8_t db2; /**< Payload byte 2 for short message */ 359 uint8_t db3; /**< Payload byte 3 for short message */ 360 uint8_t db4; /**< Payload byte 4 for short message */ 361 uint8_t db5; /**< Payload byte 5 for short message */ 362 uint8_t db6; /**< Payload byte 6 for short message */ 363 } cy_stc_ipc_msg_short_t; 364 365 /** \} group_ipc_bt_data_structures */ 366 367 /** 368 * This is the definition of an init msg structure. 369 */ 370 #ifdef BT_OLD_INIT 371 typedef struct cy_stc_ipc_msg_init_t 372 #else 373 typedef __PACKED_STRUCT cy_stc_ipc_msg_init_t 374 #endif 375 { 376 uint8_t msgId; /**< Message ID for HPC Long message */ 377 uint8_t payLoadLen; /**< Payload length in bytes */ 378 uint8_t bootType; /**< BT boot type indicator */ 379 #ifndef BT_OLD_INIT 380 uint32_t certError; /**< Certificate error value */ 381 #endif 382 } cy_stc_ipc_msg_init_t; 383 384 /** 385 * This is the definition of a sub header msg structure. 386 */ 387 typedef __PACKED_STRUCT cy_stc_ipc_msg_subheader_t 388 { 389 uint8_t msgId; /**< Message ID for HPC message */ 390 uint8_t dummy; /**< Dummy byte to be ignored */ 391 uint16_t payLoadLen; /**< Payload length in bytes */ 392 } cy_stc_ipc_msg_subheader_t; 393 394 /** 395 * This is the definition of buffer descriptor structure. 396 */ 397 typedef struct cy_stc_ipc_bt_buf_t 398 { 399 cy_en_btipc_buftype_t bufType; /**< Buffer type indicator */ 400 uint16_t bufLen; /**< Buffer length */ 401 uint8_t *bufPtr; /**< Pointer to the buffer */ 402 } cy_stc_ipc_bt_buf_t; 403 404 /** 405 * This is the definition of buffer descriptor optimized for context store/restore. 406 */ 407 typedef struct cy_stc_ipc_bt_ctxbuf_t 408 { 409 uint16_t bufType; /**< Buffer type indicator */ 410 uint16_t bufLen; /**< Buffer length */ 411 uint8_t *bufPtr; /**< Pointer to the buffer */ 412 } cy_stc_ipc_bt_ctxbuf_t; 413 414 415 /* Following are the HCI packet header typedefs */ 416 /** 417 * This is the definition of CMD header structure. 418 */ 419 typedef __PACKED_STRUCT BTHCI_CMD_HDR_t 420 { 421 uint16_t opcode; 422 uint8_t params_len; 423 } BTHCI_CMD_HDR_t; 424 425 /** 426 * This is the definition of event header structure. 427 */ 428 typedef struct BTHCI_EVENT_HDR_t 429 { 430 uint8_t code; /**< code */ 431 uint8_t params_len; /**< params_len */ 432 } BTHCI_EVENT_HDR_t; 433 434 /** 435 * This is the definition of ACL header structure. 436 */ 437 typedef __PACKED_STRUCT BTHCI_ACL_HDR_t 438 { 439 uint16_t conn_handle_and_flags; 440 uint16_t data_len; 441 } BTHCI_ACL_HDR_t; 442 443 /** 444 * This is the definition of ISO header structure. 445 */ 446 typedef __PACKED_STRUCT BTHCI_ISO_HDR_t 447 { 448 uint16_t conn_handle_and_flags; 449 uint16_t data_len; 450 } BTHCI_ISO_HDR_t; 451 452 /** 453 * This is the definition of SCO header structure. 454 */ 455 typedef struct BTHCI_SCO_HDR_t 456 { 457 __PACKED_UNION 458 { 459 uint16_t audioChannel; /**< audioChannel */ 460 uint16_t connectionHandle; /**< connectionHandle*/ 461 } u; /**< u */ 462 uint8_t data_len; /**< data_len */ 463 } BTHCI_SCO_HDR_t; 464 465 /** Typedef for internal ipc callback function pointer */ 466 typedef void (* cy_ipc_bt_int_cb_ptr_t)(void *btIpcContext, uint32_t * msgPtr); 467 468 /** 469 * This is the definition of IPC message. 470 */ 471 typedef struct cy_stc_ipc_msg_t 472 { 473 uint32_t msg[2]; /**< IPC message */ 474 } cy_stc_ipc_msg_t; 475 476 /** 477 * This is the definition of fifo for IPC messages. 478 */ 479 typedef struct cy_stc_ipc_msg_fifo_t 480 { 481 cy_stc_ipc_msg_t fifo[MAX_IPC_FIFO_SIZE]; /**< FIFO for IPC messages */ 482 uint8_t rdIdx; /**< FIFO read index */ 483 uint8_t wrIdx; /**< FIFO write index */ 484 uint8_t bufLen; /**< Number of FIFO entries */ 485 } cy_stc_ipc_msg_fifo_t; 486 487 /** 488 * \addtogroup group_ipc_bt_data_structures 489 * \{ 490 */ 491 492 /** 493 * This is the definition of HPC callback structure. 494 */ 495 typedef struct cy_stc_ipc_hcp_cb_t 496 { 497 cy_en_btipc_hpcpti_t msgType; /**< HPC Message Type */ 498 cy_ipc_bt_callback_ptr_t hpcNotifyCallbackPtr; /**< HPC Callback pointer for control channel notification */ 499 } cy_stc_ipc_hcp_cb_t; 500 501 502 /** 503 * This is the definition of BT IPC context structure. 504 */ 505 typedef struct cy_stc_ipc_bt_context_t 506 { 507 uint32_t ulChannelHCI; /**< HCI Channel used to send to BLE */ 508 uint32_t dlChannelHCI; /**< HCI Channel used to receive from BLE */ 509 510 uint32_t ulChannelHPC; /**< HPC Channel used to send to BLE */ 511 uint32_t dlChannelHPC; /**< HPC Channel used to receive from BLE */ 512 513 uint32_t intStuctureSelf; /**< Interrupt structure for the MCU */ 514 uint32_t intStucturePeer; /**< Interrupt structure for the BLE */ 515 516 uint32_t intPeerMask; /**< Interrupt mask for the peer */ 517 518 uint32_t dlNotifyMask; /**< Down link notify mask */ 519 uint32_t ulReleaseMask; /**< Up link release mask */ 520 521 cy_stc_sysint_t ipcIntConfig; /**< IPC Interrupt configuration structure */ 522 523 cy_ipc_bt_irq_handler_t irqHandlerPtr; /**< This handler will be removed later once simulations are done */ 524 525 cy_ipc_bt_int_cb_ptr_t internal_hpc_notify_cb; /**< This callback will be removed later once simulations are done */ 526 527 cy_ipc_bt_callback_ptr_t dlNotifyCallbackPtr; /**< Callback function called when the DL message is received */ 528 529 cy_ipc_bt_relcallback_ptr_t ulReleaseCallbackPtr; /**< Callback function called when the UL channel is released */ 530 531 cy_ipc_bt_bufcallback_ptr_t bufCallbackPtr; /**< Callback function called when there is a free buffer available */ 532 533 cy_stc_ipc_hcp_cb_t hpcNotifyCallbackParam[MAX_BT_IPC_HPC_CB]; /**< Array of callback pointers registered for control channel notification */ 534 535 cy_stc_ipc_bt_buf_t buffPool[MAX_BUF_COUNT]; /**< Storage for pool of buffers sent by BLE for communication */ 536 537 cy_stc_ipc_msg_fifo_t IpcFifo; /**< FIFO for HCI IPC messages sent by BLE for communication */ 538 539 cy_stc_ipc_bt_buf_t toFreeBuf[MAX_TO_FREE_BUF_COUNT]; /**< Array of buffer descriptor of HCI long buffer to be released is stored */ 540 541 uint32_t droppedHCI; /**< Count of dropped HCI messages */ 542 uint8_t bootType; /**< Boot type */ 543 uint32_t certError; /**< Certificate processing error description */ 544 545 #ifdef CY_BTIPC_STATS 546 /* Following data is used for analyses */ 547 uint32_t ipc_int_count; /**< Total number of IPC interrupts received */ 548 549 uint32_t ipc_hci_cmd_count; /**< Total number of HCI cmds received */ 550 uint32_t ipc_hci_release_count; /**< Total number of HCI release received */ 551 552 uint32_t ipc_hci_notify_count; /**< Total number of HCI notifications received */ 553 uint32_t ipc_hci_peer_release_count; /**< Total number of releases done to peer HCI channel */ 554 555 uint32_t ipc_hpc_cmd_count; /**< Total number of HPC cmds received */ 556 uint32_t ipc_hpc_release_count; /**< Total number of HPC notifications received */ 557 558 uint32_t ipc_hpc_notify_count; /**< Total number of HPC notifications received */ 559 uint32_t ipc_hpc_peer_release_count; /**< Total number of releases done to peer HPC channel */ 560 561 uint32_t ipc_hci_peer_inbuf_count; /**< Total number of HCI buffers received */ 562 uint32_t ipc_hci_peer_outbuf_count; /**< Total number of HCI buffers returned */ 563 564 uint32_t ipc_hpc_peer_inbuf_count; /**< Total number of HPC buffers received */ 565 uint32_t ipc_hpc_peer_outbuf_count; /**< Total number of HPC buffers returned */ 566 567 uint32_t ipc_hci_cmd_self_outbuf_count; /**< Total number of HCI cmd buffers pulled form pool */ 568 uint32_t ipc_hci_cmd_self_outbuf_success; /**< Total number of HCI cmd buffers sent to peer */ 569 uint32_t ipc_hci_cmd_self_inbuf_count; /**< Total number of HCI cmd buffers received back from peer */ 570 571 uint32_t ipc_hci_fifo_full; /**< Total FIFO full condition count */ 572 uint32_t ipc_hci_notify_in_fifo_full; /**< HCI Notify received during FIFO full condition */ 573 #endif 574 } cy_stc_ipc_bt_context_t; 575 576 /** 577 * This is the definition of BT IPC context structure used to restore and retrieve during RAM off state. 578 */ 579 typedef struct cy_stc_ipc_bt_save_ctxt_t 580 { 581 cy_stc_ipc_bt_ctxbuf_t buffPool[MAX_BUF_COUNT]; /**< Storage for pool of buffers sent by BLE for communication */ 582 } cy_stc_ipc_bt_save_ctxt_t; 583 584 /** 585 * This is the definition of BT IPC configuration structure. 586 */ 587 typedef struct cy_stc_ipc_bt_config_t 588 { 589 uint32_t ulChannelHCI; /**< HCI Channel used to send to BLE */ 590 uint32_t dlChannelHCI; /**< HCI Channel used to receive from BLE */ 591 592 uint32_t ulChannelHPC; /**< HPC Channel used to send to BLE */ 593 uint32_t dlChannelHPC; /**< HPC Channel used to receive from BLE */ 594 595 uint32_t intStuctureSelf; /**< Interrupt structure for the MCU */ 596 uint32_t intStucturePeer; /**< Interrupt structure for the BLE */ 597 598 cy_stc_sysint_t ipcIntConfig; /**< IPC Interrupt configuration structure */ 599 600 cy_ipc_bt_irq_handler_t irqHandlerPtr; /**< This handler will be removed later once simulations are done */ 601 602 cy_ipc_bt_int_cb_ptr_t internal_hpc_notify_cb; /**< This callback will be removed later once simulations are done */ 603 604 cy_ipc_bt_relcallback_ptr_t ulReleaseCallbackPtr; /**< Callback function called when the UL channel is released */ 605 606 cy_ipc_bt_bufcallback_ptr_t bufCallbackPtr; /**< Callback function called when there is a free buffer available */ 607 } cy_stc_ipc_bt_config_t; 608 609 /** 610 * This is the definition of HPC IOSS config msg structure. 611 */ 612 typedef __PACKED_STRUCT cy_stc_ipc_msg_iocfg_t 613 { 614 uint8_t msgId; /**< Message ID for HPC message */ 615 uint8_t dummy1; /**< Dummy byte to be ignored */ 616 uint16_t mode; /**< IO config mode */ 617 uint32_t dummy2; /**< Dummy word to be ignored */ 618 } cy_stc_ipc_msg_iocfg_t; 619 620 /** 621 * This is the definition of HPC TRNG msg structure. 622 */ 623 typedef __PACKED_STRUCT cy_stc_ipc_msg_trng_t 624 { 625 uint8_t msgId; /**< Message ID for HPC message */ 626 uint8_t dummy1; /**< Dummy byte to be ignored */ 627 uint8_t dummy2; /**< Dummy byte to be ignored */ 628 uint8_t dummy3; /**< Dummy byte to be ignored */ 629 uint32_t trng; /**< Dummy when sent to BTSS. TRNG when received from BTSS */ 630 } cy_stc_ipc_msg_trng_t; 631 632 /** 633 * This is the definition of HPC PM request structure. 634 */ 635 typedef __PACKED_STRUCT cy_stc_ipc_msg_pmcmd_t 636 { 637 uint8_t msgId; /**< Message ID for HPC message */ 638 uint8_t dummy1; /**< Not used */ 639 uint16_t dummy2; /**< Not used */ 640 uint32_t pm_op; /**< Power management operation */ 641 } cy_stc_ipc_msg_pmcmd_t; 642 643 /** 644 * This is the definition of HPC PM response structure. 645 */ 646 typedef __PACKED_STRUCT cy_stc_ipc_msg_pmresp_t 647 { 648 uint8_t msgId; /**< Message ID for HPC message */ 649 uint8_t dummy1; /**< Not used */ 650 uint16_t dummy2; /**< Not used */ 651 uint32_t pm_resp; /**< Response form BT for power management command */ 652 } cy_stc_ipc_msg_pmresp_t; 653 654 /** 655 * This is the definition of HPC resource access request structure from BTSS to MCU 656 */ 657 typedef __PACKED_STRUCT cy_stc_ipc_msg_res_access_req_t 658 { 659 uint8_t msgId; /**< Message ID for HPC message */ 660 uint8_t dummy1; /**< Not used */ 661 uint16_t dummy2; /**< Not used */ 662 uint32_t access_ctrl; /**< Access enable/disable control */ 663 } cy_stc_ipc_msg_res_access_req_t; 664 665 /** 666 * This is the definition of HPC resource access response structure from MCU to BTSS 667 */ 668 typedef __PACKED_STRUCT cy_stc_ipc_msg_res_access_resp_t 669 { 670 uint8_t msgId; /**< Message ID for HPC response */ 671 uint8_t dummy1; /**< Not used */ 672 uint16_t dummy2; /**< Not used */ 673 uint32_t result; /**< result of access request */ 674 } cy_stc_ipc_msg_res_access_resp_t; 675 676 /** 677 * This is the definition of HPC structure to indicate LPO change from MCU to BTSS 678 */ 679 typedef __PACKED_STRUCT cy_stc_ipc_msg_clklf_switch_t 680 { 681 uint8_t msgId; /**< Message ID for HPC message */ 682 uint8_t mode; /**< LPO source 0 = PILO, 1 = WCO */ 683 uint8_t dummy1; /**< Not used */ 684 uint8_t dummy2; /**< Not used */ 685 uint32_t param; /**< WCO calibration offset in ppm */ 686 } cy_stc_ipc_msg_clklf_switch_t; 687 688 /** 689 * This is the definition of HPC structure to indicate cbuk inrush mode from MCU to BTSS 690 */ 691 typedef __PACKED_STRUCT cy_stc_ipc_msg_inrush_mode_t 692 { 693 uint8_t msgId; /**< Message ID for HPC message */ 694 uint8_t mode; /**< inrush mode 0 = LOW, 1 = HIGH */ 695 uint8_t dummy1; /**< Not used */ 696 uint8_t dummy2; /**< Not used */ 697 uint32_t dummy3; /**< Not used */ 698 } cy_stc_ipc_msg_inrush_mode_t; 699 700 /** 701 * This is the definition of HPC structure to indicate buffer removal from BTSS to MCU 702 */ 703 typedef __PACKED_STRUCT cy_stc_ipc_msg_buf_remove_t 704 { 705 uint8_t msgId; /**< Message ID for HPC message */ 706 uint8_t bufType; /**< Buffer type indicator */ 707 uint8_t dummy1; /**< Not used */ 708 uint8_t dummy2; /**< Not used */ 709 uint32_t dummy3; /**< Not used */ 710 } cy_stc_ipc_msg_buf_remove_t; 711 /** \} group_ipc_bt_data_structures */ 712 713 714 /** 715 * \addtogroup group_ipc_bt_functions 716 * \{ 717 */ 718 /******************************************************************************* 719 * Function Name: Cy_BTIPC_Init 720 ****************************************************************************//** 721 * 722 * This function initializes the Bluetooth IPC. The IPC channels used for HCI and HPC packet exchange 723 * between MCU and BT SS are initialized. 724 * 725 * \note In general, this function is called during application initialization. 726 * 727 * \param btIpcConfig 728 * This is the pointer to the bt ipc configuration structure. 729 * 730 * \param btIpcContext 731 * This is the pointer to the bt ipc context structure. 732 * 733 * \return 734 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 735 * CY_BT_IPC_DRV_ERROR: BT IPC API return for general error 736 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 737 * 738 *******************************************************************************/ 739 cy_en_btipcdrv_status_t Cy_BTIPC_Init(cy_stc_ipc_bt_context_t *btIpcContext, cy_stc_ipc_bt_config_t * btIpcConfig); 740 741 742 /******************************************************************************* 743 * Function Name: Cy_BTIPC_WarmInit 744 ****************************************************************************//** 745 * 746 * This function performs the warm initialization of the Bluetooth IPC. 747 * 748 * \note In general, this function is called during application warm boot initialization. 749 * 750 * \param btIpcConfig 751 * This is the pointer to the bt ipc configuration structure. 752 * 753 * \param btIpcContext 754 * This is the pointer to the bt ipc context structure. 755 * 756 * \return 757 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 758 * CY_BT_IPC_DRV_ERROR: BT IPC API return for general error 759 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 760 * 761 *******************************************************************************/ 762 cy_en_btipcdrv_status_t Cy_BTIPC_WarmInit(cy_stc_ipc_bt_context_t *btIpcContext, cy_stc_ipc_bt_config_t * btIpcConfig); 763 764 765 /******************************************************************************* 766 * Function Name: Cy_BTIPC_Deinit 767 ****************************************************************************//** 768 * 769 * This function de-initializes the Bluetooth IPC. All the registered callbacks are deleted. 770 * 771 * \note In general, this function is called when the application does not need BT IPC service 772 * anymore. 773 * 774 * \param btIpcContext 775 * This is the pointer to the bt ipc context structure. 776 * 777 * \return 778 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 779 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 780 * 781 *******************************************************************************/ 782 cy_en_btipcdrv_status_t Cy_BTIPC_Deinit(cy_stc_ipc_bt_context_t *btIpcContext); 783 784 785 /******************************************************************************* 786 * Function Name: Cy_BTIPC_HCI_getPTI 787 ****************************************************************************//** 788 * 789 * This function gets the payload type indicator and the length of the HCI packet received 790 * from BTSS. This function can be called to find out the type of HCI packet and allocate 791 * buffer of appropriate size to copy the packet data. 792 * 793 * \note In general, this function is called before reading the packet to allocate memory 794 * of required size. 795 * 796 * \param pti 797 * This is the pointer to payload type indicator which is returned by the function. 798 * 799 * \param p_length 800 * This is the pointer to the length of the payload filled by the function. 801 * 802 * \param msgPtr 803 * This is the pointer to buffer which contains the IPC data received in DATA0 and DATA1 804 * registers. 805 * 806 * \return 807 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 808 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 809 * 810 *******************************************************************************/ 811 cy_en_btipcdrv_status_t Cy_BTIPC_HCI_getPTI (cy_en_btipc_hcipti_t *pti, uint32_t *p_length, uint32_t *msgPtr); 812 813 814 /******************************************************************************* 815 * Function Name: Cy_BTIPC_HCI_Write 816 ****************************************************************************//** 817 * 818 * This function sends the HCI packet form the BT stack to the BTSS. 819 * 820 * \param pti 821 * This is the HCI payload type indicator. 822 * 823 * \param data 824 * This is the pointer to the buffer holding the HCI payload. 825 * 826 * \param length 827 * This is the length of the HCI payload in number of bytes. 828 * 829 * \param btIpcContext 830 * This is the pointer to the bt ipc context structure 831 * 832 * \return 833 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 834 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 835 * CY_BT_IPC_DRV_ERROR_LOCK_ACQUIRE: BT IPC API return for buffer pool full error 836 * 837 *******************************************************************************/ 838 cy_en_btipcdrv_status_t Cy_BTIPC_HCI_Write(cy_stc_ipc_bt_context_t *btIpcContext, cy_en_btipc_hcipti_t pti, void *data, size_t length); 839 840 841 /******************************************************************************* 842 * Function Name: Cy_BTIPC_HPC_Write 843 ****************************************************************************//** 844 * 845 * This function sends the HPC packet form the MCU to the BTSS. 846 * 847 * \param data 848 * This is the pointer to the buffer holding the HPC payload. 849 * 850 * \param length 851 * This is the length of the HPC payload in number of bytes. 852 * 853 * \param btIpcContext 854 * This is the pointer to the bt ipc context structure 855 * 856 * \return 857 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 858 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 859 * CY_BT_IPC_DRV_ERROR_LOCK_ACQUIRE: BT IPC API return for buffer pool full error 860 * 861 *******************************************************************************/ 862 cy_en_btipcdrv_status_t Cy_BTIPC_HPC_Write(cy_stc_ipc_bt_context_t *btIpcContext, void *data, size_t length); 863 864 865 /******************************************************************************* 866 * Function Name: Cy_BTIPC_HCI_GetReadBufPtr 867 ****************************************************************************//** 868 * 869 * This function gets the pointer to the received HCI packet by MCU from BTSS. 870 * 871 * \param ppData 872 * This is the pointer to the pointer of received HCI payload buffer 873 * 874 * \param pLength 875 * This is the pointer to the size of the payload received in number of bytes 876 * 877 * \param btIpcContext 878 * This is the pointer to the bt ipc context structure 879 * 880 * \return 881 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 882 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 883 * CY_BT_IPC_DRV_ERROR_LOCK_ACQUIRE: BT IPC API return for buffer pool full error 884 * CY_BT_IPC_DRV_ERROR_LOCK_REL: BT IPCAPI return for channel release error 885 * 886 *******************************************************************************/ 887 cy_en_btipcdrv_status_t Cy_BTIPC_HCI_GetReadBufPtr (cy_stc_ipc_bt_context_t *btIpcContext, void **ppData, size_t* pLength); 888 889 890 /******************************************************************************* 891 * Function Name: Cy_BTIPC_HCI_GetWriteBufPtr 892 ****************************************************************************//** 893 * 894 * This function gets the pointer to the buffer to write HCI packet to send to BTSS. 895 * 896 * \param pti 897 * This is the HCI payload type indicator. 898 * 899 * \param ppData 900 * This is the pointer to the pointer of buffer to write HCI payload buffer 901 * 902 * \param length 903 * This is the length of the HCI payload in number of bytes. 904 * 905 * \param btIpcContext 906 * This is the pointer to the bt ipc context structure 907 * 908 * \return 909 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 910 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 911 * CY_BT_IPC_DRV_ERROR_LOCK_ACQUIRE: BT IPC API return for buffer pool full error 912 * CY_BT_IPC_DRV_ERROR_LOCK_REL: BT IPCAPI return for channel release error 913 * 914 *******************************************************************************/ 915 cy_en_btipcdrv_status_t Cy_BTIPC_HCI_GetWriteBufPtr(cy_stc_ipc_bt_context_t *btIpcContext, cy_en_btipc_hcipti_t pti, void **ppData, size_t length); 916 917 918 /******************************************************************************* 919 * Function Name: Cy_BTIPC_HPC_GetWriteBufPtr 920 ****************************************************************************//** 921 * 922 * This function gets the pointer to the buffer to write HPC long message packet to 923 * send to BTSS. 924 * 925 * \param ppData 926 * This is the pointer to the pointer of buffer to write HPC long message payload buffer 927 * 928 * \param length 929 * This is the length of the HPC payload in number of bytes. 930 * 931 * \param btIpcContext 932 * This is the pointer to the bt ipc context structure 933 * 934 * \return 935 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 936 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 937 * CY_BT_IPC_DRV_ERROR_LOCK_ACQUIRE: BT IPC API return for buffer pool full error 938 * CY_BT_IPC_DRV_ERROR_LOCK_REL: BT IPCAPI return for channel release error 939 * 940 *******************************************************************************/ 941 cy_en_btipcdrv_status_t Cy_BTIPC_HPC_GetWriteBufPtr(cy_stc_ipc_bt_context_t *btIpcContext, void **ppData, size_t length); 942 943 944 /******************************************************************************* 945 * Function Name: Cy_BTIPC_HCI_RelChannel 946 ****************************************************************************//** 947 * 948 * This function releases the HCI channel after handling the notification from the 949 * BT SS 950 * 951 * \param btIpcContext 952 * This is the pointer to the bt ipc context structure 953 * 954 * \return 955 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 956 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 957 * CY_BT_IPC_DRV_ERROR_LOCK_REL: BT IPCAPI return for channel release error 958 * 959 *******************************************************************************/ 960 cy_en_btipcdrv_status_t Cy_BTIPC_HCI_RelChannel(cy_stc_ipc_bt_context_t *btIpcContext); 961 962 963 /******************************************************************************* 964 * Function Name: Cy_BTIPC_HCI_RelBuffer 965 ****************************************************************************//** 966 * 967 * This function releases the HCI buffer after copying the data received from BTSS 968 * 969 * \param btIpcContext 970 * This is the pointer to the bt ipc context structure 971 * 972 * \param msgPtr 973 * This is the pointer to the IPC message received form BTSS 974 * 975 * \return 976 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 977 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 978 * CY_BT_IPC_DRV_ERROR_LOCK_REL: BT IPCAPI return for channel release error 979 * 980 *******************************************************************************/ 981 cy_en_btipcdrv_status_t Cy_BTIPC_HCI_RelBuffer(cy_stc_ipc_bt_context_t *btIpcContext, uint32_t* msgPtr); 982 983 984 /******************************************************************************* 985 * Function Name: Cy_BTIPC_HPC_RelChannel 986 ****************************************************************************//** 987 * 988 * This function releases the HPC channel after handling the notification from the 989 * BT SS 990 * 991 * \param buf 992 * This is the pointer to the buffer received from BT SS in DATA0 and DATA1 channel 993 * registers. 994 * 995 * \param btIpcContext 996 * This is the pointer to the bt ipc context structure 997 * 998 * \return 999 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 1000 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 1001 * CY_BT_IPC_DRV_ERROR_LOCK_REL: BT IPCAPI return for channel release error 1002 * 1003 *******************************************************************************/ 1004 cy_en_btipcdrv_status_t Cy_BTIPC_HPC_RelChannel(cy_stc_ipc_bt_context_t *btIpcContext, void * buf); 1005 1006 1007 /******************************************************************************* 1008 * Function Name: Cy_BTIPC_HCI_RegisterCb 1009 ****************************************************************************//** 1010 * 1011 * This function registers the callback for HCI message notifications from BT SS 1012 * 1013 * \param hciNotifyCallbackPtr 1014 * This is the pointer to the function to be called for HCI notifications. 1015 * 1016 * \param btIpcContext 1017 * This is the pointer to the bt ipc context structure 1018 * 1019 * \return 1020 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 1021 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 1022 * 1023 *******************************************************************************/ 1024 cy_en_btipcdrv_status_t Cy_BTIPC_HCI_RegisterCb(cy_stc_ipc_bt_context_t *btIpcContext, cy_ipc_bt_callback_ptr_t hciNotifyCallbackPtr); 1025 1026 1027 /******************************************************************************* 1028 * Function Name: Cy_BTIPC_HCI_UnregisterCb 1029 ****************************************************************************//** 1030 * 1031 * This function un-registers the callback function registered for HCI message 1032 * notifications from BT SS 1033 * 1034 * \param btIpcContext 1035 * This is the pointer to the bt ipc context structure 1036 * 1037 * \return 1038 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 1039 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 1040 * 1041 *******************************************************************************/ 1042 cy_en_btipcdrv_status_t Cy_BTIPC_HCI_UnregisterCb(cy_stc_ipc_bt_context_t *btIpcContext); 1043 1044 1045 /******************************************************************************* 1046 * Function Name: Cy_BTIPC_HPC_RegisterCb 1047 ****************************************************************************//** 1048 * 1049 * This function registers the callback for HPC message notifications from BT SS 1050 * 1051 * \param pHpcNotifyCallbackParam 1052 * This is the pointer to the function to be called for HPC notifications. 1053 * 1054 * \param btIpcContext 1055 * This is the pointer to the bt ipc context structure 1056 * 1057 * \return 1058 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 1059 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 1060 * CY_BT_IPC_DRV_ERROR: BT IPC API return for general error 1061 * 1062 *******************************************************************************/ 1063 cy_en_btipcdrv_status_t Cy_BTIPC_HPC_RegisterCb(cy_stc_ipc_bt_context_t *btIpcContext, cy_stc_ipc_hcp_cb_t *pHpcNotifyCallbackParam); 1064 1065 1066 /******************************************************************************* 1067 * Function Name: Cy_BTIPC_HPC_UnregisterCb 1068 ****************************************************************************//** 1069 * 1070 * This function un-registers the callback function registered for HPC message 1071 * notifications from BT SS 1072 * 1073 * \param pHpcNotifyCallbackParam 1074 * This is the pointer to the callback function to be un-registered. 1075 * 1076 * \param btIpcContext 1077 * This is the pointer to the bt ipc context structure 1078 * 1079 * \return 1080 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 1081 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 1082 * CY_BT_IPC_DRV_ERROR: BT IPC API return for general error 1083 * 1084 *******************************************************************************/ 1085 cy_en_btipcdrv_status_t Cy_BTIPC_HPC_UnregisterCb(cy_stc_ipc_bt_context_t *btIpcContext, cy_stc_ipc_hcp_cb_t *pHpcNotifyCallbackParam); 1086 1087 1088 /******************************************************************************* 1089 * Function Name: Cy_BTIPC_Buffer_RegisterCb 1090 ****************************************************************************//** 1091 * 1092 * This function registers the callback for buffer available notification 1093 * 1094 * \param bufCallbackPtr 1095 * This is the pointer to the function to be called for buffer available notification. 1096 * 1097 * \param btIpcContext 1098 * This is the pointer to the bt ipc context structure 1099 * 1100 * \return 1101 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 1102 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 1103 * CY_BT_IPC_DRV_ERROR: BT IPC API return for general error 1104 * 1105 *******************************************************************************/ 1106 cy_en_btipcdrv_status_t Cy_BTIPC_Buffer_RegisterCb(cy_stc_ipc_bt_context_t *btIpcContext, cy_ipc_bt_bufcallback_ptr_t bufCallbackPtr); 1107 1108 1109 /******************************************************************************* 1110 * Function Name: Cy_BTIPC_HCI_FIFOGet 1111 ****************************************************************************//** 1112 * 1113 * This function is called to pull the IPC message from FIFO. 1114 * 1115 * \param ppMsg 1116 * This is the pointer to pointer the location in FIFO where the retrieved message is stored. 1117 * 1118 * \param delete 1119 * When set to 1, the entry from the FIFO is deleted after pulling it. 1120 * 1121 * \param btIpcContext 1122 * This is the pointer to the bt ipc context structure 1123 * 1124 * \return 1125 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 1126 * CY_BT_IPC_DRV_ERROR_BUF_FULL : BT IPC API return for FIFO full 1127 * 1128 *******************************************************************************/ 1129 cy_en_btipcdrv_status_t Cy_BTIPC_HCI_FIFOGet(cy_stc_ipc_bt_context_t *btIpcContext, uint32_t **ppMsg, uint8_t delete); 1130 1131 1132 /******************************************************************************* 1133 * Function Name: Cy_BTIPC_HCI_FIFOCount 1134 ****************************************************************************//** 1135 * 1136 * This function is called to get the number of messages in the IPC FIFO. 1137 * 1138 * \param btIpcContext 1139 * This is the pointer to the bt ipc context structure 1140 * 1141 * \return 1142 * number of messages in the IPC FIFO 1143 * 1144 *******************************************************************************/ 1145 uint16_t Cy_BTIPC_HCI_FIFOCount(cy_stc_ipc_bt_context_t *btIpcContext); 1146 1147 1148 /******************************************************************************* 1149 * Function Name: Cy_BTIPC_RetrieveContext 1150 ****************************************************************************//** 1151 * 1152 * This function is called to retrieve the context to be saved during RAM off 1153 * state. 1154 * 1155 * \param pContextRet 1156 * Pointer to the context to be retrieved. This will be updated by this function. 1157 * 1158 * \param btIpcContext 1159 * This is the pointer to the bt ipc context structure 1160 * 1161 * \return 1162 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 1163 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 1164 * 1165 *******************************************************************************/ 1166 cy_en_btipcdrv_status_t Cy_BTIPC_RetrieveContext(cy_stc_ipc_bt_context_t *btIpcContext, cy_stc_ipc_bt_save_ctxt_t *pContextRet); 1167 1168 1169 /******************************************************************************* 1170 * Function Name: Cy_BTIPC_RestoreContext 1171 ****************************************************************************//** 1172 * 1173 * This function is called to restore the saved context during RAM off state. 1174 * 1175 * \param pContextRet 1176 * Pointer to the saved context structure to be restored 1177 * 1178 * \param btIpcContext 1179 * This is the pointer to the bt ipc context structure 1180 * 1181 * \return 1182 * CY_BT_IPC_DRV_SUCCESS: BT IPC API return for no error 1183 * CY_BT_IPC_DRV_ERROR_BAD_HANDLE: BT IPC API return for bad handle 1184 * 1185 *******************************************************************************/ 1186 cy_en_btipcdrv_status_t Cy_BTIPC_RestoreContext(cy_stc_ipc_bt_context_t *btIpcContext, cy_stc_ipc_bt_save_ctxt_t *pContextRet); 1187 1188 1189 /** \} group_ipc_bt_functions */ 1190 1191 void Cy_BTIPC_IRQ_Handler(cy_stc_ipc_bt_context_t *btIpcContext); 1192 1193 /* This function prototype will be removed once the simulations are done */ 1194 void Cy_BTIPC_HPC_Notify(void *btIpcContext, uint32_t * msgPtr); 1195 /* This function will print the BT IPC driver status */ 1196 #ifdef BTIPC_STATUS 1197 cy_en_btipcdrv_status_t Cy_bt_PrintStatus (cy_stc_ipc_bt_context_t *btIpcContext); 1198 #endif 1199 /** \} group_ipc_bt */ 1200 1201 #ifdef __cplusplus 1202 } 1203 #endif 1204 1205 #endif /* CY_IP_MXIPC */ 1206 1207 #endif /* !defined (CY_IPC_BT_H) */ 1208 1209 /* [] END OF FILE */ 1210