Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
w5100.c File Reference

W5100 ethernet chip I/O. More...

+ Include dependency graph for w5100.c:

Go to the source code of this file.

Macros

#define TXBUF_BASE   0x4000
 
#define RXBUF_BASE   0x6000
 
#define SOCKETS   4
 
#define CMD_SOCKET   1
 
#define TELEM_SOCKET   0
 
#define SOCK_OPEN   0x01
 
#define SOCK_CLOSE   0x10
 
#define SOCK_SEND   0x20
 
#define SOCK_RECV   0x40
 
#define SNMR_UDP   0x02
 
#define SNMR_MULTI   0x80
 
#define SNIR_SEND_OK   0x10
 
#define SNIR_TIMEOUT   0x08
 
#define CH_BASE   0x0400
 
#define CH_SIZE   0x0100
 
#define SMASK   0x07FF
 
#define RMASK   0x07FF
 
#define REG_MR   0x0000
 
#define REG_RX_MEM   0x001A
 
#define REG_TX_MEM   0x001B
 
#define REG_GAR   0x0001
 
#define REG_SUBR   0x0005
 
#define REG_SHAR   0x0009
 
#define REG_SIPR   0x000F
 
#define SOCK_MR   0x0000
 
#define SOCK_CR   0x0001
 
#define SOCK_IR   0x0002
 
#define SOCK_PORT   0x0004
 
#define SOCK_DHAR   0x0006
 
#define SOCK_DIPR   0x000C
 
#define SOCK_DPORT   0x0010
 
#define SOCK_TX_WR   0x0024
 
#define SOCK_RSR   0x0026
 
#define SOCK_RXRD   0x0028
 
#define W5100_SPI_DEV   spi1
 
#define W5100_SLAVE_IDX   SPI_SLAVE1
 
#define W5100_DRDY_GPIO   GPIOB
 
#define W5100_DRDY_GPIO_PIN   GPIO1
 

Functions

static void w5100_close_socket (uint8_t _s)
 
static void configure_socket (uint8_t _s, uint8_t _flag, uint16_t _lport, uint16_t _dport, uint8_t *_dest)
 
static void w5100_read_data (uint8_t s, volatile uint8_t *src, volatile uint8_t *dst, uint16_t len)
 
static uint16_t w5100_read (uint16_t _addr, uint8_t *_buf, uint16_t _len)
 
static void w5100_set (uint16_t _reg, uint8_t _val)
 
static uint8_t w5100_get (uint16_t _reg)
 
static void w5100_set_buffer (uint16_t _reg, volatile uint8_t *_buf, uint16_t _len)
 
static void w5100_sock_set (uint8_t _sock, uint16_t _reg, uint8_t _val)
 
static uint8_t w5100_sock_get (uint8_t _sock, uint16_t _reg)
 
static uint16_t w5100_sock_get16 (uint8_t _sock, uint16_t _reg)
 
void w5100_init (void)
 
void w5100_transmit (uint8_t data)
 
void w5100_send ()
 
uint16_t w5100_rx_size (uint8_t _s)
 
bool_t w5100_ch_available ()
 
uint16_t w5100_receive (uint8_t *buf, uint16_t len)
 

Variables

struct w5100_periph chip0
 
uint8_t ck_a
 
uint8_t ck_b
 
uint8_t w5100_rx_buf [W5100_RX_BUFFER_SIZE]
 
static uint8_t mac [] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }
 
static uint8_t ip [] = { W5100_IP }
 
static uint8_t dest [] = { W5100_MULTICAST_IP }
 
static uint8_t subnet [] = { W5100_SUBNET }
 
static uint16_t dport = W5100_MULTICAST_PORT
 
static const uint8_t RST = 7
 
uint16_t SBASE [SOCKETS]
 
uint16_t RBASE [SOCKETS]
 
static const uint16_t SSIZE = 2048
 
static const uint16_t RSIZE = 2048
 
struct w5100_transport w5100_tp
 
struct spi_transaction w5100_spi
 

Detailed Description

W5100 ethernet chip I/O.

Definition in file w5100.c.

Macro Definition Documentation

#define CH_BASE   0x0400

Definition at line 48 of file w5100.c.

Referenced by configure_socket(), w5100_sock_get(), and w5100_sock_set().

#define CH_SIZE   0x0100

Definition at line 49 of file w5100.c.

Referenced by configure_socket(), w5100_sock_get(), and w5100_sock_set().

#define CMD_SOCKET   1

Definition at line 37 of file w5100.c.

Referenced by w5100_ch_available(), w5100_init(), w5100_read_data(), and w5100_receive().

#define REG_GAR   0x0001

Definition at line 57 of file w5100.c.

Referenced by w5100_init().

#define REG_MR   0x0000

Definition at line 53 of file w5100.c.

Referenced by w5100_init().

#define REG_RX_MEM   0x001A

