1 /* USER CODE BEGIN Header */
2 /**
3   ******************************************************************************
4   * @file    hw_ipcc.c
5   * @author  MCD Application Team
6   * @brief   Hardware IPCC source file for STM32WPAN Middleware.
7   ******************************************************************************
8   * @attention
9   *
10   * Copyright (c) 2020-2021 STMicroelectronics.
11   * All rights reserved.
12   *
13   * This software is licensed under terms that can be found in the LICENSE file
14   * in the root directory of this software component.
15   * If no LICENSE file comes with this software, it is provided AS-IS.
16   *
17   ******************************************************************************
18   */
19 /* USER CODE END Header */
20 
21 /* Includes ------------------------------------------------------------------*/
22 #include "app_common.h"
23 #include "mbox_def.h"
24 
25 /* Global variables ---------------------------------------------------------*/
26 /* Private defines -----------------------------------------------------------*/
27 #define HW_IPCC_TX_PENDING( channel ) ( !(LL_C1_IPCC_IsActiveFlag_CHx( IPCC, channel )) ) &&  (((~(IPCC->C1MR)) & (channel << 16U)))
28 #define HW_IPCC_RX_PENDING( channel )  (LL_C2_IPCC_IsActiveFlag_CHx( IPCC, channel )) && (((~(IPCC->C1MR)) & (channel << 0U)))
29 
30 /* Private macros ------------------------------------------------------------*/
31 /* Private typedef -----------------------------------------------------------*/
32 /* Private variables ---------------------------------------------------------*/
33 static void (*FreeBufCb)( void );
34 
35 /* Private function prototypes -----------------------------------------------*/
36 static void HW_IPCC_BLE_EvtHandler( void );
37 static void HW_IPCC_BLE_AclDataEvtHandler( void );
38 static void HW_IPCC_MM_FreeBufHandler( void );
39 static void HW_IPCC_SYS_CmdEvtHandler( void );
40 static void HW_IPCC_SYS_EvtHandler( void );
41 static void HW_IPCC_TRACES_EvtHandler( void );
42 
43 #ifdef THREAD_WB
44 static void HW_IPCC_OT_CmdEvtHandler( void );
45 static void HW_IPCC_THREAD_NotEvtHandler( void );
46 static void HW_IPCC_THREAD_CliNotEvtHandler( void );
47 #endif
48 
49 #ifdef LLD_TESTS_WB
50 static void HW_IPCC_LLDTESTS_ReceiveCliRspHandler( void );
51 static void HW_IPCC_LLDTESTS_ReceiveM0CmdHandler( void );
52 #endif
53 #ifdef LLD_BLE_WB
54 /*static void HW_IPCC_LLD_BLE_ReceiveCliRspHandler( void );*/
55 static void HW_IPCC_LLD_BLE_ReceiveRspHandler( void );
56 static void HW_IPCC_LLD_BLE_ReceiveM0CmdHandler( void );
57 #endif
58 
59 #ifdef MAC_802_15_4_WB
60 static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void );
61 static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void );
62 #endif
63 
64 #ifdef ZIGBEE_WB
65 static void HW_IPCC_ZIGBEE_CmdEvtHandler( void );
66 static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void );
67 static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void );
68 #endif
69 
70 /* Public function definition -----------------------------------------------*/
71 
72 /******************************************************************************
73  * INTERRUPT HANDLER
74  ******************************************************************************/
HW_IPCC_Rx_Handler(void)75 void HW_IPCC_Rx_Handler( void )
76 {
77   if (HW_IPCC_RX_PENDING( HW_IPCC_SYSTEM_EVENT_CHANNEL ))
78   {
79       HW_IPCC_SYS_EvtHandler();
80   }
81 #ifdef MAC_802_15_4_WB
82   else if (HW_IPCC_RX_PENDING( HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL ))
83   {
84     HW_IPCC_MAC_802_15_4_NotEvtHandler();
85   }
86 #endif /* MAC_802_15_4_WB */
87 #ifdef THREAD_WB
88   else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL ))
89   {
90     HW_IPCC_THREAD_NotEvtHandler();
91   }
92   else if (HW_IPCC_RX_PENDING( HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL ))
93   {
94     HW_IPCC_THREAD_CliNotEvtHandler();
95   }
96 #endif /* THREAD_WB */
97 #ifdef LLD_TESTS_WB
98   else if (HW_IPCC_RX_PENDING( HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL ))
99   {
100     HW_IPCC_LLDTESTS_ReceiveCliRspHandler();
101   }
102   else if (HW_IPCC_RX_PENDING( HW_IPCC_LLDTESTS_M0_CMD_CHANNEL ))
103   {
104     HW_IPCC_LLDTESTS_ReceiveM0CmdHandler();
105   }
106 #endif /* LLD_TESTS_WB */
107 #ifdef LLD_BLE_WB
108   else if (HW_IPCC_RX_PENDING( HW_IPCC_LLD_BLE_RSP_CHANNEL ))
109   {
110     HW_IPCC_LLD_BLE_ReceiveRspHandler();
111   }
112   else if (HW_IPCC_RX_PENDING( HW_IPCC_LLD_BLE_M0_CMD_CHANNEL ))
113   {
114     HW_IPCC_LLD_BLE_ReceiveM0CmdHandler();
115   }
116 #endif /* LLD_TESTS_WB */
117 #ifdef ZIGBEE_WB
118   else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL ))
119   {
120     HW_IPCC_ZIGBEE_StackNotifEvtHandler();
121   }
122   else if (HW_IPCC_RX_PENDING( HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL ))
123   {
124     HW_IPCC_ZIGBEE_StackM0RequestHandler();
125   }
126 #endif /* ZIGBEE_WB */
127   else if (HW_IPCC_RX_PENDING( HW_IPCC_BLE_EVENT_CHANNEL ))
128   {
129     HW_IPCC_BLE_EvtHandler();
130   }
131   else if (HW_IPCC_RX_PENDING( HW_IPCC_TRACES_CHANNEL ))
132   {
133     HW_IPCC_TRACES_EvtHandler();
134   }
135 
136   return;
137 }
138 
HW_IPCC_Tx_Handler(void)139 void HW_IPCC_Tx_Handler( void )
140 {
141   if (HW_IPCC_TX_PENDING( HW_IPCC_SYSTEM_CMD_RSP_CHANNEL ))
142   {
143     HW_IPCC_SYS_CmdEvtHandler();
144   }
145 #ifdef MAC_802_15_4_WB
146   else if (HW_IPCC_TX_PENDING( HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL ))
147   {
148     HW_IPCC_MAC_802_15_4_CmdEvtHandler();
149   }
150 #endif /* MAC_802_15_4_WB */
151 #ifdef THREAD_WB
152   else if (HW_IPCC_TX_PENDING( HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL ))
153   {
154     HW_IPCC_OT_CmdEvtHandler();
155   }
156 #endif /* THREAD_WB */
157 #ifdef LLD_TESTS_WB
158 // No TX handler for LLD tests
159 #endif /* LLD_TESTS_WB */
160 #ifdef ZIGBEE_WB
161   if (HW_IPCC_TX_PENDING( HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL ))
162   {
163       HW_IPCC_ZIGBEE_CmdEvtHandler();
164   }
165 #endif /* ZIGBEE_WB */
166   else if (HW_IPCC_TX_PENDING( HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ))
167   {
168     HW_IPCC_MM_FreeBufHandler();
169   }
170   else if (HW_IPCC_TX_PENDING( HW_IPCC_HCI_ACL_DATA_CHANNEL ))
171   {
172     HW_IPCC_BLE_AclDataEvtHandler();
173   }
174 
175   return;
176 }
177 /******************************************************************************
178  * GENERAL
179  ******************************************************************************/
HW_IPCC_Enable(void)180 void HW_IPCC_Enable( void )
181 {
182   /**
183   * Such as IPCC IP available to the CPU2, it is required to keep the IPCC clock running
184   * when FUS is running on CPU2 and CPU1 enters deep sleep mode
185   */
186   LL_C2_AHB3_GRP1_EnableClock(LL_C2_AHB3_GRP1_PERIPH_IPCC);
187 
188   /**
189   * When the device is out of standby, it is required to use the EXTI mechanism to wakeup CPU2
190   */
191   LL_EXTI_EnableRisingTrig_32_63( LL_EXTI_LINE_41 );
192   /* It is required to have at least a system clock cycle before a SEV after LL_EXTI_EnableRisingTrig_32_63() */
193   LL_C2_EXTI_EnableEvent_32_63( LL_EXTI_LINE_41 );
194 
195   /**
196    * In case the SBSFU is implemented, it may have already set the C2BOOT bit to startup the CPU2.
197    * In that case, to keep the mechanism transparent to the user application, it shall call the system command
198    * SHCI_C2_Reinit( ) before jumping to the application.
199    * When the CPU2 receives that command, it waits for its event input to be set to restart the CPU2 firmware.
200    * This is required because once C2BOOT has been set once, a clear/set on C2BOOT has no effect.
201    * When SHCI_C2_Reinit( ) is not called, generating an event to the CPU2 does not have any effect
202    * So, by default, the application shall both set the event flag and set the C2BOOT bit.
203    */
204   __SEV( );       /* Set the internal event flag and send an event to the CPU2 */
205   __WFE( );       /* Clear the internal event flag */
206   LL_PWR_EnableBootC2( );
207 
208   return;
209 }
210 
HW_IPCC_Init(void)211 void HW_IPCC_Init( void )
212 {
213   LL_AHB3_GRP1_EnableClock( LL_AHB3_GRP1_PERIPH_IPCC );
214 
215   LL_C1_IPCC_EnableIT_RXO( IPCC );
216   LL_C1_IPCC_EnableIT_TXF( IPCC );
217 
218   HAL_NVIC_EnableIRQ(IPCC_C1_RX_IRQn);
219   HAL_NVIC_EnableIRQ(IPCC_C1_TX_IRQn);
220 
221   return;
222 }
223 
224 /******************************************************************************
225  * BLE
226  ******************************************************************************/
HW_IPCC_BLE_Init(void)227 void HW_IPCC_BLE_Init( void )
228 {
229   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_BLE_EVENT_CHANNEL );
230 
231   return;
232 }
233 
HW_IPCC_BLE_SendCmd(void)234 void HW_IPCC_BLE_SendCmd( void )
235 {
236   LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_BLE_CMD_CHANNEL );
237 
238   return;
239 }
240 
HW_IPCC_BLE_EvtHandler(void)241 static void HW_IPCC_BLE_EvtHandler( void )
242 {
243   HW_IPCC_BLE_RxEvtNot();
244 
245   LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_BLE_EVENT_CHANNEL );
246 
247   return;
248 }
249 
HW_IPCC_BLE_SendAclData(void)250 void HW_IPCC_BLE_SendAclData( void )
251 {
252   LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL );
253   LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL );
254 
255   return;
256 }
257 
HW_IPCC_BLE_AclDataEvtHandler(void)258 static void HW_IPCC_BLE_AclDataEvtHandler( void )
259 {
260   LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_HCI_ACL_DATA_CHANNEL );
261 
262   HW_IPCC_BLE_AclDataAckNot();
263 
264   return;
265 }
266 
HW_IPCC_BLE_AclDataAckNot(void)267 __weak void HW_IPCC_BLE_AclDataAckNot( void ){};
HW_IPCC_BLE_RxEvtNot(void)268 __weak void HW_IPCC_BLE_RxEvtNot( void ){};
269 
270 /******************************************************************************
271  * SYSTEM
272  ******************************************************************************/
HW_IPCC_SYS_Init(void)273 void HW_IPCC_SYS_Init( void )
274 {
275   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL );
276 
277   return;
278 }
279 
HW_IPCC_SYS_SendCmd(void)280 void HW_IPCC_SYS_SendCmd( void )
281 {
282   LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL );
283   LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL );
284 
285   return;
286 }
287 
HW_IPCC_SYS_CmdEvtHandler(void)288 static void HW_IPCC_SYS_CmdEvtHandler( void )
289 {
290   LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_SYSTEM_CMD_RSP_CHANNEL );
291 
292   HW_IPCC_SYS_CmdEvtNot();
293 
294   return;
295 }
296 
HW_IPCC_SYS_EvtHandler(void)297 static void HW_IPCC_SYS_EvtHandler( void )
298 {
299   HW_IPCC_SYS_EvtNot();
300 
301   LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_SYSTEM_EVENT_CHANNEL );
302 
303   return;
304 }
305 
HW_IPCC_SYS_CmdEvtNot(void)306 __weak void HW_IPCC_SYS_CmdEvtNot( void ){};
HW_IPCC_SYS_EvtNot(void)307 __weak void HW_IPCC_SYS_EvtNot( void ){};
308 
309 /******************************************************************************
310  * MAC 802.15.4
311  ******************************************************************************/
312 #ifdef MAC_802_15_4_WB
HW_IPCC_MAC_802_15_4_Init(void)313 void HW_IPCC_MAC_802_15_4_Init( void )
314 {
315   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL );
316 
317   return;
318 }
319 
HW_IPCC_MAC_802_15_4_SendCmd(void)320 void HW_IPCC_MAC_802_15_4_SendCmd( void )
321 {
322   LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL );
323   LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL );
324 
325   return;
326 }
327 
HW_IPCC_MAC_802_15_4_SendAck(void)328 void HW_IPCC_MAC_802_15_4_SendAck( void )
329 {
330   LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL );
331   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL );
332 
333   return;
334 }
335 
HW_IPCC_MAC_802_15_4_CmdEvtHandler(void)336 static void HW_IPCC_MAC_802_15_4_CmdEvtHandler( void )
337 {
338   LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MAC_802_15_4_CMD_RSP_CHANNEL );
339 
340   HW_IPCC_MAC_802_15_4_CmdEvtNot();
341 
342   return;
343 }
344 
HW_IPCC_MAC_802_15_4_NotEvtHandler(void)345 static void HW_IPCC_MAC_802_15_4_NotEvtHandler( void )
346 {
347   LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_MAC_802_15_4_NOTIFICATION_ACK_CHANNEL );
348 
349   HW_IPCC_MAC_802_15_4_EvtNot();
350 
351   return;
352 }
HW_IPCC_MAC_802_15_4_CmdEvtNot(void)353 __weak void HW_IPCC_MAC_802_15_4_CmdEvtNot( void ){};
HW_IPCC_MAC_802_15_4_EvtNot(void)354 __weak void HW_IPCC_MAC_802_15_4_EvtNot( void ){};
355 #endif
356 
357 /******************************************************************************
358  * THREAD
359  ******************************************************************************/
360 #ifdef THREAD_WB
HW_IPCC_THREAD_Init(void)361 void HW_IPCC_THREAD_Init( void )
362 {
363   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL );
364   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL );
365 
366   return;
367 }
368 
HW_IPCC_OT_SendCmd(void)369 void HW_IPCC_OT_SendCmd( void )
370 {
371   LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL );
372   LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL );
373 
374   return;
375 }
376 
HW_IPCC_CLI_SendCmd(void)377 void HW_IPCC_CLI_SendCmd( void )
378 {
379   LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_THREAD_CLI_CMD_CHANNEL );
380 
381   return;
382 }
383 
HW_IPCC_THREAD_SendAck(void)384 void HW_IPCC_THREAD_SendAck( void )
385 {
386   LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL );
387   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL );
388 
389   return;
390 }
391 
HW_IPCC_THREAD_CliSendAck(void)392 void HW_IPCC_THREAD_CliSendAck( void )
393 {
394   LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL );
395   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL );
396 
397   return;
398 }
399 
HW_IPCC_OT_CmdEvtHandler(void)400 static void HW_IPCC_OT_CmdEvtHandler( void )
401 {
402   LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_THREAD_OT_CMD_RSP_CHANNEL );
403 
404   HW_IPCC_OT_CmdEvtNot();
405 
406   return;
407 }
408 
HW_IPCC_THREAD_NotEvtHandler(void)409 static void HW_IPCC_THREAD_NotEvtHandler( void )
410 {
411   LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_THREAD_NOTIFICATION_ACK_CHANNEL );
412 
413   HW_IPCC_THREAD_EvtNot();
414 
415   return;
416 }
417 
HW_IPCC_THREAD_CliNotEvtHandler(void)418 static void HW_IPCC_THREAD_CliNotEvtHandler( void )
419 {
420   LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_THREAD_CLI_NOTIFICATION_ACK_CHANNEL );
421 
422   HW_IPCC_THREAD_CliEvtNot();
423 
424   return;
425 }
426 
HW_IPCC_OT_CmdEvtNot(void)427 __weak void HW_IPCC_OT_CmdEvtNot( void ){};
HW_IPCC_CLI_CmdEvtNot(void)428 __weak void HW_IPCC_CLI_CmdEvtNot( void ){};
HW_IPCC_THREAD_EvtNot(void)429 __weak void HW_IPCC_THREAD_EvtNot( void ){};
430 
431 #endif /* THREAD_WB */
432 
433 /******************************************************************************
434  * LLD TESTS
435  ******************************************************************************/
436 #ifdef LLD_TESTS_WB
HW_IPCC_LLDTESTS_Init(void)437 void HW_IPCC_LLDTESTS_Init( void )
438 {
439   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL );
440   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL );
441   return;
442 }
443 
HW_IPCC_LLDTESTS_SendCliCmd(void)444 void HW_IPCC_LLDTESTS_SendCliCmd( void )
445 {
446   LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_LLDTESTS_CLI_CMD_CHANNEL );
447   return;
448 }
449 
HW_IPCC_LLDTESTS_ReceiveCliRspHandler(void)450 static void HW_IPCC_LLDTESTS_ReceiveCliRspHandler( void )
451 {
452   LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL );
453   HW_IPCC_LLDTESTS_ReceiveCliRsp();
454   return;
455 }
456 
HW_IPCC_LLDTESTS_SendCliRspAck(void)457 void HW_IPCC_LLDTESTS_SendCliRspAck( void )
458 {
459   LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL );
460   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_CLI_RSP_CHANNEL );
461   return;
462 }
463 
HW_IPCC_LLDTESTS_ReceiveM0CmdHandler(void)464 static void HW_IPCC_LLDTESTS_ReceiveM0CmdHandler( void )
465 {
466   LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL );
467   HW_IPCC_LLDTESTS_ReceiveM0Cmd();
468   return;
469 }
470 
HW_IPCC_LLDTESTS_SendM0CmdAck(void)471 void HW_IPCC_LLDTESTS_SendM0CmdAck( void )
472 {
473   LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL );
474   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLDTESTS_M0_CMD_CHANNEL );
475   return;
476 }
HW_IPCC_LLDTESTS_ReceiveCliRsp(void)477 __weak void HW_IPCC_LLDTESTS_ReceiveCliRsp( void ){};
HW_IPCC_LLDTESTS_ReceiveM0Cmd(void)478 __weak void HW_IPCC_LLDTESTS_ReceiveM0Cmd( void ){};
479 #endif /* LLD_TESTS_WB */
480 
481 /******************************************************************************
482  * LLD BLE
483  ******************************************************************************/
484 #ifdef LLD_BLE_WB
HW_IPCC_LLD_BLE_Init(void)485 void HW_IPCC_LLD_BLE_Init( void )
486 {
487   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL );
488   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL );
489   return;
490 }
491 
HW_IPCC_LLD_BLE_SendCliCmd(void)492 void HW_IPCC_LLD_BLE_SendCliCmd( void )
493 {
494   LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_LLD_BLE_CLI_CMD_CHANNEL );
495   return;
496 }
497 
498 /*static void HW_IPCC_LLD_BLE_ReceiveCliRspHandler( void )
499 {
500   LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL );
501   HW_IPCC_LLD_BLE_ReceiveCliRsp();
502   return;
503 }*/
504 
HW_IPCC_LLD_BLE_SendCliRspAck(void)505 void HW_IPCC_LLD_BLE_SendCliRspAck( void )
506 {
507   LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL );
508   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_CLI_RSP_CHANNEL );
509   return;
510 }
511 
HW_IPCC_LLD_BLE_ReceiveM0CmdHandler(void)512 static void HW_IPCC_LLD_BLE_ReceiveM0CmdHandler( void )
513 {
514   //LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL );
515   HW_IPCC_LLD_BLE_ReceiveM0Cmd();
516   return;
517 }
518 
HW_IPCC_LLD_BLE_SendM0CmdAck(void)519 void HW_IPCC_LLD_BLE_SendM0CmdAck( void )
520 {
521   LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL );
522   //LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_M0_CMD_CHANNEL );
523   return;
524 }
HW_IPCC_LLD_BLE_ReceiveCliRsp(void)525 __weak void HW_IPCC_LLD_BLE_ReceiveCliRsp( void ){};
HW_IPCC_LLD_BLE_ReceiveM0Cmd(void)526 __weak void HW_IPCC_LLD_BLE_ReceiveM0Cmd( void ){};
527 
528 /* Transparent Mode */
HW_IPCC_LLD_BLE_SendCmd(void)529 void HW_IPCC_LLD_BLE_SendCmd( void )
530 {
531   LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_LLD_BLE_CMD_CHANNEL );
532   return;
533 }
534 
HW_IPCC_LLD_BLE_ReceiveRspHandler(void)535 static void HW_IPCC_LLD_BLE_ReceiveRspHandler( void )
536 {
537   LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL );
538   HW_IPCC_LLD_BLE_ReceiveRsp();
539   return;
540 }
541 
HW_IPCC_LLD_BLE_SendRspAck(void)542 void HW_IPCC_LLD_BLE_SendRspAck( void )
543 {
544   LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL );
545   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_LLD_BLE_RSP_CHANNEL );
546   return;
547 }
548 
549 #endif /* LLD_BLE_WB */
550 
551 /******************************************************************************
552  * ZIGBEE
553  ******************************************************************************/
554 #ifdef ZIGBEE_WB
HW_IPCC_ZIGBEE_Init(void)555 void HW_IPCC_ZIGBEE_Init( void )
556 {
557   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL );
558   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL );
559 
560   return;
561 }
562 
HW_IPCC_ZIGBEE_SendM4RequestToM0(void)563 void HW_IPCC_ZIGBEE_SendM4RequestToM0( void )
564 {
565   LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL );
566   LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL );
567 
568   return;
569 }
570 
HW_IPCC_ZIGBEE_SendM4AckToM0Notify(void)571 void HW_IPCC_ZIGBEE_SendM4AckToM0Notify( void )
572 {
573   LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL );
574   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL );
575 
576   return;
577 }
578 
HW_IPCC_ZIGBEE_CmdEvtHandler(void)579 static void HW_IPCC_ZIGBEE_CmdEvtHandler( void )
580 {
581   LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_ZIGBEE_CMD_APPLI_CHANNEL );
582 
583   HW_IPCC_ZIGBEE_RecvAppliAckFromM0();
584 
585   return;
586 }
587 
HW_IPCC_ZIGBEE_StackNotifEvtHandler(void)588 static void HW_IPCC_ZIGBEE_StackNotifEvtHandler( void )
589 {
590   LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_APPLI_NOTIF_ACK_CHANNEL );
591 
592   HW_IPCC_ZIGBEE_RecvM0NotifyToM4();
593 
594   return;
595 }
596 
HW_IPCC_ZIGBEE_StackM0RequestHandler(void)597 static void HW_IPCC_ZIGBEE_StackM0RequestHandler( void )
598 {
599   LL_C1_IPCC_DisableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL );
600 
601   HW_IPCC_ZIGBEE_RecvM0RequestToM4();
602 
603   return;
604 }
605 
HW_IPCC_ZIGBEE_SendM4AckToM0Request(void)606 void HW_IPCC_ZIGBEE_SendM4AckToM0Request( void )
607 {
608   LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL );
609   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_ZIGBEE_M0_REQUEST_CHANNEL );
610 
611   return;
612 }
613 
HW_IPCC_ZIGBEE_RecvAppliAckFromM0(void)614 __weak void HW_IPCC_ZIGBEE_RecvAppliAckFromM0( void ){};
HW_IPCC_ZIGBEE_RecvM0NotifyToM4(void)615 __weak void HW_IPCC_ZIGBEE_RecvM0NotifyToM4( void ){};
HW_IPCC_ZIGBEE_RecvM0RequestToM4(void)616 __weak void HW_IPCC_ZIGBEE_RecvM0RequestToM4( void ){};
617 #endif /* ZIGBEE_WB */
618 
619 /******************************************************************************
620  * MEMORY MANAGER
621  ******************************************************************************/
HW_IPCC_MM_SendFreeBuf(void (* cb)(void))622 void HW_IPCC_MM_SendFreeBuf( void (*cb)( void ) )
623 {
624   if ( LL_C1_IPCC_IsActiveFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL ) )
625   {
626     FreeBufCb = cb;
627     LL_C1_IPCC_EnableTransmitChannel( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL );
628   }
629   else
630   {
631     cb();
632 
633     LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL );
634   }
635 
636   return;
637 }
638 
HW_IPCC_MM_FreeBufHandler(void)639 static void HW_IPCC_MM_FreeBufHandler( void )
640 {
641   LL_C1_IPCC_DisableTransmitChannel( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL );
642 
643   FreeBufCb();
644 
645   LL_C1_IPCC_SetFlag_CHx( IPCC, HW_IPCC_MM_RELEASE_BUFFER_CHANNEL );
646 
647   return;
648 }
649 
650 /******************************************************************************
651  * TRACES
652  ******************************************************************************/
HW_IPCC_TRACES_Init(void)653 void HW_IPCC_TRACES_Init( void )
654 {
655   LL_C1_IPCC_EnableReceiveChannel( IPCC, HW_IPCC_TRACES_CHANNEL );
656 
657   return;
658 }
659 
HW_IPCC_TRACES_EvtHandler(void)660 static void HW_IPCC_TRACES_EvtHandler( void )
661 {
662   HW_IPCC_TRACES_EvtNot();
663 
664   LL_C1_IPCC_ClearFlag_CHx( IPCC, HW_IPCC_TRACES_CHANNEL );
665 
666   return;
667 }
668 
HW_IPCC_TRACES_EvtNot(void)669 __weak void HW_IPCC_TRACES_EvtNot( void ){};
670 
671