COSA
An Object-Oriented Platform for Arduino Programming
|
#include <W5100.hh>
Classes | |
struct | CommonRegister |
class | Driver |
struct | SocketRegister |
Public Member Functions | |
W5100 (const uint8_t *mac=NULL, Board::DigitalPin csn=Board::D10) | |
void | addr (uint8_t ip[4], uint8_t subnet[4]) |
void | dns_addr (uint8_t ip[4]) |
bool | begin_P (const char *hostname, uint16_t timeout=500) |
bool | begin_P (str_P hostname, uint16_t timeout=500) |
bool | begin (uint8_t ip[4]=NULL, uint8_t subnet[4]=NULL, uint16_t timeout=500) |
int | bind (uint8_t ip[4], uint8_t subnet[4], uint8_t gateway[4]=NULL) |
Socket * | socket (Socket::Protocol proto, uint16_t port=0, uint8_t flag=0) |
bool | end () |
Static Public Attributes | |
static const uint8_t | MAC [6] |
Protected Types | |
enum | { MR_RST = 0x80, MR_PB = 0x10, MR_PPPoE = 0x08, MR_AI = 0x02, MR_IND = 0x01 } |
enum | { IR_CONFLICT = 0x80, IR_UNREACH = 0x40, IR_PPPoE = 0x20, IR_S3_INT = 0x08, IR_S2_INT = 0x04, IR_S1_INT = 0x02, IR_S0_INT = 0x01 } |
enum | { IMR_CONFLICT = 0x80, IMR_UNREACH = 0x40, IMR_PPPoE = 0x20, IMR_S3_INT = 0x08, IMR_S2_INT = 0x04, IMR_S1_INT = 0x02, IMR_S0_INT = 0x01 } |
enum | { RMSR_S3_POS = 6, RMSR_S2_POS = 4, RMSR_S1_POS = 2, RMSR_S0_POS = 0 } |
enum | { MR_FLAG_MASK = 0xe0, MR_MULTI = 0x80, MR_MF = 0x40, MR_ND = 0x20, MR_MC = 0x20, MR_PROTO_MASK = 0x0f, MR_PROTO_CLOSED = 0x00, MR_PROTO_TCP = 0x01, MR_PROTO_UDP = 0x02, MR_PROTO_IPRAW = 0x03, MR_PROTO_MACRAW = 0x04, MR_PROTO_PPPoE = 0x05 } |
enum | { CR_OPEN = 0x01, CR_LISTEN = 0x02, CR_CONNECT = 0x04, CR_DISCON = 0x08, CR_CLOSE = 0x10, CR_SEND = 0x20, CR_SEND_MAC = 0x21, CR_SEND_KEEP = 0x22, CR_RECV = 0x40 } |
enum | { IR_SEND_OK = 0x10, IR_TIMEOUT = 0x08, IR_RECV = 0x04, IR_DISCON = 0x02, IR_CON = 0x01 } |
enum | { SR_CLOSED = 0x00, SR_ARP = 0x01, SR_INIT = 0x13, SR_LISTEN = 0x14, SR_SYNSENT = 0x15, SR_SYNRECV = 0x16, SR_ESTABLISHED = 0x17, SR_FIN_WAIT = 0x18, SR_CLOSING = 0x1A, SR_TIME_WAIT = 0x1B, SR_CLOSE_WAIT = 0x1C, SR_LAST_ACK = 0x1D, SR_UDP = 0x22, SR_IPRAW = 0x32, SR_MACRAW = 0x42, SR_PPPoE = 0x5F } |
enum | { OP_WRITE = 0xf0, OP_READ = 0x0f } |
Protected Member Functions | |
void | write (uint16_t addr, uint8_t data) |
void | write (uint16_t addr, const void *buf, size_t len, bool progmem=false) |
void | write_P (uint16_t addr, const void *buf, size_t len) |
uint8_t | read (uint16_t addr) |
void | read (uint16_t addr, void *buf, size_t len) |
void | issue (uint16_t addr, uint8_t cmd) |
Protected Attributes | |
Driver | m_sock [SOCK_MAX] |
CommonRegister * | m_creg |
uint16_t | m_local |
const uint8_t * | m_mac |
uint8_t | m_dns [4] |
Static Protected Attributes | |
static const uint16_t | COMMON_REGISTER_BASE = 0x0000 |
static const uint16_t | COMMON_REGISTER_SIZE = sizeof(CommonRegister) |
static const uint16_t | SOCKET_REGISTER_BASE = 0x0400 |
static const uint16_t | SOCKET_REGISTER_SIZE = sizeof(SocketRegister) |
static const uint16_t | TX_MEMORY_BASE = 0x4000 |
static const uint16_t | TX_MEMORY_MAX = 0x2000 |
static const uint16_t | RX_MEMORY_BASE = 0x6000 |
static const uint16_t | RX_MEMORY_MAX = 0x2000 |
static const size_t | BUF_MAX = 2048 |
static const uint16_t | BUF_MASK = 0x07ff |
static const uint8_t | TX_MEMORY_SIZE = 0x55 |
static const uint8_t | RX_MEMORY_SIZE = 0x55 |
static const size_t | MSG_MAX = BUF_MAX / 2 |
static const uint8_t | SOCK_MAX = 4 |
static const uint8_t | DNS_RETRY_MAX = 4 |
Private Member Functions | |
void | set_clock (Clock rate) |
void | set_clock (uint32_t freq) |
Static Private Member Functions | |
static Clock | clock (uint32_t freq) |
static Clock | cycle (uint16_t ns) |
Private Attributes | |
Driver * | m_next |
List of drivers. More... | |
Interrupt::Handler * | m_irq |
Interrupt handler. More... | |
OutputPin | m_cs |
Device chip select pin. More... | |
Pulse | m_pulse |
Chip select pulse width. More... | |
uint8_t | m_spcr |
SPI/SPCR hardware control register setting. More... | |
uint8_t | m_spsr |
SPI/SPSR hardware status register. More... | |
Cosa WIZnet W5100 device driver class. Provides an implementation of the Cosa Socket and Cosa IOStream::Device classes. A socket may be bound directly to a Cosa IOStream. The device internal transmitter buffer is used. The buffer is sent on flush (TCP/UDP) or when full (TCP). Integrated with Cosa INET/DHCP so that the ethernet controller may obtain a network address and information from a DHCP server.
|
protected |
|
protected |
Interrupt Register bitfields, pp. 22.
Enumerator | |
---|---|
IR_CONFLICT |
IP Conflict. |
IR_UNREACH |
Destination unreachable. |
IR_PPPoE |
PPPoE Connection Close. |
IR_S3_INT | |
IR_S2_INT | |
IR_S1_INT | |
IR_S0_INT |
|
protected |
Interrupt Mask Register bitfields, pp. 23.
Enumerator | |
---|---|
IMR_CONFLICT |
Mask IP Conflict. |
IMR_UNREACH |
Mask Destination unreachable. |
IMR_PPPoE |
Mask PPPoE Connection Close. |
IMR_S3_INT | |
IMR_S2_INT | |
IMR_S1_INT | |
IMR_S0_INT |
|
protected |
|
protected |
Socket Mode Register bitfields, pp. 26.
|
protected |
Socket Command Register values, pp. 27-28.
|
protected |
|
protected |
|
protected |
W5100::W5100 | ( | const uint8_t * | mac = NULL , |
Board::DigitalPin | csn = Board::D10 |
||
) |
Construct W5100 device driver with given hardware address, and chip select.
[in] | mac | hardware address (in program memory, default NULL). |
[in] | csn | chip selection pin (Default D10). |
void W5100::addr | ( | uint8_t | ip[4], |
uint8_t | subnet[4] | ||
) |
Get the current network address and subnet mask.
[in] | ip | network address. |
[in] | subnet | mask. |
Initiate W5100 device driver with given network address and subnet mask. Returns true if successful otherwise false.
[in] | ip | network address (Default NULL, 0.0.0.0). |
[in] | subnet | mask (Default NULL, 0.0.0.0). |
[in] | timeout | retry timeout period (Default 500 ms). |
bool W5100::begin_P | ( | const char * | hostname, |
uint16_t | timeout = 500 |
||
) |
|
inline |
int W5100::bind | ( | uint8_t | ip[4], |
uint8_t | subnet[4], | ||
uint8_t | gateway[4] = NULL |
||
) |
Bind to the given network address and subnet mask. Returns zero if successful otherwise negative error code.
[in] | ip | network address. |
[in] | subnet | mask. |
[in] | gateway | network address (Default NULL). |
|
inline |
bool W5100::end | ( | ) |
Terminate W5100 device driver. Closes all active sockets. Return true if successful otherwise false.
|
protected |
Issue given command to register with given address and await completion.
[in] | addr | address on device. |
[in] | cmd | command to issue. |
|
protected |
Read byte from given address.
[in] | addr | address on device. |
|
protected |
Socket* W5100::socket | ( | Socket::Protocol | proto, |
uint16_t | port = 0 , |
||
uint8_t | flag = 0 |
||
) |
Allocate socket with the given protocol, port and flags. Returns pointer to socket. The socket is deallocated with Socket::close().
[in] | proto | socket protocol. |
[in] | port | number (Default 0). |
[in] | flag | (Default 0). |
|
inlineprotected |
|
protected |
|
inlineprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
protected |
|
protected |
|
protected |
|
protected |
|
static |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |
|
staticprotected |