1515#include "fwk_platform_ble.h"
1616#include "fwk_platform_hdlc.h"
1717#include "fwk_platform_ot.h"
18- #include "fsl_adapter_rfimu.h"
19- #include "fsl_adapter_rpmsg.h"
18+ #include "fsl_adapter_imu.h"
2019#include "fsl_os_abstraction.h"
2120
2221/* -------------------------------------------------------------------------- */
2322/* Private macros */
2423/* -------------------------------------------------------------------------- */
2524
26- #ifndef PLATFORM_HDLC_RPMSG_LOCAL_ADDR
27- #define PLATFORM_HDLC_RPMSG_LOCAL_ADDR 10
25+ #ifndef PLATFORM_HDLC_IMUMC_LOCAL_ADDR
26+ #define PLATFORM_HDLC_IMUMC_LOCAL_ADDR 10
2827#endif
2928
30- #ifndef PLATFORM_HDLC_RPMSG_REMOTE_ADDR
31- #define PLATFORM_HDLC_RPMSG_REMOTE_ADDR 20
29+ #ifndef PLATFORM_HDLC_IMUMC_REMOTE_ADDR
30+ #define PLATFORM_HDLC_IMUMC_REMOTE_ADDR 20
3231#endif
3332
34- #ifndef PLATFORM_HDLC_RPMSG_ALLOC_FAILED_DELAY_MS
35- #define PLATFORM_HDLC_RPMSG_ALLOC_FAILED_DELAY_MS 2U
33+ #ifndef PLATFORM_HDLC_IMUMC_ALLOC_FAILED_DELAY_MS
34+ #define PLATFORM_HDLC_IMUMC_ALLOC_FAILED_DELAY_MS 2U
3635#endif
3736
38- #ifndef PLATFORM_HDLC_RPMSG_LINK_READY_CHECK_RETRY
39- #define PLATFORM_HDLC_RPMSG_LINK_READY_CHECK_RETRY 100
37+ #ifndef PLATFORM_HDLC_IMUMC_LINK_READY_CHECK_RETRY
38+ #define PLATFORM_HDLC_IMUMC_LINK_READY_CHECK_RETRY 100
4039#endif
4140
42- #ifndef PLATFORM_HDLC_RPMSG_LINK_READY_DELAY_MS
43- #define PLATFORM_HDLC_RPMSG_LINK_READY_DELAY_MS 100
41+ #ifndef PLATFORM_HDLC_IMUMC_LINK_READY_DELAY_MS
42+ #define PLATFORM_HDLC_IMUMC_LINK_READY_DELAY_MS 100
4443#endif
4544
4645/* -------------------------------------------------------------------------- */
5251/* -------------------------------------------------------------------------- */
5352
5453/*!
55- * \brief Initialize HDLC RPMSG channel
54+ * \brief Initialize HDLC IMUMC channel
5655 *
5756 * \return int return status: >=0 for success, <0 for errors
5857 */
59- static int PLATFORM_InitHdlcRpmsg (void );
58+ static int PLATFORM_InitHdlcImumc (void );
6059
6160/*!
62- * \brief Terminate HDLC RPMSG channel
61+ * \brief Terminate HDLC IMUMC channel
6362 *
6463 * \return int return status: >=0 for success, <0 for errors
6564 */
66- static int PLATFORM_TerminateHdlcRpmsg (void );
65+ static int PLATFORM_TerminateHdlcImumc (void );
6766
6867/*!
69- * \brief RPMSG Rx callback used to receive HDLC messages from Controller
68+ * \brief IMUMC Rx callback used to receive HDLC messages from Controller
7069 *
7170 * \param[in] param Usually NULL
7271 * \param[in] data pointer to data buffer
7372 * \param[in] len size of the data
74- * \return hal_rpmsg_return_status_t tells RPMSG to free or hold the buffer
73+ * \return hal_imumc_return_status_t tells IMUMC to free or hold the buffer
7574 */
76- static hal_rpmsg_return_status_t PLATFORM_HdlcRpmsgRxCallback (void * param , uint8_t * data , uint32_t len );
75+ static hal_imumc_return_status_t PLATFORM_HdlcImumcRxCallback (void * param , uint8_t * data , uint32_t len );
7776
7877/*!
7978 * \brief Checks if the IMU link is ready - used before sending a message
@@ -90,12 +89,12 @@ static bool PLATFORM_IsHdlcLinkReady(void);
9089static platform_hdlc_rx_callback_t hdlcRxCallback ;
9190static void * callbackParam = NULL ;
9291
93- static RPMSG_HANDLE_DEFINE ( hdlcRpmsgHandle );
94- static const hal_rpmsg_config_t hdlcRpmsgConfig = {
95- .local_addr = PLATFORM_HDLC_RPMSG_LOCAL_ADDR ,
96- .remote_addr = PLATFORM_HDLC_RPMSG_REMOTE_ADDR ,
92+ static IMUMC_HANDLE_DEFINE ( hdlcImumcHandle );
93+ static const hal_imumc_config_t hdlcImumcConfig = {
94+ .local_addr = PLATFORM_HDLC_IMUMC_LOCAL_ADDR ,
95+ .remote_addr = PLATFORM_HDLC_IMUMC_REMOTE_ADDR ,
9796 .imuLink = kIMU_LinkCpu2Cpu3 ,
98- .callback = PLATFORM_HdlcRpmsgRxCallback ,
97+ .callback = & PLATFORM_HdlcImumcRxCallback ,
9998 .param = NULL ,
10099};
101100
@@ -112,15 +111,15 @@ int PLATFORM_InitHdlcInterface(platform_hdlc_rx_callback_t callback, void *param
112111
113112 do
114113 {
115- /* RPMSG/IMU requires 15.4 controller to be started */
114+ /* IMUMC requires 15.4 controller to be started */
116115 if (PLATFORM_InitOt () != 0 )
117116 {
118117 ret = -1 ;
119118 break ;
120119 }
121120
122- /* Init RPMSG interface */
123- if (PLATFORM_InitHdlcRpmsg () != 0 )
121+ /* Init IMUMC interface */
122+ if (PLATFORM_InitHdlcImumc () != 0 )
124123 {
125124 ret = -2 ;
126125 break ;
@@ -150,13 +149,13 @@ int PLATFORM_TerminateHdlcInterface(void)
150149 break ;
151150 }
152151
153- if (HAL_ImuDeinit (kIMU_LinkCpu2Cpu3 , 0 ) != kStatus_HAL_RpmsgSuccess )
152+ if (HAL_ImuDeinit (kIMU_LinkCpu2Cpu3 , 0 ) != kStatus_HAL_ImumcSuccess )
154153 {
155154 ret = -2 ;
156155 break ;
157156 }
158157
159- if (PLATFORM_TerminateHdlcRpmsg () != 0 )
158+ if (PLATFORM_TerminateHdlcImumc () != 0 )
160159 {
161160 ret = -3 ;
162161 break ;
@@ -184,8 +183,8 @@ int PLATFORM_ResetHdlcInterface(void)
184183{
185184 int ret = 0 ;
186185
187- /* Init RPMSG interface */
188- if (PLATFORM_InitHdlcRpmsg () != 0 )
186+ /* Init IMUMC interface */
187+ if (PLATFORM_InitHdlcImumc () != 0 )
189188 {
190189 ret = -1 ;
191190 }
@@ -195,25 +194,25 @@ int PLATFORM_ResetHdlcInterface(void)
195194
196195int PLATFORM_SendHdlcMessage (uint8_t * msg , uint32_t len )
197196{
198- hal_rpmsg_status_t rpmsgStatus ;
197+ hal_imumc_status_t imumcStatus ;
199198 int ret = 0 ;
200199 int hdlcLinkReadyRetry = 0 ;
201200 uint32_t remainingBytes = len ;
202201 uint8_t * pMsg = msg ;
203- uint8_t * pRpmsgBuffer = NULL ;
202+ uint8_t * pImumcBuffer = NULL ;
204203
205204 do
206205 {
207206 /* Make sure the link is ready before sending a message */
208207 while (PLATFORM_IsHdlcLinkReady () == false)
209208 {
210- if (hdlcLinkReadyRetry >= PLATFORM_HDLC_RPMSG_LINK_READY_CHECK_RETRY )
209+ if (hdlcLinkReadyRetry >= PLATFORM_HDLC_IMUMC_LINK_READY_CHECK_RETRY )
211210 {
212211 ret = -1 ;
213212 break ;
214213 }
215214 hdlcLinkReadyRetry ++ ;
216- OSA_TimeDelay (PLATFORM_HDLC_RPMSG_LINK_READY_DELAY_MS );
215+ OSA_TimeDelay (PLATFORM_HDLC_IMUMC_LINK_READY_DELAY_MS );
217216 }
218217
219218 if (ret != 0 )
@@ -223,34 +222,34 @@ int PLATFORM_SendHdlcMessage(uint8_t *msg, uint32_t len)
223222
224223 (void )PLATFORM_RequestBleWakeUp ();
225224
226- /* Send HDLC Packet through RPMSG channel
227- * If the size if larger than the maximum RPMSG buffer size, we have to send chunks of the packet */
225+ /* Send HDLC Packet through IMUMC channel
226+ * If the size if larger than the maximum IMUMC buffer size, we have to send chunks of the packet */
228227 while (remainingBytes > 0 )
229228 {
230229 uint32_t sizeToSend ;
231230
232- if (remainingBytes > RPMSG_TXQ23_BUFLENGTH )
231+ if (remainingBytes > IMUMC_TXQ23_BUFLENGTH )
233232 {
234- sizeToSend = RPMSG_TXQ23_BUFLENGTH ;
233+ sizeToSend = IMUMC_TXQ23_BUFLENGTH ;
235234 }
236235 else
237236 {
238237 sizeToSend = remainingBytes ;
239238 }
240239
241- /* Allocate a RPMSG buffer in shared memory */
242- pRpmsgBuffer = HAL_RpmsgAllocTxBuffer ( hdlcRpmsgHandle , sizeToSend );
243- assert (pRpmsgBuffer != NULL );
240+ /* Allocate a IMUMC buffer in shared memory */
241+ pImumcBuffer = HAL_ImumcAllocTxBuffer ( hdlcImumcHandle , sizeToSend );
242+ assert (pImumcBuffer != NULL );
244243
245- /* Copy the message to the RPMSG buffer */
246- (void )memcpy (pRpmsgBuffer , pMsg , sizeToSend );
244+ /* Copy the message to the IMUMC buffer */
245+ (void )memcpy (pImumcBuffer , pMsg , sizeToSend );
247246
248247 /* Send the message without any copy as it's already stored in the shared memory */
249- rpmsgStatus = HAL_RpmsgNoCopySend ( hdlcRpmsgHandle , pRpmsgBuffer , sizeToSend );
250- if (rpmsgStatus != kStatus_HAL_RpmsgSuccess )
248+ imumcStatus = HAL_ImumcNoCopySend ( hdlcImumcHandle , pImumcBuffer , sizeToSend );
249+ if (imumcStatus != kStatus_HAL_ImumcSuccess )
251250 {
252251 /* An error here means the IMU link is not ready yet, we can assert here as it shouldn't happen
253- * because we wait for the IMU link to be ready in PLATFORM_InitHdlcRpmsg () */
252+ * because we wait for the IMU link to be ready in PLATFORM_InitHdlcImumc () */
254253 assert (0 );
255254 ret = -1 ;
256255 break ;
@@ -271,16 +270,18 @@ int PLATFORM_SendHdlcMessage(uint8_t *msg, uint32_t len)
271270/* Private functions */
272271/* -------------------------------------------------------------------------- */
273272
274- static int PLATFORM_InitHdlcRpmsg (void )
273+ static int PLATFORM_InitHdlcImumc (void )
275274{
276- hal_rpmsg_status_t rpmsgStatus ;
275+ hal_imumc_status_t imumcStatus ;
276+ hal_imumc_config_t imumcConfig ;
277277 int ret = 0 ;
278278
279+ imumcConfig = hdlcImumcConfig ;
279280 do
280281 {
281- /* Init RPMSG/IMU Channel */
282- rpmsgStatus = HAL_RpmsgInit (( hal_rpmsg_handle_t ) hdlcRpmsgHandle , ( hal_rpmsg_config_t * ) & hdlcRpmsgConfig );
283- if (rpmsgStatus != kStatus_HAL_RpmsgSuccess )
282+ /* Init IMUMC Channel */
283+ imumcStatus = HAL_ImumcInit (( hal_imumc_handle_t ) hdlcImumcHandle , & imumcConfig );
284+ if (imumcStatus != kStatus_HAL_ImumcSuccess )
284285 {
285286 ret = -1 ;
286287 break ;
@@ -290,21 +291,21 @@ static int PLATFORM_InitHdlcRpmsg(void)
290291 return ret ;
291292}
292293
293- static int PLATFORM_TerminateHdlcRpmsg (void )
294+ static int PLATFORM_TerminateHdlcImumc (void )
294295{
295- hal_rpmsg_status_t rpmsgStatus ;
296+ hal_imumc_status_t imumcStatus ;
296297 int ret = 0 ;
297298
298- rpmsgStatus = HAL_RpmsgDeinit (( hal_rpmsg_handle_t ) hdlcRpmsgHandle );
299- if (rpmsgStatus != kStatus_HAL_RpmsgSuccess )
299+ imumcStatus = HAL_ImumcDeinit (( hal_imumc_handle_t ) hdlcImumcHandle );
300+ if (imumcStatus != kStatus_HAL_ImumcSuccess )
300301 {
301302 ret = -1 ;
302303 }
303304
304305 return ret ;
305306}
306307
307- static hal_rpmsg_return_status_t PLATFORM_HdlcRpmsgRxCallback (void * param , uint8_t * data , uint32_t len )
308+ static hal_imumc_return_status_t PLATFORM_HdlcImumcRxCallback (void * param , uint8_t * data , uint32_t len )
308309{
309310 (void )PLATFORM_HandleControllerPowerState ();
310311
@@ -318,5 +319,5 @@ static hal_rpmsg_return_status_t PLATFORM_HdlcRpmsgRxCallback(void *param, uint8
318319
319320static bool PLATFORM_IsHdlcLinkReady (void )
320321{
321- return (HAL_ImuLinkIsUp (hdlcRpmsgConfig .imuLink ) == kStatus_HAL_RpmsgSuccess );
322+ return (HAL_ImuLinkIsUp (hdlcImumcConfig .imuLink ) == kStatus_HAL_ImumcSuccess );
322323}
0 commit comments