1.2.1.2.3 Using The Library (Meters&More)
For Meters&More, SRV_PCOUP_Set_Config has to be called once the PLC Driver is ready (binary loaded to PLC Device) and before any transmission is requested.
As only CENELEC-A band is available, this configuration only needs to be done once.
G3-PLC Example application using PLC PHY Coupling service
#include "definitions.h" typedef enum { APP_STATE_INIT, APP_STATE_OPEN, APP_STATE_READY, APP_STATE_ERROR } APP_STATE; typedef struct { APP_STATE state; DRV_HANDLE drvPlcHandle; } APP_DATA; APP_DATA appData; static void APP_PLC_DataCfmCb(DRV_PLC_PHY_TRANSMISSION_CFM_OBJ *cfmObj, uintptr_t context) { /* Do whatever with transmission confirm */ } static void APP_PLC_DataIndCb(DRV_PLC_PHY_RECEPTION_OBJ *indObj, uintptr_t context) { /* Do whatever with received frame indication */ } void APP_Initialize (void) { /* Initialize application state */ appData.state = APP_STATE_INIT; /* Get the default transmission branch */ appData.plcBand = SRV_PCOUP_Get_Default_Phy_Band(); } void APP_Tasks (void) { /* Check the application's current state. */ switch (appData.state) { case APP_STATE_INIT: { /* Open PLC driver */ appData.drvPlcHandle = DRV_PLC_PHY_Open(DRV_PLC_PHY_INDEX, NULL); if (appData.drvPlcHandle != DRV_HANDLE_INVALID) { /* Register PLC callbacks */ DRV_PLC_PHY_DataIndCallbackRegister(appData.drvPlcHandle, APP_PLC_DataIndCb, DRV_PLC_PHY_INDEX); DRV_PLC_PHY_DataCfmCallbackRegister(appData.drvPlcHandle, APP_PLC_DataCfmCb, DRV_PLC_PHY_INDEX); /* Enable PLC Transmission */ DRV_PLC_PHY_Enable_TX(appData.drvPlcHandle, true); /* Go to next state to wait until PLC Driver is ready */ appData.state = APP_STATE_OPEN; } else { appData.state = APP_PLC_STATE_ERROR; } break; } case APP_STATE_OPEN: { /* Check PLC Driver status */ if (DRV_PLC_PHY_Status(DRV_PLC_PHY_INDEX) == SYS_STATUS_READY) { /* Apply PLC PHY Coupling configuration */ SRV_PCOUP_Set_Config(appData.drvPlcHandle); /* At this point the PLC Transceiver is ready for transmission */ appData.state = APP_STATE_READY; } } break; case APP_STATE_READY: { /* Do whatever, request transmission or wait to receive something */ break; } /* The default state should never be executed. */ default: { /* Handle error in application's state machine. */ break; } } }