Defines | Functions

# timerhs_drv.h File Reference

This file contains the low level functions (drivers) of 10-bit High Speed timer. More...

`#include "config.h"`
Include dependency graph for timerhs_drv.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

## Defines
#define | COM4D1 3
#define | COM4D0 2
#define | Timerhs_get_counter() ( timerhs_get_counter() )
#define | Timerhs_get_capture() ( timerhs_get_capture() )
#define | Timerhs_set_pwm_a(value) ( Timerhs_set_compare_a(value) )
#define | Timerhs_set_pwm_b(value) ( Timerhs_set_compare_b(value) )
#define | Timerhs_set_pwm_c(value) ( Timerhs_set_compare_c(value) )
#define | Timerhs_get_pwm_a() ( Timerhs_get_compare_a() )
#define | Timerhs_get_pwm_b() ( Timerhs_get_compare_b() )
#define | Timerhs_get_pwm_c() ( Timerhs_get_compare_c() )
#define | Timerhs_off() Timerhs_set_clock(TIMER16_NO_CLOCK)
#define | Timerhs_clear()
#define | Timerhs_set_synchronous_mode() PLL_SET_HS_TMR_PSCAL_NULL
#define | Timerhs_set_counter(value) ( TC4H = ((U8)((value)>>8)), TCNT4L = ((U8)(value)))
#define | Timerhs_get_counter_low() ((U16)(TCNT4))
#define | Timerhs_get_counter_high() ((U16)(TC4H))
#define | Timerhs_set_compare_a(value) ( TC4H = ((U16)((value)>>8)), OCR4A = ((U8)(value)))
#define | Timerhs_set_compare_b(value) ( TC4H = ((U16)((value)>>8)), OCR4B = ((U8)(value)))
#define | Timerhs_set_compare_c(value) ( TC4H = ((U16)((value)>>8)), OCR4C = ((U8)(value)))
#define | Timerhs_set_top(value) Timerhs_set_compare_c(value)
#define | Timerhs_set_nb_bit(n) Timerhs_set_compare_c((U16)((1<<n)-1))
#define | Timerhs_set_compare_d(value) ( TC4H = ((U8)((value)>>8)), OCR4D = ((U8)(value)))
#define | Timerhs_get_compare_a() ( (U16)OCR4A|TC4H<<8 )
#define | Timerhs_get_compare_b() ( (U16)OCR4B|TC4H<<8 )
#define | Timerhs_get_compare_d() ( (U16)OCR4D|TC4H<<8 )
#define | Timerhs_enable_pwm_a() (DDRC|=0x80, TCCR4A |= (1<<COM4A1), TCCR4A |= (1<<PWM4A))
#define | Timerhs_enable_pwm_b() (DDRB|=0x40, TCCR4A |= (1<<COM4B1), TCCR4A |= (1<<PWM4B))
#define | Timerhs_enable_pwm_d() (DDRD|=0x80, TCCR4C |= (1<<COM4D1), TCCR4C |= (1<<PWM4D))
#define | Timerhs_enable_pwm_a_and_na() (DDRC|=0xC0, TCCR4A |= (1<<COM4A0), TCCR4A |= (1<<PWM4A))
#define | Timerhs_enable_pwm_b_and_nb() (DDRB|=0x60, TCCR4A |= (1<<COM4B0), TCCR4A |= (1<<PWM4B))
#define | Timerhs_enable_pwm_d_and_nd() (DDRD|=0xC0, TCCR4C |= (1<<COM4D0), TCCR4C |= (1<<PWM4D))
#define | Timerhs_set_enhanced_pwm_mode() (TCCR4E |= (1<<ENHC4))
#define | Timerhs_set_waveform_mode(conf) ( TCCR4D = (TCCR4A & (~((1<<WGM41)|(1<<WGM40)))) | ((conf & 0x3) ))
#define | Timerhs_set_clock(value) ( TCCR4B = (TCCR4B & (~TIMERHS_CLK_MASK)) | (value) )
#define | Timerhs_get_clock() (((TCCR4B & TIMERHS_CLK_MASK) )
#define | TIMERHS_WGM_NORMAL (0)
#define | TIMERHS_WGM_FAST_PWM (0)
#define | TIMERHS_WGM_PHASEFREQCORRECT_PWM (1)
#define | TIMERHS_WGM_PWM6_SINGLE_SLOPE (2)
#define | TIMERHS_WGM_PWM6_DUAL_SLOPE (3)
#define | TIMERHS_NO_CLOCK (0)
#define | TIMERHS_CLK_BY_1 (1)
#define | TIMERHS_CLK_BY_2 (2)
#define | TIMERHS_CLK_BY_4 (3)
#define | TIMERHS_CLK_BY_8 (4)
#define | TIMERHS_CLK_BY_16 (5)
#define | TIMERHS_CLK_BY_32 (6)
#define | TIMERHS_CLK_BY_64 (7)
#define | TIMERHS_CLK_BY_128 (8)
#define | TIMERHS_CLK_BY_256 (9)
#define | TIMERHS_CLK_BY_512 (10)
#define | TIMERHS_CLK_BY_1024 (11)
#define | TIMERHS_CLK_BY_2048 (12)
#define | TIMERHS_CLK_BY_4096 (13)
#define | TIMERHS_CLK_BY_8192 (14)
#define | TIMERHS_CLK_BY_16384 (15)
#define | TIMERHS_CLK_MASK ((1<<CS43) | (1<<CS42) |(1<<CS41) |(1<<CS40) )
## Functions
U16 | timerhs_get_counter (void)
| This function READ the 16-bit TIMER counter.
U16 | timerhs_get_capture (void)
| This function READ the 16-bit TIMER capture register.

