Version V3.0

Add to W5300
This commit is contained in:
Woo Youl Kim
2015-06-04 20:41:00 +09:00
parent bd4a3a8d55
commit 1e940bbf14
14 changed files with 3153 additions and 219 deletions

View File

@ -59,9 +59,14 @@ void WIZCHIP_WRITE(uint32_t AddrSel, uint8_t wb )
#elif ( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_) )
//add indirect bus
WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x000000FF));
WIZCHIP.IF.BUS._write_byte(IDM_DR,wb);
//M20150601 : Rename the function for integrating with W5300
//WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
//WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x000000FF));
//WIZCHIP.IF.BUS._write_byte(IDM_DR,wb);
WIZCHIP.IF.BUS._write_data(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
WIZCHIP.IF.BUS._write_data(IDM_AR1,(AddrSel & 0x000000FF));
WIZCHIP.IF.BUS._write_data(IDM_DR,wb);
#else
#error "Unknown _WIZCHIP_IO_MODE_ in W5200. !!!"
#endif
@ -89,9 +94,13 @@ uint8_t WIZCHIP_READ(uint32_t AddrSel)
#elif ( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_) )
//add indirect bus
WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x000000FF));
ret = WIZCHIP.IF.BUS._read_byte(IDM_DR);
//M20150601 : Rename the function for integrating with W5300
//WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
//WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x000000FF));
//ret = WIZCHIP.IF.BUS._read_byte(IDM_DR);
WIZCHIP.IF.BUS._write_data(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
WIZCHIP.IF.BUS._write_data(IDM_AR1,(AddrSel & 0x000000FF));
ret = WIZCHIP.IF.BUS._read_data(IDM_DR);
#else
#error "Unknown _WIZCHIP_IO_MODE_ in W5200. !!!"
@ -121,12 +130,21 @@ void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len)
WIZCHIP.IF.SPI._write_byte(pBuf[i]);
#elif ( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_) )
WIZCHIP_WRITE(MR,WIZCHIP_READ(MR) | MR_AI);
WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x000000FF));
for(i = 0 ; i < len; i++)
WIZCHIP.IF.BUS._write_byte(IDM_DR,pBuf[i]);
WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) & ~MR_AI);
//M20150601 : Rename the function for integrating with W5300
/*
WIZCHIP_WRITE(MR,WIZCHIP_READ(MR) | MR_AI);
WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x000000FF));
for(i = 0 ; i < len; i++)
WIZCHIP.IF.BUS._write_byte(IDM_DR,pBuf[i]);
WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) & ~MR_AI);
*/
setMR(getMR() | MR_AI);
WIZCHIP.IF.BUS._write_data(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
WIZCHIP.IF.BUS._write_data(IDM_AR1,(AddrSel & 0x000000FF));
for(i = 0 ; i < len; i++)
WIZCHIP.IF.BUS._write_data(IDM_DR,pBuf[i]);
WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) & ~MR_AI);
#else
#error "Unknown _WIZCHIP_IO_MODE_ in W5200. !!!!"
#endif
@ -138,7 +156,6 @@ void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len)
/**
@brief This function reads into W5200 memory(Buffer)
*/
void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len)
{
uint16_t i = 0;
@ -154,12 +171,21 @@ void WIZCHIP_READ_BUF (uint32_t AddrSel, uint8_t* pBuf, uint16_t len)
pBuf[i] = WIZCHIP.IF.SPI._read_byte();
#elif ( (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_BUS_) )
WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) | MR_AI);
WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x000000FF));
for(i = 0 ; i < len; i++)
pBuf[i] = WIZCHIP.IF.BUS._read_byte(IDM_DR);
WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) & ~MR_AI);
//M20150601 : Rename the function for integrating with W5300
/*
WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) | MR_AI);
WIZCHIP.IF.BUS._write_byte(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
WIZCHIP.IF.BUS._write_byte(IDM_AR1,(AddrSel & 0x000000FF));
for(i = 0 ; i < len; i++)
pBuf[i] = WIZCHIP.IF.BUS._read_byte(IDM_DR);
WIZCHIP_WRITE(MR, WIZCHIP_READ(MR) & ~MR_AI);
*/
setMR(getMR() | MR_AI);
WIZCHIP.IF.BUS._write_data(IDM_AR0,(AddrSel & 0x0000FF00) >> 8);
WIZCHIP.IF.BUS._write_data(IDM_AR1,(AddrSel & 0x000000FF));
for(i = 0 ; i < len; i++)
pBuf[i] = WIZCHIP.IF.BUS._read_data(IDM_DR);
setMR(getMR() & ~MR_AI);
#else
#error "Unknown _WIZCHIP_IO_MODE_ in W5200. !!!!"
#endif

View File

