TinyX61_macros.h File Reference


Detailed Description

This file contains the function declarations.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file TinyX61_macros.h.

#include "compiler.h"

Include dependency graph for TinyX61_macros.h:

This graph shows which files directly or indirectly include this file:

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 Documentation

#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))

ADC clock prescaled by 8 value.

Definition at line 350 of file TinyX61_macros.h.

#define ADC_RESOLUTION   1024

The ADC resolution.

Definition at line 347 of file TinyX61_macros.h.

#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

Parameters:
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))

Disable global interrupt flag.

Definition at line 89 of file TinyX61_macros.h.

#define GLOBAL_INTERRUPT_BIT_MASK   0x80

Bit mask for the global interrupt flag in SREG.

Definition at line 326 of file TinyX61_macros.h.

#define RESTORE_INTERRUPT ( state   )     (SREG = (state))

Restore the interrupt state.

Definition at line 86 of file TinyX61_macros.h.

 
#define SAVE_INTERRUPT (  )     SREG

Save the current interrupt state.

Definition at line 83 of file TinyX61_macros.h.

#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:

{ \
    U8 tempL = OCR0A; \
    (destinationVariable) = ((U16)OCR0B << 8) | tempL; \
  }
Read 16 bit value from OCR0A/B.

Reads the 16 bit OCR0A/B value.

Parameters:
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); \
  }
Atomic 16 bit read from OCRA/B.

Reads the 16 bit OCR0A/B value in one atomic operation.

Parameters:
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); \
  }
Read 16 bit value from TCNT0.

Reads the 16 bit value of TCNT0 (TCNT0L/H).

Parameters:
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); \
  }
Atomic 16 bit read from TCNT0.

Reads the 16 bit value of TCNT0 (TCNT0L/H) in one atomic operation.

Parameters:
destinationVariable Destination variable.

Definition at line 143 of file TinyX61_macros.h.

#define TC0_WRITE_16_BIT_OCR0AB ( value   ) 

Value:

{ \
    OCR0B = (U8)((value) >> 8); \
    OCR0A = (U8)(value);\
  }
Write 16 bit value to OCR0A/B.

Writes a 16 bit value to OCR0A/B.

Parameters:
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); \
  }
Write 16 bit value to OCR0A/B.

Writes a 16 bit value to OCR0A/B.

Parameters:
value New 16 bit OCR0A/B value.

Definition at line 204 of file TinyX61_macros.h.

#define TC0_WRITE_TCNT0 ( value   ) 

Value:

{ \
    TCNT0H = (U8)((value) >> 8); \
    TCNT0L = (U8)(value); \
  }
Write 16 bit value to TCNT0.

Writes a 16 bit value to TCNT0 (TCNT0L/H).

Parameters:
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); \
  }
Atomic 16 bit write to TCNT0.

Writes a 16 bit value to TCNT0 (TCNT0L/H) in one atomic operation.

Parameters:
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); \
  }
Read 10 bit value from a Timer/Counter1 register.

Reads a 10 bit value from any 10 bit Timer/counter1 register.

Parameters:
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); \
  }
Atomic 10 bit read from a Timer/Counter1 register.

Reads a 10 bit value from any 10 bit Timer/counter1 register in one atomic operation.

Parameters:
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); \
  }
Set same output compare value for all output channels of Timer/counter1.

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.

Parameters:
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); \
  }
Write 10 bit value to a Timer/Counter1 register.

Writes a 10 bit value to any 10 bit Timer/Counter1 register.

Parameters:
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); \
  }
Atomic 10 bit write to a Timer/Counter1 register.

Writes a 10 bit value to any 10 bit Timer/Counter1 register in one atomic. operation.

Parameters:
destinationRegister Destination register.
value Register value.

Definition at line 252 of file TinyX61_macros.h.


Function Documentation

void Set_cpu_prescaler ( U8  x  ) 

Set prescaler.

This function set the internal CPU core clock prescaler

Parameters:
x Prescaler Value.

Definition at line 255 of file mc_drv.c.

00256    {
00257       U8 save_int=SREG&0x80;
00258       Disable_interrupt();
00259       CLKPR=(1<<CLKPCE);
00260       CLKPR=x;
00261       if(save_int) { Enable_interrupt(); }
00262    }


Generated on Mon Dec 1 11:12:22 2008 for AVR498 : Atmel BLDC control on ATAVRMC301 with ATtiny861 by  doxygen 1.5.4