## Detailed Description

This file contains the low level functions (drivers) of 10-bit High Speed timer.

- Compiler: IAR EWAVR and GNU GCC for AVR
- Supported devices: ATmega32U4

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

Definition in file timerhs_drv.h.

## Define Documentation

#define COM4D1 3

Definition at line 55 of file timerhs_drv.h.

#define COM4D0 2

Definition at line 58 of file timerhs_drv.h.

#define Timerhs_get_counter | ( | ) | ( timerhs_get_counter() )

Definition at line 66 of file timerhs_drv.h.

#define Timerhs_get_capture | ( | ) | ( timerhs_get_capture() )

Definition at line 67 of file timerhs_drv.h.

#define Timerhs_set_pwm_a | ( |  | value ) | ( Timerhs_set_compare_a(value) )

Definition at line 69 of file timerhs_drv.h.

#define Timerhs_set_pwm_b | ( |  | value ) | ( Timerhs_set_compare_b(value) )

Definition at line 70 of file timerhs_drv.h.

#define Timerhs_set_pwm_c | ( |  | value ) | ( Timerhs_set_compare_c(value) )

Definition at line 71 of file timerhs_drv.h.

#define Timerhs_get_pwm_a | ( | ) | ( Timerhs_get_compare_a() )

Definition at line 72 of file timerhs_drv.h.

#define Timerhs_get_pwm_b | ( | ) | ( Timerhs_get_compare_b() )

Definition at line 73 of file timerhs_drv.h.

#define Timerhs_get_pwm_c | ( | ) | ( Timerhs_get_compare_c() )

Definition at line 74 of file timerhs_drv.h.

#define Timerhs_off | ( | ) | Timerhs_set_clock(TIMER16_NO_CLOCK)

Definition at line 76 of file timerhs_drv.h.

#define Timerhs_clear | ( | ) |

Value:

    ( TCCR4B=0, TCCR4A=0, TCCR4C=0, TCCR4D=0, TCCR4E=0,TC4H=0, TCNT4= 0,\
                                      TC4H=0, OCR4A=0, \
                                      TC4H=0, OCR4B=0, \
                                      TC4H=0, OCR4D=0\
                                    )

Definition at line 98 of file timerhs_drv.h.

