git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@1474 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
parent
fe24da9fcc
commit
99563ecc3d
|
@ -30,6 +30,26 @@
|
||||||
|
|
||||||
#if CH_HAL_USE_MAC || defined(__DOXYGEN__)
|
#if CH_HAL_USE_MAC || defined(__DOXYGEN__)
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver exported variables. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver local variables. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver local functions. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver interrupt handlers. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver exported functions. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Low level MII driver initialization.
|
* @brief Low level MII driver initialization.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -29,6 +29,13 @@
|
||||||
|
|
||||||
#if CH_HAL_USE_MAC || defined(__DOXYGEN__)
|
#if CH_HAL_USE_MAC || defined(__DOXYGEN__)
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver constants. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#define PHY_MICREL_KS8721 0
|
||||||
|
#define PHY_DAVICOM_9161 1
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver pre-compile time settings. */
|
/* Driver pre-compile time settings. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -41,12 +48,9 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* PHY specific constants. */
|
/* Derived constants and error checks. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
#define PHY_MICREL_KS8721 0
|
|
||||||
#define PHY_DAVICOM_9161 1
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Pins latched by the PHY at reset.
|
* @brief Pins latched by the PHY at reset.
|
||||||
*/
|
*/
|
||||||
|
@ -83,6 +87,10 @@ typedef uint16_t phyreg_t;
|
||||||
*/
|
*/
|
||||||
typedef uint8_t phyaddr_t;
|
typedef uint8_t phyaddr_t;
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver macros. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* External declarations. */
|
/* External declarations. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -28,11 +28,11 @@
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Low Level Driver exported variables. */
|
/* Driver exported variables. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Low Level Driver local variables. */
|
/* Driver local variables. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -49,11 +49,11 @@ const AT91SAM7PIOConfig pal_default_config =
|
||||||
};
|
};
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Low Level Driver local functions. */
|
/* Driver local functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Low Level Driver interrupt handlers. */
|
/* Driver interrupt handlers. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
static CH_IRQ_HANDLER(spurious_handler) {
|
static CH_IRQ_HANDLER(spurious_handler) {
|
||||||
|
@ -68,7 +68,7 @@ static CH_IRQ_HANDLER(spurious_handler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Low Level Driver exported functions. */
|
/* Driver exported functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -52,10 +52,18 @@
|
||||||
#define AT91SAM7_USBDIV AT91C_CKGR_USBDIV_1
|
#define AT91SAM7_USBDIV AT91C_CKGR_USBDIV_1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Derived constants and error checks. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver data structures and types. */
|
/* Driver data structures and types. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver macros. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* External declarations. */
|
/* External declarations. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -33,11 +33,6 @@
|
||||||
|
|
||||||
#if CH_HAL_USE_MAC || defined(__DOXYGEN__)
|
#if CH_HAL_USE_MAC || defined(__DOXYGEN__)
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Ethernet driver 1.
|
|
||||||
*/
|
|
||||||
MACDriver ETH1;
|
|
||||||
|
|
||||||
#define EMAC_PIN_MASK (AT91C_PB0_ETXCK_EREFCK | AT91C_PB1_ETXEN | \
|
#define EMAC_PIN_MASK (AT91C_PB0_ETXCK_EREFCK | AT91C_PB1_ETXEN | \
|
||||||
AT91C_PB2_ETX0 | AT91C_PB3_ETX1 | \
|
AT91C_PB2_ETX0 | AT91C_PB3_ETX1 | \
|
||||||
AT91C_PB4_ECRS | AT91C_PB5_ERX0 | \
|
AT91C_PB4_ECRS | AT91C_PB5_ERX0 | \
|
||||||
|
@ -53,6 +48,19 @@ MACDriver ETH1;
|
||||||
#define TSR_BITS (AT91C_EMAC_UBR | AT91C_EMAC_COL | AT91C_EMAC_RLES | \
|
#define TSR_BITS (AT91C_EMAC_UBR | AT91C_EMAC_COL | AT91C_EMAC_RLES | \
|
||||||
AT91C_EMAC_BEX | AT91C_EMAC_COMP | AT91C_EMAC_UND)
|
AT91C_EMAC_BEX | AT91C_EMAC_COMP | AT91C_EMAC_UND)
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver exported variables. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Ethernet driver 1.
|
||||||
|
*/
|
||||||
|
MACDriver ETH1;
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver local variables. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
#ifndef __DOXYGEN__
|
#ifndef __DOXYGEN__
|
||||||
static bool_t link_up;
|
static bool_t link_up;
|
||||||
|
|
||||||
|
@ -70,6 +78,10 @@ static uint8_t tb[EMAC_TRANSMIT_DESCRIPTORS * EMAC_TRANSMIT_BUFFERS_SIZE]
|
||||||
__attribute__((aligned(8)));
|
__attribute__((aligned(8)));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver local functions. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief IRQ handler.
|
* @brief IRQ handler.
|
||||||
*/
|
*/
|
||||||
|
@ -107,6 +119,23 @@ static void serve_interrupt(void) {
|
||||||
AT91C_BASE_AIC->AIC_EOICR = 0;
|
AT91C_BASE_AIC->AIC_EOICR = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Cleans an incomplete frame.
|
||||||
|
* @param from the start position of the incomplete frame
|
||||||
|
*/
|
||||||
|
static void cleanup(EMACDescriptor *from) {
|
||||||
|
|
||||||
|
while (from != rxptr) {
|
||||||
|
from->w1 &= ~W1_R_OWNERSHIP;
|
||||||
|
if (++from >= &rd[EMAC_RECEIVE_DESCRIPTORS])
|
||||||
|
from = rd;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver interrupt handlers. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief EMAC IRQ veneer handler.
|
* @brief EMAC IRQ veneer handler.
|
||||||
*/
|
*/
|
||||||
|
@ -119,6 +148,10 @@ CH_IRQ_HANDLER(irq_handler) {
|
||||||
CH_IRQ_EPILOGUE();
|
CH_IRQ_EPILOGUE();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver exported functions. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Low level MAC initialization.
|
* @brief Low level MAC initialization.
|
||||||
*/
|
*/
|
||||||
|
@ -295,19 +328,6 @@ void mac_lld_release_transmit_descriptor(MACTransmitDescriptor *tdp) {
|
||||||
chSysUnlock();
|
chSysUnlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Cleans an incomplete frame.
|
|
||||||
* @param from the start position of the incomplete frame
|
|
||||||
*/
|
|
||||||
static void cleanup(EMACDescriptor *from) {
|
|
||||||
|
|
||||||
while (from != rxptr) {
|
|
||||||
from->w1 &= ~W1_R_OWNERSHIP;
|
|
||||||
if (++from >= &rd[EMAC_RECEIVE_DESCRIPTORS])
|
|
||||||
from = rd;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Returns a receive descriptor.
|
* @brief Returns a receive descriptor.
|
||||||
*
|
*
|
||||||
|
|
|
@ -30,47 +30,7 @@
|
||||||
#if CH_HAL_USE_MAC || defined(__DOXYGEN__)
|
#if CH_HAL_USE_MAC || defined(__DOXYGEN__)
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver pre-compile time settings. */
|
/* Driver constants. */
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Number of available transmit buffers.
|
|
||||||
*/
|
|
||||||
#if !defined(MAC_TRANSMIT_BUFFERS) || defined(__DOXYGEN__)
|
|
||||||
#define MAC_TRANSMIT_BUFFERS 2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Number of available receive buffers.
|
|
||||||
*/
|
|
||||||
#if !defined(MAC_RECEIVE_BUFFERS) || defined(__DOXYGEN__)
|
|
||||||
#define MAC_RECEIVE_BUFFERS 2
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Maximum supported frame size.
|
|
||||||
*/
|
|
||||||
#if !defined(MAC_BUFFERS_SIZE) || defined(__DOXYGEN__)
|
|
||||||
#define MAC_BUFFERS_SIZE 1518
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Interrupt priority level for the EMAC device.
|
|
||||||
*/
|
|
||||||
#if !defined(EMAC_INTERRUPT_PRIORITY) || defined(__DOXYGEN__)
|
|
||||||
#define EMAC_INTERRUPT_PRIORITY (AT91C_AIC_PRIOR_HIGHEST - 3)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* Derived constants and error checks. */
|
|
||||||
/*===========================================================================*/
|
|
||||||
|
|
||||||
#if !CH_USE_SEMAPHORES || !CH_USE_EVENTS
|
|
||||||
#error "the MAC driver requires CH_USE_SEMAPHORES and CH_USE_EVENTS"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*===========================================================================*/
|
|
||||||
/* EMAC specific constants. */
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
#define EMAC_RECEIVE_BUFFERS_SIZE 128 /* Do not modify */
|
#define EMAC_RECEIVE_BUFFERS_SIZE 128 /* Do not modify */
|
||||||
|
@ -116,6 +76,46 @@
|
||||||
#define W2_T_WRAP 0x40000000
|
#define W2_T_WRAP 0x40000000
|
||||||
#define W2_T_USED 0x80000000
|
#define W2_T_USED 0x80000000
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver pre-compile time settings. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Number of available transmit buffers.
|
||||||
|
*/
|
||||||
|
#if !defined(MAC_TRANSMIT_BUFFERS) || defined(__DOXYGEN__)
|
||||||
|
#define MAC_TRANSMIT_BUFFERS 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Number of available receive buffers.
|
||||||
|
*/
|
||||||
|
#if !defined(MAC_RECEIVE_BUFFERS) || defined(__DOXYGEN__)
|
||||||
|
#define MAC_RECEIVE_BUFFERS 2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Maximum supported frame size.
|
||||||
|
*/
|
||||||
|
#if !defined(MAC_BUFFERS_SIZE) || defined(__DOXYGEN__)
|
||||||
|
#define MAC_BUFFERS_SIZE 1518
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Interrupt priority level for the EMAC device.
|
||||||
|
*/
|
||||||
|
#if !defined(EMAC_INTERRUPT_PRIORITY) || defined(__DOXYGEN__)
|
||||||
|
#define EMAC_INTERRUPT_PRIORITY (AT91C_AIC_PRIOR_HIGHEST - 3)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Derived constants and error checks. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
#if !CH_USE_SEMAPHORES || !CH_USE_EVENTS
|
||||||
|
#error "the MAC driver requires CH_USE_SEMAPHORES and CH_USE_EVENTS"
|
||||||
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver data structures and types. */
|
/* Driver data structures and types. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -163,6 +163,10 @@ typedef struct {
|
||||||
of the buffers chain. */
|
of the buffers chain. */
|
||||||
} MACReceiveDescriptor;
|
} MACReceiveDescriptor;
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver macros. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* External declarations. */
|
/* External declarations. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
|
@ -29,6 +29,26 @@
|
||||||
|
|
||||||
#if CH_HAL_USE_PAL || defined(__DOXYGEN__)
|
#if CH_HAL_USE_PAL || defined(__DOXYGEN__)
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver exported variables. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver local variables. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver local functions. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver interrupt handlers. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver exported functions. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief AT91SAM7 I/O ports configuration.
|
* @brief AT91SAM7 I/O ports configuration.
|
||||||
* @details PIO registers initialization.
|
* @details PIO registers initialization.
|
||||||
|
|
|
@ -47,6 +47,10 @@
|
||||||
#error "serial lines not defined for this SAM7 version"
|
#error "serial lines not defined for this SAM7 version"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver exported variables. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
#if USE_SAM7_USART0 || defined(__DOXYGEN__)
|
#if USE_SAM7_USART0 || defined(__DOXYGEN__)
|
||||||
/** @brief USART0 serial driver identifier.*/
|
/** @brief USART0 serial driver identifier.*/
|
||||||
SerialDriver SD1;
|
SerialDriver SD1;
|
||||||
|
@ -57,6 +61,10 @@ SerialDriver SD1;
|
||||||
SerialDriver SD2;
|
SerialDriver SD2;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver local variables. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
/** @brief Driver default configuration.*/
|
/** @brief Driver default configuration.*/
|
||||||
static const SerialDriverConfig default_config = {
|
static const SerialDriverConfig default_config = {
|
||||||
38400,
|
38400,
|
||||||
|
@ -65,7 +73,7 @@ static const SerialDriverConfig default_config = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Low Level Driver local functions. */
|
/* Driver local functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -175,7 +183,7 @@ static void notify2(void) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Low Level Driver interrupt handlers. */
|
/* Driver interrupt handlers. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
#if USE_SAM7_USART0 || defined(__DOXYGEN__)
|
#if USE_SAM7_USART0 || defined(__DOXYGEN__)
|
||||||
|
@ -201,7 +209,7 @@ CH_IRQ_HANDLER(USART1IrqHandler) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Low Level Driver exported functions. */
|
/* Driver exported functions. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -29,6 +29,10 @@
|
||||||
|
|
||||||
#if CH_HAL_USE_SERIAL || defined(__DOXYGEN__)
|
#if CH_HAL_USE_SERIAL || defined(__DOXYGEN__)
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver constants. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Driver pre-compile time settings. */
|
/* Driver pre-compile time settings. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -76,7 +80,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* Unsupported event flags and custom events. */
|
/* Derived constants and error checks. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -131,6 +135,10 @@ typedef struct {
|
||||||
uint32_t mr;
|
uint32_t mr;
|
||||||
} SerialDriverConfig;
|
} SerialDriverConfig;
|
||||||
|
|
||||||
|
/*===========================================================================*/
|
||||||
|
/* Driver macros. */
|
||||||
|
/*===========================================================================*/
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* External declarations. */
|
/* External declarations. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
|
Loading…
Reference in New Issue