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 */ |
Referenced by _pplc_cmd_op(), pplc_if_read16(), pplc_if_read32(), pplc_if_read8(), and pplc_if_read_buf().
#define PPLC_CMD_WRITE 0x2a /* < Write operation */ |
Referenced by pplc_if_write16(), pplc_if_write32(), pplc_if_write8(), and pplc_if_write_buf().
#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 |
Transmit PPLC command to Proxy PLC controller.
uc_cmd | PPLC command to send |
us_addr | Address where is the data to apply command |
us_len | Number of bytes in operation |
ptr_buf | Pointer to data buffer |
uc_bytes_rep | Number of repetitions(only use in PPLC_CMD_WRITE_REP command) |
true | if there is no error |
false | if there is an error |
References Disable_global_interrupt, Enable_global_interrupt, pdc_disable_transfer(), pdc_enable_transfer(), PDC_PPLC_BUFFER_SIZE, pdc_rx_init(), pdc_tx_init(), PPLC_CMD_READ, PPLC_CMD_WRITE_REP, PPLC_SPI_MODULE, 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 |
Initialize Proxy PLC controller.
This function will change the system clock prescaler configuration to match the parameters.
References gs_ul_pplc_clock, PPLC_CS, PPLC_DLYBCT, PPLC_DLYBS, PPLC_PCS, PPLC_SPI_MODULE, spi_configure_cs_behavior(), SPI_CS_RISE_NO_TX, spi_disable(), spi_disable_mode_fault_detect(), spi_enable(), spi_enable_clock(), spi_get_pdc_base(), spi_reset(), spi_set_baudrate_div(), spi_set_bits_per_transfer(), spi_set_clock_phase(), spi_set_clock_polarity(), spi_set_fixed_peripheral_select(), spi_set_master_mode(), spi_set_peripheral_chip_select_value(), spi_set_transfer_delay(), and sysclk_get_cpu_hz().
Referenced by pplc_if_init().
void pplc_if_and8 | ( | uint16_t | us_addr, |
uint8_t | uc_mask | ||
) |
Apply AND mask to 8 bits register.
us_addr | Addres of register to apply uc_mask |
uc_mask | Mask |
References _pplc_cmd_op(), and PPLC_CMD_AND.
Referenced by _get_crc(), _init_IIR_filter(), _init_phy_layer(), _phy_rx_task(), _phy_tx_result_task(), _reset_rx_flag_interrupt(), _update_emit1_mode(), _update_emit2_mode(), _update_txrx1_polarity(), _update_txrx2_polarity(), phy_carrier_detect_buff_enable(), phy_carrier_detect_disable(), phy_clear_sfr_err(), phy_cmd_cfg_param(), phy_force_tx_buff_disable(), phy_handler(), phy_mac_crc_disable(), phy_reception_buff_enable(), phy_transmission_buff_disable(), and phy_tx_frame().
void pplc_if_init | ( | void | ) |
Initialize PPLC interface.
References _pplc_if_config(), IOPORT_DIR_INPUT, IOPORT_DIR_OUTPUT, ioport_set_pin_dir(), ioport_set_pin_level(), pio_enable_interrupt(), pio_handler_set(), pmc_enable_periph_clk(), PPLC_ARST_GPIO, PPLC_ARST_INACTIVE_LEVEL, pplc_handler, pplc_if_int_handler(), PPLC_INT_ATTR, PPLC_INT_GPIO, PPLC_INT_ID, PPLC_INT_IRQn, PPLC_INT_MASK, PPLC_INT_PIO, PPLC_PRIO, PPLC_SRST_GPIO, and PPLC_SRST_INACTIVE_LEVEL.
Referenced by phy_init().
|
static |
References pplc_handler, and UNUSED.
Referenced by pplc_if_init().
void pplc_if_or8 | ( | uint16_t | us_addr, |
uint8_t | uc_mask | ||
) |
Apply OR mask to 8 bits register.
us_addr | Addres of register to apply uc_mask |
uc_mask | Mask |
References _pplc_cmd_op(), and PPLC_CMD_OR.
Referenced by _get_crc(), _init_phy_layer(), _update_emit1_mode(), _update_emit2_mode(), _update_txrx1_polarity(), _update_txrx2_polarity(), phy_carrier_detect_buff_disable(), phy_carrier_detect_enable(), phy_clear_global_interrupt(), phy_cmd_cfg_param(), phy_force_tx_buff_enable(), phy_mac_crc_enable(), phy_reception_buff_disable(), phy_tx_frame(), and phy_tx_frame_result_cb().
uint16_t pplc_if_read16 | ( | uint16_t | us_addr | ) |
Read 16bits from PPLC.
us_addr | Address to read |
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.
us_addr | Address to read |
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.
us_addr | Address to read |
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.
us_addr | Write address |
ptr_buf | Pointer to data buffer |
us_len | Length of buffer to send |
true | if there is no error |
false | if 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.
us_addr | Address to destination |
us_data | Data to write |
true | if there is no error |
false | if 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.
us_addr | Address to destination |
ul_dat | Data to write |
true | if there is no error |
false | if 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.
us_addr | Address to destination |
uc_dat | Data to write |
true | if there is no error |
false | if 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.
us_addr | Initial sddress to read |
ptr_buf | Destination of readed data |
us_len | Number of bytes to read |
true | if there is no error |
false | if 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.
us_addr | Write address |
uc_bytes_rep | Number of bytes to repeat |
ptr_buf | Pointer to data buffer |
us_len | Length of buffer to send |
true | if there is no error |
false | if 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.
us_addr | Addres of register to apply uc_mask |
uc_mask | Mask |
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 |
|
static |
|
static |
|
static |
Referenced by _pplc_if_config().
|
static |
Describes an PPLC interrupt handler.
Referenced by pplc_if_init(), pplc_if_int_handler(), and pplc_set_handler().
|
static |