#define Timerhs_set_synchronous_mode | ( | ) | PLL_SET_HS_TMR_PSCAL_NULL

Definition at line 104 of file timerhs_drv.h.

#define Timerhs_set_counter | ( |  | value ) | ( TC4H = ((U8)((value)>>8)), TCNT4L = ((U8)(value)))

Definition at line 108 of file timerhs_drv.h.

#define Timerhs_get_counter_low | ( | ) | ((U16)(TCNT4))

Definition at line 109 of file timerhs_drv.h.

Referenced by timerhs_get_counter().

#define Timerhs_get_counter_high | ( | ) | ((U16)(TC4H))

Definition at line 110 of file timerhs_drv.h.

Referenced by timerhs_get_counter().

#define Timerhs_set_compare_a | ( |  | value ) | ( TC4H = ((U16)((value)>>8)), OCR4A = ((U8)(value)))

Definition at line 112 of file timerhs_drv.h.

#define Timerhs_set_compare_b | ( |  | value ) | ( TC4H = ((U16)((value)>>8)), OCR4B = ((U8)(value)))

Definition at line 113 of file timerhs_drv.h.

#define Timerhs_set_compare_c | ( |  | value ) | ( TC4H = ((U16)((value)>>8)), OCR4C = ((U8)(value)))

Definition at line 114 of file timerhs_drv.h.

#define Timerhs_set_top | ( |  | value ) | Timerhs_set_compare_c(value)

Definition at line 115 of file timerhs_drv.h.

#define Timerhs_set_nb_bit | ( |  | n ) | Timerhs_set_compare_c((U16)((1<<n)-1))

Definition at line 116 of file timerhs_drv.h.

#define Timerhs_set_compare_d | ( |  | value ) | ( TC4H = ((U8)((value)>>8)), OCR4D = ((U8)(value)))

Definition at line 117 of file timerhs_drv.h.

#define Timerhs_get_compare_a | ( | ) | ( (U16)OCR4A|TC4H<<8 )

Definition at line 118 of file timerhs_drv.h.

#define Timerhs_get_compare_b | ( | ) | ( (U16)OCR4B|TC4H<<8 )

Definition at line 119 of file timerhs_drv.h.

#define Timerhs_get_compare_d | ( | ) | ( (U16)OCR4D|TC4H<<8 )

Definition at line 120 of file timerhs_drv.h.

#define Timerhs_enable_pwm_a | ( | ) | (DDRC|=0x80, TCCR4A |= (1<<COM4A1), TCCR4A |= (1<<PWM4A))

Definition at line 122 of file timerhs_drv.h.

#define Timerhs_enable_pwm_b | ( | ) | (DDRB|=0x40, TCCR4A |= (1<<COM4B1), TCCR4A |= (1<<PWM4B))

Definition at line 123 of file timerhs_drv.h.

#define Timerhs_enable_pwm_d | ( | ) | (DDRD|=0x80, TCCR4C |= (1<<COM4D1), TCCR4C |= (1<<PWM4D))

Definition at line 124 of file timerhs_drv.h.

#define Timerhs_enable_pwm_a_and_na | ( | ) | (DDRC|=0xC0, TCCR4A |= (1<<COM4A0), TCCR4A |= (1<<PWM4A))

Definition at line 126 of file timerhs_drv.h.

#define Timerhs_enable_pwm_b_and_nb | ( | ) | (DDRB|=0x60, TCCR4A |= (1<<COM4B0), TCCR4A |= (1<<PWM4B))

Definition at line 127 of file timerhs_drv.h.

#define Timerhs_enable_pwm_d_and_nd | ( | ) | (DDRD|=0xC0, TCCR4C |= (1<<COM4D0), TCCR4C |= (1<<PWM4D))

Definition at line 128 of file timerhs_drv.h.

#define Timerhs_set_enhanced_pwm_mode | ( | ) | (TCCR4E |= (1<<ENHC4))

Definition at line 130 of file timerhs_drv.h.