Definition at line 54 of file w5100.c.

Referenced by w5100_init().

#define REG_SHAR   0x0009

Definition at line 59 of file w5100.c.

Referenced by w5100_init().

#define REG_SIPR   0x000F

Definition at line 60 of file w5100.c.

Referenced by w5100_init().

#define REG_SUBR   0x0005

Definition at line 58 of file w5100.c.

Referenced by w5100_init().

#define REG_TX_MEM   0x001B

Definition at line 55 of file w5100.c.

Referenced by w5100_init().

#define RMASK   0x07FF

Definition at line 51 of file w5100.c.

Referenced by w5100_read_data().

#define RXBUF_BASE   0x6000

Definition at line 34 of file w5100.c.

Referenced by w5100_init().

#define SMASK   0x07FF

Definition at line 50 of file w5100.c.

Referenced by w5100_send().

#define SNIR_SEND_OK   0x10

Definition at line 46 of file w5100.c.

#define SNIR_TIMEOUT   0x08

Definition at line 47 of file w5100.c.

#define SNMR_MULTI   0x80

Definition at line 45 of file w5100.c.

Referenced by w5100_init().

#define SNMR_UDP   0x02

Definition at line 44 of file w5100.c.

Referenced by configure_socket().

#define SOCK_CLOSE   0x10

Definition at line 41 of file w5100.c.

Referenced by w5100_close_socket().

#define SOCK_CR   0x0001

Definition at line 63 of file w5100.c.

Referenced by configure_socket(), w5100_close_socket(), w5100_receive(), and w5100_send().

#define SOCK_DHAR   0x0006

Definition at line 66 of file w5100.c.

Referenced by configure_socket().

#define SOCK_DIPR   0x000C

Definition at line 67 of file w5100.c.

Referenced by configure_socket().

#define SOCK_DPORT   0x0010

Definition at line 68 of file w5100.c.

Referenced by configure_socket().

#define SOCK_IR   0x0002

Definition at line 64 of file w5100.c.

Referenced by w5100_close_socket().

#define SOCK_MR   0x0000

Definition at line 62 of file w5100.c.

Referenced by configure_socket().

#define SOCK_OPEN   0x01

Definition at line 40 of file w5100.c.

Referenced by configure_socket().

#define SOCK_PORT   0x0004

Definition at line 65 of file w5100.c.

Referenced by configure_socket().

#define SOCK_RECV   0x40

Definition at line 43 of file w5100.c.

Referenced by w5100_receive().

#define SOCK_RSR   0x0026

Definition at line 70 of file w5100.c.

Referenced by w5100_rx_size().

#define SOCK_RXRD   0x0028

Definition at line 71 of file w5100.c.

Referenced by w5100_receive().

#define SOCK_SEND   0x20

Definition at line 42 of file w5100.c.

Referenced by w5100_send().

#define SOCK_TX_WR   0x0024

Definition at line 69 of file w5100.c.

Referenced by w5100_send().

#define SOCKETS   4

Definition at line 35 of file w5100.c.

Referenced by w5100_init().

#define TELEM_SOCKET   0

Definition at line 38 of file w5100.c.

Referenced by w5100_init(), and w5100_send().

#define TXBUF_BASE   0x4000

Definition at line 33 of file w5100.c.

Referenced by w5100_init().

#define W5100_DRDY_GPIO   GPIOB

Definition at line 82 of file w5100.c.

Referenced by w5100_init().

#define W5100_DRDY_GPIO_PIN   GPIO1

Definition at line 86 of file w5100.c.

Referenced by w5100_init().

#define W5100_SLAVE_IDX   SPI_SLAVE1

Definition at line 78 of file w5100.c.

Referenced by w5100_init().

#define W5100_SPI_DEV   spi1

Definition at line 74 of file w5100.c.

Referenced by w5100_get(), and w5100_set().

Function Documentation

static void configure_socket ( uint8_t  _s,
uint8_t  _flag,
uint16_t  _lport,
uint16_t  _dport,
uint8_t _dest 
)
static

Definition at line 312 of file w5100.c.

References CH_BASE, CH_SIZE, SNMR_UDP, SOCK_CR, SOCK_DHAR, SOCK_DIPR, SOCK_DPORT, SOCK_MR, SOCK_OPEN, SOCK_PORT, w5100_close_socket(), w5100_set_buffer(), and w5100_sock_set().

Referenced by w5100_init().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool_t w5100_ch_available ( void  )

Definition at line 337 of file w5100.c.

References CMD_SOCKET, FALSE, TRUE, and w5100_rx_size().

Referenced by w5100_read_buffer().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void w5100_close_socket ( uint8_t  _s)
static

Definition at line 305 of file w5100.c.

References SOCK_CLOSE, SOCK_CR, SOCK_IR, and w5100_sock_set().

