Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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)
 
static int true_function (struct w5100_periph *p, long *fd, uint16_t len)
 
static void dev_transmit (struct w5100_periph *p, long fd, uint8_t byte)
 
static void dev_transmit_buffer (struct w5100_periph *p, long fd, uint8_t *data, uint16_t len)
 
static void dev_send (struct w5100_periph *p, long fd)
 
static int dev_char_available (struct w5100_periph *p)
 
static uint8_t dev_getch (struct w5100_periph *p)
 
void w5100_init (void)
 
void w5100_transmit (uint8_t data)
 
void w5100_transmit_buffer (uint8_t *data, uint16_t len)
 
void w5100_send ()
 
uint16_t w5100_rx_size (uint8_t _s)
 
bool 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 spi_transaction w5100_spi
 

Detailed Description

W5100 ethernet chip I/O.

Definition in file w5100.c.

Macro Definition Documentation

◆ CH_BASE

#define CH_BASE   0x0400

Definition at line 48 of file w5100.c.

◆ CH_SIZE

#define CH_SIZE   0x0100

Definition at line 49 of file w5100.c.

◆ CMD_SOCKET

#define CMD_SOCKET   1

Definition at line 37 of file w5100.c.

◆ REG_GAR

#define REG_GAR   0x0001

Definition at line 57 of file w5100.c.

◆ REG_MR

#define REG_MR   0x0000

Definition at line 53 of file w5100.c.

◆ REG_RX_MEM

#define REG_RX_MEM   0x001A

Definition at line 54 of file w5100.c.

◆ REG_SHAR

#define REG_SHAR   0x0009

Definition at line 59 of file w5100.c.

◆ REG_SIPR

#define REG_SIPR   0x000F

Definition at line 60 of file w5100.c.

◆ REG_SUBR

#define REG_SUBR   0x0005

Definition at line 58 of file w5100.c.

◆ REG_TX_MEM

#define REG_TX_MEM   0x001B

Definition at line 55 of file w5100.c.

◆ RMASK

#define RMASK   0x07FF

Definition at line 51 of file w5100.c.

◆ RXBUF_BASE

#define RXBUF_BASE   0x6000

Definition at line 34 of file w5100.c.

◆ SMASK

#define SMASK   0x07FF

Definition at line 50 of file w5100.c.

◆ SNIR_SEND_OK

#define SNIR_SEND_OK   0x10

Definition at line 46 of file w5100.c.

◆ SNIR_TIMEOUT

#define SNIR_TIMEOUT   0x08

Definition at line 47 of file w5100.c.

◆ SNMR_MULTI

#define SNMR_MULTI   0x80

Definition at line 45 of file w5100.c.

◆ SNMR_UDP

#define SNMR_UDP   0x02

Definition at line 44 of file w5100.c.

◆ SOCK_CLOSE

#define SOCK_CLOSE   0x10

Definition at line 41 of file w5100.c.

◆ SOCK_CR

#define SOCK_CR   0x0001

Definition at line 63 of file w5100.c.

◆ SOCK_DHAR

#define SOCK_DHAR   0x0006

Definition at line 66 of file w5100.c.

◆ SOCK_DIPR

#define SOCK_DIPR   0x000C

Definition at line 67 of file w5100.c.

◆ SOCK_DPORT

#define SOCK_DPORT   0x0010

Definition at line 68 of file w5100.c.

◆ SOCK_IR

#define SOCK_IR   0x0002

Definition at line 64 of file w5100.c.

◆ SOCK_MR

#define SOCK_MR   0x0000

Definition at line 62 of file w5100.c.

◆ SOCK_OPEN

#define SOCK_OPEN   0x01

Definition at line 40 of file w5100.c.

◆ SOCK_PORT

#define SOCK_PORT   0x0004

Definition at line 65 of file w5100.c.

◆ SOCK_RECV

#define SOCK_RECV   0x40

Definition at line 43 of file w5100.c.

◆ SOCK_RSR

#define SOCK_RSR   0x0026

Definition at line 70 of file w5100.c.

◆ SOCK_RXRD

#define SOCK_RXRD   0x0028

Definition at line 71 of file w5100.c.

◆ SOCK_SEND

#define SOCK_SEND   0x20

Definition at line 42 of file w5100.c.

◆ SOCK_TX_WR

#define SOCK_TX_WR   0x0024

Definition at line 69 of file w5100.c.

◆ SOCKETS

#define SOCKETS   4

Definition at line 35 of file w5100.c.

◆ TELEM_SOCKET

#define TELEM_SOCKET   0

Definition at line 38 of file w5100.c.

◆ TXBUF_BASE

#define TXBUF_BASE   0x4000

Definition at line 33 of file w5100.c.

◆ W5100_DRDY_GPIO

#define W5100_DRDY_GPIO   GPIOB

Definition at line 82 of file w5100.c.

◆ W5100_DRDY_GPIO_PIN

#define W5100_DRDY_GPIO_PIN   GPIO1

Definition at line 86 of file w5100.c.

◆ W5100_SLAVE_IDX

#define W5100_SLAVE_IDX   SPI_SLAVE1

Definition at line 78 of file w5100.c.

◆ W5100_SPI_DEV

#define W5100_SPI_DEV   spi1

Definition at line 74 of file w5100.c.

Function Documentation

◆ configure_socket()

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

Definition at line 352 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:

◆ dev_char_available()

static int dev_char_available ( struct w5100_periph p)
static

Definition at line 177 of file w5100.c.

References w5100_ch_available().

