Microchip® Advanced Software Framework

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Proxy PLC Controller

This module provides configuration and utils to control the PLC interface with the ATPL230 PHY layer.

Macros

#define MAX_NUM_READ_RX_COUNTER   10
 
#define PDC_PPLC_BUFFER_SIZE   800
 
#define PPLC_CLOCK   9000000 /* < PPLC clock setting */
 
#define PPLC_CMD_AND   0x4c /* < AND operation */
 
#define PPLC_CMD_OR   0x71 /* < OR operation */
 
#define PPLC_CMD_READ   0x63 /* < Read operation */
 
#define PPLC_CMD_WRITE   0x2a /* < Write operation */
 
#define PPLC_CMD_WRITE_REP   0x1e /* < Repetitive write operation */
 
#define PPLC_CMD_XOR   0x6d /* < XOR operation */
 
#define PPLC_DLYBCT   0 /* < Delay between consecutive transfers */
 
#define PPLC_DLYBS   10 /* < Delay before SPCK */
 
#define PPLC_PCS   spi_get_pcs(PPLC_CS)
 
#define PPLC_PRIO   11 /* < PPLC interruption group priority */
 

Functions

static int8_t _pplc_cmd_op (uint8_t uc_cmd, uint16_t us_addr, uint16_t us_len, uint8_t *ptr_buf, uint8_t uc_bytes_rep)
 Transmit PPLC command to Proxy PLC controller. More...
 
static void _pplc_if_config (void)
 Initialize Proxy PLC controller. More...
 
void pplc_if_and8 (uint16_t us_addr, uint8_t uc_mask)
 Apply AND mask to 8 bits register. More...
 
void pplc_if_init (void)
 Initialize PPLC interface. More...
 
static void pplc_if_int_handler (uint32_t ul_id, uint32_t ul_mask)
 
void pplc_if_or8 (uint16_t us_addr, uint8_t uc_mask)
 Apply OR mask to 8 bits register. More...
 
uint16_t pplc_if_read16 (uint16_t us_addr)
 Read 16bits from PPLC. More...
 
uint32_t pplc_if_read32 (uint16_t us_addr)
 Read 32bits from PPLC. More...
 
uint8_t pplc_if_read8 (uint16_t us_addr)
 Read 8bits from PPLC. More...
 
uint8_t pplc_if_read_buf (uint16_t us_addr, uint8_t *ptr_buf, uint16_t us_len)
 Write the content of buffer to PPLC. More...
 
uint8_t pplc_if_write16 (uint16_t us_addr, uint16_t us_data)
 Write 16 bits to PPLC. More...
 
uint8_t pplc_if_write32 (uint16_t us_addr, uint32_t ul_dat)
 Write 32 bits to PPLC. More...
 
uint8_t pplc_if_write8 (uint16_t us_addr, uint8_t uc_dat)
 Write 8 bits to PPLC. More...
 
uint8_t pplc_if_write_buf (uint16_t us_addr, uint8_t *ptr_buf, uint16_t us_len)
 Read bytes from PPLC. More...
 
uint8_t pplc_if_write_rep (uint16_t us_addr, uint8_t uc_bytes_rep, uint8_t *ptr_buf, uint16_t us_len)
 Write 8 bits to PPLC repetitive at the same address. More...
 
void pplc_if_xor8 (uint16_t us_addr, uint8_t uc_mask)
 Apply XOR mask to 8 bits register. More...
 
void pplc_set_handler (void(*p_handler)(void))
 Set an interrupt handler for the specified interrput source. More...
 

Variables

Pdc * g_pplc_pdc
 
pdc_packet_t g_pplc_rx_packet
 
pdc_packet_t g_pplc_tx_packet
 
static uint8_t gs_pplc_rx_buffer [PDC_PPLC_BUFFER_SIZE]
 
static uint8_t gs_pplc_tx_buffer [PDC_PPLC_BUFFER_SIZE]
 
static uint32_t gs_ul_pplc_clock = PPLC_CLOCK
 
static void(* pplc_handler )(void)
 Describes an PPLC interrupt handler. More...
 
static uint8_t uc_pplc_is_busy
 

