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
95 static uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
146 for (
int i = 0; i < _len; i++) {
229 for (
int i = 0; i <
SOCKETS; i++) {
263 pprz_transport_init(&pprz_w5100_tp);
284 for (i = 0; i < len; i++) {
308 if (offset + len >
SSIZE) {
326 while (complete != 0x00) {
340 }
while (val != val1);
361 if (_dest[0] != 0x00) {
367 uint8_t mac_multi[] = { 0x01, 0x00, 0x5E, 0x01, 0x01, 0x0B };
397 data_len = (data_len << 8) + head[7];
422 if ((src_mask + len) >
RSIZE) {
423 size =
RSIZE - src_mask;
434 for (
int i = 0; i < _len; i++) {
enum SPIClockPolarity cpol
clock polarity control
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 gpio_clear(ioportid_t port, uint16_t pin)
Clear a gpio output to low level.
static int true_function(struct w5100_periph *p, long *fd, uint16_t len)
static const uint16_t SSIZE
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.
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
static void dev_send(struct w5100_periph *p, long fd)
enum SPIBitOrder bitorder
MSB/LSB order.
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
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]
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 sys_time_usleep(uint32_t us)
sys_time_usleep(uint32_t us)
static void dev_transmit_buffer(struct w5100_periph *p, long fd, uint8_t *data, uint16_t len)
static const float offset[]
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]
volatile uint8_t work_rx[4]
static uint16_t w5100_sock_get16(uint8_t _sock, uint16_t _reg)
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
static void dev_transmit(struct w5100_periph *p, long fd, uint8_t byte)
bool w5100_ch_available()
uint16_t input_length
number of data words to read
static void w5100_set_buffer(uint16_t _reg, volatile uint8_t *_buf, uint16_t _len)
#define W5100_DRDY_GPIO_PIN
void w5100_transmit_buffer(uint8_t *data, uint16_t len)
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]
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
volatile uint8_t * input_buf
pointer to receive buffer for DMA
static uint8_t w5100_get(uint16_t _reg)
void w5100_transmit(uint8_t data)
struct link_device device
Generic device interface.
static void gpio_set(ioportid_t port, uint16_t pin)
Set a gpio output to high level.
static void configure_socket(uint8_t _s, uint8_t _flag, uint16_t _lport, uint16_t _dport, uint8_t *_dest)
enum SPITransactionStatus status