Referenced by w5100_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dev_getch()

static uint8_t dev_getch ( struct w5100_periph p)
static

Definition at line 178 of file w5100.c.

References w5100_receive().

Referenced by w5100_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dev_send()

static void dev_send ( struct w5100_periph p,
long  fd 
)
static

Definition at line 176 of file w5100.c.

References w5100_send().

Referenced by w5100_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dev_transmit()

static void dev_transmit ( struct w5100_periph p,
long  fd,
uint8_t  byte 
)
static

Definition at line 174 of file w5100.c.

References w5100_transmit().

Referenced by w5100_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dev_transmit_buffer()

static void dev_transmit_buffer ( struct w5100_periph p,
long  fd,
uint8_t data,
uint16_t  len 
)
static

Definition at line 175 of file w5100.c.

References w5100_transmit_buffer().

Referenced by w5100_init().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ true_function()

static int true_function ( struct w5100_periph p,
long *  fd,
uint16_t  len 
)
static

Definition at line 173 of file w5100.c.

Referenced by w5100_init().

+ Here is the caller graph for this function:

◆ w5100_ch_available()

bool w5100_ch_available ( void  )

Definition at line 378 of file w5100.c.

References CMD_SOCKET, and w5100_rx_size().

Referenced by dev_char_available(), and w5100_read_buffer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ w5100_close_socket()

static void w5100_close_socket ( uint8_t  _s)
static

Definition at line 344 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:

◆ w5100_get()

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:

◆ w5100_init()

◆ w5100_read()

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

Definition at line 432 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:

◆ w5100_read_data()

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

Definition at line 412 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:

◆ w5100_receive()

uint16_t w5100_receive ( uint8_t buf,
uint16_t  len 
)

Definition at line 386 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 dev_getch(), and w5100_read_buffer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ w5100_rx_size()

uint16_t w5100_rx_size ( uint8_t  _s)

Definition at line 331 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:

◆ w5100_send()

void w5100_send ( void  )

Definition at line 289 of file w5100.c.

References chip0, w5100_periph::curbuf, offset, SBASE, SMASK, SOCK_CR, SOCK_SEND, SOCK_TX_WR, SSIZE, TELEM_SOCKET, w5100_periph::tx_buf, w5100_periph::tx_extract_idx, w5100_periph::tx_insert_idx, W5100_BUFFER_NUM, w5100_set_buffer(), w5100_sock_get(), w5100_sock_get16(), and w5100_sock_set().

Referenced by dev_send().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ w5100_set()

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:

◆ w5100_set_buffer()

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:

◆ w5100_sock_get()

static uint8_t w5100_sock_get ( uint8_t  _sock,
uint16_t  _reg 
)
inlinestatic

Definition at line 157 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:

◆ w5100_sock_get16()

static uint16_t w5100_sock_get16 ( uint8_t  _sock,
uint16_t  _reg 
)
inlinestatic

Definition at line 162 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:

◆ w5100_sock_set()

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:

◆ w5100_transmit()

void w5100_transmit ( uint8_t  data)

Definition at line 266 of file w5100.c.

References chip0, w5100_periph::curbuf, w5100_periph::tx_buf, w5100_periph::tx_extract_idx, w5100_periph::tx_insert_idx, and W5100_TX_BUFFER_SIZE.

Referenced by dev_transmit(), and w5100_transmit_buffer().

+ Here is the caller graph for this function:

◆ w5100_transmit_buffer()

void w5100_transmit_buffer ( uint8_t data,
uint16_t  len 
)

Definition at line 281 of file w5100.c.

References w5100_transmit().

Referenced by dev_transmit_buffer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ chip0

struct w5100_periph chip0

Definition at line 1 of file w5100.c.

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

◆ ck_a

uint8_t ck_a

Definition at line 91 of file w5100.c.

Referenced by if().

◆ ck_b

uint8_t ck_b

Definition at line 91 of file w5100.c.

Referenced by if().

◆ dest

uint8_t dest[] = { W5100_MULTICAST_IP }
static

◆ dport

uint16_t dport = W5100_MULTICAST_PORT
static

Definition at line 101 of file w5100.c.

Referenced by w5100_init().

◆ ip

uint8_t ip[] = { W5100_IP }
static

Definition at line 98 of file w5100.c.

Referenced by w5100_init().

◆ mac

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

Definition at line 95 of file w5100.c.

Referenced by w5100_init().

◆ RBASE

uint16_t RBASE[SOCKETS]

Definition at line 106 of file w5100.c.

Referenced by w5100_init(), and w5100_read_data().

◆ RSIZE

const uint16_t RSIZE = 2048
static

Definition at line 108 of file w5100.c.

Referenced by w5100_init(), and w5100_read_data().

◆ RST

const uint8_t RST = 7
static

Definition at line 103 of file w5100.c.

Referenced by w5100_init().

◆ SBASE

uint16_t SBASE[SOCKETS]

Definition at line 105 of file w5100.c.

Referenced by w5100_init(), and w5100_send().

◆ SSIZE

const uint16_t SSIZE = 2048
static

Definition at line 107 of file w5100.c.

Referenced by w5100_init(), and w5100_send().

◆ subnet

uint8_t subnet[] = { W5100_SUBNET }
static

Definition at line 100 of file w5100.c.

Referenced by w5100_init().

◆ w5100_rx_buf

Definition at line 92 of file w5100.c.

Referenced by w5100_read_buffer().

◆ w5100_spi

struct spi_transaction w5100_spi

Definition at line 108 of file w5100.c.

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