33 #define TXBUF_BASE 0x4000
34 #define RXBUF_BASE 0x6000
38 #define TELEM_SOCKET 0
40 #define SOCK_OPEN 0x01
41 #define SOCK_CLOSE 0x10
42 #define SOCK_SEND 0x20
43 #define SOCK_RECV 0x40
45 #define SNMR_MULTI 0x80
46 #define SNIR_SEND_OK 0x10
47 #define SNIR_TIMEOUT 0x08
48 #define CH_BASE 0x0400
49 #define CH_SIZE 0x0100
50 #define SMASK 0x07FF // Tx buffer MASK
51 #define RMASK 0x07FF // Tx buffer MASK
54 #define REG_RX_MEM 0x001A
55 #define REG_TX_MEM 0x001B
57 #define REG_GAR 0x0001
58 #define REG_SUBR 0x0005
59 #define REG_SHAR 0x0009
60 #define REG_SIPR 0x000F
62 #define SOCK_MR 0x0000
63 #define SOCK_CR 0x0001
64 #define SOCK_IR 0x0002
65 #define SOCK_PORT 0x0004
66 #define SOCK_DHAR 0x0006
67 #define SOCK_DIPR 0x000C
68 #define SOCK_DPORT 0x0010
69 #define SOCK_TX_WR 0x0024
70 #define SOCK_RSR 0x0026
71 #define SOCK_RXRD 0x0028
74 #define W5100_SPI_DEV spi1
77 #ifndef W5100_SLAVE_IDX
78 #define W5100_SLAVE_IDX SPI_SLAVE1
81 #ifndef W5100_DRDY_GPIO
82 #define W5100_DRDY_GPIO GPIOB
85 #ifndef W5100_DRDY_GPIO_PIN
86 #define W5100_DRDY_GPIO_PIN GPIO1
94 static uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
145 for (
int i = 0; i < _len; i++) {
227 for (
int i = 0; i <
SOCKETS; i++) {
294 if (offset + len >
SSIZE) {
312 while (complete != 0x00) {
326 }
while (val != val1);
347 if (_dest[0] != 0x00) {
353 uint8_t mac_multi[] = { 0x01, 0x00, 0x5E, 0x01, 0x01, 0x0B };
383 data_len = (data_len << 8) + head[7];
408 if ((src_mask + len) >
RSIZE) {
409 size =
RSIZE - src_mask;
420 for (
int i = 0; i < _len; i++) {
put_byte_t put_byte
put one byte
enum SPIClockPolarity cpol
clock polarity control
uint8_t(* get_byte_t)(void *)
static void w5100_set(uint16_t _reg, uint8_t _val)
volatile uint8_t work_tx[4]
#define W5100_TX_BUFFER_SIZE
static void w5100_sock_set(uint8_t _sock, uint16_t _reg, uint8_t _val)
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
uint16_t output_length
number of data words to write
static void dev_transmit(struct w5100_periph *p, uint8_t byte)
check_free_space_t check_free_space
check if transmit buffer is not full
static const uint16_t SSIZE
static int true_function(struct w5100_periph *p, uint8_t len)
uint16_t w5100_rx_size(uint8_t _s)
Some architecture independent helper functions for GPIOs.
#define W5100_RX_BUFFER_SIZE
static uint8_t dev_getch(struct w5100_periph *p)
SPI transaction structure.
enum SPIBitOrder bitorder
MSB/LSB order.
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
enum SPISlaveSelect select
slave selection behavior
volatile uint8_t tx_buf[W5100_BUFFER_NUM][W5100_TX_BUFFER_SIZE]
void * periph
pointer to parent implementation
uint16_t w5100_receive(uint8_t *buf, uint16_t len)
static uint8_t w5100_sock_get(uint8_t _sock, uint16_t _reg)
Architecture independent SPI (Serial Peripheral Interface) API.
enum SPIClockPhase cpha
clock phase control
void gpio_set(uint32_t port, uint16_t pin)
Set a gpio output to high level.
bool_t spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit a spi transaction.
Architecture independent timing functions.
static int dev_char_available(struct w5100_periph *p)
volatile uint16_t tx_insert_idx[W5100_BUFFER_NUM]
static const uint16_t RSIZE
volatile uint16_t tx_extract_idx[W5100_BUFFER_NUM]
void gpio_clear(uint32_t port, uint16_t pin)
Clear a gpio output to low level.
volatile uint8_t work_rx[4]
static uint16_t w5100_sock_get16(uint8_t _sock, uint16_t _reg)
get_byte_t get_byte
get a new char
static uint16_t w5100_read(uint16_t _addr, uint8_t *_buf, uint16_t _len)
static void w5100_read_data(uint8_t s, volatile uint8_t *src, volatile uint8_t *dst, uint16_t len)
static void w5100_close_socket(uint8_t _s)
struct w5100_periph chip0
int(* char_available_t)(void *)
uint16_t input_length
number of data words to read
void(* put_byte_t)(void *, uint8_t)
static void w5100_set_buffer(uint16_t _reg, volatile uint8_t *_buf, uint16_t _len)
static void sys_time_usleep(uint32_t us)
#define W5100_DRDY_GPIO_PIN
void(* send_message_t)(void *)
slave is selected before transaction and unselected after
struct spi_transaction w5100_spi
enum SPIDataSizeSelect dss
data transfer word size
uint8_t w5100_rx_buf[W5100_RX_BUFFER_SIZE]
static void dev_send(struct w5100_periph *p)
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
volatile uint8_t * input_buf
pointer to receive buffer for DMA
int(* check_free_space_t)(void *, uint8_t)
Function pointers definition.
static uint8_t w5100_get(uint16_t _reg)
char_available_t char_available
check if a new character is available
void w5100_transmit(uint8_t data)
struct link_device device
Generic device interface.
bool_t w5100_ch_available()
static void configure_socket(uint8_t _s, uint8_t _flag, uint16_t _lport, uint16_t _dport, uint8_t *_dest)
void gpio_setup_output(uint32_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
send_message_t send_message
send completed buffer
enum SPITransactionStatus status