Referenced by configure_socket().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static uint8_t w5100_get ( uint16_t  _reg)
inlinestatic

Definition at line 130 of file w5100.c.

References spi_transaction::input_buf, spi_transaction::output_buf, spi_submit(), SPITransSuccess, spi_transaction::status, w5100_spi, and W5100_SPI_DEV.

Referenced by w5100_read(), and w5100_sock_get().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static uint16_t w5100_read ( uint16_t  _addr,
uint8_t _buf,
uint16_t  _len 
)
static

Definition at line 387 of file w5100.c.

References w5100_get().

Referenced by w5100_read_data().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void w5100_read_data ( uint8_t  s,
volatile uint8_t src,
volatile uint8_t dst,
uint16_t  len 
)
static

Definition at line 369 of file w5100.c.

References CMD_SOCKET, RBASE, RMASK, RSIZE, and w5100_read().

Referenced by w5100_receive().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint16_t w5100_receive ( uint8_t buf,
uint16_t  len 
)

Definition at line 344 of file w5100.c.

References CMD_SOCKET, SOCK_CR, SOCK_RECV, SOCK_RXRD, w5100_read_data(), w5100_sock_get16(), and w5100_sock_set().

Referenced by w5100_read_buffer().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint16_t w5100_rx_size ( uint8_t  _s)

Definition at line 293 of file w5100.c.

References SOCK_RSR, val, and w5100_sock_get16().

Referenced by w5100_ch_available().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void w5100_set ( uint16_t  _reg,
uint8_t  _val 
)
inlinestatic

Definition at line 117 of file w5100.c.

References spi_transaction::output_buf, spi_submit(), SPITransSuccess, spi_transaction::status, w5100_spi, and W5100_SPI_DEV.

Referenced by w5100_init(), w5100_set_buffer(), and w5100_sock_set().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void w5100_set_buffer ( uint16_t  _reg,
volatile uint8_t _buf,
uint16_t  _len 
)
inlinestatic

Definition at line 144 of file w5100.c.

References w5100_set().

Referenced by configure_socket(), w5100_init(), and w5100_send().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static uint8_t w5100_sock_get ( uint8_t  _sock,
uint16_t  _reg 
)
inlinestatic

Definition at line 156 of file w5100.c.

References CH_BASE, CH_SIZE, and w5100_get().

Referenced by w5100_send(), and w5100_sock_get16().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static uint16_t w5100_sock_get16 ( uint8_t  _sock,
uint16_t  _reg 
)
inlinestatic

Definition at line 160 of file w5100.c.

References w5100_sock_get().

Referenced by w5100_receive(), w5100_rx_size(), and w5100_send().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void w5100_sock_set ( uint8_t  _sock,
uint16_t  _reg,
uint8_t  _val 
)
inlinestatic

Definition at line 152 of file w5100.c.

References CH_BASE, CH_SIZE, and w5100_set().

Referenced by configure_socket(), w5100_close_socket(), w5100_receive(), and w5100_send().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

struct w5100_periph chip0

Definition at line 89 of file w5100.c.

Referenced by w5100_init(), w5100_send(), and w5100_transmit().

uint8_t ck_a

Definition at line 90 of file w5100.c.

uint8_t ck_b

Definition at line 90 of file w5100.c.

uint8_t dest[] = { W5100_MULTICAST_IP }
static

Definition at line 98 of file w5100.c.

Referenced by pflash_program_array(), and w5100_init().

uint16_t dport = W5100_MULTICAST_PORT
static

Definition at line 100 of file w5100.c.

Referenced by w5100_init().

uint8_t ip[] = { W5100_IP }
static

Definition at line 97 of file w5100.c.

Referenced by w5100_init().

uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }
static

Definition at line 94 of file w5100.c.

Referenced by w5100_init().

uint16_t RBASE[SOCKETS]

Definition at line 105 of file w5100.c.

Referenced by w5100_init(), and w5100_read_data().

const uint16_t RSIZE = 2048
static

Definition at line 107 of file w5100.c.

Referenced by w5100_init(), and w5100_read_data().

const uint8_t RST = 7
static

Definition at line 102 of file w5100.c.

Referenced by w5100_init().

uint16_t SBASE[SOCKETS]

Definition at line 104 of file w5100.c.

Referenced by w5100_init(), and w5100_send().

const uint16_t SSIZE = 2048
static

Definition at line 106 of file w5100.c.

Referenced by w5100_init(), and w5100_send().

uint8_t subnet[] = { W5100_SUBNET }
static

Definition at line 99 of file w5100.c.

Referenced by w5100_init().

Definition at line 91 of file w5100.c.

Referenced by w5100_read_buffer().

struct spi_transaction w5100_spi

Definition at line 110 of file w5100.c.

Referenced by w5100_get(), w5100_init(), and w5100_set().

struct w5100_transport w5100_tp

Definition at line 109 of file w5100.c.