/******************************************************************************
 * @name        main
 *
 * @brief       This routine is the starting point of the application
 *
 * @param       None
 *
 * @return      None
 *
 *****************************************************************************
 * This function initializes the system, enables the interrupts and calls the
 * application
 *****************************************************************************/
void 
main(void)
{
    /* Bootloader application */
	GPIO_Bootloader_Init();
	Switch_mode();              /* switch between the application and the bootloader mode */

	Init_Sys();        /* initial the system */
	
#if MAX_TIMER_OBJECTS
    (void)TimerQInitialize(0);
#endif
    (void)TestApp_Init(); /* Initialize the USB Test Application */

    while(TRUE)
    {
       Watchdog_Reset();

       /* Call the application task */
       TestApp_Task();
    }
}
Пример #2
0
/*FUNCTION*----------------------------------------------------------------
*
* Function Name  : main
* Returned Value : none
* Comments       :
*     Execution starts here
*
*END*--------------------------------------------------------------------*/
void main() 
{
    /* Body */
    USB_STATUS           status = USB_OK;
    _usb_host_handle     host_handle;
    uint_32 i;
    /* Initialize the current platform. Call for the _bsp_platform_init which is specific to each processor family */
    _bsp_platform_init();
    GPIO_Init();

    /* Protect bootloader area (sector 0 to sector 3)*/
#ifdef  __MCF52259_H__ 
	#ifdef __DEBUG__
		MCF_CFM_CFMPROT = 0x0F;
	#else
		MCF_CFM_CFMPROT = 0x07;
	#endif
#elif defined(MCU_MK60N512VMD100)
         FTFL_FPROT3 = 0xF0; 
#endif /* End __MCF52259_H__ */

#ifdef __DEBUG__
    sci1_init();
#endif
    
    for(i=0;i<=2000;i++);
    Switch_mode();                /* check for bootloader mode */ 
    TimerInit();
    POLL_init();                  /* Init polling global variable */
    
    SetOutput(BSP_LED1, FALSE);
    SetOutput(BSP_LED2, FALSE);
    
    DisableInterrupts; 
#if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
    usb_int_dis();
#endif  
    status = _usb_host_init
             (HOST_CONTROLLER_NUMBER,    /* Use value in header file */
             MAX_FRAME_SIZE,             /* Frame size per USB spec  */
             &host_handle);              /* Returned pointer */

    if (status != USB_OK) {
#ifdef __DEBUG__
        printf("\nUSB Host Initialization failed. STATUS: %x", status);
#endif
    }

    /*
    ** Since we are going to act as the host driver, register
    ** the driver information for wanted class/subclass/protocols
    */
    status = _usb_host_driver_info_register(host_handle, (void*)DriverInfoTable);
    if (status != USB_OK) {
#ifdef __DEBUG__
        printf("\nDriver Registration failed. STATUS: %x", status);
#endif
    } 
    EnableInterrupts;
#if (defined _MCF51MM256_H) || (defined _MCF51JE256_H)
    usb_int_en();
#endif
    /* Run bootloader mode */
#ifdef __DEBUG__
    printf("\n****************************************************************************\n\r");
    printf("*                              Bootloader mode                             *\n\r");
    printf("****************************************************************************\n\r"); 
    printf("\nUSB stick boot loader\n\rWaiting for USB mass storage to be attached...\n\r");
#endif
    for(;;) {
        Main_Task();
        Poll();
        __RESET_WATCHDOG(); /* feeds the dog */
    } /* loop forever */
    /* please make sure that you never leave main */
} /* EndBody */