/* emac instance number */
u32_t inst_num;
- u8_t mac_addr[6];
+ u8_t mac_addr[MAC_ADDR_LEN];
/* emac base address */
u32_t emac_base;
return rpp_eth_hw_init_postInit(netif);
}
+#define INIT_ONLY_AFTER_RESET 1
err_t rpp_eth_hw_init(struct hdkif *hdkif)
{
- /* FIXME: express initial index using defines */
- uint8_t index = 80; /* Initially used to hw reset of PHY connected to GIO pin 'rpp project only'; 1us - according to PHY specification. */
+ uint8_t index = configCPU_CLOCK_HZ/1000000;; /* Initially used to hw reset of PHY connected to GIO pin 'rpp project only'; 1us - according to PHY specification. */
uint16_t regContent;
uint32_t physAlive;
/* Deactivate reset pin of PHY */
/* for hw reset of PHY, it is necessary that PIN_NAME_ETHRST is 1us logical low state, before putting it to logical high */
- /* we have pull-down resistor, so after reset, we only need to put ETHRST pin to log. high */
+#if !INIT_ONLY_AFTER_RESET
hal_gpio_pin_set_value(*hal_gpio_pin_get_dsc(PIN_NAME_ETHRST,-1),0);
while(index--);
+#endif
+ /* we have pull-down resistor, so after reset, we only need to put ETHRST pin to log. high */
hal_gpio_pin_set_value(*hal_gpio_pin_get_dsc(PIN_NAME_ETHRST,-1),1);
/* initializes EMAC control module and EMAC module */
for (regContent = 0; regContent < 8; regContent++) /* i..channel_number */
EMACMACAddrSet(hdkif->emac_base, regContent, hdkif->mac_addr, EMAC_MACADDR_NO_MATCH_NO_FILTER);
- /* wait for autonegotiation to be done - XXX: autoneg still don't have to be done, you need to check if LINK is up in user app, using eth api fnc or netif api fnc */
+ /* wait for autonegotiation to be done or continue, when delay was reached */
#if !NO_SYS
uint32_t timeToWake = hdkif->waitTicksForPHYAneg + sys_jiffies();
- while(hdkif->phy_autoneg_is_done(hdkif->mdio_base, hdkif->phy_addr) == FALSE && timeToWake > sys_jiffies())vTaskDelay(20); /* XXX: if init is not done at the startup, this might cause troubles */
+ while(hdkif->phy_autoneg_is_done(hdkif->mdio_base, hdkif->phy_addr) == FALSE && timeToWake > sys_jiffies())vTaskDelay(20); /* XXX: if init is not done at the startup, but couple days later, this might cause troubles */
#else
while(hdkif->phy_autoneg_is_done(hdkif->mdio_base, hdkif->phy_addr) == FALSE && autonegFinishWait--); /* wait till aneg done */
#endif
rpp_debug_printf((const char *) "aneg timeout \r\n");
#endif
- /* check if phy link is up - it is when autoneg was completed succesfully */
-/* if(!PHY_link_status_get(hdkif->mdio_base, hdkif->phy_addr, 3))
- {
-#ifdef DEBUG
- rpp_debug_printf((const char *) "Link is down\r\n");
-#endif
- return PHY_LINK_DOWN;
- }*/
-
/* provide informations retrieved from autoneg to EMAC module */
hdkif->phy_partnerability(hdkif->mdio_base, hdkif->phy_addr, ®Content);
if (regContent & (PHY_100BASETXDUPL_m | PHY_10BASETDUPL_m)) {
vim_mask_set(RXinterruptVectorNumber);
sys_arch_sem_wait(&(hdkif->goRX), 0);
/* TODO: this place is candidate for LINKINT polling (if not solved through interrupt later) */
- //xSemaphoreTake( hdkif->goRX, 0 );
#endif
/* Get the bd which contains the earliest filled data */