#define MAX_NUM_READ_RX_COUNTER   10
#define PDC_PPLC_BUFFER_SIZE   800

Referenced by _pplc_cmd_op().

#define PPLC_CLOCK   9000000 /* < PPLC clock setting */
#define PPLC_CMD_AND   0x4c /* < AND operation */

Referenced by pplc_if_and8().

#define PPLC_CMD_OR   0x71 /* < OR operation */

Referenced by pplc_if_or8().

#define PPLC_CMD_READ   0x63 /* < Read operation */
#define PPLC_CMD_WRITE   0x2a /* < Write operation */
#define PPLC_CMD_WRITE_REP   0x1e /* < Repetitive write operation */

Referenced by _pplc_cmd_op(), and pplc_if_write_rep().

#define PPLC_CMD_XOR   0x6d /* < XOR operation */

Referenced by pplc_if_xor8().

#define PPLC_DLYBCT   0 /* < Delay between consecutive transfers */

Referenced by _pplc_if_config().

#define PPLC_DLYBS   10 /* < Delay before SPCK */

Referenced by _pplc_if_config().

#define PPLC_PCS   spi_get_pcs(PPLC_CS)

Referenced by _pplc_if_config().

#define PPLC_PRIO   11 /* < PPLC interruption group priority */

Referenced by pplc_if_init().

static int8_t _pplc_cmd_op ( uint8_t  uc_cmd,
uint16_t  us_addr,
uint16_t  us_len,
uint8_t *  ptr_buf,
uint8_t  uc_bytes_rep 
)
static

Transmit PPLC command to Proxy PLC controller.

Parameters
uc_cmdPPLC command to send
us_addrAddress where is the data to apply command
us_lenNumber of bytes in operation
ptr_bufPointer to data buffer
uc_bytes_repNumber of repetitions(only use in PPLC_CMD_WRITE_REP command)
Return values
trueif there is no error
falseif there is an error

References Disable_global_interrupt, Enable_global_interrupt, NULL, pdc_disable_transfer(), pdc_enable_transfer(), PDC_PPLC_BUFFER_SIZE, pdc_rx_init(), pdc_tx_init(), PPLC_CMD_READ, PPLC_CMD_WRITE_REP, spi_read_status(), pdc_packet::ul_addr, and pdc_packet::ul_size.

Referenced by pplc_if_and8(), pplc_if_or8(), pplc_if_read16(), pplc_if_read32(), pplc_if_read8(), pplc_if_read_buf(), pplc_if_write16(), pplc_if_write32(), pplc_if_write8(), pplc_if_write_buf(), pplc_if_write_rep(), and pplc_if_xor8().

static void _pplc_if_config ( void  )
static
static void pplc_if_int_handler ( uint32_t  ul_id,
uint32_t  ul_mask 
)
static

References NULL, pplc_handler, and UNUSED.

Referenced by pplc_if_init().

uint16_t pplc_if_read16 ( uint16_t  us_addr)

Read 16bits from PPLC.

Parameters
us_addrAddress to read
Returns
Value readed

References _pplc_cmd_op(), and PPLC_CMD_READ.

Referenced by phy_get_cfg_param(), phy_rx_frame_cb(), and phy_tx_frame_result_cb().

uint32_t pplc_if_read32 ( uint16_t  us_addr)

Read 32bits from PPLC.

Parameters
us_addrAddress to read
Returns
Value readed

References _pplc_cmd_op(), and PPLC_CMD_READ.

Referenced by _get_crc(), phy_get_cfg_param(), phy_rx_frame_cb(), and phy_tx_frame().

uint8_t pplc_if_read8 ( uint16_t  us_addr)

Read 8bits from PPLC.

Parameters
us_addrAddress to read
Returns
Value readed

References _pplc_cmd_op(), and PPLC_CMD_READ.

Referenced by phy_get_carrier_detect(), phy_get_cfg_param(), phy_get_mac_en(), phy_get_sfr_err(), phy_handler(), phy_rx_frame_cb(), and phy_transmission_buff_is_enable().

uint8_t pplc_if_read_buf ( uint16_t  us_addr,
uint8_t *  ptr_buf,
uint16_t  us_len 
)

