/*----------------------------------------------------------------------------- */ void main(void) { System_Init (); Usb_Init (); EA = 1; while (1) { if (BLINK_SELECTORUPDATE) { BLINK_SELECTORUPDATE = 0; SendPacket (IN_BLINK_SELECTORID); } } }
//----------------------------------------------------------------------------- // Main Routine //----------------------------------------------------------------------------- void main(void) { System_Init (); // Init Sysclk, Ports, USB0, Timer2, Timer0, ADC, PCA Usb_Init (); EA = 1; P0 = 0xFF; while (1) { /* if (BLINK_SELECTORUPDATE) { BLINK_SELECTORUPDATE = 0; SendPacket (IN_BLINK_SELECTORID); } */ } }
void main(void) { u32 cnt = 0; Init_Device(); //use code generate by silicon tool. TI0 = 1; //make uart0 in send enable status //----------------------------------------- event_init(); //-----------------------------------------add a timer event for printf #if 0 { timer_ev_unit_st xdata unit; timer_event_init(); unit.event = EVENT_ID_TIMER_DEBUG; unit.time = TRIG_TIME; unit.callback = func_for_debug; timer_event_add(&unit); } #endif //----------------------------------------- report_handler_init(); // while(cnt++<65536); // config_sensor(); test_func(); Usb_Init(); Interrupts_Init(); //open relative interrupt. //g_panel_point.ID = 0; //g_panel_point.x = 0; //g_panel_point.y = 0; while (1) { event_process(); if(g_work_style == WORK_STYLE_PREVIEW) { get_frame_data(); //while(EP_STATUS[1] != 0); send_debug_info_to_host(REPORT_ID_IN_DBGINFO); } else if(g_work_style == WORK_STYLE_CAL) { } else if(g_work_style == WORK_STYLE_NOMAL) { /* g_panel_point.x +=200; g_panel_point.y +=100; g_panel_point.x %= 1600; g_panel_point.y %= 900; fill_hid_packet(&g_panel_point,1); send_debug_info_to_host(REPORT_ID_IN_MTOUCH); */ } } }
/** ****************************************************************************** ** \brief Initialize USB ** ******************************************************************************/ void UsbConfig_UsbInit(void) { stc_usb_config_t stcUsbConfig; #if (!defined(USB_DISBALE_DEVICE_FUNCTIONALITY)) stc_usbdevice_config_t stcUsbDeviceConfig; #endif Usb_Init(); /* Setup USB 0 */ USB_ZERO_STRUCT(stcUsbConfig); #if (FM_PERIPHERAL_USB_DEVICE_ENABLED) USB_ZERO_STRUCT(stcUsbDeviceConfig); #endif /* (FM_PERIPHERAL_USB_DEVICE_ENABLED) */ #if ((FM_PERIPHERAL_ENABLE_USB0_HOST == ON) && (FM_PERIPHERAL_ENABLE_USB0_DEVICE == ON)) stcUsbConfig.enMode = UsbHostDeviceEnabled; #elif ((FM_PERIPHERAL_ENABLE_USB0_HOST == ON) && (FM_PERIPHERAL_ENABLE_USB0_DEVICE == OFF)) stcUsbConfig.enMode = UsbHostEnabled; #elif ((FM_PERIPHERAL_ENABLE_USB0_HOST == OFF) && (FM_PERIPHERAL_ENABLE_USB0_DEVICE == ON)) stcUsbConfig.enMode = UsbDeviceEnabled; #endif #if (FM_PERIPHERAL_USB_DEVICE_ENABLED) #if ((USE_USBDESCRIPTORS_H == 1) || (USB_USE_PDL == 1)) stcUsbDeviceConfig.pu8DeviceDescriptor = (uint8_t*)au8DeviceDescriptor; stcUsbDeviceConfig.pu8ConfigDescriptor = (uint8_t*)au8ConfigDescriptor; stcUsbDeviceConfig.astcReportDescriptors = (stc_usbdevice_reportdescriptor_t*)astcReportDescriptors; stcUsbDeviceConfig.pstcStringDescriptors = (stc_usbdevice_stringdescriptor_t*)pstcStringDescriptors; stcUsbDeviceConfig.u8StringDescriptorCount = USBDESCRIPTORS_STRINGDESCRIPTOR_COUNT; #endif /* ((USE_USBDESCRIPTORS_H == 1) || (USB_USE_PDL == 1)) */ #endif /* (FM_PERIPHERAL_USB_DEVICE_ENABLED) */ stcUsbConfig.bUseInterrupts = TRUE; #if (FM_PERIPHERAL_USB_DEVICE_ENABLED) #if ((FM_PERIPHERAL_ENABLE_USB0 == ON) && ((USE_USBDEVICEHW_H == 1) || (USB_USE_PDL == 1))) stcUsbConfig.pfnDeviceVbus = UsbConfig_Device0Vbus; #endif #endif /* (FM_PERIPHERAL_USB_DEVICE_ENABLED) */ #if ((FM_PERIPHERAL_USB_HOST_ENABLED)) #if ((FM_PERIPHERAL_ENABLE_USB0 == ON) && ((USE_USBHOSTHW_H == 1) || (USB_USE_PDL == 1))) stcUsbConfig.pfnHostVbus = UsbConfig_Host0Vbus; stcUsbConfig.pfnHostPullDownHostEnable = UsbConfig_Host0PulldownHostEnable; stcUsbConfig.pfnHostOvercurrent = UsbConfig_Host0Overcurrent; #endif #endif /* ((FM_PERIPHERAL_USB_HOST_ENABLED)) */ #if FM_PERIPHERAL_ENABLE_USB0_DEVICE == ON stcUsbDeviceConfig.pfnInitClassesCallback = UsbConfig_UsbDeviceClassesInitCallback0; #endif #if FM_PERIPHERAL_ENABLE_USB0_DEVICE == ON UsbDevice_Init((stc_usbn_t*)&USB0,&stcUsbConfig,&stcUsbDeviceConfig); #endif #if FM_PERIPHERAL_ENABLE_USB0 == ON #if FM_PERIPHERAL_ENABLE_USB0_HOST == ON UsbHost_Init((stc_usbn_t*)&USB0,&stcUsbConfig); #endif Usb_Configure((stc_usbn_t*)&USB0,&stcUsbConfig); #endif /* Setup USB 1 */ USB_ZERO_STRUCT(stcUsbConfig); #if (FM_PERIPHERAL_USB_DEVICE_ENABLED) USB_ZERO_STRUCT(stcUsbDeviceConfig); #endif #if ((FM_PERIPHERAL_ENABLE_USB1_HOST == ON) && (FM_PERIPHERAL_ENABLE_USB1_DEVICE == ON)) stcUsbConfig.enMode = UsbHostDeviceEnabled; #elif ((FM_PERIPHERAL_ENABLE_USB1_HOST == ON) && (FM_PERIPHERAL_ENABLE_USB1_DEVICE == OFF)) stcUsbConfig.enMode = UsbHostEnabled; #elif ((FM_PERIPHERAL_ENABLE_USB1_HOST == OFF) && (FM_PERIPHERAL_ENABLE_USB1_DEVICE == ON)) stcUsbConfig.enMode = UsbDeviceEnabled; #endif #if (FM_PERIPHERAL_USB_DEVICE_ENABLED) #if ((USE_USBDESCRIPTORS_H == 1) || (USB_USE_PDL == 1)) stcUsbDeviceConfig.pu8DeviceDescriptor = (uint8_t*)au8DeviceDescriptor; stcUsbDeviceConfig.pu8ConfigDescriptor = (uint8_t*)au8ConfigDescriptor; stcUsbDeviceConfig.astcReportDescriptors = (stc_usbdevice_reportdescriptor_t*)astcReportDescriptors; stcUsbDeviceConfig.pstcStringDescriptors = (stc_usbdevice_stringdescriptor_t*)pstcStringDescriptors; stcUsbDeviceConfig.u8StringDescriptorCount = USBDESCRIPTORS_STRINGDESCRIPTOR_COUNT; #endif #endif /* (FM_PERIPHERAL_USB_DEVICE_ENABLED) */ stcUsbConfig.bUseInterrupts = TRUE; #if (FM_PERIPHERAL_USB_DEVICE_ENABLED) #if ((FM_PERIPHERAL_ENABLE_USB1 == ON) && ((USE_USBDEVICEHW_H == 1) || (USB_USE_PDL == 1))) stcUsbConfig.pfnDeviceVbus = UsbConfig_Device1Vbus; #endif #endif /* (FM_PERIPHERAL_USB_DEVICE_ENABLED) */ #if (FM_PERIPHERAL_USB_HOST_ENABLED) #if ((FM_PERIPHERAL_ENABLE_USB1 == ON) && ((USE_USBHOSTHW_H == 1) || (USB_USE_PDL == 1))) stcUsbConfig.pfnHostVbus = UsbConfig_Host1Vbus; stcUsbConfig.pfnHostPullDownHostEnable = UsbConfig_Host1PulldownHostEnable; stcUsbConfig.pfnHostOvercurrent = UsbConfig_Host1Overcurrent; #endif #endif /* (FM_PERIPHERAL_USB_HOST_ENABLED) */ #if FM_PERIPHERAL_ENABLE_USB1_DEVICE == ON stcUsbDeviceConfig.pfnInitClassesCallback = UsbConfig_UsbDeviceClassesInitCallback1; #endif #if FM_PERIPHERAL_ENABLE_USB1_DEVICE == ON UsbDevice_Init((stc_usbn_t*)&USB1,&stcUsbConfig,&stcUsbDeviceConfig); #endif #if FM_PERIPHERAL_ENABLE_USB1 == ON #if FM_PERIPHERAL_ENABLE_USB1_HOST == ON UsbHost_Init((stc_usbn_t*)&USB1,&stcUsbConfig); #endif Usb_Configure((stc_usbn_t*)&USB1,&stcUsbConfig); #endif }