Welcome to mirror list, hosted at ThFree Co, Russian Federation.

shci_tl.h « tl « ble_thread « patterns « interface « STM32_WPAN « ST « Middlewares - github.com/Flipper-Zero/STM32CubeWB.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 3fbc492f1cea97b4dc4d2d90f1fe8b9548acbebc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
/**
 ******************************************************************************
 * @file    shci_tl.h
 * @author  MCD Application Team
 * @brief   System HCI command header for the system channel
 ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; Copyright (c) 2019 STMicroelectronics. 
  * All rights reserved.</center></h2>
  *
  * This software component is licensed by ST under BSD 3-Clause license,
  * the "License"; You may not use this file except in compliance with the 
  * License. You may obtain a copy of the License at:
  *                        opensource.org/licenses/BSD-3-Clause
  *
  ******************************************************************************
 */


#ifndef __SHCI_TL_H_
#define __SHCI_TL_H_

#ifdef __cplusplus
extern "C" {
#endif

#include "tl.h"

/* Exported defines -----------------------------------------------------------*/
typedef enum
{
  SHCI_TL_UserEventFlow_Disable,
  SHCI_TL_UserEventFlow_Enable,
} SHCI_TL_UserEventFlowStatus_t;

typedef enum
{
  SHCI_TL_CmdBusy,
  SHCI_TL_CmdAvailable
} SHCI_TL_CmdStatus_t;

/**
 * @brief Structure used to manage the BUS IO operations.
 *        All the structure fields will point to functions defined at user level.
 * @{
 */ 
typedef struct
{                
  int32_t (* Init)    (void* pConf); /**< Pointer to SHCI TL function for the IO Bus initialization */
  int32_t (* DeInit)  (void); /**< Pointer to SHCI TL function for the IO Bus de-initialization */
  int32_t (* Reset)   (void); /**< Pointer to SHCI TL function for the IO Bus reset */
  int32_t (* Receive) (uint8_t*, uint16_t); /**< Pointer to SHCI TL function for the IO Bus data reception */
  int32_t (* Send)    (uint8_t*, uint16_t); /**< Pointer to SHCI TL function for the IO Bus data transmission */
  int32_t (* DataAck) (uint8_t*, uint16_t* len); /**< Pointer to SHCI TL function for the IO Bus data ack reception */
  int32_t (* GetTick) (void); /**< Pointer to BSP function for getting the HAL time base timestamp */    
} tSHciIO;
/**
 * @}
 */

/**
 * @brief Contain the SHCI context
 * @{
 */
typedef struct
{   
  tSHciIO io; /**< Manage the BUS IO operations */
  void (* UserEvtRx) (void * pData); /**< User System events callback function pointer */
} tSHciContext;

typedef struct
{
  SHCI_TL_UserEventFlowStatus_t status;
  TL_EvtPacket_t *pckt;
} tSHCI_UserEvtRxParam;

typedef struct
{
  uint8_t *p_cmdbuffer;
  void (* StatusNotCallBack) (SHCI_TL_CmdStatus_t status);
} SHCI_TL_HciInitConf_t;

/**
  * shci_send
  * @brief  Send an System HCI Command
  *
  * @param : cmd_code = Opcode of the command
  * @param : len_cmd_payload = Length of the command payload
  * @param : p_cmd_payload = Address of the command payload
  * @param : p_rsp_status = Address of the full buffer holding the command complete event
  * @retval : None
  */
void shci_send( uint16_t cmd_code, uint8_t len_cmd_payload, uint8_t * p_cmd_payload, TL_EvtPacket_t * p_rsp_status );
 
/**
 * @brief  Register IO bus services.
 * @param  fops The SHCI IO structure managing the IO BUS
 * @retval None
 */
void shci_register_io_bus(tSHciIO* fops);

/**
 * @brief  Interrupt service routine that must be called when the system channel
 *         reports a packet has been received
 *
 * @param  pdata Packet or event pointer
 * @retval None
 */
void shci_notify_asynch_evt(void* pdata);

/**
 * @brief  This function resume the User Event Flow which has been stopped on return 
 *         from UserEvtRx() when the User Event has not been processed.
 *
 * @param  None
 * @retval None
 */
void shci_resume_flow(void);


/**
 * @brief  This function is called when an System HCI Command is sent to the CPU2 and the response is waited.
 *         It is called from the same context the System HCI command has been sent.
 *         It shall not return until the command response notified by shci_cmd_resp_release() is received.
 *         A weak implementation is available in shci_tl.c based on polling mechanism
 *         The user may re-implement this function in the application to improve performance :
 *         - It may use UTIL_SEQ_WaitEvt() API when using the Sequencer
 *         - It may use a semaphore when using cmsis_os interface
 *
 * @param  timeout: Waiting timeout
 * @retval None
 */
void shci_cmd_resp_wait(uint32_t timeout);

/**
 * @brief  This function is called when an System HCI command is received from the CPU2.
 *         A weak implementation is available in shci_tl.c based on polling mechanism
 *         The user may re-implement this function in the application to improve performance :
 *         - It may use UTIL_SEQ_SetEvt() API when using the Sequencer
 *         - It may use a semaphore when using cmsis_os interface
 *
 *
 * @param  flag: Release flag
 * @retval None
 */
void shci_cmd_resp_release(uint32_t flag);


/**
 * @brief  This process shall be called each time the shci_notify_asynch_evt notification is received
 *
 * @param  None
 * @retval None
 */

void shci_user_evt_proc(void);

/**
 * @brief Initialize the System Host Controller Interface.
 *        This function must be called before any communication on the System Channel
 *
 * @param  pData: System events callback function pointer
 *         This callback is triggered when an user event is received on
 *         the System Channel from CPU2.
 * @param  pConf: Configuration structure pointer
 * @retval None
 */
void shci_init(void(* UserEvtRx)(void* pData), void* pConf);

#ifdef __cplusplus
}
#endif

#endif /* __SHCI_TL_H_ */