From ab40eaf9ac5b43e7087588fe7f435bdbc9a6eb23 Mon Sep 17 00:00:00 2001 From: lottaviano Date: Tue, 24 May 2011 13:41:11 +0000 Subject: [PATCH] Make MAC address configurable using hw files. Users can now modify the hw_eth.c file to change MAC address. Adjust the drivers accordingly. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@4920 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cpu/arm/drv/eth_at91.c | 7 ----- bertos/cpu/cortex-m3/drv/eth_sam3.c | 7 ----- bertos/drv/eth.h | 5 ++-- bertos/hw/hw_eth.c | 40 ++++++++++++++++++++++++++ bertos/hw/hw_eth.h | 44 +++++++++++++++++++++++++++++ 5 files changed, 86 insertions(+), 17 deletions(-) create mode 100644 bertos/hw/hw_eth.c create mode 100644 bertos/hw/hw_eth.h diff --git a/bertos/cpu/arm/drv/eth_at91.c b/bertos/cpu/arm/drv/eth_at91.c index 529d7af4..4f19fca1 100644 --- a/bertos/cpu/arm/drv/eth_at91.c +++ b/bertos/cpu/arm/drv/eth_at91.c @@ -67,13 +67,6 @@ #define EMAC_RX_INTS (BV(EMAC_RCOMP) | BV(EMAC_ROVR) | BV(EMAC_RXUBR)) #define EMAC_TX_INTS (BV(EMAC_TCOMP) | BV(EMAC_TXUBR) | BV(EMAC_RLEX)) -/* - * MAC address configuration (please change this in your project!). - * - * TODO: make this paramater user-configurable from the Wizard. - */ -const uint8_t mac_addr[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 }; - /* Silent Doxygen bug... */ #ifndef __doxygen__ /* diff --git a/bertos/cpu/cortex-m3/drv/eth_sam3.c b/bertos/cpu/cortex-m3/drv/eth_sam3.c index 0247f618..f83dba72 100644 --- a/bertos/cpu/cortex-m3/drv/eth_sam3.c +++ b/bertos/cpu/cortex-m3/drv/eth_sam3.c @@ -72,13 +72,6 @@ #define EMAC_RX_INTS (BV(EMAC_RCOMP) | BV(EMAC_ROVR) | BV(EMAC_RXUBR)) #define EMAC_TX_INTS (BV(EMAC_TCOMP) | BV(EMAC_TXUBR) | BV(EMAC_RLEX)) -/* - * MAC address configuration (please change this in your project!). - * - * TODO: make this paramater user-configurable from the Wizard. - */ -const uint8_t mac_addr[] = { 0x00, 0x45, 0x56, 0x78, 0x9a, 0xbc }; - /* Silent Doxygen bug... */ #ifndef __doxygen__ /* diff --git a/bertos/drv/eth.h b/bertos/drv/eth.h index 57ce35f4..786e7979 100644 --- a/bertos/drv/eth.h +++ b/bertos/drv/eth.h @@ -37,12 +37,13 @@ * $WIZ$ module_name = "eth" * $WIZ$ module_configuration = "bertos/cfg/cfg_eth.h" * $WIZ$ module_supports = "at91sam7x or sam3x" - * $WIZ$ module_depends = "timer" + * $WIZ$ module_hw = "bertos/hw/hw_eth.h", "bertos/hw/hw_eth.c" */ #ifndef DRV_ETH_H #define DRV_ETH_H +#include "hw/hw_eth.h" #include #define ETH_ADDR_LEN 6 @@ -131,6 +132,4 @@ ssize_t eth_recv(uint8_t *buf, size_t len); int eth_init(void); -extern const uint8_t mac_addr[ETH_ADDR_LEN]; - #endif /* DRV_ETH_H */ diff --git a/bertos/hw/hw_eth.c b/bertos/hw/hw_eth.c new file mode 100644 index 00000000..c24cbfb0 --- /dev/null +++ b/bertos/hw/hw_eth.c @@ -0,0 +1,40 @@ +/** + * \file + * + * + * \brief MAC address definition + * + * \author Luca Ottaviano + */ + +#include "hw/hw_eth.h" + +uint8_t mac_addr[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 }; diff --git a/bertos/hw/hw_eth.h b/bertos/hw/hw_eth.h new file mode 100644 index 00000000..71c2ac89 --- /dev/null +++ b/bertos/hw/hw_eth.h @@ -0,0 +1,44 @@ +/** + * \file + * + * + * \brief MAC address definition + * + * \author Luca Ottaviano + */ +#ifndef HW_ETH_H +#define HW_ETH_H + +#include + +extern uint8_t mac_addr[6]; + +#endif // HW_ETH_H -- 2.25.1