#include <aversive.h>
#include "pwm.h"
#include <aversive/parts.h>
#include <aversive/timers.h>
#include <pwm_config.h>
#include "timers_synch.h"
Go to the source code of this file.
Defines | |
#define | pwm0_init_ddr() |
#define | pwm0_sign_set() |
#define | pwm0_sign_reset() |
#define | pwm1A_init_ddr() |
#define | pwm1A_sign_set() |
#define | pwm1A_sign_reset() |
#define | pwm1B_init_ddr() |
#define | pwm1B_sign_set() |
#define | pwm1B_sign_reset() |
#define | pwm1C_init_ddr() |
#define | pwm1C_sign_set() |
#define | pwm1C_sign_reset() |
#define | pwm2_init_ddr() |
#define | pwm2_sign_set() |
#define | pwm2_sign_reset() |
#define | pwm3A_init_ddr() |
#define | pwm3A_sign_set() |
#define | pwm3A_sign_reset() |
#define | pwm3B_init_ddr() |
#define | pwm3B_sign_set() |
#define | pwm3B_sign_reset() |
#define | pwm3C_init_ddr() |
#define | pwm3C_sign_set() |
#define | pwm3C_sign_reset() |
#define | pwm_invert_value(mode, value) |
#define | pwm_timer_8bits_init(n, mode, prescale, timer_mode) |
#define | pwm_timer_16bits_init(n, m, mode, prescale, timer_mode) |
#define | pwm_timer_8bits_set(n, value, mode) |
#define | pwm_timer_16bits_set(n, m, value, mode) |
Functions | |
void | pwm_init (void) |
void | pwm_set (void *data, int32_t value) |
Definition in file pwm.c.
#define pwm_invert_value | ( | mode, | |||
value | ) |
Value:
do { \ if ( mode & PWM_SPECIAL_SIGN_MODE ) { \ value = value & PWM_MAX; \ } \ else { \ value = -value; \ } \ } while(0)
Definition at line 219 of file pwm.c.
Referenced by pwm_ng_set().
#define pwm_timer_16bits_init | ( | n, | |||
m, | |||||
mode, | |||||
prescale, | |||||
timer_mode | ) |
Value:
do { \ TCCR##n##A = (TCCR##n##A | \ ( ( timer_mode & 0x01 )?( 1 << WGM##n##0 ):0 ) | \ ( ( timer_mode & 0x02 )?( 1 << WGM##n##1 ):0 ) ) ; \ \ TCCR##n##B = ( ( ( timer_mode & 0x04 )?( 1 << WGM##n##2 ):0 ) | \ ( ( timer_mode & 0x08 )?( 1 << WGM##n##3 ):0 ) | \ ( ( prescale << CS##n##0 ) ) ); \ if(mode & PWM_REVERSE) { \ TCCR##n##A = ( ( (TCCR##n##A) & \ (~(0x03 << COM##n##m##0)) ) | \ (0x01 << COM##n##m##0) ); \ } \ else { \ TCCR##n##A = ( ( (TCCR##n##A) & \ (~(0x03 << COM##n##m##0)) ) | \ (0x02 << COM##n##m##0) ); \ } \ OCR##n##m = 0; \ sbi(OCR##n##m##_DDR,OCR##n##m##_BIT); \ pwm##n##m##_init_ddr(); \ } while(0)
#define pwm_timer_16bits_set | ( | n, | |||
m, | |||||
value, | |||||
mode | ) |
Value:
do { \ MAX(value, PWM_MAX); \ if ( mode & PWM_SIGNED ) { \ MIN(value, PWM_MIN); \ if (value < 0) { \ pwm##n##m##_sign_set(); \ pwm_invert_value(mode, value); \ } \ else { \ pwm##n##m##_sign_reset(); \ } \ } \ else { \ MIN(value, 0); \ } \ OCR##n##m = ( value >> ( PWM_SIGNIFICANT_BITS \ - TIMER##n##_PWM_BITS )) ; \ } while(0)
#define pwm_timer_8bits_init | ( | n, | |||
mode, | |||||
prescale, | |||||
timer_mode | ) |
Value:
do { \ TCCR##n = ( ( ( timer_mode & 0x01 )?( 1 << WGM##n##0 ):0 ) | \ ( ( timer_mode & 0x02 )?( 1 << WGM##n##1 ):0 ) | \ ( ( prescale << CS##n##0 ) ) ); \ if(mode & PWM_REVERSE) { \ TCCR##n = ( ( (TCCR##n) & (~(0x03 << COM##n##0)) ) | \ (0x01 << COM##n##0) ); \ } \ else { \ TCCR##n = ( ( (TCCR##n) & (~(0x03 << COM##n##0)) ) | \ (0x02 << COM##n##0) ); \ } \ OCR##n = 0x00; \ sbi(OCR##n##_DDR,OCR##n##_BIT); \ pwm##n##_init_ddr(); \ } while(0)
#define pwm_timer_8bits_set | ( | n, | |||
value, | |||||
mode | ) |
Value:
do { \ MAX(value, PWM_MAX); \ if ( mode & PWM_SIGNED ) { \ MIN(value, PWM_MIN); \ if (value < 0) { \ pwm##n##_sign_set(); \ pwm_invert_value(mode, value); \ } \ else { \ pwm##n##_sign_reset(); \ } \ } \ else { \ MIN(value, 0); \ } \ OCR##n =(uint8_t) ( value >> ( PWM_SIGNIFICANT_BITS - 8 )); \ } while(0)
void pwm_init | ( | void | ) |
void pwm_set | ( | void * | data, | |
int32_t | value | |||
) |