Microchip® Advanced Software Framework

ksz8851snl.h File Reference

KS8851SNL driver for SAM.

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

#include "gpio.h"

Functions

void configure_intn (void(*p_handler)(uint32_t, uint32_t))
 Configure the INTN interrupt. More...
 
void ksz8851_fifo_dummy (uint32_t len)
 Write dummy data to the internal fifo buffer. More...
 
void ksz8851_fifo_read (uint8_t *buf, uint32_t len)
 Read internal fifo buffer. More...
 
void ksz8851_fifo_write (uint8_t *buf, uint32_t tot_len, uint32_t len)
 Write internal fifo buffer. More...
 
void ksz8851_reg_clrbits (uint16_t reg, uint16_t bits_to_clr)
 Read register content, clear bitmask and write back to register. More...
 
uint16_t ksz8851_reg_read (uint16_t reg)
 Read a register value. More...
 
void ksz8851_reg_setbits (uint16_t reg, uint16_t bits_to_set)
 Read register content, set bitmask and write back to register. More...
 
void ksz8851_reg_write (uint16_t reg, uint16_t wrdata)
 Write a register value. More...
 
uint32_t ksz8851snl_init (void)
 KSZ8851SNL initialization function. More...
 

void configure_intn ( void(*)(uint32_t, uint32_t)  p_handler)

Configure the INTN interrupt.

References pio_enable_interrupt(), pio_set_debounce_filter(), and pmc_enable_periph_clk().

Referenced by ksz8851snl_low_level_init().

void ksz8851_fifo_dummy ( uint32_t  len)

Write dummy data to the internal fifo buffer.

Parameters
lenthe amount of dummy data to write.

References g_p_spi_pdc, pdc_disable_transfer(), pdc_enable_transfer(), pdc_rx_init(), pdc_tx_init(), spi_read_status(), tmpbuf, pdc_packet::ul_addr, and pdc_packet::ul_size.

Referenced by ksz8851snl_update().

void ksz8851_fifo_read ( uint8_t *  buf,
uint32_t  len 
)

Read internal fifo buffer.

Parameters
bufthe buffer to store the data from the fifo buffer.
lenthe amount of data to read.

References FIFO_READ, g_p_spi_pdc, pdc_disable_transfer(), pdc_enable_transfer(), pdc_rx_init(), pdc_tx_init(), spi_enable_interrupt(), tmpbuf, pdc_packet::ul_addr, and pdc_packet::ul_size.

Referenced by ksz8851snl_update().

void ksz8851_fifo_write ( uint8_t *  buf,
uint32_t  tot_len,
uint32_t  len 
)

Write internal fifo buffer.

Parameters
bufthe buffer to send to the fifo buffer.
tot_lenthe total amount of data to write.
lenthe size of the first pbuf to write from the pbuf chain.

References FIFO_WRITE, g_p_spi_pdc, pdc_disable_transfer(), pdc_enable_transfer(), pdc_rx_init(), pdc_tx_init(), spi_enable_interrupt(), tmpbuf, pdc_packet::ul_addr, and pdc_packet::ul_size.

Referenced by ksz8851snl_update().

void ksz8851_reg_clrbits ( uint16_t  reg,
uint16_t  bits_to_clr 
)

Read register content, clear bitmask and write back to register.

Parameters
regthe register address to modify.
bits_to_setbitmask to apply.

References ksz8851_reg_read(), and ksz8851_reg_write().

Referenced by ksz8851snl_init(), and ksz8851snl_update().

uint16_t ksz8851_reg_read ( uint16_t  reg)
void ksz8851_reg_setbits ( uint16_t  reg,
uint16_t  bits_to_set 
)

Read register content, set bitmask and write back to register.

Parameters
regthe register address to modify.
bits_to_setbitmask to apply.

References ksz8851_reg_read(), and ksz8851_reg_write().

Referenced by ksz8851snl_init(), and ksz8851snl_update().

void ksz8851_reg_write ( uint16_t  reg,
uint16_t  wrdata 
)
uint32_t ksz8851snl_init ( void  )

KSZ8851SNL initialization function.

Returns
0 on success, 1 on communication error.

References ADDR_PTR_AUTO_INC, BUS_CLOCK_166, BUS_CLOCK_DIVIDEDBY_1, CHIP_ID_8851_16, CONFIG_SPI_MASTER_DELAY_BCT, CONFIG_SPI_MASTER_DELAY_BS, delay_ms, g_p_spi_pdc, gpio_configure_pin, gpio_set_pin_high, gpio_set_pin_low, INT_RX, ksz8851_reg_clrbits(), ksz8851_reg_read(), ksz8851_reg_setbits(), ksz8851_reg_write(), pdc_enable_transfer(), PORT_AUTO_NEG_RESTART, PORT_FORCE_FULL_DUPLEX, REG_BUS_CLOCK_CTRL, REG_CHIP_ID, REG_INT_MASK, REG_INT_STATUS, REG_MAC_ADDR_0, REG_MAC_ADDR_2, REG_MAC_ADDR_4, REG_PORT_CTRL, REG_RX_ADDR_PTR, REG_RX_CTRL1, REG_RX_CTRL2, REG_RX_FRAME_CNT_THRES, REG_RXQ_CMD, REG_TX_ADDR_PTR, REG_TX_CTRL, RX_CTRL_ALL_MULTICAST, RX_CTRL_BROADCAST, RX_CTRL_BURST_LEN_FRAME, RX_CTRL_ENABLE, RX_CTRL_FLOW_ENABLE, RX_CTRL_ICMP_CHECKSUM, RX_CTRL_IP_CHECKSUM, RX_CTRL_IPV6_UDP_NOCHECKSUM, RX_CTRL_MAC_FILTER, RX_CTRL_TCP_CHECKSUM, RX_CTRL_UDP_CHECKSUM, RX_CTRL_UDP_LITE_CHECKSUM, RX_CTRL_UNICAST, RXQ_CMD_CNTL, SPI_CLK_PHASE, SPI_CLK_POLARITY, spi_disable(), spi_disable_mode_fault_detect(), spi_enable(), spi_enable_clock(), spi_reset(), spi_set_baudrate_div(), spi_set_bits_per_transfer(), spi_set_clock_phase(), spi_set_clock_polarity(), spi_set_master_mode(), spi_set_peripheral_chip_select_value(), spi_set_transfer_delay(), sysclk_get_cpu_hz(), TX_CTRL_CRC_ENABLE, TX_CTRL_ENABLE, TX_CTRL_FLOW_ENABLE, TX_CTRL_ICMP_CHECKSUM, TX_CTRL_IP_CHECKSUM, TX_CTRL_PAD_ENABLE, TX_CTRL_TCP_CHECKSUM, and TX_CTRL_UDP_CHECKSUM.

Referenced by ksz8851snl_low_level_init().