16 #define output_disconnected 0x01 19 #define Set_timer_data_register_to_zero() (TCNT0=0x00) 22 #define PSC_ONE_RAMP (0<<PMODE01)|(0<<PMODE00) 23 #define PSC_TWO_RAMP (0<<PMODE01)|(1<<PMODE00) 24 #define PSC_FOUR_RAMP (1<<PMODE01)|(0<<PMODE00) 25 #define PSC_CENTERED (1<<PMODE01)|(1<<PMODE00) 27 #define RAMP_MODE_NUMBER PSC_CENTERED 29 #define SET_PLOCK (1<<PLOCK0) 30 #define RELEASE_PLOCK (0<<PLOCK0) 32 #define PRESC_NODIV (0<<PPRE01)|(0<<PPRE00) 33 #define PRESC_DIV_BY_4 (0<<PPRE01)|(1<<PPRE00) 34 #define PRESC_DIV_BY_16 (1<<PPRE01)|(0<<PPRE00) 35 #define PRESC_DIV_BY_64 (1<<PPRE01)|(1<<PPRE00) 37 #define OUTPUT_ACTIVE_HIGH (1<<POP0) 38 #define OUTPUT_ACTIVE_LOW (0<<POP0) 40 #define Enable_over_current() \ 41 PFRC0A = (1<<PELEV0A)|(1<<PFLTE0A)|\ 42 (0<<PRFM0A3)|(1<<PRFM0A2)|(1<<PRFM0A1)|(1<<PRFM0A0); 43 #define Disable_over_current() \ 44 PFRC0A = (1<<PELEV0A)|(1<<PFLTE0A)|\ 45 (0<<PRFM0A3)|(0<<PRFM0A2)|(0<<PRFM0A1)|(0<<PRFM0A0); 48 #define HALL_A() (PORTE_INT0_vect) 53 #define HALL_SENSOR_VALUE() (PORTE.IN & 0x07) 55 #define Clear_Port_Q1() (PORTC.OUTCLR = PIN5_bm) 56 #define Clear_Port_Q3() (PORTC.OUTCLR = PIN3_bm) 57 #define Clear_Port_Q5() (PORTC.OUTCLR = PIN1_bm) 58 #define Clear_Port_Q2() (PORTC.OUTCLR = PIN4_bm) 59 #define Clear_Port_Q4() (PORTC.OUTCLR = PIN2_bm) 60 #define Clear_Port_Q6() (PORTC.OUTCLR = PIN0_bm) 61 #define Set_Port_Q2() (PORTC.OUTSET = PIN4_bm) 62 #define Set_Port_Q4() (PORTC.OUTSET = PIN2_bm) 63 #define Set_Port_Q6() (PORTC.OUTSET = PIN0_bm) 66 #define Set_none() (AWEX_SetOutputOverrideValue(AWEXC,0)) 68 #define Set_Q1Q4() AWEX_SetOutputOverrideValue(AWEXC,PIN5_bm | PIN2_bm)//(AWEXC.OUTOVEN = (PIN5_bm | PIN2_bm)) 70 #define Set_Q1Q6() AWEX_SetOutputOverrideValue(AWEXC,PIN5_bm | PIN0_bm)//(AWEXC.OUTOVEN = (PIN5_bm | PIN0_bm)) 72 #define Set_Q3Q2() AWEX_SetOutputOverrideValue(AWEXC,PIN3_bm | PIN4_bm)//(AWEXC.OUTOVEN = (PIN3_bm | PIN4_bm)) 74 #define Set_Q3Q6() AWEX_SetOutputOverrideValue(AWEXC,PIN3_bm | PIN0_bm)//(AWEXC.OUTOVEN = (PIN3_bm | PIN0_bm)) 76 #define Set_Q5Q2() AWEX_SetOutputOverrideValue(AWEXC,PIN1_bm | PIN4_bm)//(AWEXC.OUTOVEN = (PIN1_bm | PIN4_bm)) 78 #define Set_Q5Q4() AWEX_SetOutputOverrideValue(AWEXC,PIN1_bm | PIN2_bm)//(AWEXC.OUTOVEN = (PIN1_bm | PIN2_bm)) 81 #define switch_ON_LED() (PORTE &= ~(1<<PE2)) 82 #define switch_OFF_LED() (PORTE |= (1<<PE2)) 85 #define Set_EXT1() (PORTB |= (1<<PB3)) // EXT1 86 #define Clear_EXT1() (PORTB &= ~(1<<PB3)) 87 #define Set_EXT2() (PORTB |= (1<<PB4)) // EXT2 88 #define Clear_EXT2() (PORTB &= ~(1<<PB4)) 89 #define Toggle_EXT2() (PINB |= (1<<PINB4)) 90 #define Set_EXT3() (PORTC |= (1<<PC1)) // EXT3 91 #define Clear_EXT3() (PORTC &= ~(1<<PC1)) 92 #define Set_EXT4() (PORTC |= (1<<PC2)) // EXT4 93 #define Clear_EXT4() (PORTC &= ~(1<<PC2)) 94 #define Set_EXT5() (PORTB |= (1<<PB5)) // EXT5 95 #define Clear_EXT5() (PORTB &= ~(1<<PB5)) 96 #define Set_EXT6() (PORTE |= (1<<PE1)) // EXT6 97 #define Clear_EXT6() (PORTE &= ~(1<<PE1)) 98 #define Set_EXT7() (PORTD |= (1<<PD3)) // EXT7 99 #define Clear_EXT7() (PORTD &= ~(1<<PD3)) 100 #define Set_EXT8() (PORTD |= (1<<PD4)) // EXT8 101 #define Clear_EXT8() (PORTD &= ~(1<<PD4)) 102 #define Set_EXT9() (PORTE |= (1<<PE0)) // EXT9 103 #define Clear_EXT9() (PORTE &= ~(1<<PE0)) 104 #define Set_EXT10() (PORTD |= (1<<PD2)) // EXT10 105 #define Clear_EXT10() (PORTD &= ~(1<<PD2)) 107 #define Get_EXT1() ((PINB & (1<<PB3))>>PB3) // EXT1 108 #define Get_EXT2() ((PINB & (1<<PB4))>>PB4) // EXT2 109 #define Get_EXT3() ((PINC & (1<<PC1))>>PC1) // EXT3 110 #define Get_EXT4() ((PINC & (1<<PC2))>>PC2) // EXT4 111 #define Get_EXT5() ((PINB & (1<<PB5))>>PB5) // EXT5 112 #define Get_EXT6() ((PINE & (1<<PE1))>>PE1) // EXT6 113 #define Get_EXT7() ((PIND & (1<<PD3))>>PD3) // EXT7 114 #define Get_EXT8() ((PIND & (1<<PD4))>>PD4) // EXT8 115 #define Get_EXT9() ((PINE & (1<<PE0))>>PE0) // EXT9 116 #define Get_EXT10() ((PIND & (1<<PD2))>>PD2) // EXT10 121 #define CONV_CURRENT 2 131 void PWM_Init (
unsigned int OCRnRB);
void mc_set_Over_Current(U8 Level)
Set the Over Current threshold.
void mc_init_timer0(void)
Timer 0 Configuration The timer 0 is used to generate an IT when an overflow occurs.
void mc_inrush_task(void)
the purpose of this function is to manage the delay used when the overcurrent detection is disabled...
void mc_init_HW(void)
init HW
void mc_switch_commutation(U8 position)
Set the Switching Commutation value on outputs according to sensor or estimation position.
U8 mc_get_hall(void)
Get the value of hall sensors (1 to 6)
void mc_duty_cycle(U8 level)
Set the duty cycle values in the PSC according to the value calculate by the regulation loop...
void mc_estimation_speed(void)
estimation speed
void mc_disable_during_inrush(void)
the purpose of this function is to disable the overcurrent detection during startup (inrush current...
void mc_init_timer1(void)
timer 1 Configuration Use to generate a 250us activation for sampling speed regulation ...
void PWM_Init(unsigned int OCRnRB)
Initialization of PWM generator PSC0.
U8 mc_Get_Potentiometer(void)
void mc_ADC_Scheduler(void)
Launch the scheduler for the ADC.