Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of WIZnetInterface_Ricky by
Diff: arch/int/W7500x_toe.h
- Revision:
- 14:2101ab5ee40f
- Parent:
- 8:4c02de1dbf3a
- Child:
- 20:5a1969320666
--- a/arch/int/W7500x_toe.h Tue Jun 16 13:03:28 2015 +0900 +++ b/arch/int/W7500x_toe.h Wed Jun 17 00:24:45 2015 +0000 @@ -249,7 +249,7 @@ template<typename T> T reg_rd(uint16_t addr, uint8_t cb) { - uint8_t buf[sizeof(T)]; + uint8_t buf[sizeof(T)] = {0,}; for(int i = 0; i < sizeof(buf); i++) { // Little Endian to Big Endian buf[i] = *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)((cb<<16)+addr)+i); } @@ -263,33 +263,16 @@ return *reinterpret_cast<T*>(buf); } - void reg_rd_mac(uint16_t addr, uint8_t* data) { - data[0] = *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+3)); - data[1] = *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+2)); - data[2] = *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+1)); - data[3] = *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+0)); - data[4] = *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+7)); - data[5] = *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+6)); - } + void reg_rd_mac(uint16_t addr, uint8_t* data); + + void reg_wr_ip(uint16_t addr, uint8_t cb, const char* ip); - void reg_wr_ip(uint16_t addr, uint8_t cb, const char* ip) { - uint8_t buf[4]; - uint32_t wr_ip = 0; - char* p = (char*)ip; - for(int i = 0; i < 4; i++) { - wr_ip = (wr_ip<<8); - buf[i] = atoi(p); - wr_ip |= buf[i]; - p = strchr(p, '.'); - if (p == NULL) break; - p++; - } - *(volatile uint32_t *)(W7500x_WZTOE_BASE + (uint32_t)((cb<<16)+addr)) = wr_ip; - } + void sreg_ip(int socket, uint16_t addr, const char* ip); - void sreg_ip(int socket, uint16_t addr, const char* ip) { - reg_wr_ip(addr, (uint8_t)(0x01+(socket<<2)), ip); - } + int ethernet_link(void); + + void ethernet_set_link(int speed, int duplex); + protected: uint8_t mac[6]; @@ -310,8 +293,6 @@ *(volatile uint8_t *)(W7500x_WZTOE_BASE + (uint32_t)(addr+6)) = data[5] ; } }; -extern int ethernet_link(void); -extern void ethernet_set_link(int speed, int duplex); extern uint32_t str_to_ip(const char* str); extern void printfBytes(char* str, uint8_t* buf, int len);