| 891 | } |
| 892 | |
| 893 | int main(void) |
| 894 | { |
| 895 | CyGlobalIntEnable; |
| 896 | CySysTickStart(); |
| 897 | CySysTickSetCallback(4, system_timer_cb); |
| 898 | INDEX_IRQ_StartEx(&index_irq_cb); |
| 899 | SAMPLER_DMA_FINISHED_IRQ_StartEx(&capture_dma_finished_irq_cb); |
| 900 | SEQUENCER_DMA_FINISHED_IRQ_StartEx(&replay_dma_finished_irq_cb); |
| 901 | INPUT_VOLTAGE_ADC_Stop(); |
| 902 | OUTPUT_VOLTAGE_ADC_Stop(); |
| 903 | DRIVESELECT_REG_Write(0); |
| 904 | UART_Start(); |
| 905 | USBFS_Start(0, USBFS_DWR_VDDD_OPERATION); |
| 906 | USBFS_DisableOutEP(FLUXENGINE_DATA_OUT_EP_NUM); |
| 907 | |
| 908 | CyWdtStart(CYWDT_1024_TICKS, CYWDT_LPMODE_DISABLED); |
| 909 | |
| 910 | for (;;) |
| 911 | { |
| 912 | CyWdtClear(); |
| 913 | |
| 914 | if (motor_on) |
| 915 | { |
| 916 | uint32_t time_on = clock - motor_on_time; |
| 917 | if (time_on > MOTOR_ON_TIME) |
| 918 | stop_motor(); |
| 919 | } |
| 920 | |
| 921 | if (!USBFS_GetConfiguration() || USBFS_IsConfigurationChanged()) |
| 922 | { |
| 923 | print("Waiting for USB..."); |
| 924 | while (!USBFS_GetConfiguration()) |
| 925 | CyWdtClear(); |
| 926 | print("USB ready"); |
| 927 | USBFS_EnableOutEP(FLUXENGINE_CMD_OUT_EP_NUM); |
| 928 | print("Scanning drives..."); |
| 929 | detect_drives(); |
| 930 | } |
| 931 | |
| 932 | if (USBFS_GetEPState(FLUXENGINE_CMD_OUT_EP_NUM) == USBFS_OUT_BUFFER_FULL) |
| 933 | { |
| 934 | set_drive_flags(¤t_drive_flags); |
| 935 | handle_command(); |
| 936 | USBFS_EnableOutEP(FLUXENGINE_CMD_OUT_EP_NUM); |
| 937 | print("idle"); |
| 938 | } |
| 939 | } |
| 940 | } |
| 941 | |
| 942 | const uint8_t USBFS_MSOS_CONFIGURATION_DESCR[USBFS_MSOS_CONF_DESCR_LENGTH] = { |
| 943 | /* Length of the descriptor 4 bytes */ 0x28u, 0x00u, 0x00u, 0x00u, |
nothing calls this directly
no test coverage detected