Software Overview
MC9S12UF32 Card Reader Reference Design User Manual, Rev. 0.1
14
Freescale Semiconductor
Figure 3-2. Main Software Flow
3.2 Main Software Flow
3.2.1 Main Program
The USB events handler puts the UF32 into suspend when USB bus suspend is detected. The USB Mass
Storage (USBMS) handler calls corresponding routines for different USBMS commands. The card
insertion and removal handler checks any card is inserted into or removed from the sockets.
3.2.1.1 USB Events Handler
The USB Events Handler puts the UF32 into STOP mode when the USB suspend is detected.
3.2.1.2 USBMS Events Handler
The USB Events Handler handles the USB Mass Storage reset and the USB Mass Storage Command
Block Wrapper.
3.2.1.3 Card Insertion and Removal Handler
The card insertion and removal handler checks any card inserted or removed from the sockets for every
100ms. The time interval is defined in the timer hook function. If any card is detected to be inserted, the
handler will enable and initialize the card host controller. If any card is detected to be removed, the handler
will disable the card host controller.
MAIN PROGRAM
INITIALIZATION
USB EVENTS
TIMER INTERRUPT
CHECK AND SERVE
RETURN
INCREASE GLOBAL TIMER
COUNTER FOR EVERY 1ms
USBMS EVENTS
CARD INSERTION &
HANDLER
USB INTERRUPTS
USB ENDPOINT 0
HANDLER
USBMS BULK OUT
RETURN
USBMS BULK IN
HANDLER
HANDLER
ANY HOOK FUNCTION
HANDLER
REMOVAL HANDLER