1010/* Includes */
1111/* -------------------------------------------------------------------------- */
1212
13- #include "fwk_platform_ble.h"
14- #include "ble_controller.h"
13+ #ifndef __ZEPHYR__
1514#include "fsl_rom_api.h"
1615#include "fsl_debug_console.h"
16+ #endif
17+
18+ #include "fsl_common.h"
19+ #include "fwk_platform_ble.h"
20+ #include "ble_controller.h"
1721
1822#ifdef SERIAL_BTSNOOP
1923#include "sbtsnoop.h"
@@ -32,6 +36,7 @@ static blec_result_t PLATFORM_HciRxCallback(blec_hciPacketType_t packetType, voi
3236/* -------------------------------------------------------------------------- */
3337
3438static void (* hci_rx_callback )(uint8_t packetType , uint8_t * data , uint16_t len );
39+ static bool is_initialized = false;
3540
3641/* -------------------------------------------------------------------------- */
3742/* Public functions */
@@ -41,19 +46,30 @@ int PLATFORM_InitBle(void)
4146{
4247 int ret = 0 ;
4348
44- /* Initialize the controller only when this flag is set, otherwise it means it
45- * will be initialized by upper layers */
46- #if defined(gUseHciTransportDownward_d ) && (gUseHciTransportDownward_d > 0 )
47- if (kBLEC_Success != BLEController_Init (PLATFORM_HciRxCallback , gAppMaxTxPowerDbm_c , NULL ))
49+ do
4850 {
49- ret = 1 ;
50- }
51- #else
52- uint8_t bdAddr [6 ];
51+ if (is_initialized )
52+ {
53+ ret = 1 ;
54+ break ;
55+ }
5356
54- PLATFORM_GetBDAddr (bdAddr );
55- (void )BLEController_WriteBdAddr (bdAddr );
56- #endif
57+ /* Initialize the controller only when this flag is set, otherwise it means it
58+ * will be initialized by upper layers */
59+ #if defined(gUseHciTransportDownward_d ) && (gUseHciTransportDownward_d > 0 )
60+ if (kBLEC_Success != BLEController_Init (PLATFORM_HciRxCallback , gAppMaxTxPowerDbm_c , NULL ))
61+ {
62+ ret = -1 ;
63+ }
64+ #else
65+ uint8_t bdAddr [6 ];
66+
67+ PLATFORM_GetBDAddr (bdAddr );
68+ (void )BLEController_WriteBdAddr (bdAddr );
69+ #endif
70+
71+ is_initialized = true;
72+ } while (false);
5773
5874 return ret ;
5975}
@@ -79,14 +95,21 @@ int PLATFORM_SendHciMessageAlt(uint8_t packetType, uint8_t *msg, uint32_t len)
7995 return ret ;
8096}
8197
82- void PLATFORM_SetHciRxCallback (void (* callback )(uint8_t packetType , uint8_t * data , uint16_t len ))
98+ int PLATFORM_StartHci (void )
99+ {
100+ return 0 ;
101+ }
102+
103+ int PLATFORM_SetHciRxCallback (void (* callback )(uint8_t packetType , uint8_t * data , uint16_t len ))
83104{
84105 hci_rx_callback = callback ;
85106 (void )hci_rx_callback ;
107+ return 0 ;
86108}
87109
88110void PLATFORM_GetBDAddr (uint8_t * bleDeviceAddress )
89111{
112+ #ifndef __ZEPHYR__
90113 flash_config_t flashInstance ;
91114 status_t status ;
92115
@@ -102,6 +125,7 @@ void PLATFORM_GetBDAddr(uint8_t *bleDeviceAddress)
102125 location == kFFR_BdAddrLocationNmpa ? "NMPA" :
103126 "UUID" );
104127 }
128+ #endif
105129}
106130
107131bool PLATFORM_CheckNextBleConnectivityActivity (void )
0 commit comments