#include "config.h"#include "ADC_task.h"#include "Timer0_PWM.h"#include "ATA6824_defs.h"#include "Hall_sensors.h"#include "an_compare.h"Include dependency graph for main.c:

Go to the source code of this file.
Enumerations | |
| enum | Motor_ctrl_t { MOTOR_STATUS_STOPPED, MOTOR_STATUS_CW, MOTOR_STATUS_CCW } |
Functions | |
| void | display_defaults (void) |
| display_defaults signals to the user that diagnostics have detected a fault. It displays it on corresponding LED. Two faults are software latched. When those faults have been latched, the corresponding LEDs is/are set ON. Those are cleared when faults are unlatched The DG3 over-temperature doesn't need to be latched. As long as it's present the corresponding LED is toogled, then cleared if it's not present. | |
| void | main (void) |
| void display_defaults | ( | void | ) |
display_defaults signals to the user that diagnostics have detected a fault. It displays it on corresponding LED. Two faults are software latched. When those faults have been latched, the corresponding LEDs is/are set ON. Those are cleared when faults are unlatched The DG3 over-temperature doesn't need to be latched. As long as it's present the corresponding LED is toogled, then cleared if it's not present.
Definition at line 164 of file main.c.
References ATA6824_diag_mgt, ATA6824_diag_mgt_t::dg1, ATA6824_diag_mgt_t::dg2, ATA6824_diag_mgt_t::dg3, NO_FAILURE, SoftTimer_t::ovf, and time_count_1s.
Referenced by main().
00165 { 00166 // Display short-cicuit detected (latched DG1 signal) 00167 if (ATA6824_diag_mgt.dg1 != NO_FAILURE) SET_DG1_LED(); 00168 else RESET_DG1_LED(); 00169 00170 // Display pump charge failure, undervoltage or overvoltage detected (latched DG2 signal) 00171 if (ATA6824_diag_mgt.dg2 != NO_FAILURE) SET_DG2_LED(); 00172 else RESET_DG2_LED(); 00173 00174 // Toggle DG3_LED in over-temperature conditions 00175 if (time_count_1s.ovf == true) 00176 { 00177 if (ATA6824_diag_mgt.dg3 != NO_FAILURE) 00178 TOGGLE_DG3_LED(); 00179 else 00180 RESET_DG3_LED(); 00181 time_count_1s.ovf = false; // Clear 1s overflow flag 00182 } 00183 }
| void main | ( | void | ) |
Definition at line 79 of file main.c.
References adc_get_speed(), ADC_Init(), ADC_task(), AN_compare_init(), clear_faults(), Diag_inputs_ISR_init(), display_defaults(), Hall_sensors_ISR_init(), manage_time_base(), MOTOR_STATUS_CCW, MOTOR_STATUS_CW, MOTOR_STATUS_STOPPED, refresh_ATA6824_watchdog(), TIMER0_SET_OC0B_PWM, and Timer0_start().
00080 { 00081 Motor_ctrl_t motor_status = MOTOR_STATUS_STOPPED; 00082 00083 CLKPR = 0x80; 00084 CLKPR = 0x00; // No system clock prescaler 00085 CONFIG_IO_PORTS(); // Configure I/O ports 00086 00087 ADC_Init(); // initialize ADC 00088 Timer0_start(); // Starts Timer 0 for a 31250Hz PWM and 00089 // time management. 00090 Hall_sensors_ISR_init(); // Configures Pin change interrupts (PCINT0) 00091 Diag_inputs_ISR_init(); // Configures DG1/2/3 pin change interrupts (PCINT1) 00092 AN_compare_init(); // Configures over-current detection through 00093 // analog comparator 00094 00095 SET_WD_TRIG(); // 1st watchdog refresh 00096 00097 __enable_interrupt(); // enable interrupts 00098 00099 while(1) // End-less loop 00100 { 00101 ADC_task(); // Manage ADC acquisitions 00102 manage_time_base(); // Manage time base 00103 refresh_ATA6824_watchdog(); // Refresh ATA6824 Watchdog 00104 00105 /* Motor management */ 00106 switch(motor_status) 00107 { 00108 //-------------------------------------------------------------------- 00109 case MOTOR_STATUS_STOPPED: // Motor is stopped 00110 if (GET_SWITCH_CW()) 00111 { 00112 SET_MOTOR_DIR(); // Set motor direction 00113 TIMER0_SET_OC0B_PWM((U8)((adc_get_speed()>>2))); // Update PWM ratio 00114 motor_status = MOTOR_STATUS_CW; 00115 } 00116 else if (GET_SWITCH_CCW()) 00117 { 00118 RESET_MOTOR_DIR(); // Reset motor direction 00119 TIMER0_SET_OC0B_PWM((U8)((adc_get_speed()>>2))); // Update PWM ratio 00120 motor_status = MOTOR_STATUS_CCW; 00121 } 00122 else 00123 TIMER0_SET_OC0B_PWM(0x00); // Set PWM ratio to zero 00124 break; 00125 00126 //-------------------------------------------------------------------- 00127 case MOTOR_STATUS_CW: // Motor runs Clockwise 00128 case MOTOR_STATUS_CCW: // Motor runs counter clockwise 00129 00130 if (!GET_SWITCH_CW() && !GET_SWITCH_CCW()) // Stop command from switch 00131 { 00132 TIMER0_SET_OC0B_PWM(0x00); // Set PWM ratio to zero 00133 motor_status = MOTOR_STATUS_STOPPED; // Update motor status 00134 } 00135 else 00136 TIMER0_SET_OC0B_PWM((U8)((adc_get_speed()>>2))); // Update PWM ratio 00137 break; 00138 00139 //-------------------------------------------------------------------- 00140 default: 00141 motor_status = MOTOR_STATUS_STOPPED; 00142 TIMER0_SET_OC0B_PWM(0x00); // Set PWM ratio to zero 00143 break; 00144 } 00145 00146 // Default display on LEDs 00147 display_defaults(); 00148 00149 // Clear faults when Release push-button is pushed and faults no more remain 00150 if (GET_RELEASE_BP()) 00151 clear_faults(); // Clear not remaining faults (latched by software) 00152 }; 00153 }
Here is the call graph for this function:

1.4.7