X-Git-Url: http://rtime.felk.cvut.cz/gitweb/pes-rpp/rpp-lib.git/blobdiff_plain/70cb8ee4c1219d5a8bb476f73d1d5aad533eac14..96013f29ca870065ad02502fcd26e8fb6c6cafc0:/rpp/src/rpp/eth.c diff --git a/rpp/src/rpp/eth.c b/rpp/src/rpp/eth.c index 1379fba..0d3fd72 100644 --- a/rpp/src/rpp/eth.c +++ b/rpp/src/rpp/eth.c @@ -1,5 +1,6 @@ /** * Copyright (c) 2001-2004 Swedish Institute of Computer Science. + * Copyright (C) 2013-2015 Czech Technical University in Prague * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -27,6 +28,9 @@ * This file is part of the lwIP TCP/IP stack. * * Author: Adam Dunkels + * Carlos Jenkins + * Rostislav Lisovy + * Jan Doležal * */ @@ -37,26 +41,6 @@ * interface driver for lwIP. * */ -/* Copyright (C) 2013-2014 Czech Technical University in Prague - * - * Authors: - * - Carlos Jenkins - * - Rostislav Lisovy - * - Jan Doležal - * - * This document contains proprietary information belonging to Czech - * Technical University in Prague. Passing on and copying of this - * document, and communication of its contents is not permitted - * without prior written authorization. - * - * File: eth.c - * Abstract: - * Ethernet Communication RPP API implementation file. Using one PHY. - * - * References: - * eth.h - * RPP API documentation. - */ #include "rpp/rpp.h" @@ -76,7 +60,7 @@ #include "netif/ppp_oe.h" /* end - lwIP headers */ -#include "hal/hal.h" +#include "drv/digital_io.h" #include "sys/sys.h" /* includes - sys/phy_dp83848h.h */ #include "drv/emac.h" #include "os/os.h" @@ -274,7 +258,7 @@ err_t rpp_eth_hw_init_postInit(struct netif *netif); * * @note mac_addr[0] is considered MSB */ -void hdkif_macaddrset(u32_t inst_num, u8_t *mac_addr) +static void hdkif_macaddrset(u32_t inst_num, u8_t *mac_addr) { struct hdkif *hdkif; u32_t temp; @@ -352,7 +336,6 @@ int8_t rpp_eth_init_postInit(uint32_t instNum, uint8_t *macArray) struct ip_addr net_mask; struct ip_addr gw_addr; int8_t retVal = SUCCESS; - int ret; struct netif *netif = &hdkNetIF[instNum]; struct netif *netif_tmp; u8_t mac_addr[MAC_ADDR_LEN] = RPP_MAC_ADDR; @@ -426,7 +409,7 @@ int8_t rpp_eth_init_postInit(uint32_t instNum, uint8_t *macArray) #if STATIC_IP_ADDRESS netif_set_up(netif); #elif LWIP_DHCP - ret = dhcp_start(netif); + int ret = dhcp_start(netif); if (ret != ERR_OK) { rpp_debug_printf("dhcp mem err\r\n"); return DHCP_MEM_ERR; @@ -513,7 +496,7 @@ err_t rpp_eth_lwip_init(struct netif *netif) } #define INIT_ONLY_AFTER_RESET 1 // FIXME Why? Wat? Wut? For future implementation? -err_t rpp_eth_hw_init(struct hdkif *hdkif) +static err_t rpp_eth_hw_init(struct hdkif *hdkif) { uint8_t index; uint16_t regContent; @@ -538,16 +521,17 @@ err_t rpp_eth_hw_init(struct hdkif *hdkif) */ index = configCPU_CLOCK_HZ/1000000; #endif /* NO_SYS */ - hal_gpio_pin_set_value(*hal_gpio_pin_get_dsc(PIN_NAME_ETHRST, -1), 0); - while(index--) - ; + dio_gpio_pin_set_value(*dio_gpio_pin_get_dsc(PIN_NAME_ETHRST, -1), 0); + while (index--) ; #endif /* !INIT_ONLY_AFTER_RESET */ + /* we have pull-down resistor, so after reset, we only need to put ETHRST pin to log. high */ + dio_gpio_pin_set_value(*dio_gpio_pin_get_dsc(DIO_PIN_NAME_ETHRST, -1), 1); /* * 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); + dio_gpio_pin_set_value(*dio_gpio_pin_get_dsc(DIO_PIN_NAME_ETHRST, -1), 1); /* Initialize EMAC control module and EMAC module */ EMACInit(hdkif->emac_ctrl_base, hdkif->emac_base); @@ -638,7 +622,7 @@ err_t rpp_eth_hw_init(struct hdkif *hdkif) return SUCCESS; } -err_t rpp_eth_hw_init_postInit(struct netif *netif) +static err_t rpp_eth_hw_init_postInit(struct netif *netif) { /* 0x3FFFFFFF is for 80MHz aproximately 13s */ volatile unsigned int autonegFinishWait = 0x3FFFFFFF; @@ -887,7 +871,7 @@ err_t rpp_eth_send(struct netif *netif, struct pbuf *p) /** * When called from rpp_eth_send(), the 'lev' lock is held */ -err_t rpp_eth_send_raw(struct netif *netif, struct pbuf *pbuf) +static err_t rpp_eth_send_raw(struct netif *netif, struct pbuf *pbuf) { struct pbuf *q; struct txch *txch; @@ -1062,9 +1046,9 @@ void rpp_eth_recv_raw_thr(void *arg) volatile struct emac_rx_bd *curr_bd; volatile struct emac_rx_bd *curr_tail; volatile struct emac_rx_bd *curr_head; - volatile struct pbuf *pbuf; - volatile struct pbuf *new_pbuf; - volatile struct pbuf *q; + struct pbuf *pbuf; + struct pbuf *new_pbuf; + struct pbuf *q; hdkif = netif->state; rxch = &(hdkif->rxch);