Hardware initialization of the operation is relatively simple, the main code from the routine "AT91RM9200-BASICUHP" copied, in addition to increase the interrupt vector initialization part.
In AM9200, the interruption of the USB is based on the AIC interrupt, so set the corresponding AIC interrupt. Before you set up the OHCI interrupt register, the code is as follows:
/** * USB Host initialization * @return 0-Success * * Short Ohcihardinit(void) {unsigned intReg Open the USB host using the Clock AT91F_UHP_CFGPMC (); At91c_base_pmc->pmc_scer |= (AT91C_PMC_UHP); Forcing UHP_HC to reset Puhp->uhp_hccontrol = 0; Writing the Uhp_hcca Puhp->uhp_hchcca = (unsigned int ) &HCCA; //Enabling list processing Puhp->uhp_hccontrol = 0; //Set the frame interval puhp->uhp_hcfminterval = at91c_fminterval; Puhp->uhp_hcperiodicstart = AT91C_PRDSTRT; //Initializing the Uhp_hcdonehead puhp->uhp_ hcbulkdonehead = 0x00; Hcca. Uhp_hccadonehead = 0x0000; //forcing UHP_HC to operational state Reg = puhp->uhp_hccontrol; Puhp->uhp_hccontrol = 0x80; //Enabling Port Power puhp->uhp_hcrhportstatus[0] = 0x00000100; puhp->uhp_hcrhportstatus[1] = 0x00000100; Puhp->uhp_hcrhdescriptora = Ohci_hc_rhdescriptora_nps; puhp->uhp_hcrhstatus = 0x00010000; //Udp:connect a pull-up //When debugging found that the data returned without setting this register is problematic at91f_pio_setoutput ( At91c_base_piod, AT91C_PIO_PD5); //Set USB Host Interrupt Register puhp->uhp_hcinterruptenable = OHC I_hc_intr_mie | OHCI_HC_INTR_RHSC | Ohci_hc_intr_ue | OHCI_HC_INTR_WDH | OHCI_HC_INTR_FNO; puhp->uhp_hcinterruptstatus = OHCI_HC_INTR_RHSC | Ohci_hc_intr_ue | OHCI_HC_INTR_WDH | Ohci_hc_intr_fno; //Set AIC interrupt information At91f_aic_configureit ( at91c_base_aic, & nbsp; AT91C_ID_UHP, At91c_aic_ Prior_highest, at91c_aic_srctype_int_edge_triggered, At91f_asm_uhp_handler); At91f_aic_enableit (AT91C_BASE_AIC,AT91C_ID_UHP); return0; } |
Interrupt registers in OHCI set a number of interrupts, actually useful is WDH interrupt, the interrupt is the TD after the transmission of the resulting. It is possible to determine whether the data has been transmitted by determining whether the interrupt was produced and matched with HCCA to determine if the end of the TD queue was reached.
The relevant constant definitions in the code can be found in the "AT91RM9200.h", "Lib_at91rm9200.h", "ohci.h" header files, which are available in the routines "AT91RM9200-BASICUHP".
This article is from the "Rainman" blog, please be sure to keep this source http://lancelot.blog.51cto.com/393579/229673