#define Timerhs_set_waveform_mode | ( |  | conf ) | ( TCCR4D = (TCCR4A & (~((1<<WGM41)|(1<<WGM40)))) | ((conf & 0x3) ))

Definition at line 133 of file timerhs_drv.h.

#define Timerhs_set_clock | ( |  | value ) | ( TCCR4B = (TCCR4B & (~TIMERHS_CLK_MASK)) | (value) )

Definition at line 135 of file timerhs_drv.h.

#define Timerhs_get_clock | ( | ) | (((TCCR4B & TIMERHS_CLK_MASK) )

Definition at line 136 of file timerhs_drv.h.

#define TIMERHS_WGM_NORMAL (0)

Definition at line 143 of file timerhs_drv.h.

#define TIMERHS_WGM_FAST_PWM (0)

Definition at line 144 of file timerhs_drv.h.

#define TIMERHS_WGM_PHASEFREQCORRECT_PWM (1)

Definition at line 145 of file timerhs_drv.h.

#define TIMERHS_WGM_PWM6_SINGLE_SLOPE (2)

Definition at line 146 of file timerhs_drv.h.

#define TIMERHS_WGM_PWM6_DUAL_SLOPE (3)

Definition at line 147 of file timerhs_drv.h.

#define TIMERHS_NO_CLOCK (0)

Definition at line 151 of file timerhs_drv.h.

#define TIMERHS_CLK_BY_1 (1)

Definition at line 152 of file timerhs_drv.h.

#define TIMERHS_CLK_BY_2 (2)

Definition at line 153 of file timerhs_drv.h.

#define TIMERHS_CLK_BY_4 (3)

Definition at line 154 of file timerhs_drv.h.

#define TIMERHS_CLK_BY_8 (4)

Definition at line 155 of file timerhs_drv.h.

#define TIMERHS_CLK_BY_16 (5)

Definition at line 156 of file timerhs_drv.h.

#define TIMERHS_CLK_BY_32 (6)

Definition at line 157 of file timerhs_drv.h.

#define TIMERHS_CLK_BY_64 (7)

Definition at line 158 of file timerhs_drv.h.

#define TIMERHS_CLK_BY_128 (8)

Definition at line 159 of file timerhs_drv.h.

#define TIMERHS_CLK_BY_256 (9)

Definition at line 160 of file timerhs_drv.h.

#define TIMERHS_CLK_BY_512 (10)

Definition at line 161 of file timerhs_drv.h.

#define TIMERHS_CLK_BY_1024 (11)

Definition at line 162 of file timerhs_drv.h.

#define TIMERHS_CLK_BY_2048 (12)

Definition at line 163 of file timerhs_drv.h.

#define TIMERHS_CLK_BY_4096 (13)

Definition at line 164 of file timerhs_drv.h.

#define TIMERHS_CLK_BY_8192 (14)

Definition at line 165 of file timerhs_drv.h.

#define TIMERHS_CLK_BY_16384 (15)

Definition at line 166 of file timerhs_drv.h.

#define TIMERHS_CLK_MASK ((1<<CS43) | (1<<CS42) |(1<<CS41) |(1<<CS40) )

Definition at line 168 of file timerhs_drv.h.

## Function Documentation

U16 timerhs_get_counter | ( | void | ) |

This function READ the 16-bit TIMER counter.

Warning:

Parameters:

Returns:
  16-bit counter value

This function READ the 16-bit TIMER counter.

Warning:

Parameters:

Returns:
  hs-bit counter value

Definition at line 65 of file timerhs_drv.c.

References Timerhs_get_counter_high, and Timerhs_get_counter_low.

    {
        U16 u16_temp;

        u16_temp  =  Timerhs_get_counter_low();
        u16_temp |= (Timerhs_get_counter_high() << 8 );

        return u16_temp;
    }

U16 timerhs_get_capture | ( | void | ) |

This function READ the 16-bit TIMER capture register.

Warning:

Parameters:

Returns:
  16-bit capture value