1- /******************************************************************************
2- * *
3- * file : Ipc_Driver_app.c
4- * project : Dual Core Inverter KMT.pjt
5- * authors : Federico D. Ceccarelli
6- * *
1+ /**
2+ *
3+ * \file ipc.c
4+ *
5+ * project Dual Core Inverter KMT.pjt
6+ *
7+ * \author Federico D. Ceccarelli
8+ *
79 *******************************************************************************
8- * Description:
9- * This is an implementation of the IPC driver for the KMT
10- * dual core project purposes.
10+ *
11+ * \brief apipc implementation.
12+ *
13+ * apipc is an ipc_driver library implementation for TMS320C28x Texas
14+ * Instruments cores. The api present a bunch of routines to simplify data
15+ * tranfer between cores.
1116 *
1217 *******************************************************************************
13- * Version 1.0 10/05/2021
14- *******************************************************************************/
18+ * Version 0.1 10/05/2021
19+ ******************************************************************************
20+ */
1521
1622#include "F2837xD_device.h" // F2837xD Headerfile Include File
1723#include "F2837xD_Examples.h" // F2837xD Examples Include File
2026#include "../lib/mymalloc/mymalloc.h"
2127#include "../lib/circular_buffer/buffer.h"
2228
23- /* ipclib shared buffers space allocation */
24- // NOTE: space is allocated depending on the .cmd file included in the project
29+ /**
30+ * \defgroup apipc_data_sections apipc shared buffers space allocation
31+ *
32+ * \note space is allocated depending on the .cmd file included in the project
33+ * @{*/
2534#pragma DATA_SECTION(cl_r_w_data,".cpul_cpur_data");
2635#pragma DATA_SECTION(l_apipc_obj,".base_cpul_cpur_addr");
2736#pragma DATA_SECTION(r_apipc_obj,".base_cpur_cpul_addr");
28-
29- /* ipclib shared buffers space declaration */
30- uint16_t cl_r_w_data [CL_R_W_DATA_LENGTH ]; // mapped to .cpul_cpur_data of shared RAM owned by local cpu.
31- struct apipc_obj l_apipc_obj [APIPC_MAX_OBJ ]; // mapped to .base_cpul_cpur_addr of shared RAM owned by local cpu.
32- struct apipc_obj r_apipc_obj [APIPC_MAX_OBJ ]; // mapped to .base_cpur_cpul_addr of shared RAM owned by remote cpu.
33-
34- /* IPC API Drivers handlers declaration. */
35- // NOTE: Should be declared one handler for every interrupt
36- volatile tIpcController g_sIpcController1 ;
37- volatile tIpcController g_sIpcController2 ;
38-
39- /* mymalloc API handler declaration. */
37+ /** @}*/
38+
39+ /**
40+ * \defgrup apipc_data_declaration ipclib shared buffers space declaration
41+ * @{*/
42+ uint16_t cl_r_w_data [CL_R_W_DATA_LENGTH ]; /**< mapped to .cpul_cpur_data of shared RAM owned by local cpu. */
43+ struct apipc_obj l_apipc_obj [APIPC_MAX_OBJ ]; /**< mapped to .base_cpul_cpur_addr of shared RAM owned by local cpu. */
44+ struct apipc_obj r_apipc_obj [APIPC_MAX_OBJ ]; /**< mapped to .base_cpur_cpul_addr of shared RAM owned by remote cpu. */
45+ /** @}*/
46+
47+ /**
48+ * \defgroup ipc_handlers IPC Drivers handlers declaration.
49+ *
50+ * \note Should be declared one handler for every interrupt
51+ * @{
52+ */
53+ volatile tIpcController g_sIpcController1 ; /**< INT0 IPC Drivers handler. */
54+ volatile tIpcController g_sIpcController2 ; /**< INT1 IPC Drivers handler. */
55+ /** @}*/
56+
57+ /** mymalloc API handler declaration. */
4058mymalloc_handler l_r_w_data_h ;
4159
42- /* circular_buffer handler declaration. */
60+ /** circular_buffer handler declaration. */
4361circular_buffer_handler message_cbh ;
44- /* ipc mesasages array memory allocation */
62+ /** ipc mesasages array memory allocation */
4563tIpcMessage message_array [APIPC_MAX_OBJ ];
4664
4765/* statics functions prototipes declarations */
@@ -57,7 +75,7 @@ static enum apipc_rc apipc_process_messages(void);
5775/* apipc_sram_acces_config: */
5876static void apipc_sram_acces_config (void )
5977{
60- /**
78+ /*
6179 * Each CPU owns different GSxM blocks of memory to send data & pointer address
6280 * to the remote core.
6381 * If a core master a block of GSxM RAM it can R/W/Fetc it.
@@ -157,8 +175,8 @@ void apipc_init(void)
157175 apipc_check_remote_cpu_init ();
158176}
159177
160- /* apipc_register_obj: register an obj parameters to be able to tranfer between
161- * cores */
178+ /* apipc_register_obj: register data as an apipc obj to be able to be tranfer
179+ * between cores */
162180enum apipc_rc apipc_register_obj (uint16_t obj_idx , enum apipc_obj_type obj_type ,
163181 void * paddr , size_t size , uint16_t startup )
164182{
@@ -195,8 +213,7 @@ enum apipc_obj_sm apipc_obj_state(uint16_t obj_idx)
195213}
196214
197215
198- /* apipc_send: request transfer an object on demand. object should have been
199- * inited to apipc_obj_sm_started to function */
216+ /* apipc_send: request transfer an object on demand. */
200217ram_func enum apipc_rc apipc_send (uint16_t obj_idx )
201218{
202219 enum apipc_rc rc ;
@@ -251,7 +268,8 @@ enum apipc_rc apipc_flags_clear_bits(uint16_t obj_idx, uint32_t bmask)
251268 return rc ;
252269}
253270
254- /* apipc_write: */
271+ /* apipc_write: to write a value to the remote core apipc interacts with the
272+ * ipc driver according to the obj type */
255273static enum apipc_rc apipc_write (uint16_t obj_idx )
256274{
257275 enum apipc_rc rc ;
@@ -262,6 +280,7 @@ static enum apipc_rc apipc_write(uint16_t obj_idx)
262280 uint32_t ulData ;
263281 uint32_t ulMask ;
264282
283+ /* initialize local variables */
265284 rc = APIPC_RC_SUCCESS ;
266285 plobj = & l_apipc_obj [obj_idx ];
267286 probj = & r_apipc_obj [obj_idx ];
@@ -352,6 +371,9 @@ static enum apipc_rc apipc_write(uint16_t obj_idx)
352371 return rc ;
353372}
354373
374+ /*
375+ * apipc_proc_obj -
376+ */
355377static void apipc_proc_obj (struct apipc_obj * plobj )
356378{
357379 switch (plobj -> obj_sm )
@@ -368,6 +390,7 @@ static void apipc_proc_obj(struct apipc_obj *plobj)
368390 break ;
369391 }
370392
393+ // Init an obj transmition
371394 case APIPC_OBJ_SM_INIT :
372395 plobj -> retry = 3 ;
373396 plobj -> obj_sm = APIPC_OBJ_SM_WRITING ;
@@ -546,6 +569,7 @@ static void apipc_message_handler (tIpcMessage *psMessage)
546569 }
547570}
548571
572+ /* apipc_app - apipc application */
549573void apipc_app (void )
550574{
551575 static enum apipc_sm apipc_app_sm = APIPC_SM_UNKNOWN ;
@@ -561,7 +585,7 @@ void apipc_app(void)
561585 {
562586 case APIPC_SM_UNKNOWN :
563587 if (IPCRtoLFlagBusy (APIPC_FLAG_API_INITED ) && IPCLtoRFlagBusy (APIPC_FLAG_API_INITED ))
564- #if defined( CPU2 )
588+ #if defined( CPU2 )
565589 if (IPCRtoLFlagBusy (APIPC_FLAG_APP_START ))
566590#endif
567591 apipc_app_sm = APIPC_SM_STARTUP_REMOTE ;
0 commit comments