MCPcopy Create free account
hub / github.com/davidgiven/fluxengine / main

Function main

FluxEngine.cydsn/main.c:893–940  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

891}
892
893int 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(&current_drive_flags);
935 handle_command();
936 USBFS_EnableOutEP(FLUXENGINE_CMD_OUT_EP_NUM);
937 print("idle");
938 }
939 }
940}
941
942const uint8_t USBFS_MSOS_CONFIGURATION_DESCR[USBFS_MSOS_CONF_DESCR_LENGTH] = {
943/* Length of the descriptor 4 bytes */ 0x28u, 0x00u, 0x00u, 0x00u,

Callers

nothing calls this directly

Calls 5

stop_motorFunction · 0.85
printFunction · 0.85
detect_drivesFunction · 0.85
set_drive_flagsFunction · 0.85
handle_commandFunction · 0.85

Tested by

no test coverage detected