1 /** 2 ****************************************************************************** 3 * @file shci_tl.h 4 * @author MCD Application Team 5 * @brief System HCI command header for the system channel 6 ****************************************************************************** 7 * @attention 8 * 9 * <h2><center>© Copyright (c) 2019 STMicroelectronics. 10 * All rights reserved.</center></h2> 11 * 12 * This software component is licensed by ST under BSD 3-Clause license, 13 * the "License"; You may not use this file except in compliance with the 14 * License. You may obtain a copy of the License at: 15 * opensource.org/licenses/BSD-3-Clause 16 * 17 ****************************************************************************** 18 */ 19 20 21 #ifndef __SHCI_TL_H_ 22 #define __SHCI_TL_H_ 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 #include "tl.h" 29 30 /* Exported defines -----------------------------------------------------------*/ 31 typedef enum 32 { 33 SHCI_TL_UserEventFlow_Disable, 34 SHCI_TL_UserEventFlow_Enable, 35 } SHCI_TL_UserEventFlowStatus_t; 36 37 typedef enum 38 { 39 SHCI_TL_CmdBusy, 40 SHCI_TL_CmdAvailable 41 } SHCI_TL_CmdStatus_t; 42 43 /** 44 * @brief Structure used to manage the BUS IO operations. 45 * All the structure fields will point to functions defined at user level. 46 * @{ 47 */ 48 typedef struct 49 { 50 int32_t (* Init) (void* pConf); /**< Pointer to SHCI TL function for the IO Bus initialization */ 51 int32_t (* DeInit) (void); /**< Pointer to SHCI TL function for the IO Bus de-initialization */ 52 int32_t (* Reset) (void); /**< Pointer to SHCI TL function for the IO Bus reset */ 53 int32_t (* Receive) (uint8_t*, uint16_t); /**< Pointer to SHCI TL function for the IO Bus data reception */ 54 int32_t (* Send) (uint8_t*, uint16_t); /**< Pointer to SHCI TL function for the IO Bus data transmission */ 55 int32_t (* DataAck) (uint8_t*, uint16_t* len); /**< Pointer to SHCI TL function for the IO Bus data ack reception */ 56 int32_t (* GetTick) (void); /**< Pointer to BSP function for getting the HAL time base timestamp */ 57 } tSHciIO; 58 /** 59 * @} 60 */ 61 62 /** 63 * @brief Contain the SHCI context 64 * @{ 65 */ 66 typedef struct 67 { 68 tSHciIO io; /**< Manage the BUS IO operations */ 69 void (* UserEvtRx) (void * pData); /**< User System events callback function pointer */ 70 } tSHciContext; 71 72 typedef struct 73 { 74 SHCI_TL_UserEventFlowStatus_t status; 75 TL_EvtPacket_t *pckt; 76 } tSHCI_UserEvtRxParam; 77 78 typedef struct 79 { 80 uint8_t *p_cmdbuffer; 81 void (* StatusNotCallBack) (SHCI_TL_CmdStatus_t status); 82 } SHCI_TL_HciInitConf_t; 83 84 /** 85 * shci_send 86 * @brief Send an System HCI Command 87 * 88 * @param : cmd_code = Opcode of the command 89 * @param : len_cmd_payload = Length of the command payload 90 * @param : p_cmd_payload = Address of the command payload 91 * @param : p_rsp_status = Address of the full buffer holding the command complete event 92 * @retval : None 93 */ 94 void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payload, TL_EvtPacket_t * p_rsp_status ); 95 96 /** 97 * @brief Register IO bus services. 98 * @param fops The SHCI IO structure managing the IO BUS 99 * @retval None 100 */ 101 void shci_register_io_bus(tSHciIO* fops); 102 103 /** 104 * @brief Interrupt service routine that must be called when the system channel 105 * reports a packet has been received 106 * 107 * @param pdata Packet or event pointer 108 * @retval None 109 */ 110 void shci_notify_asynch_evt(void* pdata); 111 112 /** 113 * @brief This function resume the User Event Flow which has been stopped on return 114 * from UserEvtRx() when the User Event has not been processed. 115 * 116 * @param None 117 * @retval None 118 */ 119 void shci_resume_flow(void); 120 121 122 /** 123 * @brief This function is called when an System HCO Command is sent and the response 124 * is waited from the CPU2. 125 * The application shall implement a mechanism to not return from this function 126 * until the waited event is received. 127 * This is notified to the application with shci_cmd_resp_release(). 128 * It is called from the same context the System HCI command has been sent. 129 * 130 * @param timeout: Waiting timeout 131 * @retval None 132 */ 133 void shci_cmd_resp_wait(uint32_t timeout); 134 135 /** 136 * @brief This function is called when an System HCI command is sent and the response is 137 * received from the CPU2. 138 * 139 * @param flag: Release flag 140 * @retval None 141 */ 142 void shci_cmd_resp_release(uint32_t flag); 143 144 145 /** 146 * @brief This process shall be called each time the shci_notify_asynch_evt notification is received 147 * 148 * @param None 149 * @retval None 150 */ 151 152 void shci_user_evt_proc(void); 153 154 /** 155 * @brief Initialize the System Host Controller Interface. 156 * This function must be called before any communication on the System Channel 157 * 158 * @param pData: System events callback function pointer 159 * This callback is triggered when an user event is received on 160 * the System Channel from CPU2. 161 * @param pConf: Configuration structure pointer 162 * @retval None 163 */ 164 void shci_init(void(* UserEvtRx)(void* pData), void* pConf); 165 166 #ifdef __cplusplus 167 } 168 #endif 169 170 #endif /* __SHCI_TL_H_ */ 171