git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1191 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
gdisirio 2009-09-27 18:17:17 +00:00
parent 4c8314f804
commit ee0d07151a
6 changed files with 12 additions and 10 deletions

View File

@ -65,7 +65,7 @@ void macObjectInit(MACDriver *macp) {
* @note This function must be invoked only with the driver in the stopped * @note This function must be invoked only with the driver in the stopped
* state. If invoked on an active interface then it is ignored. * 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); mac_lld_set_address(macp, p);
} }
@ -91,8 +91,8 @@ MACTransmitDescriptor *macWaitTransmitDescriptor(MACDriver *macp,
systime_t time) { systime_t time) {
MACTransmitDescriptor *tdp; MACTransmitDescriptor *tdp;
while ((time > 0) && while (((tdp = max_lld_get_transmit_descriptor(macp, size)) == NULL) &&
(tdp = max_lld_get_transmit_descriptor(macp, size)) == NULL) { (time > 0)) {
chSysLock(); chSysLock();
systime_t now = chTimeNow(); systime_t now = chTimeNow();
if (chSemWaitTimeoutS(&tdsem, time) == RDY_TIMEOUT) { if (chSemWaitTimeoutS(&tdsem, time) == RDY_TIMEOUT) {
@ -140,8 +140,8 @@ MACReceiveDescriptor *macWaitReceiveDescriptor(MACDriver *macp,
systime_t time) { systime_t time) {
MACReceiveDescriptor *rdp; MACReceiveDescriptor *rdp;
while ((time > 0) && while (((rdp = max_lld_get_receive_descriptor(macp, szp)) == NULL) &&
(rdp = max_lld_get_receive_descriptor(macp, szp)) == NULL) { (time > 0)) {
chSysLock(); chSysLock();
systime_t now = chTimeNow(); systime_t now = chTimeNow();
if (chSemWaitTimeoutS(&rdsem, time) == RDY_TIMEOUT) { if (chSemWaitTimeoutS(&rdsem, time) == RDY_TIMEOUT) {

View File

@ -60,7 +60,7 @@ extern "C" {
#endif #endif
void macInit(void); void macInit(void);
void macObjectInit(MACDriver *macp); void macObjectInit(MACDriver *macp);
void macSetAddress(MACDriver *macp, uint8_t *p); void macSetAddress(MACDriver *macp, const uint8_t *p);
void macStart(MACDriver *macp); void macStart(MACDriver *macp);
void macStop(MACDriver *macp); void macStop(MACDriver *macp);
MACTransmitDescriptor *macWaitTransmitDescriptor(MACDriver *macp, MACTransmitDescriptor *macWaitTransmitDescriptor(MACDriver *macp,

View File

@ -120,6 +120,7 @@ CH_IRQ_HANDLER(irq_handler) {
void mac_lld_init(void) { void mac_lld_init(void) {
unsigned i; unsigned i;
phyInit();
macObjectInit(&MAC1); macObjectInit(&MAC1);
/* /*
@ -183,6 +184,7 @@ void mac_lld_init(void) {
/* /*
* Interrupt configuration. * Interrupt configuration.
*/ */
AT91C_BASE_EMAC->EMAC_IER = AT91C_EMAC_RCOMP | AT91C_EMAC_TCOMP;
AIC_ConfigureIT(AT91C_ID_EMAC, AIC_ConfigureIT(AT91C_ID_EMAC,
AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL | EMAC_INTERRUPT_PRIORITY, AT91C_AIC_SRCTYPE_INT_HIGH_LEVEL | EMAC_INTERRUPT_PRIORITY,
irq_handler); irq_handler);
@ -198,7 +200,7 @@ void mac_lld_init(void) {
* used. The MAC address must be aligned with the most significant * used. The MAC address must be aligned with the most significant
* byte first. * 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) | AT91C_BASE_EMAC->EMAC_SA1L = (AT91_REG)((p[2] << 24) | (p[3] << 16) |
(p[4] << 8) | p[5]); (p[4] << 8) | p[5]);

View File

@ -134,7 +134,7 @@ extern MACDriver MAC1;
extern "C" { extern "C" {
#endif #endif
void mac_lld_init(void); 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, MACTransmitDescriptor *max_lld_get_transmit_descriptor(MACDriver *macp,
size_t size); size_t size);
void mac_lld_release_transmit_descriptor(MACDriver *macp, void mac_lld_release_transmit_descriptor(MACDriver *macp,

View File

@ -42,7 +42,7 @@ void mac_lld_init(void) {
* this parameter is set to @p NULL then a system default MAC is * this parameter is set to @p NULL then a system default MAC is
* used. * used.
*/ */
void mac_lld_set_address(MACDriver *macp, uint8_t *p) { void mac_lld_set_address(MACDriver *macp, const uint8_t *p) {
} }

View File

@ -75,7 +75,7 @@ typedef struct {
extern "C" { extern "C" {
#endif #endif
void mac_lld_init(void); 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, MACTransmitDescriptor *max_lld_get_transmit_descriptor(MACDriver *macp,
size_t size); size_t size);
void mac_lld_release_transmit_descriptor(MACDriver *macp, void mac_lld_release_transmit_descriptor(MACDriver *macp,