1.1.2.4.1 DRV_G3_MACRT_Initialize Function

C

SYS_MODULE_OBJ DRV_G3_MACRT_Initialize (
    const SYS_MODULE_INDEX index,
    const SYS_MODULE_INIT * const init
);

Summary

Initializes the MAC RT instance for the specified driver index.

Description

This routine initializes the G3 MAC RT driver making it ready for clients to open and use. The initialization data is specified by the init parameter. It is a single instance driver, so this API should be called only once.

Parameters

ParamDescription
indexIndex for the instance to be initialized. As driver is single instance, index '0' must always be used.
initPointer to the init data structure containing any data necessary to initialize the driver.

Returns

If successful, returns a valid handle to a driver instance object. Otherwise, it returns SYS_MODULE_OBJ_INVALID.

Example

SYS_MODULE_OBJ   sysObjDrvMACRT;

DRV_PLC_PLIB_INTERFACE drvPLCPlib = {

    .spiPlibTransferSetup = (DRV_PLC_SPI_PLIB_TRANSFER_SETUP)SPI0_TransferSetup,
    .dmaChannelTx = SYS_DMA_CHANNEL_1,
    .dmaChannelRx  = SYS_DMA_CHANNEL_0,
    .spiAddressTx =  (void *)&(SPI0_REGS->SPI_TDR),
    .spiAddressRx  = (void *)&(SPI0_REGS->SPI_RDR),
    .spiClockFrequency = DRV_PLC_SPI_CLK,
    .ldoPin = DRV_PLC_LDO_EN_PIN, 
    .resetPin = DRV_PLC_RESET_PIN,
    .extIntPin = DRV_PLC_EXT_INT_PIN,
};

DRV_PLC_HAL_INTERFACE drvPLCHalAPI = {
    .plcPlib = &drvPLCPlib,
    .init = (DRV_PLC_HAL_INIT)drv_plc_hal_init,
    .setup = (DRV_PLC_HAL_SETUP)drv_plc_hal_setup,
    .reset = (DRV_PLC_HAL_RESET)drv_plc_hal_reset,
    .getCd = (DRV_PLC_HAL_GET_CD)drv_plc_hal_get_cd,
    .enableExtInt = (DRV_PLC_HAL_ENABLE_EXT_INT)drv_plc_hal_enable_interrupt,
    .delay = (DRV_PLC_HAL_DELAY)drv_plc_hal_delay,
    .sendBootCmd = (DRV_PLC_HAL_SEND_BOOT_CMD)drv_plc_hal_send_boot_cmd,
    .sendWrRdCmd = (DRV_PLC_HAL_SEND_WRRD_CMD)drv_plc_hal_send_wrrd_cmd,
};

extern uint8_t g3_macrt_bin_start;
extern uint8_t g3_macrt_bin_end;

DRV_G3_MACRT_INIT drvPLCMacRtInitData = {
    .plcHal = &drvPLCHalAPI,
    .numClients = DRV_G3_MACRT_CLIENTS_NUMBER_IDX,  
    .plcProfile = DRV_G3_MACRT_PLC_PROFILE,
    .binStartAddress = (uint32_t)&g3_macrt_bin_start,
    .binEndAddress = (uint32_t)&g3_macrt_bin_end,
    .secure = DRV_G3_MACRT_SECURE,       
};

sysObjDrvMACRT = DRV_G3_MACRT_Initialize(DRV_G3_MACRT_INDEX_0, (SYS_MODULE_INIT *)&drvPLCMacRtInitData);
// Register Callback function is mandatory to handle PLC interruption 
PIO_PinInterruptCallbackRegister(DRV_G3_MACRT_EXT_INT_PIN, DRV_G3_MACRT_ExternalInterruptHandler, sysObjDrvMACRT);

Remarks

This routine must be called before any other DRV_G3_MACRT routine is called.This routine should only be called once during system initialization.This routine will block for hardware access.