Definition in file TinyX61_macros.h.
#include "compiler.h"
Go to the source code of this file.
Defines | |
| #define | ADC_PRESCALER_16 ((1 << ADPS2) | (0 << ADPS1) | (0 << ADPS0)) |
| ADC clock prescaled by 8 value. | |
| #define | ADC_PRESCALER_8 ((0 << ADPS2) | (1 << ADPS1) | (1 << ADPS0)) |
| ADC clock prescaled by 8 value. | |
| #define | ADC_RESOLUTION 1024 |
| The ADC resolution. | |
| #define | ADC_TS_FREERUNNING ((0 << ADTS2) | (0 << ADTS1) | (0 << ADTS0)) |
| ADC trigger source selection to set ADC in free-running mode. | |
| #define | CLEAR_ALL_TIMER0_INT_FLAGS (TIFR = TIFR | 0x1B) |
| Macro that clears all Timer/Counter0 interrupt flags. | |
| #define | CLEAR_ALL_TIMER1_INT_FLAGS (TIFR = TIFR | 0xE4) |
| Macro that clears all Timer/counter0 interrupt flags. | |
| #define | Clear_prescaler() (Set_cpu_prescaler(0)) |
| Clear prescaler. | |
| #define | DISABLE_ALL_TIMER0_INTS (TIMSK &= 0xE4) |
| Macro that disables all Timer/Counter0 interrupts. | |
| #define | DISABLE_ALL_TIMER1_INTS (TIMSK &= 0x1B) |
| Macro that disables all Timer/Counter1 interrupts. | |
| #define | DISABLE_INTERRUPT() (SREG &= (~GLOBAL_INTERRUPT_BIT_MASK)) |
| Disable global interrupt flag. | |
| #define | GLOBAL_INTERRUPT_BIT_MASK 0x80 |
| Bit mask for the global interrupt flag in SREG. | |
| #define | RESTORE_INTERRUPT(state) (SREG = (state)) |
| Restore the interrupt state. | |
| #define | SAVE_INTERRUPT() SREG |
| Save the current interrupt state. | |
| #define | SET_TIMER0_COMPA_INT (TIMSK = (1 << OCIE0A)) |
| Macro that enable Timer/Counter0 Compare A interrupt. | |
| #define | SET_TIMER1_INT_ZC_DETECTION (TIMSK = (1 << TOIE1)) |
| Macro that enables Timer/Counter1 interrupt where zero crossings are detected. | |
| #define | TC0_READ_16_BIT_OCR0AB(destinationVariable) |
| Read 16 bit value from OCR0A/B. | |
| #define | TC0_READ_16_BIT_OCR0AB_INT_SAFE(destinationVariable) |
| Atomic 16 bit read from OCRA/B. | |
| #define | TC0_READ_TCNT0(destinationVariable) |
| Read 16 bit value from TCNT0. | |
| #define | TC0_READ_TCNT0_INT_SAFE(destinationVariable) |
| Atomic 16 bit read from TCNT0. | |
| #define | TC0_WRITE_16_BIT_OCR0AB(value) |
| Write 16 bit value to OCR0A/B. | |
| #define | TC0_WRITE_16_BIT_OCR0AB_INT_SAFE(value) |
| Write 16 bit value to OCR0A/B. | |
| #define | TC0_WRITE_TCNT0(value) |
| Write 16 bit value to TCNT0. | |
| #define | TC0_WRITE_TCNT0_INT_SAFE(value) |
| Atomic 16 bit write to TCNT0. | |
| #define | TC1_READ_10_BIT_REGISTER(sourceRegister, destinationVariable) |
| Read 10 bit value from a Timer/Counter1 register. | |
| #define | TC1_READ_10_BIT_REGISTER_INT_SAFE(sourceRegister, destinationVariable) |
| Atomic 10 bit read from a Timer/Counter1 register. | |
| #define | TC1_SET_ALL_COMPARE_VALUES(compareValue) |
| Set same output compare value for all output channels of Timer/counter1. | |
| #define | TC1_WRITE_10_BIT_REGISTER(destinationRegister, value) |
| Write 10 bit value to a Timer/Counter1 register. | |
| #define | TC1_WRITE_10_BIT_REGISTER_INT_SAFE(destinationRegister, value) |
| Atomic 10 bit write to a Timer/Counter1 register. | |
Functions | |
| void | Set_cpu_prescaler (U8 x) |
| Set prescaler. | |
| #define ADC_PRESCALER_16 ((1 << ADPS2) | (0 << ADPS1) | (0 << ADPS0)) |
ADC clock prescaled by 8 value.
Definition at line 353 of file TinyX61_macros.h.
Referenced by ADCInit(), and MotorPWMBottom().
| #define ADC_PRESCALER_8 ((0 << ADPS2) | (1 << ADPS1) | (1 << ADPS0)) |
| #define ADC_RESOLUTION 1024 |
| #define ADC_TS_FREERUNNING ((0 << ADTS2) | (0 << ADTS1) | (0 << ADTS0)) |
ADC trigger source selection to set ADC in free-running mode.
Definition at line 356 of file TinyX61_macros.h.
| #define CLEAR_ALL_TIMER0_INT_FLAGS (TIFR = TIFR | 0x1B) |
Macro that clears all Timer/Counter0 interrupt flags.
Definition at line 338 of file TinyX61_macros.h.
Referenced by Commutate(), and MotorPWMBottom().
| #define CLEAR_ALL_TIMER1_INT_FLAGS (TIFR = TIFR | 0xE4) |
Macro that clears all Timer/counter0 interrupt flags.
Definition at line 329 of file TinyX61_macros.h.
Referenced by MotorPWMBottom().
| #define Clear_prescaler | ( | ) | (Set_cpu_prescaler(0)) |
Clear prescaler.
This function reset the internal CPU core clock prescaler
| none |
Definition at line 308 of file TinyX61_macros.h.
Referenced by mc_init_HW().
| #define DISABLE_ALL_TIMER0_INTS (TIMSK &= 0xE4) |
Macro that disables all Timer/Counter0 interrupts.
Definition at line 341 of file TinyX61_macros.h.
Referenced by Commutate().
| #define DISABLE_ALL_TIMER1_INTS (TIMSK &= 0x1B) |
Macro that disables all Timer/Counter1 interrupts.
Definition at line 332 of file TinyX61_macros.h.
Referenced by MotorPWMBottom().
| #define DISABLE_INTERRUPT | ( | ) | (SREG &= (~GLOBAL_INTERRUPT_BIT_MASK)) |
| #define GLOBAL_INTERRUPT_BIT_MASK 0x80 |
| #define RESTORE_INTERRUPT | ( | state | ) | (SREG = (state)) |
| #define SAVE_INTERRUPT | ( | ) | SREG |
| #define SET_TIMER0_COMPA_INT (TIMSK = (1 << OCIE0A)) |
Macro that enable Timer/Counter0 Compare A interrupt.
Definition at line 344 of file TinyX61_macros.h.
| #define SET_TIMER1_INT_ZC_DETECTION (TIMSK = (1 << TOIE1)) |
Macro that enables Timer/Counter1 interrupt where zero crossings are detected.
Definition at line 335 of file TinyX61_macros.h.
Referenced by Commutate(), and mc_start_motor().
| #define TC0_READ_16_BIT_OCR0AB | ( | destinationVariable | ) |
Value:
Read 16 bit value from OCR0A/B.Reads the 16 bit OCR0A/B value.
| destinationVariable | Destination variable. |
Definition at line 174 of file TinyX61_macros.h.
| #define TC0_READ_16_BIT_OCR0AB_INT_SAFE | ( | destinationVariable | ) |
Value:
{ \
U8 iFlagTemp; \
iFlagTemp = SAVE_INTERRUPT(); \
DISABLE_INTERRUPT(); \
U8 tempL = OCR0A; \
(destinationVariable) = ((U16)OCR0B << 8) | tempL; \
RESTORE_INTERRUPT(iFlagTemp); \
}
Reads the 16 bit OCR0A/B value in one atomic operation.
| destinationVariable | Destination variable. |
Definition at line 187 of file TinyX61_macros.h.
| #define TC0_READ_TCNT0 | ( | destinationVariable | ) |
Value:
{ \
U8 tempL; \
tempL = TCNT0L; \
(destinationVariable) = ((TCNT0H << 8) | tempL); \
}
Reads the 16 bit value of TCNT0 (TCNT0L/H).
| destinationVariable | Destination variable. |
Definition at line 112 of file TinyX61_macros.h.
Referenced by MotorPWMBottom().
| #define TC0_READ_TCNT0_INT_SAFE | ( | destinationVariable | ) |
Value:
{ \
U8 iFlagTemp; \
U8 tempL; \
iFlagTemp = SAVE_INTERRUPT(); \
DISABLE_INTERRUPT(); \
tempL = TCNT0L; \
(destinationVariable) = ((TCNT0H << 8) | tempL); \
RESTORE_INTERRUPT(iFlagTemp); \
}
Reads the 16 bit value of TCNT0 (TCNT0L/H) in one atomic operation.
| destinationVariable | Destination variable. |
Definition at line 143 of file TinyX61_macros.h.
| #define TC0_WRITE_16_BIT_OCR0AB | ( | value | ) |
Value:
Write 16 bit value to OCR0A/B.Writes a 16 bit value to OCR0A/B.
| value | New 16 bit OCR0A/B value. |
Definition at line 161 of file TinyX61_macros.h.
| #define TC0_WRITE_16_BIT_OCR0AB_INT_SAFE | ( | value | ) |
Value:
{ \
U8 iFlagTemp; \
iFlagTemp = SAVE_INTERRUPT(); \
DISABLE_INTERRUPT(); \
OCR0B = (U8)((value) >> 8); \
OCR0A = (U8)(value);\
RESTORE_INTERRUPT(iFlagTemp); \
}
Writes a 16 bit value to OCR0A/B.
| value | New 16 bit OCR0A/B value. |
Definition at line 204 of file TinyX61_macros.h.
| #define TC0_WRITE_TCNT0 | ( | value | ) |
Value:
Write 16 bit value to TCNT0.Writes a 16 bit value to TCNT0 (TCNT0L/H).
| value | New 16 bit TCNT0 value. |
Definition at line 99 of file TinyX61_macros.h.
Referenced by Commutate(), mc_start_motor(), and MotorPWMBottom().
| #define TC0_WRITE_TCNT0_INT_SAFE | ( | value | ) |
Value:
{ \
U8 iFlagTemp; \
iFlagTemp = SAVE_INTERRUPT(); \
DISABLE_INTERRUPT(); \
TCNT0H = (U8)((value) >> 8); \
TCNT0L = (U8)(value); \
RESTORE_INTERRUPT(iFlagTemp); \
}
Writes a 16 bit value to TCNT0 (TCNT0L/H) in one atomic operation.
| value | New 16 bit TCNT0 value. |
Definition at line 126 of file TinyX61_macros.h.
| #define TC1_READ_10_BIT_REGISTER | ( | sourceRegister, | |||
| destinationVariable | ) |
Value:
{ \
U8 tempL; \
tempL = (sourceRegister); \
(destinationVariable) = ( ((U16)TC1H << 8) | tempL); \
}
Reads a 10 bit value from any 10 bit Timer/counter1 register.
| sourceRegister | Source register | |
| destinationVariable | Destination variable. |
Definition at line 236 of file TinyX61_macros.h.
| #define TC1_READ_10_BIT_REGISTER_INT_SAFE | ( | sourceRegister, | |||
| destinationVariable | ) |
Value:
{ \
U8 iFlagTemp; \
U8 tempL; \
iFlagTemp = SAVE_INTERRUPT(); \
tempL = (sourceRegister); \
(destinationVariable) = ( ((U16)TC1H << 8) | tempL); \
RESTORE_INTERRUPT(iFlagTemp); \
}
Reads a 10 bit value from any 10 bit Timer/counter1 register in one atomic operation.
| sourceRegister | Source register | |
| destinationVariable | Destination variable |
Definition at line 271 of file TinyX61_macros.h.
| #define TC1_SET_ALL_COMPARE_VALUES | ( | compareValue | ) |
Value:
{ \
U16 tempValue = compareValue; \
TC1H = ((U8)((tempValue) >> 8)); \
OCR1A = ((U8)tempValue); \
OCR1B = ((U8)tempValue); \
OCR1D = ((U8)tempValue); \
}
This macro sets the same output compare value to all three output channels of Timer/counter1. This does not apply to PWM6 mode, where all channels controlled by a single compare register.
| compareValue | New output compare value. |
Definition at line 290 of file TinyX61_macros.h.
| #define TC1_WRITE_10_BIT_REGISTER | ( | destinationRegister, | |||
| value | ) |
Value:
{ \
TC1H = ((value) >> 8); \
(destinationRegister) = (U8)(value); \
}
Writes a 10 bit value to any 10 bit Timer/Counter1 register.
| destinationRegister | Destination register. | |
| value | Register value. |
Definition at line 222 of file TinyX61_macros.h.
Referenced by mc_set_duty_cycle(), and PWMInit().
| #define TC1_WRITE_10_BIT_REGISTER_INT_SAFE | ( | destinationRegister, | |||
| value | ) |
Value:
{ \
U8 iFlagTemp; \
iFlagTemp = SAVE_INTERRUPT(); \
DISABLE_INTERRUPT(); \
TC1H = ((value) >> 8); \
(destinationRegister) = (U8)(value); \
RESTORE_INTERRUPT(iFlagTemp); \
}
Writes a 10 bit value to any 10 bit Timer/Counter1 register in one atomic. operation.
| destinationRegister | Destination register. | |
| value | Register value. |
Definition at line 252 of file TinyX61_macros.h.
| void Set_cpu_prescaler | ( | U8 | x | ) |
1.5.4