82#include <util/atomic.h>
88#define _writeGpioPinPwm( ddr, port, pin, nbr, chl, ocr, com, tccr, value ) \
96 else if ( value >= 255 ) \
104 ATOMIC_BLOCK( ATOMIC_RESTORESTATE ) \
143#define writeGpioPinPwm( pinName, value ) _writeGpioPinPwm( pinName, value )
180 *(pinVar.
tccr()) &= ~( 1 << pinVar.
com() );
181 *(pinVar.
port()) &= ~( 1 << pinVar.
bitNbr() );
184 else if ( value == 255 )
186 *(pinVar.
tccr()) &= ~( 1 << pinVar.
com() );
191 *(pinVar.
tccr()) |= ( 1 << pinVar.
com() );
193 ATOMIC_BLOCK( ATOMIC_RESTORESTATE )
195 *(pinVar.
ocr()) = value;
299#if defined(__AVR_ATmega2560__)
This file contains the primary macros for naming and manipulating GPIO pin names.
void writeGpioPinPwmV(const GpioPinVariable &pinVar, uint8_t value)
Write a PWM value to a pin.
Definition Pwm.h:176
void initPwmTimer5()
Initialize timer5 for PWM.
Definition Pwm.cpp:168
void clearTimer4()
Clear timer4.
Definition Pwm.cpp:134
void initPwmTimer4()
Initialize timer4 for PWM.
Definition Pwm.cpp:143
void initPwmTimer3()
Initialize timer3 for PWM.
Definition Pwm.cpp:117
void initPwmTimer0()
Initialize timer0 for PWM.
Definition Pwm.cpp:43
void clearTimer0()
Clear timer0.
Definition Pwm.cpp:34
void initPwmTimer1()
Initialize timer1 for PWM.
Definition Pwm.cpp:67
void clearTimer1()
Clear timer1.
Definition Pwm.cpp:58
void clearTimer5()
Clear timer5.
Definition Pwm.cpp:159
void clearTimer2()
Clear timer2.
Definition Pwm.cpp:82
void clearTimer3()
Clear timer3.
Definition Pwm.cpp:108
void initPwmTimer2()
Initialize timer2 for PWM.
Definition Pwm.cpp:91
This class defines a type that can encode a GPIO pin as a variable. Read the section on [GPIO Pin Var...
Definition GpioPinMacros.h:425
uint8_t bitNbr() const
Return the bit number of this GPIO pin within the DDR, PORT, and PIN registers.
Definition GpioPinMacros.h:469
Gpio8Ptr port() const
Return a pointer to the PORT register.
Definition GpioPinMacros.h:453
Gpio16Ptr ocr() const
Return a pointer to the OCR register (PWM related).
Definition GpioPinMacros.h:461
uint8_t com() const
Return the bit number needed for manipulating TCCR register (PWM related).
Definition GpioPinMacros.h:473
Gpio8Ptr tccr() const
Return a pointer to the TCCR register (PWM related).
Definition GpioPinMacros.h:465