@ -43,7 +43,9 @@
#include <stdint.h>
#include "wizchip_conf.h"
/// \cond DOXY_APPLY_CODE
#if (_WIZCHIP_ == 5200)
/// \endcond
#define _WIZCHIP_SN_BASE_ (0x4000)
#define _WIZCHIP_SN_SIZE_ (0x0100)
@ -265,7 +267,7 @@
/**
* @ingroup Common_register_group_W5200
* @brief Timeout register address( 1 is 100us )(R/W)
* @details \ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of \ref _RTR_ is x07D0or 000
* @details \ref _RTR_ configures the retransmission timeout period. The unit of timeout period is 100us and the default of \ref _RTR_ is x07D0.
* And so the default timeout period is 200ms(100us X 2000). During the time configured by \ref _RTR_, W5200 waits for the peer response
* to the packet that is transmitted by \ref Sn_CR (CONNECT, DISCON, CLOSE, SEND, SEND_MAC, SEND_KEEP command).
* If the peer does not respond within the \ref _RTR_ time, W5200 retransmits the packet or issues timeout.
@ -276,7 +278,7 @@
* @ingroup Common_register_group_W5200
* @brief Retry count register(R/W)
* @details \ref _RCR_ configures the number of time of retransmission.
* When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (\ref Sn_IR[TIMEOUT] = '1').
* When retransmission occurs as many as ref _RCR_+1 Timeout interrupt is issued (\ref Sn_IR_TIMEOUT = '1').
*/
#define _RCR_ (_W5200_IO_BASE_ + (0x0019)) // Retry Count
@ -502,7 +504,7 @@
* @ingroup Socket_register_group_W5200
* @brief source port register(R/W)
* @details \ref Sn_PORT configures the source port number of Socket n.
* It is valid when Socket n is used in TCP/UPD mode. It should be set before OPEN command is ordered.
* It is valid when Socket n is used in TCP/UDP mode. It should be set before OPEN command is ordered.
*/
#define Sn_PORT(sn) (_W5200_IO_BASE_ + WIZCHIP_SREG_BLOCK(sn) + (0x0004)) // source port register
@ -1107,7 +1109,7 @@
/**
* @brief UDP socket
* @details This indicates Socket n is opened in UDP mode(Sn_MR(P[3:0]) = 010).\n
* It changes to SOCK_UPD when Sn_MR(P[3:0]) = 010 and OPEN command is ordered.\n
* It changes to SOCK_UDP when Sn_MR(P[3:0]) = 010 and OPEN command is ordered.\n
* Unlike TCP mode, data can be transfered without the connection-process.
*/
#define SOCK_UDP 0x22 ///< udp socket
@ -1230,8 +1232,11 @@ void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len);
* @param (uint8_t)mr The value to be set.
* @sa getMR()
*/
#define setMR(mr) \
WIZCHIP_WRITE(MR,mr)
#if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
#define setMR(mr) WIZCHIP_WRITE(MR,mr)
#else
#define setMR(mr) (*((uint8_t*)MR) = mr)
#endif
/**
* @ingroup Common_register_access_function_W5200
@ -1239,8 +1244,11 @@ void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len);
* @return uint8_t. The value of Mode register.
* @sa setMR()
*/
#define getMR() \
WIZCHIP_READ(MR)
#if (_WIZCHIP_IO_MODE_ & _WIZCHIP_IO_MODE_SPI_)
#define getMR() WIZCHIP_READ(MR)
#else
#define getMR() (*(uint8_t*)MR)
#endif
/**
* @ingroup Common_register_access_function_W5200
@ -1743,8 +1751,13 @@ void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len);
* @param (uint8_t)proto Value to set \ref Sn_PROTO
* @sa getSn_PROTO()
*/
//M20150601 : Fixed Wrong Register address
/*
#define setSn_PROTO(sn, proto) \
WIZCHIP_WRITE(Sn_TOS(sn), tos)
*/
#define setSn_PROTO(sn, proto) \
WIZCHIP_WRITE(Sn_PROTO(sn), proto)
/**
* @ingroup Socket_register_access_function_W5200
@ -1753,8 +1766,13 @@ void WIZCHIP_WRITE_BUF(uint32_t AddrSel, uint8_t* pBuf, uint16_t len);
* @return uint8_t. Value of @ref Sn_PROTO.
* @sa setSn_PROTO()
*/
//M20150601 : Fixed Wrong Register address
/*
#define getSn_PROTO(sn) \
WIZCHIP_READ(Sn_TOS(sn))
*/
#define getSn_PROTO(sn) \
WIZCHIP_READ(Sn_PROTO(sn))
/**
* @ingroup Socket_register_access_function_W5200
@ -1907,7 +1925,7 @@ uint16_t getSn_RX_RSR(uint8_t sn);
* @ingroup Socket_register_access_function_W5200
* @brief Get @ref Sn_RX_RD register
* @param (uint8_t)sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>.
* @regurn uint16_t. Value of @ref Sn_RX_RD.
* @return uint16_t. Value of @ref Sn_RX_RD.
* @sa setSn_RX_RD()
*/
#define getSn_RX_RD(sn) \
@ -1960,7 +1978,7 @@ uint16_t getSn_RX_RSR(uint8_t sn);
* @brief Set @ref Sn_FRAG register
* @param (uint8_t)sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>.
* @param (uint16_t)frag Value to set \ref Sn_FRAG
* @sa getSn_FRAD()
* @sa getSn_FRAG()
*/
#define setSn_FRAG(sn, frag) { \
WIZCHIP_WRITE(Sn_FRAG(sn), (uint8_t)(frag >>8)); \
@ -2041,7 +2059,6 @@ uint16_t getSn_TxBASE(uint8_t sn);
* and updates the Tx write pointer register.
* This function is being called by send() and sendto() function also.
*
* @note User should read upper byte first and lower byte later to get proper value.
* @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>.
* @param wizdata Pointer buffer to write data
* @param len Data length
@ -2058,7 +2075,6 @@ void wiz_send_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
* to <i>wizdata(pointer variable)</i> of the length of <i>len(variable)</i> bytes.
* This function is being called by recv() also.
*
* @note User should read upper byte first and lower byte later to get proper value.
* @param sn Socket number. It should be <b>0 ~ @ref \_WIZCHIP_SOCK_NUM_</b>.
* @param wizdata Pointer buffer to read data
* @param len Data length
@ -2075,7 +2091,9 @@ void wiz_recv_data(uint8_t sn, uint8_t *wizdata, uint16_t len);
*/
void wiz_recv_ignore(uint8_t sn, uint16_t len);
/// \cond DOXY_APPLY_CODE
#endif
/// \endcond
#endif //_W5200_H_