From ee0d07151a144a8425d8cfd0740098d1b76711c2 Mon Sep 17 00:00:00 2001 From: gdisirio Date: Sun, 27 Sep 2009 18:17:17 +0000 Subject: git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1191 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/io/mac.c | 10 +++++----- os/io/mac.h | 2 +- os/io/platforms/AT91SAM7X/mac_lld.c | 4 +++- os/io/platforms/AT91SAM7X/mac_lld.h | 2 +- os/io/templates/mac_lld.c | 2 +- os/io/templates/mac_lld.h | 2 +- 6 files changed, 12 insertions(+), 10 deletions(-) diff --git a/os/io/mac.c b/os/io/mac.c index d7c20df05..c9ee88317 100644 --- a/os/io/mac.c +++ b/os/io/mac.c @@ -65,7 +65,7 @@ void macObjectInit(MACDriver *macp) { * @note This function must be invoked only with the driver in the stopped * state. If invoked on an active interface then it is ignored. */ -void macSetAddress(MACDriver *macp, uint8_t *p) { +void macSetAddress(MACDriver *macp, const uint8_t *p) { mac_lld_set_address(macp, p); } @@ -91,8 +91,8 @@ MACTransmitDescriptor *macWaitTransmitDescriptor(MACDriver *macp, systime_t time) { MACTransmitDescriptor *tdp; - while ((time > 0) && - (tdp = max_lld_get_transmit_descriptor(macp, size)) == NULL) { + while (((tdp = max_lld_get_transmit_descriptor(macp, size)) == NULL) && + (time > 0)) { chSysLock(); systime_t now = chTimeNow(); if (chSemWaitTimeoutS(&tdsem, time) == RDY_TIMEOUT) { @@ -140,8 +140,8 @@ MACReceiveDescriptor *macWaitReceiveDescriptor(MACDriver *macp, systime_t time) { MACReceiveDescriptor *rdp; - while ((time > 0) && - (rdp = max_lld_get_receive_descriptor(macp, szp)) == NULL) { + while (((rdp = max_lld_get_receive_descriptor(macp, szp)) == NULL) && + (time > 0)) { chSysLock(); systime_t now = chTimeNow(); if (chSemWaitTimeoutS(&rdsem, time) == RDY_TIMEOUT) { diff --git a/os/io/mac.h b/os/io/mac.h index de2120ec4..9bbfa5cef 100644 --- a/os/io/mac.h +++ b/os/io/mac.h @@ -60,7 +60,7 @@ extern "C" { #endif void macInit(void); void macObjectInit(MACDriver *macp); - void macSetAddress(MACDriver *macp, uint8_t *p); + void macSetAddress(MACDriver *macp, const uint8_t *p); void macStart(MACDriver *macp); void macStop(MACDriver *macp); MACTransmitDescriptor *macWaitTransmitDescriptor(MACDriver *macp, diff --git a/os/io/platforms/AT91SAM7X/mac_lld.c b/os/io/platforms/AT91SAM7X/mac_lld.c index 7b0d4b86a..f218af15a 100644 --- a/os/io/platforms/AT91SAM7X/mac_lld.c +++ b/os/io/platforms/AT91SAM7X/mac_lld.c @@ -120,6 +120,7 @@ CH_IRQ_HANDLER(irq_handler) { void mac_lld_init(void) { unsigned i; + phyInit(); macObjectInit(&MAC1); /* @@ -183,6 +184,7 @@ void mac_lld_init(void) { /* * Interrupt configuration. */ + AT91C_BASE_EMAC->EMAC_IER = AT91C_EMAC_RCOMP | AT91C_EMAC_TCOMP; AIC_ConfigureIT(AT91C_ID_EMAC, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL | EMAC_INTERRUPT_PRIORITY, irq_handler); @@ -198,7 +200,7 @@ void mac_lld_init(void) { * used. The MAC address must be aligned with the most significant * byte first. */ -void mac_lld_set_address(MACDriver *macp, uint8_t *p) { +void mac_lld_set_address(MACDriver *macp, const uint8_t *p) { AT91C_BASE_EMAC->EMAC_SA1L = (AT91_REG)((p[2] << 24) | (p[3] << 16) | (p[4] << 8) | p[5]); diff --git a/os/io/platforms/AT91SAM7X/mac_lld.h b/os/io/platforms/AT91SAM7X/mac_lld.h index 05a8abb78..f414eb61f 100644 --- a/os/io/platforms/AT91SAM7X/mac_lld.h +++ b/os/io/platforms/AT91SAM7X/mac_lld.h @@ -134,7 +134,7 @@ extern MACDriver MAC1; extern "C" { #endif void mac_lld_init(void); - void mac_lld_set_address(MACDriver *macp, uint8_t *p); + void mac_lld_set_address(MACDriver *macp, const uint8_t *p); MACTransmitDescriptor *max_lld_get_transmit_descriptor(MACDriver *macp, size_t size); void mac_lld_release_transmit_descriptor(MACDriver *macp, diff --git a/os/io/templates/mac_lld.c b/os/io/templates/mac_lld.c index c9bac58c0..a780a32ff 100644 --- a/os/io/templates/mac_lld.c +++ b/os/io/templates/mac_lld.c @@ -42,7 +42,7 @@ void mac_lld_init(void) { * this parameter is set to @p NULL then a system default MAC is * used. */ -void mac_lld_set_address(MACDriver *macp, uint8_t *p) { +void mac_lld_set_address(MACDriver *macp, const uint8_t *p) { } diff --git a/os/io/templates/mac_lld.h b/os/io/templates/mac_lld.h index 10b84dc0f..377a18ea1 100644 --- a/os/io/templates/mac_lld.h +++ b/os/io/templates/mac_lld.h @@ -75,7 +75,7 @@ typedef struct { extern "C" { #endif void mac_lld_init(void); - void mac_lld_set_address(MACDriver *macp, uint8_t *p); + void mac_lld_set_address(MACDriver *macp, const uint8_t *p); MACTransmitDescriptor *max_lld_get_transmit_descriptor(MACDriver *macp, size_t size); void mac_lld_release_transmit_descriptor(MACDriver *macp, -- cgit v1.2.3