git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@15800 27425a3e-05d8-49a3-a47f-9c15f0e5edd8

This commit is contained in:
Giovanni Di Sirio 2022-09-22 14:55:22 +00:00
parent 8db57fad44
commit 80a5f29892
3 changed files with 49 additions and 118 deletions

View File

@ -225,7 +225,7 @@ typedef struct {
/* Link status flag.*/ \
bool link_up; \
/* PHY address (pre shifted).*/ \
uint32_t phyaddr; \
uint32_t phyaddr; \
/* Receive next frame pointer.*/ \
stm32_eth_rx_descriptor_t *rxptr; \
/* Transmit next frame pointer.*/ \

View File

@ -237,35 +237,28 @@ static void mac_lld_set_address(const uint8_t *p) {
/*===========================================================================*/
OSAL_IRQ_HANDLER(STM32_ETH_HANDLER) {
uint32_t dmasr;
MACDriver *macp = &ETHD1;
uint32_t dmacsr;
OSAL_IRQ_PROLOGUE();
dmasr = ETH->DMACSR;
dmacsr = ETH->DMACSR;
ETH->DMACSR = dmacsr; /* Clear status bits.*/
if (dmasr & ETH_DMACSR_RI) {
/* Data Received.*/
ETH->DMACSR = ETH_DMACSR_RI;
ETH->DMACIER &= ~ETH_DMACIER_RIE;
osalSysLockFromISR();
osalThreadDequeueAllI(&ETHD1.rdqueue, MSG_RESET);
#if MAC_USE_EVENTS
osalEventBroadcastFlagsI(&ETHD1.rdevent, 0);
#endif
osalSysUnlockFromISR();
if ((dmacsr & (ETH_DMACSR_RI | ETH_DMACSR_TI)) != 0U) {
if ((dmacsr & ETH_DMACSR_TI) != 0U) {
/* Data Transmitted.*/
__mac_tx_wakeup(macp);
}
if ((dmacsr & ETH_DMACSR_RI) != 0U) {
/* Data Received.*/
__mac_rx_wakeup(macp);
}
__mac_callback(macp);
}
if (dmasr & ETH_DMACSR_TI) {
/* Data Transmitted.*/
ETH->DMACSR = ETH_DMACSR_TI;
osalSysLockFromISR();
osalThreadDequeueAllI(&ETHD1.tdqueue, MSG_RESET);
osalSysUnlockFromISR();
}
ETH->DMACSR |= ETH_DMACSR_NIS;
ETH->DMACIER = ETH_DMACIER_NIE | ETH_DMACIER_RIE | ETH_DMACIER_TIE;
OSAL_IRQ_EPILOGUE();
}

View File

@ -230,104 +230,42 @@ typedef struct {
volatile uint32_t tdes3;
} stm32_eth_tx_descriptor_t;
/**
* @brief Driver configuration structure.
*/
typedef struct {
/**
* @brief MAC address.
*/
uint8_t *mac_address;
/* End of the mandatory fields.*/
} MACConfig;
/**
* @brief Structure representing a MAC driver.
*/
struct MACDriver {
/**
* @brief Driver state.
*/
macstate_t state;
/**
* @brief Current configuration data.
*/
const MACConfig *config;
/**
* @brief Transmit semaphore.
*/
threads_queue_t tdqueue;
/**
* @brief Receive semaphore.
*/
threads_queue_t rdqueue;
#if MAC_USE_EVENTS || defined(__DOXYGEN__)
/**
* @brief Receive event.
*/
event_source_t rdevent;
#endif
/* End of the mandatory fields.*/
/**
* @brief Link status flag.
*/
bool link_up;
/**
* @brief PHY address (pre shifted).
*/
uint32_t phyaddr;
/**
* @brief Receive next frame index.
*/
uint16_t rdindex;
/**
* @brief Transmit next frame index.
*/
uint16_t tdindex;
};
/**
* @brief Structure representing a transmit descriptor.
*/
typedef struct {
/**
* @brief Current write offset.
*/
size_t offset;
/**
* @brief Available space size.
*/
size_t size;
/* End of the mandatory fields.*/
/**
* @brief Pointer to the physical descriptor.
*/
stm32_eth_tx_descriptor_t *physdesc;
} MACTransmitDescriptor;
/**
* @brief Structure representing a receive descriptor.
*/
typedef struct {
/**
* @brief Current read offset.
*/
size_t offset;
/**
* @brief Available data size.
*/
size_t size;
/* End of the mandatory fields.*/
/**
* @brief Pointer to the physical descriptor.
*/
stm32_eth_rx_descriptor_t *physdesc;
} MACReceiveDescriptor;
/*===========================================================================*/
/* Driver macros. */
/*===========================================================================*/
/**
* @brief Low level fields of the MAC driver structure.
*/
#define mac_lld_driver_fields \
/* Link status flag.*/ \
bool link_up; \
/* PHY address (pre shifted).*/ \
uint32_t phyaddr; \
/* Receive next frame index.*/ \
uint32_t rdindex; \
/* Transmit next frame index.*/ \
uint32_t tdindex
/**
* @brief Low level fields of the MAC configuration structure.
*/
#define mac_lld_config_fields
/**
* @brief Low level fields of the MAC transmit descriptor structure.
*/
#define mac_lld_transmit_descriptor_fields \
/* Pointer to the physical descriptor.*/ \
stm32_eth_tx_descriptor_t *physdesc
/**
* @brief Low level fields of the MAC receive descriptor structure.
*/
#define mac_lld_receive_descriptor_fields \
/* Pointer to the physical descriptor.*/ \
stm32_eth_rx_descriptor_t *physdesc
/*===========================================================================*/
/* External declarations. */
/*===========================================================================*/