TinyX61_macros.h File Reference

Macros for 10 and 16 bit access for the ATtinyX61 family of microcontrollers. More...

#include "config.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 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 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.


Detailed Description

Macros for 10 and 16 bit access for the ATtinyX61 family of microcontrollers.

Application note:
AVR073: Accessing 10 and 16 bit registers in ATtinyX61
Documentation
For comprehensive code documentation, supported compilers, compiler settings and supported devices see readme.html
Author:
Atmel Corporation: http://www.atmel.com
Support email: avr@atmel.com
Name
Revision
1.2
RCSfile
TinyX61_macros.h,v
Date
2006/04/25 10:38:06

Definition in file TinyX61_macros.h.


Define Documentation

 
#define DISABLE_INTERRUPT (  )     (SREG &= (~GLOBAL_INTERRUPT_BIT_MASK))

Disable global interrupt flag.

Definition at line 73 of file TinyX61_macros.h.

#define GLOBAL_INTERRUPT_BIT_MASK   0x80

Bit mask for the global interrupt flag in SREG.

Definition at line 29 of file TinyX61_macros.h.

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

Restore the interrupt state.

Definition at line 70 of file TinyX61_macros.h.

 
#define SAVE_INTERRUPT (  )     SREG

Save the current interrupt state.

Definition at line 67 of file TinyX61_macros.h.

#define TC0_READ_16_BIT_OCR0AB ( destinationVariable   ) 

Value:

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

Reads the 16 bit OCR0A/B value.

Parameters:
destinationVariable Destination variable.

Definition at line 158 of file TinyX61_macros.h.

#define TC0_READ_16_BIT_OCR0AB_INT_SAFE ( destinationVariable   ) 

Value:

{ \
    uint8_t iFlagTemp; \
    iFlagTemp = SAVE_INTERRUPT(); \
    DISABLE_INTERRUPT(); \
    uint8_t tempL = OCR0A; \
    (destinationVariable) = ((uint16_t)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 171 of file TinyX61_macros.h.

#define TC0_READ_TCNT0 ( destinationVariable   ) 

Value:

{ \
    uint8_t 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 96 of file TinyX61_macros.h.

Referenced by HallChangeISR().

#define TC0_READ_TCNT0_INT_SAFE ( destinationVariable   ) 

Value:

{ \
    uint8_t iFlagTemp; \
    uint8_t 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 127 of file TinyX61_macros.h.

#define TC0_WRITE_16_BIT_OCR0AB ( value   ) 

Value:

{ \
    OCR0B = (uint8_t)((value) >> 8); \
    OCR0A = (uint8_t)(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 145 of file TinyX61_macros.h.

#define TC0_WRITE_16_BIT_OCR0AB_INT_SAFE ( value   ) 

Value:

{ \
    uint8_t iFlagTemp; \
    iFlagTemp = SAVE_INTERRUPT(); \
    DISABLE_INTERRUPT(); \
    OCR0B = (uint8_t)((value) >> 8); \
    OCR0A = (uint8_t)(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 188 of file TinyX61_macros.h.

#define TC0_WRITE_TCNT0 ( value   ) 

Value:

{ \
    TCNT0H = (uint8_t)((value) >> 8); \
    TCNT0L = (uint8_t)(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 83 of file TinyX61_macros.h.

Referenced by HallChangeISR(), ovfl_timer0(), and Timer0Init().

#define TC0_WRITE_TCNT0_INT_SAFE ( value   ) 

Value:

{ \
    uint8_t iFlagTemp; \
    iFlagTemp = SAVE_INTERRUPT(); \
    DISABLE_INTERRUPT(); \
    TCNT0H = (uint8_t)((value) >> 8); \
    TCNT0L = (uint8_t)(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 110 of file TinyX61_macros.h.

#define TC1_READ_10_BIT_REGISTER ( sourceRegister,
destinationVariable   ) 

Value:

{ \
    uint8_t tempL; \
    tempL = (sourceRegister); \
    (destinationVariable) = ( ((uint16_t)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 220 of file TinyX61_macros.h.

#define TC1_READ_10_BIT_REGISTER_INT_SAFE ( sourceRegister,
destinationVariable   ) 

Value:

{ \
    uint8_t iFlagTemp; \
    uint8_t tempL; \
    iFlagTemp = SAVE_INTERRUPT(); \
    tempL = (sourceRegister); \
    (destinationVariable) = ( ((uint16_t)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 255 of file TinyX61_macros.h.

#define TC1_SET_ALL_COMPARE_VALUES ( compareValue   ) 

Value:

{ \
      uint16_t tempValue = compareValue; \
      TC1H = ((uint8_t)((tempValue) >> 8)); \
      OCR1A = ((uint8_t)tempValue); \
      OCR1B = ((uint8_t)tempValue); \
      OCR1D = ((uint8_t)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 274 of file TinyX61_macros.h.

#define TC1_WRITE_10_BIT_REGISTER ( destinationRegister,
value   ) 

Value:

{ \
    TC1H = ((value) >> 8); \
    (destinationRegister) = (uint8_t)(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 206 of file TinyX61_macros.h.

Referenced by MotorSetDutyCycle(), and PWMInit().

#define TC1_WRITE_10_BIT_REGISTER_INT_SAFE ( destinationRegister,
value   ) 

Value:

{ \
  uint8_t iFlagTemp; \
  iFlagTemp = SAVE_INTERRUPT(); \
  DISABLE_INTERRUPT(); \
  TC1H = ((value) >> 8); \
  (destinationRegister) = (uint8_t)(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 236 of file TinyX61_macros.h.


Generated on Wed Oct 22 16:03:26 2008 for AVR496 : Atmel BLDC control on ATAVRMC301 with ATtiny861 by  doxygen 1.5.7.1