15
15
#include "fwk_platform_ble.h"
16
16
#include "fwk_platform_hdlc.h"
17
17
#include "fwk_platform_ot.h"
18
- #include "fsl_adapter_rfimu.h"
19
- #include "fsl_adapter_rpmsg.h"
18
+ #include "fsl_adapter_imu.h"
20
19
#include "fsl_os_abstraction.h"
21
20
22
21
/* -------------------------------------------------------------------------- */
23
22
/* Private macros */
24
23
/* -------------------------------------------------------------------------- */
25
24
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
28
27
#endif
29
28
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
32
31
#endif
33
32
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
36
35
#endif
37
36
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
40
39
#endif
41
40
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
44
43
#endif
45
44
46
45
/* -------------------------------------------------------------------------- */
52
51
/* -------------------------------------------------------------------------- */
53
52
54
53
/*!
55
- * \brief Initialize HDLC RPMSG channel
54
+ * \brief Initialize HDLC IMUMC channel
56
55
*
57
56
* \return int return status: >=0 for success, <0 for errors
58
57
*/
59
- static int PLATFORM_InitHdlcRpmsg (void );
58
+ static int PLATFORM_InitHdlcImumc (void );
60
59
61
60
/*!
62
- * \brief Terminate HDLC RPMSG channel
61
+ * \brief Terminate HDLC IMUMC channel
63
62
*
64
63
* \return int return status: >=0 for success, <0 for errors
65
64
*/
66
- static int PLATFORM_TerminateHdlcRpmsg (void );
65
+ static int PLATFORM_TerminateHdlcImumc (void );
67
66
68
67
/*!
69
- * \brief RPMSG Rx callback used to receive HDLC messages from Controller
68
+ * \brief IMUMC Rx callback used to receive HDLC messages from Controller
70
69
*
71
70
* \param[in] param Usually NULL
72
71
* \param[in] data pointer to data buffer
73
72
* \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
75
74
*/
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 );
77
76
78
77
/*!
79
78
* \brief Checks if the IMU link is ready - used before sending a message
@@ -90,12 +89,12 @@ static bool PLATFORM_IsHdlcLinkReady(void);
90
89
static platform_hdlc_rx_callback_t hdlcRxCallback ;
91
90
static void * callbackParam = NULL ;
92
91
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 ,
97
96
.imuLink = kIMU_LinkCpu2Cpu3 ,
98
- .callback = PLATFORM_HdlcRpmsgRxCallback ,
97
+ .callback = & PLATFORM_HdlcImumcRxCallback ,
99
98
.param = NULL ,
100
99
};
101
100
@@ -112,15 +111,15 @@ int PLATFORM_InitHdlcInterface(platform_hdlc_rx_callback_t callback, void *param
112
111
113
112
do
114
113
{
115
- /* RPMSG/IMU requires 15.4 controller to be started */
114
+ /* IMUMC requires 15.4 controller to be started */
116
115
if (PLATFORM_InitOt () != 0 )
117
116
{
118
117
ret = -1 ;
119
118
break ;
120
119
}
121
120
122
- /* Init RPMSG interface */
123
- if (PLATFORM_InitHdlcRpmsg () != 0 )
121
+ /* Init IMUMC interface */
122
+ if (PLATFORM_InitHdlcImumc () != 0 )
124
123
{
125
124
ret = -2 ;
126
125
break ;
@@ -150,13 +149,13 @@ int PLATFORM_TerminateHdlcInterface(void)
150
149
break ;
151
150
}
152
151
153
- if (HAL_ImuDeinit (kIMU_LinkCpu2Cpu3 , 0 ) != kStatus_HAL_RpmsgSuccess )
152
+ if (HAL_ImuDeinit (kIMU_LinkCpu2Cpu3 , 0 ) != kStatus_HAL_ImumcSuccess )
154
153
{
155
154
ret = -2 ;
156
155
break ;
157
156
}
158
157
159
- if (PLATFORM_TerminateHdlcRpmsg () != 0 )
158
+ if (PLATFORM_TerminateHdlcImumc () != 0 )
160
159
{
161
160
ret = -3 ;
162
161
break ;
@@ -184,8 +183,8 @@ int PLATFORM_ResetHdlcInterface(void)
184
183
{
185
184
int ret = 0 ;
186
185
187
- /* Init RPMSG interface */
188
- if (PLATFORM_InitHdlcRpmsg () != 0 )
186
+ /* Init IMUMC interface */
187
+ if (PLATFORM_InitHdlcImumc () != 0 )
189
188
{
190
189
ret = -1 ;
191
190
}
@@ -195,25 +194,25 @@ int PLATFORM_ResetHdlcInterface(void)
195
194
196
195
int PLATFORM_SendHdlcMessage (uint8_t * msg , uint32_t len )
197
196
{
198
- hal_rpmsg_status_t rpmsgStatus ;
197
+ hal_imumc_status_t imumcStatus ;
199
198
int ret = 0 ;
200
199
int hdlcLinkReadyRetry = 0 ;
201
200
uint32_t remainingBytes = len ;
202
201
uint8_t * pMsg = msg ;
203
- uint8_t * pRpmsgBuffer = NULL ;
202
+ uint8_t * pImumcBuffer = NULL ;
204
203
205
204
do
206
205
{
207
206
/* Make sure the link is ready before sending a message */
208
207
while (PLATFORM_IsHdlcLinkReady () == false)
209
208
{
210
- if (hdlcLinkReadyRetry >= PLATFORM_HDLC_RPMSG_LINK_READY_CHECK_RETRY )
209
+ if (hdlcLinkReadyRetry >= PLATFORM_HDLC_IMUMC_LINK_READY_CHECK_RETRY )
211
210
{
212
211
ret = -1 ;
213
212
break ;
214
213
}
215
214
hdlcLinkReadyRetry ++ ;
216
- OSA_TimeDelay (PLATFORM_HDLC_RPMSG_LINK_READY_DELAY_MS );
215
+ OSA_TimeDelay (PLATFORM_HDLC_IMUMC_LINK_READY_DELAY_MS );
217
216
}
218
217
219
218
if (ret != 0 )
@@ -223,34 +222,34 @@ int PLATFORM_SendHdlcMessage(uint8_t *msg, uint32_t len)
223
222
224
223
(void )PLATFORM_RequestBleWakeUp ();
225
224
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 */
228
227
while (remainingBytes > 0 )
229
228
{
230
229
uint32_t sizeToSend ;
231
230
232
- if (remainingBytes > RPMSG_TXQ23_BUFLENGTH )
231
+ if (remainingBytes > IMUMC_TXQ23_BUFLENGTH )
233
232
{
234
- sizeToSend = RPMSG_TXQ23_BUFLENGTH ;
233
+ sizeToSend = IMUMC_TXQ23_BUFLENGTH ;
235
234
}
236
235
else
237
236
{
238
237
sizeToSend = remainingBytes ;
239
238
}
240
239
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 );
244
243
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 );
247
246
248
247
/* 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 )
251
250
{
252
251
/* 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 () */
254
253
assert (0 );
255
254
ret = -1 ;
256
255
break ;
@@ -271,16 +270,18 @@ int PLATFORM_SendHdlcMessage(uint8_t *msg, uint32_t len)
271
270
/* Private functions */
272
271
/* -------------------------------------------------------------------------- */
273
272
274
- static int PLATFORM_InitHdlcRpmsg (void )
273
+ static int PLATFORM_InitHdlcImumc (void )
275
274
{
276
- hal_rpmsg_status_t rpmsgStatus ;
275
+ hal_imumc_status_t imumcStatus ;
276
+ hal_imumc_config_t imumcConfig ;
277
277
int ret = 0 ;
278
278
279
+ imumcConfig = hdlcImumcConfig ;
279
280
do
280
281
{
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 )
284
285
{
285
286
ret = -1 ;
286
287
break ;
@@ -290,21 +291,21 @@ static int PLATFORM_InitHdlcRpmsg(void)
290
291
return ret ;
291
292
}
292
293
293
- static int PLATFORM_TerminateHdlcRpmsg (void )
294
+ static int PLATFORM_TerminateHdlcImumc (void )
294
295
{
295
- hal_rpmsg_status_t rpmsgStatus ;
296
+ hal_imumc_status_t imumcStatus ;
296
297
int ret = 0 ;
297
298
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 )
300
301
{
301
302
ret = -1 ;
302
303
}
303
304
304
305
return ret ;
305
306
}
306
307
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 )
308
309
{
309
310
(void )PLATFORM_HandleControllerPowerState ();
310
311
@@ -318,5 +319,5 @@ static hal_rpmsg_return_status_t PLATFORM_HdlcRpmsgRxCallback(void *param, uint8
318
319
319
320
static bool PLATFORM_IsHdlcLinkReady (void )
320
321
{
321
- return (HAL_ImuLinkIsUp (hdlcRpmsgConfig .imuLink ) == kStatus_HAL_RpmsgSuccess );
322
+ return (HAL_ImuLinkIsUp (hdlcImumcConfig .imuLink ) == kStatus_HAL_ImumcSuccess );
322
323
}
0 commit comments