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
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++) {
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++) {
void gpio_setup_output(ioportid_t port, uint16_t gpios)
Setup one or more pins of the given GPIO port as outputs.
static void gpio_set(ioportid_t port, uint16_t pin)
Set a gpio output to high level.
static void gpio_clear(ioportid_t port, uint16_t pin)
Clear a gpio output to low level.
void sys_time_usleep(uint32_t us)
sys_time_usleep(uint32_t us)
static const float offset[]
Some architecture independent helper functions for GPIOs.
enum SPIClockPolarity cpol
clock polarity control
enum SPIClockPhase cpha
clock phase control
enum SPISlaveSelect select
slave selection behavior
enum SPIDataSizeSelect dss
data transfer word size
volatile uint8_t * output_buf
pointer to transmit buffer for DMA
uint16_t input_length
number of data words to read
enum SPIClockDiv cdiv
prescaler of main clock to use as SPI clock
volatile uint8_t * input_buf
pointer to receive buffer for DMA
uint8_t slave_idx
slave id: SPI_SLAVE0 to SPI_SLAVE4
enum SPIBitOrder bitorder
MSB/LSB order.
uint16_t output_length
number of data words to write
enum SPITransactionStatus status
bool spi_submit(struct spi_periph *p, struct spi_transaction *t)
Submit SPI transaction.
@ SPICpolIdleLow
CPOL = 0.
@ SPISelectUnselect
slave is selected before transaction and unselected after
SPI transaction structure.
Architecture independent SPI (Serial Peripheral Interface) API.
Architecture independent timing functions.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
static void w5100_set_buffer(uint16_t _reg, volatile uint8_t *_buf, uint16_t _len)
void w5100_transmit(uint8_t data)
static void w5100_read_data(uint8_t s, volatile uint8_t *src, volatile uint8_t *dst, uint16_t len)
void w5100_transmit_buffer(uint8_t *data, uint16_t len)
static const uint16_t SSIZE
static const uint16_t RSIZE
uint16_t w5100_rx_size(uint8_t _s)
static int true_function(struct w5100_periph *p, long *fd, uint16_t len)
static uint16_t w5100_read(uint16_t _addr, uint8_t *_buf, uint16_t _len)
static void dev_transmit(struct w5100_periph *p, long fd, uint8_t byte)
struct w5100_periph chip0
static uint8_t w5100_sock_get(uint8_t _sock, uint16_t _reg)
#define W5100_DRDY_GPIO_PIN
uint8_t w5100_rx_buf[W5100_RX_BUFFER_SIZE]
static uint8_t dev_getch(struct w5100_periph *p)
static void w5100_close_socket(uint8_t _s)
uint16_t w5100_receive(uint8_t *buf, uint16_t len)
static uint16_t w5100_sock_get16(uint8_t _sock, uint16_t _reg)
static int dev_char_available(struct w5100_periph *p)
bool w5100_ch_available()
struct spi_transaction w5100_spi
static void dev_transmit_buffer(struct w5100_periph *p, long fd, uint8_t *data, uint16_t len)
static void w5100_set(uint16_t _reg, uint8_t _val)
static void configure_socket(uint8_t _s, uint8_t _flag, uint16_t _lport, uint16_t _dport, uint8_t *_dest)
static uint8_t w5100_get(uint16_t _reg)
static void w5100_sock_set(uint8_t _sock, uint16_t _reg, uint8_t _val)
static void dev_send(struct w5100_periph *p, long fd)
#define W5100_TX_BUFFER_SIZE
volatile uint16_t tx_extract_idx[W5100_BUFFER_NUM]
volatile uint8_t work_tx[4]
volatile uint8_t work_rx[4]
struct link_device device
Generic device interface.
#define W5100_RX_BUFFER_SIZE
volatile uint8_t tx_buf[W5100_BUFFER_NUM][W5100_TX_BUFFER_SIZE]
volatile uint16_t tx_insert_idx[W5100_BUFFER_NUM]