Microchip® Advanced Software Framework

pplc_if.c File Reference

Proxy PLC Controller interface layer implementation.

Copyright (c) 2014-2018 Microchip Technology Inc. and its subsidiaries.

#include "string.h"
#include "pplc_if.h"
#include "conf_pplc_if.h"
#include "ioport.h"
#include "sysclk.h"
#include "spi.h"
#include "pdc.h"
#include "pio.h"
#include "pio_handler.h"

Macros

#define MAX_NUM_READ_RX_COUNTER   10
 
#define PDC_PPLC_BUFFER_SIZE   800
 
#define PPLC_PCS   spi_get_pcs(PPLC_CS)
 

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