2016-08-05 14:44:09 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2016 Freie Universität Berlin
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2017-07-02 23:21:36 +02:00
|
|
|
* @defgroup drivers_w5100 W5100 ethernet driver
|
2017-02-07 13:26:01 +01:00
|
|
|
* @ingroup drivers_netdev
|
2016-08-05 14:44:09 +02:00
|
|
|
* @brief Driver for W5100 ethernet devices
|
|
|
|
*
|
|
|
|
* This device driver only exposes the MACRAW mode of W5100 devices, so it does
|
|
|
|
* not offer any support for the on-chip IPv4, UDP, and TCP capabilities of
|
|
|
|
* these chips. In connection with RIOT we are only interested in the RAW
|
2017-02-15 13:07:34 +01:00
|
|
|
* Ethernet packets, which we can use through netdev with any software network
|
2016-08-05 14:44:09 +02:00
|
|
|
* stack provided by RIOT (e.g. GNRC). This enables W5100 devices to communicate
|
|
|
|
* via IPv6, enables unlimited connections, and more...
|
|
|
|
*
|
|
|
|
* @note This driver expects to be triggered by the external interrupt
|
|
|
|
* line of the W5100 device. On some Arduino shields this is not
|
|
|
|
* enabled by default, you have to close the corresponding solder
|
|
|
|
* bridge to make it work...
|
|
|
|
*
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Interface definition for the W5100 device driver
|
|
|
|
*
|
|
|
|
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef W5100_H
|
|
|
|
#define W5100_H
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "periph/spi.h"
|
|
|
|
#include "periph/gpio.h"
|
2017-02-15 13:07:34 +01:00
|
|
|
#include "net/netdev.h"
|
2016-08-05 14:44:09 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief W5100 error codes
|
|
|
|
*/
|
|
|
|
enum {
|
|
|
|
W5100_ERR_BUS = -1,
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief W5100 device descriptor
|
|
|
|
*/
|
|
|
|
typedef struct {
|
|
|
|
spi_t spi; /**< SPI bus used */
|
2016-11-08 18:44:16 +01:00
|
|
|
spi_clk_t clk; /**< clock speed used on the selected SPI bus */
|
2016-08-05 14:44:09 +02:00
|
|
|
gpio_t cs; /**< pin connected to the chip select line */
|
|
|
|
gpio_t evt; /**< pin connected to the INT line */
|
|
|
|
} w5100_params_t;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Device descriptor for W5100 devices
|
|
|
|
*/
|
|
|
|
typedef struct {
|
2017-02-15 13:07:34 +01:00
|
|
|
netdev_t nd; /**< extends the netdev structure */
|
2016-08-05 14:44:09 +02:00
|
|
|
w5100_params_t p; /**< device configuration parameters */
|
|
|
|
} w5100_t;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief So the initial device setup
|
|
|
|
*
|
2017-02-15 13:07:34 +01:00
|
|
|
* This function pre-initializes the netdev structure, saves the configuration
|
2016-08-05 14:44:09 +02:00
|
|
|
* parameters and finally initializes the SPI bus and the used GPIO pins.
|
2022-03-16 16:53:37 +01:00
|
|
|
*
|
|
|
|
* @param [out] dev the handle of the device to initialize
|
|
|
|
* @param [in] params parameters for device initialization
|
|
|
|
* @param [in] index Index of @p params in a global parameter struct array.
|
|
|
|
* If initialized manually, pass a unique identifier instead.
|
2016-08-05 14:44:09 +02:00
|
|
|
*/
|
2022-03-16 16:53:37 +01:00
|
|
|
void w5100_setup(w5100_t *dev, const w5100_params_t *params, uint8_t index);
|
2016-08-05 14:44:09 +02:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-05-23 18:19:52 +02:00
|
|
|
#endif /* W5100_H */
|
2022-08-11 16:24:37 +02:00
|
|
|
/** @} */
|