aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms/AT91SAM7/mac_lld.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/platforms/AT91SAM7/mac_lld.c')
-rw-r--r--os/hal/platforms/AT91SAM7/mac_lld.c56
1 files changed, 38 insertions, 18 deletions
diff --git a/os/hal/platforms/AT91SAM7/mac_lld.c b/os/hal/platforms/AT91SAM7/mac_lld.c
index 9cd4ad4fe..9517c4838 100644
--- a/os/hal/platforms/AT91SAM7/mac_lld.c
+++ b/os/hal/platforms/AT91SAM7/mac_lld.c
@@ -33,11 +33,6 @@
#if CH_HAL_USE_MAC || defined(__DOXYGEN__)
-/**
- * @brief Ethernet driver 1.
- */
-MACDriver ETH1;
-
#define EMAC_PIN_MASK (AT91C_PB0_ETXCK_EREFCK | AT91C_PB1_ETXEN | \
AT91C_PB2_ETX0 | AT91C_PB3_ETX1 | \
AT91C_PB4_ECRS | AT91C_PB5_ERX0 | \
@@ -53,6 +48,19 @@ MACDriver ETH1;
#define TSR_BITS (AT91C_EMAC_UBR | AT91C_EMAC_COL | AT91C_EMAC_RLES | \
AT91C_EMAC_BEX | AT91C_EMAC_COMP | AT91C_EMAC_UND)
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/**
+ * @brief Ethernet driver 1.
+ */
+MACDriver ETH1;
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+
#ifndef __DOXYGEN__
static bool_t link_up;
@@ -70,6 +78,10 @@ static uint8_t tb[EMAC_TRANSMIT_DESCRIPTORS * EMAC_TRANSMIT_BUFFERS_SIZE]
__attribute__((aligned(8)));
#endif
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
/**
* @brief IRQ handler.
*/
@@ -108,6 +120,23 @@ static void serve_interrupt(void) {
}
/**
+ * @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.
*/
CH_IRQ_HANDLER(irq_handler) {
@@ -119,6 +148,10 @@ CH_IRQ_HANDLER(irq_handler) {
CH_IRQ_EPILOGUE();
}
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
/**
* @brief Low level MAC initialization.
*/
@@ -296,19 +329,6 @@ void mac_lld_release_transmit_descriptor(MACTransmitDescriptor *tdp) {
}
/**
- * @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.
*
* @param[in] macp pointer to the @p MACDriver object