1.1.3 Transmission

In the PLC & Go application, to transmit a message, it is only needed to call the function APP_PLC_SendData() passing as parameters the pointer to the data buffer and the data length. The function includes the length of the message to transmit in the first two bytes of the data buffer so that, at the reception of the message, it is possible to know the real length of the message.

Any message transmitted by the PLC_PHY module requires a header including some transmission parameters. These parameters and the data are stored in the structure DRV_PLC_PHY_TRANSMISSION_OBJ.

The PLC & Go application only allow the configuration of some transmission parameters related to the modulation. The rest of the parameters required to send a PLC message are configured by default during the initialization stage in the function APP_PLC_SetInitialConfiguration() in the state APP_PLC_STATE_OPEN.

The function APP_PLC_SetInitialConfiguration() configures the transmission parameters and stores the values in the structure.

Once the transmission is configured, the function APP_PLC_SendData() prepares the data to be sent by PLC, storing the data in the transmission buffer (appPlcTx.pDataTx) and indicating the length of the data buffer (appPlcTx.pl360Tx.dataLength). When all the information is in the transmission structure, the function DRV_PLC_PHY_Send() sends the PLC message.

After sending the message to be transmitted to the PLC_PHY device, a TX data confirm event is triggered indicating the result of the transmission. This event is managed by the APP_PLC_DataCfmCb() callback function. This callback receives as parameter a data structure of type DRV_PLC_PHY_TRANSMISSION_CFM_OBJ.

  1. Structure DRV_PLC_PHY_TRANSMISSION_OBJ
    // *****************************************************************************
    /* PRIME Transmission setup data
    
       Summary
        This struct includes all information to describe any transmissions.
    
       Remarks:
        None
    */
    typedef struct __attribute__((packed, aligned(1))) {
      /* Pointer to data buffer to transmit */
      uint8_t *pTransmitData;
      /* Instant when transmission has to start referred to 1us PHY counter */
      uint32_t time;
      /* Length of the data to transmit in bytes */
      uint16_t dataLength;
      /* Transmission Mode (absolute, relative, cancel, continuous). Constants above */
      uint8_t mode;
      /* Attenuation level with which the message will be transmitted */
      uint8_t attenuation;
      /* Forced transmission */
      uint8_t forced;
      /* Buffer Id used for transmission */
      DRV_PLC_PHY_BUFFER_ID bufferId;
      /* Scheme of Modulation */
      DRV_PLC_PHY_SCH scheme;
      /* PRIME Frame type */
      DRV_PLC_PHY_FRAME_TYPE frameType;
    } DRV_PLC_PHY_TRANSMISSION_OBJ;

    Transmission messages are composed using data structure DRV_PLC_PHY_TRANSMISSION_OBJ defined in drv_plc_phy_comm.h.

    Where:
    • pTransmitData: Pointer to the buffer containing the data to transmit
    • time: Delay to send the message in ms referred to PLC_PHY internal timer
    • dataLength: length of the data buffer containing the data to transmit
    • mode: Transmission mode
    uc_tx_modeDescription
    TX_MODE_ABSOLUTEThe message is sent at the specified time, referred to PL360 internal timer (1 us). Time defined in ul_tx_time
    TX_MODE_RELATIVEThe message is sent with a delay referred to the transmission request time. Delay defined in ul_tx_time
    TX_MODE_PREAMBLE_CONTINUOUSContinuous transmission of the preamble. Used for testing
    TX_MODE_SYMBOLS_CONTINUOUSContinuous transmission of a message. Used for testing
    TX_MODE_CANCELCancels the ongoing transmission (started or programmed)
    • attenuation: Attenuation level with which the message will be transmitted
    • bufferId: Buffer to store the transmission data. There are two available buffers. However, transmissions cannot be overlapped in time. In that case, TX_BUFFER_0 has priority
    bufferIdDescription
    TX_BUFFER_0First transmission buffer
    TX_BUFFER_1Second transmission buffer
    • modScheme: Modulation scheme
    uc_mod_schemeValueDescription
    SCHEME_DBPSK0 Differential BPSK
    SCHEME_DQPSK1 Differential QPSK
    SCHEME_D8PSK2Differential 8PSK
    SCHEME_DBPSK_C4Differential BPSK Convolutional
    SCHEME_DQPSK_C5Differential QPSK Convolutional
    SCHEME_D8PSK_C6Differential 8PSK Convolutional
    SCHEME_R_DBPSK12Robust Differential BPSK
    SCHEME_R_DQPSK13Robust Differential QPSK
    • frameType: Frame Type
    frameTypeValueDescription
    FRAME_TYPE_A0 Frame Type A
    FRAME_TYPE_B2Frame Type B
    FRAME_TYPE_BC3Frame Type BC
  2. Structure DRV_PLC_PHY_TRANSMISSION_CFM_OBJ
    // *****************************************************************************
    /* PRIME Result of a transmission
    
       Summary
        This struct includes all information to describe any result of a previous 
        transmission.
    
       Remarks:
        None
    */
    typedef struct {
      /* Instant when frame transmission started referred to 1us PHY counter */
      uint32_t time;
      /* RMS value emitted */
      uint32_t rmsCalc;
      /* PRIME Frame type */
      DRV_PLC_PHY_FRAME_TYPE frameType;
      /* Tx Result (see "TX Result values" above) */
      DRV_PLC_PHY_TX_RESULT result;
      /* Buffer Id used for transmission */
      DRV_PLC_PHY_BUFFER_ID bufferId;
    } DRV_PLC_PHY_TRANSMISSION_CFM_OBJ;
    The event returns one of the following transmission result values:
    // *****************************************************************************
    /* PRIME Result values of a previous transmission
    
       Summary
        This list involves all available results from MCHP implementation
    
       Remarks:
        None
    */
    typedef enum {
      /* Transmission result: already in process */
      DRV_PLC_PHY_TX_RESULT_PROCESS = 0,
      /* Transmission result: end successfully */
      DRV_PLC_PHY_TX_RESULT_SUCCESS = 1,
      /* Transmission result: invalid length error */
      DRV_PLC_PHY_TX_RESULT_INV_LENGTH = 2,
      /* Transmission result: busy channel error */
      DRV_PLC_PHY_TX_RESULT_BUSY_CH = 3,
      /* Transmission result: busy in transmission error */
      DRV_PLC_PHY_TX_RESULT_BUSY_TX = 4,
      /* Transmission result: busy in reception error */
      DRV_PLC_PHY_TX_RESULT_BUSY_RX = 5,
      /* Transmission result: invalid modulation scheme error */
      DRV_PLC_PHY_TX_RESULT_INV_SCHEME = 6,
      /* Transmission result: timeout error */
      DRV_PLC_PHY_TX_RESULT_TIMEOUT = 7,
      /* Transmission result: invalid buffer identifier error */
      DRV_PLC_PHY_TX_RESULT_INV_BUFFER = 8,
      /* Transmission result: invalid PRIME Mode error */
      DRV_PLC_PHY_TX_RESULT_INV_MODE = 9,
      /* Transmission result: invalid transmission mode */
      DRV_PLC_PHY_TX_RESULT_INV_TX_MODE = 10,
      /* Transmission result: Transmission cancelled */
      DRV_PLC_PHY_TX_RESULT_CANCELLED = 11,
      /* Transmission result: high temperature error */
      DRV_PLC_PHY_TX_RESULT_HIGH_TEMP_120 = 12,
      /* Transmission result: high temperature warning */
      DRV_PLC_PHY_TX_RESULT_HIGH_TEMP_110 = 13,
      /* Transmission result: No transmission ongoing */
      DRV_PLC_PHY_TX_RESULT_NO_TX = 255,
    } DRV_PLC_PHY_TX_RESULT;