/** * Main function of the motor controller. */ int main(void) { int demo_counter; int demo_dir; system_init(); led_init(); debug_pins_init(); gprot_init(); usart_init(); sys_tick_init(); cpu_load_process_init(); comm_process_init(); sensor_process_init(); //adc_init(); pwm_init(); comm_tim_init(); control_process_init(); bemf_hd_init(); demo_counter = 500; demo_dir = 1; demo = false; while (true) { run_cpu_load_process(); /* if (adc_new_data_trigger) { adc_new_data_trigger = false; run_sensor_process(); } */ if (*comm_process_trigger) { *comm_process_trigger = false; run_comm_process(); } run_control_process(); if (demo) { if (demo_counter == 0) { demo_counter = 300; pwm_val += demo_dir; if (pwm_val > 2000) { demo_dir = -1; } if (pwm_val < 500) { demo_dir = 1; } } else { demo_counter--; } } } }
/** * Main function of the motor controller. */ int main(void) { int demo_counter; int demo_dir; system_init(); led_init(); debug_pins_init(); gprot_init(); usart_init(); sys_tick_init(); cpu_load_process_init(); comm_process_init(); sensor_process_init(); adc_init(); pwm_init(); comm_tim_init(); control_process_init(); bemf_hd_init(); demo_counter = 500; demo_dir = 1; demo = false; int flag = 0; while (true) { run_cpu_load_process(); if(flag%1000000 == 0) { //gpc_send_string("Hello World, I am ALIVE\n", strlen("Hello World, I am ALIVE\n")); DEBUG("HELLO WORLD\n"); flag++; } else { flag++; } if (*comm_process_trigger) { *comm_process_trigger = false; run_comm_process(); } run_control_process(); if (*sensor_process_trigger) { *sensor_process_trigger = false; run_sensor_process(); } //TOGGLE(LED_BLUE); if (demo) { if (demo_counter == 0) { demo_counter = 300; pwm_val += demo_dir; if (pwm_val > 300) { demo_dir = -1; } if (pwm_val < 100) { demo_dir = 1; } } else { demo_counter--; } } } }