Interrupt Handling
This section provides an overview of interrupt handling, which is necessary to understand the reception and transmission of network packets. After reading this section, you should be ready to understand the descriptions and explanations of the follow section of this chapter
Interrupt handling is accomplished using the following multi-level scheme:
- Processor level interrupt handler
- µC/TCP-IP BSP interrupt handler (Network BSP)
- Device driver interrupt handler
During initialization, the device driver registers all necessary interrupt sources with the BSP interrupt management code. This may also be accomplished by plugging an interrupt vector table during compile time. Once the global interrupt vector sources are configured and an interrupt occurs, the system will call the first-level interrupt handler. The first-level handler then calls the network device’s BSP handler which in turn calls NetIF_ISR_Handler()
with the interface number and ISR type. The ISR type may be known if a dedicated interrupt vector is assigned to the source, or it may be de-multiplexed from the device driver by reading a register. If the interrupt type is unknown, then the BSP interrupt handler should call NetIF_ISR_Handler()
with the appropriate interface number and NET_IF_ISR_TYPE_UNKNOWN
.
The following ISR types have been defined from within µC/TCP-IP, however, additional type codes may be defined within each device’s net_dev.h
:
NET_DEV_ISR_TYPE_UNKNOWN
NET_DEV_ISR_TYPE_RX
NET_DEV_ISR_TYPE_RX_RUNT
NET_DEV_ISR_TYPE_RX_OVERRUN
NET_DEV_ISR_TYPE_TX_RDY
NET_DEV_ISR_TYPE_TX_COMPLETE
NET_DEV_ISR_TYPE_TX_COLLISION_LATE
NET_DEV_ISR_TYPE_TX_COLLISION_EXCESS
NET_DEV_ISR_TYPE_JABBER
NET_DEV_ISR_TYPE_BABBLE
NET_DEV_ISR_TYPE_TX_DONE
NET_DEV_ISR_TYPE_PHY
Depending on the architecture, there may be a network device BSP interrupt handler for each implemented device interrupt type (see also Network Board Support Package and NetDev_ISR_Handler Ethernet). PHY interrupts should call NetIF_ISR_Handler()
with a type code equal to NET_DEV_ISR_TYPE_PHY
.
(1) The device driver must call the network device BSP during initialization in order to configure any module clocks, GPIO, or external interrupt controllers that require configuration. Note: Network device BSP is processor- and device-specific and must be supplied by the application developer. See Network Board Support Package for more details.