2 * Ethernet Communication RPP API header file.
6 * @copyright Copyright (C) 2013 Czech Technical University in Prague
8 * @author Carlos Jenkins <carlos@jenkins.co.cr>
9 * @author Rostislav Lisový
10 * @author Jan Doležal <pm.jenik@gmail.com>
17 #include "lwip/netif.h"
19 /* this MAC address is used when user doesn't put the address to postInit function */
20 #define RPP_MAC_ADDR {0x12,0x34,0x56,0x78,0x9a,0xbc}
22 #define RPP_IP_ADDR 0xC0A8F701 /* 192.168.247.1 IP4_ADDR(rppip, 192,168,0,10); */
23 #define RPP_NETMASK 0xFFFFFF00 /* 255.255.255.0 IP4_ADDR(rppnetmask, 255,255,255,0); */
24 #define RPP_GW 0xC0A8F7FE /* 192.168.247.254 IP4_ADDR(rppgw, 192,168,0,254); */
27 #define NO_PHY_ALIVE -1
28 #define DFLT_PHY_NOT_ALIVE -1
29 #define UNKN_DUPLEX_MODE -2 /* this could mean that autonegotiation was not completed yet */
30 #define MACADDR_NOT_SET -3
31 #define PHY_LINK_DOWN -4
33 #define NETIF_ADD_ERR -10 /* could be one of previous */
34 #define DHCP_MEM_ERR -11
35 #define DHCP_BIND_TIMEOUT -12
38 * ETH module system startup initialization.
40 * Call this method before using this module.
41 * This method starts autonegotiation and doesn't check for end of autoneg.
42 * When eth module is about to be used, you have to run rpp_eth_init_postInit()
43 * first and you should check whether link is up.
45 * @return SUCCESS if initialization successful.\n
46 * FAILURE if module already initialized.
48 int8_t rpp_eth_init();
52 * ETH module application initialization.
54 * Call this method before using eth module.
55 * This method blocks on autonegotiation till it's complete and creates tasks
56 * for lwIP (including lwIP init) and for receiving. Sets IP address using
57 * predefined static IP or DHCP. Before calling this method you must call rpp_eth_init() first.
59 * @param instNum number of EMAC instance
60 * @param macArray address assigned to link layer - when NULL RPP_MAC_ADDR is used
61 * @param waitTicksForPHYAneg maximum amount of ticks it will wait for autonegotiation
63 * @return SUCCESS if init successful.
64 * NETIF_ADD_ERR if lwip netif was not succesfully initialized or on low hw init error.
65 * DHCP_MEM_ERR if DHCP unsuccesfull.
68 int8_t rpp_eth_init_postInit(uint32_t instNum, uint8_t *macArray);
73 * Handles too short packets, preserves the integrity of the transmission,
74 * calls rpp_et_send_raw()
76 * @param netif lwIP network interface describing struct
77 * @param p buffer for data to be sent
79 err_t rpp_eth_send(struct netif * netif, struct pbuf *p);
82 * Handles transmission of data buffer p through EMAC to network.
84 * @param netif lwIP network interface describing struct
85 * @param p buffer for data to be sent
87 err_t rpp_eth_send_raw(struct netif *netif, struct pbuf *p);
90 * Receives raw data and sends them upward to lwIP stack.
91 * Handles rx emac descriptors.
95 void rpp_eth_recv_raw(void *arg);
98 * Handles receiving by running rpp_eth_recv_raw()
100 * @param instNum number of EMAC instance
102 void RxIntHandler(u32_t instNum);
105 * Handles tx emac descriptors.
107 * @param instNum number of EMAC instance
109 void TxIntHandler(u32_t instNum);
111 #endif /* __RPP_ETH_H */