Write the content of buffer to PPLC.

Parameters
us_addrWrite address
ptr_bufPointer to data buffer
us_lenLength of buffer to send
Return values
trueif there is no error
falseif there is an error

References _pplc_cmd_op(), and PPLC_CMD_READ.

Referenced by _init_phy_layer(), phy_get_cfg_param(), and phy_rx_frame_cb().

uint8_t pplc_if_write16 ( uint16_t  us_addr,
uint16_t  us_data 
)

Write 16 bits to PPLC.

Parameters
us_addrAddress to destination
us_dataData to write
Return values
trueif there is no error
falseif there is an error

References _pplc_cmd_op(), PPLC_CMD_WRITE, and uc_data_buf.

Referenced by _init_phy_layer(), phy_set_cfg_param(), and phy_tx_frame().

uint8_t pplc_if_write32 ( uint16_t  us_addr,
uint32_t  ul_dat 
)

Write 32 bits to PPLC.

Parameters
us_addrAddress to destination
ul_datData to write
Return values
trueif there is no error
falseif there is an error

References _pplc_cmd_op(), PPLC_CMD_WRITE, and uc_data_buf.

Referenced by _get_crc(), _init_phy_layer(), _update_channel(), phy_set_cfg_param(), and phy_tx_frame().

uint8_t pplc_if_write8 ( uint16_t  us_addr,
uint8_t  uc_dat 
)

Write 8 bits to PPLC.

Parameters
us_addrAddress to destination
uc_datData to write
Return values
trueif there is no error
falseif there is an error

References _pplc_cmd_op(), and PPLC_CMD_WRITE.

Referenced by _get_crc(), _init_IIR_filter(), _init_phy_layer(), _update_channel(), _update_emit1_mode(), _update_emit2_mode(), phy_set_cfg_param(), and phy_tx_frame().

uint8_t pplc_if_write_buf ( uint16_t  us_addr,
uint8_t *  ptr_buf,
uint16_t  us_len 
)

Read bytes from PPLC.

Parameters
us_addrInitial sddress to read
ptr_bufDestination of readed data
us_lenNumber of bytes to read
Return values
trueif there is no error
falseif there is an error

References _pplc_cmd_op(), and PPLC_CMD_WRITE.

Referenced by _init_phy_layer(), _store_filter_sec(), phy_set_cfg_param(), and phy_tx_frame().

uint8_t pplc_if_write_rep ( uint16_t  us_addr,
uint8_t  uc_bytes_rep,
uint8_t *  ptr_buf,
uint16_t  us_len 
)

Write 8 bits to PPLC repetitive at the same address.

Parameters
us_addrWrite address
uc_bytes_repNumber of bytes to repeat
ptr_bufPointer to data buffer
us_lenLength of buffer to send
Return values
trueif there is no error
falseif there is an error

References _pplc_cmd_op(), and PPLC_CMD_WRITE_REP.

Referenced by _get_crc().

void pplc_if_xor8 ( uint16_t  us_addr,
uint8_t  uc_mask 
)

Apply XOR mask to 8 bits register.

Parameters
us_addrAddres of register to apply uc_mask
uc_maskMask

References _pplc_cmd_op(), and PPLC_CMD_XOR.

Referenced by phy_cmd_cfg_param().

void pplc_set_handler ( void(*)(void)  p_handler)

Set an interrupt handler for the specified interrput source.

References pplc_handler.

Referenced by phy_init().

Pdc* g_pplc_pdc
pdc_packet_t g_pplc_rx_packet
pdc_packet_t g_pplc_tx_packet
uint8_t gs_pplc_rx_buffer[PDC_PPLC_BUFFER_SIZE]
static
uint8_t gs_pplc_tx_buffer[PDC_PPLC_BUFFER_SIZE]
static
uint32_t gs_ul_pplc_clock = PPLC_CLOCK
static

Referenced by _pplc_if_config().

void(* pplc_handler)(void)
static

Describes an PPLC interrupt handler.

Referenced by pplc_if_init(), pplc_if_int_handler(), and pplc_set_handler().

uint8_t uc_pplc_is_busy
static