Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // socket.h
- struct skt_t {
- uint8_t *dst_mac;
- uint8_t *dst_ip;
- uint16_t base_addr;
- uint16_t tx_reg_addr;
- uint16_t rx_reg_addr;
- uint16_t src_port;
- uint16_t dst_port;
- uint8_t id;
- socket_sts status;
- socket_protocol protocol;
- uint8_t tx_memory_kb;
- uint8_t rx_memory_kb;
- uint8_t imr;
- } skt_t;
- void W5500_socket_init(struct skt_t *skt, socket_id socket, socket_protocol mode);
- void W5500_socket_open(struct skt_t *skt);
- // socket.c
- struct skt_t _skt[8];
- void W5500_socket_init(struct skt_t *skt, socket_id socket, socket_protocol mode)
- {
- // pointing to the 'socket' element on the _skt struct
- skt = &_skt[socket];
- // changing the configuration
- skt->base_addr = SKT_SOCKET_BASE(socket);
- skt->tx_reg_addr = SKT_TX_BASE(socket);
- skt->rx_reg_addr = SKT_RX_BASE(socket);
- skt->src_port = 0x0000;
- skt->status = SOCKET_STS_CLOSED;
- skt->protocol = mode;
- skt->tx_memory_kb = 2;
- skt->rx_memory_kb = 2;
- }
- // here i'm trying to access a member of the skt_t struct array i previously
- // accessed
- void W5500_socket_open(struct skt_t *skt)
- {
- if (skt->protocol == SOCKET_MODE_TCP) {
- LED_Write(1);
- }
- }
- // main.c
- // tcp_server will be a pointer to a member of the _skt struct array
- struct skt_t *tcp_server;
- int main(void)
- {
- // with this function i set _skt[0].protocol to SOCKET_MODE_TCP
- W5500_socket_init(tcp_server, 0, SOCKET_MODE_TCP);
- // after this function LED should be turned on
- // but it doesn't
- W5500_socket_open(tcp_server);
- while (1) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement