iLLD_TC27xC  1.0
How to use the MSC Interface driver?
Collaboration diagram for How to use the MSC Interface driver?:

The MSC interface driver provides a default MSC configuration

In the following sections it will be described, how to integrate the driver into the application framework.

Preparation

Include Files

Include following header file into your C code:

#include <msc_commands.h>

Variables

Declare the MSC handle as global variable in your C code:

Module Initialisation

The module initialisation can be done as followed:

// create configuration (same is used for all MSCs)
IfxMsc_Msc_initModuleConfig(&mscConfig, &MODULE_MSC0);
// increase baudrate for faster simulation:
mscConfig.clockConfig.baudrate = 25000000;
// FCL only activated on transfers
// in this case we also don't need a selection bit
// initialize MSCs
for(int i=0; i<IFXMSC_COUNT; ++i) {
// init module pointer
mscConfig.msc = (Ifx_MSC*)IfxMsc_cfg_indexMap[i].module;
// IO Config
mscConfig.io = IfxMsc_PinMap[i];
// initialize module
IfxMsc_Msc_initModule(&msc[i], &mscConfig);
}

The MSC is ready for use now!

Data Transfers

The MSC driver provides simple to use transfer function

for(int n=0; n<10; ++n) {
// clear IRQ flag of previous transfer
for(int i=0; i<IFXMSC_COUNT; ++i) {
msc[i].msc->ISC.B.CDEDI = 1;
}
// new transfer
for(int i=0; i<IFXMSC_COUNT; ++i) {
const unsigned dataL = i*0x1000 + n;
const unsigned dataH = i*0x1000 + 0x0100 + n;
IfxMsc_Msc_sendData(&msc[i], dataL, dataH);
}
// wait until transfers are finished
for(int i=0; i<IFXMSC_COUNT; ++i) {
while( !msc[i].msc->ISR.B.DEDI ); // check if new data could be written
while( msc[i].msc->DSS.B.DFA ); // check if we are still in the active data phase
}