Jump to main content

# 1.1.1.4.1 DRV_PLC_PHY_Initialize Function

## C

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

## Summary

Initializes the PLC PHY instance for the specified driver index.

## Description

This routine initializes the G3 PLC PHY 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

Param | Description
--- | ---
index | Index for the instance to be initialized. As driver is single instance, index '0' must always be used.
init | Pointer 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 sysObjDrvPlcPhy;

    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),
        .spiMR = (void *)&(SPI0_REGS->SPI_MR),
        .spiCSR = (void *)&(SPI0_REGS->SPI_CSR),
        .spiClockFrequency = DRV_PLC_SPI_CLK,
        .ldoPin = DRV_PLC_LDO_EN_PIN,
        .resetPin = DRV_PLC_RESET_PIN,
        .extIntPin = DRV_PLC_EXT_INT_PIN,
        .txEnablePin = DRV_PLC_TX_ENABLE_PIN,
        .stByPin = DRV_PLC_STBY_PIN,
        .thMonPin = DRV_PLC_THMON_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,
        .setStandBy = (DRV_PLC_HAL_SET_STBY)DRV_PLC_HAL_SetStandBy,
        .getThermalMonitor = (DRV_PLC_HAL_GET_THMON)DRV_PLC_HAL_GetThermalMonitor,
        .setTxEnable = (DRV_PLC_HAL_SET_TXENABLE)DRV_PLC_HAL_SetTxEnable,
        .enableExtInt = (DRV_PLC_HAL_ENABLE_EXT_INT)DRV_PLC_HAL_EnableInterrupts,
        .delay = (DRV_PLC_HAL_DELAY)DRV_PLC_HAL_Delay,
        .sendBootCmd = (DRV_PLC_HAL_SEND_BOOT_CMD)DRV_PLC_HAL_SendBootCmd,
        .sendWrRdCmd = (DRV_PLC_HAL_SEND_WRRD_CMD)DRV_PLC_HAL_SendWrRdCmd,
    };

    extern uint8_t plc_phy_bin_start;
    extern uint8_t plc_phy_bin_end;

    DRV_PLC_PHY_INIT drvPlcPhyInitData = {
        .plcHal = &drvPLCHalAPI,
        .numClients = DRV_PLC_PHY_CLIENTS_NUMBER_IDX,
        .plcProfile = DRV_PLC_PHY_PROFILE,
        .binStartAddress = (uint32_t)&plc_phy_bin_start,
        .binEndAddress = (uint32_t)&plc_phy_bin_end,
        .secure = DRV_PLC_SECURE,
    };

    sysObjDrvPlcPhy = DRV_PLC_PHY_Initialize(DRV_PLC_PHY_INDEX, (SYS_MODULE_INIT
    *)&drvPlcPhyInitData);
    // Register Callback function is mandatory to handle PLC interruption
    PIO_PinInterruptCallbackRegister((PIO_PIN)DRV_PLC_EXT_INT_PIN,
    DRV_PLC_PHY_ExternalInterruptHandler, sysObj.drvPlcPhy);

## Remarks

This routine must be called before any other DRV_PLC_PHY routine is called.

This routine should only be called once during system initialization.

This routine will block for hardware access.

Rev: G