From 6d9719eaf269fda4b8e6886db78b3c8cc60ed8bb Mon Sep 17 00:00:00 2001 From: asterix Date: Mon, 26 May 2008 09:08:17 +0000 Subject: [PATCH] Add empty PWM driver implementation for AVR. git-svn-id: https://src.develer.com/svnoss/bertos/trunk@1344 38d2e660-2303-0410-9eaa-f027e97ec537 --- bertos/cpu/avr/drv/pwm_avr.c | 96 +++++++++++++++++++++++++++++++++--- bertos/cpu/avr/drv/pwm_avr.h | 40 ++++++++++++--- 2 files changed, 120 insertions(+), 16 deletions(-) diff --git a/bertos/cpu/avr/drv/pwm_avr.c b/bertos/cpu/avr/drv/pwm_avr.c index d10988ad..ada71356 100644 --- a/bertos/cpu/avr/drv/pwm_avr.c +++ b/bertos/cpu/avr/drv/pwm_avr.c @@ -38,11 +38,91 @@ * */ -#include - -#if CPU_AVR - #warning TODO:No AVR implementation of PWM. -/*#elif Add other AVR families here */ -#else - #error Unknown CPU -#endif + +#include "pwm_avr.h" +#include "hw_cpu.h" + +#include "appconfig.h" + +#warning TODO:This is an exmple of implementation of PWM low level channel for AVR, implemnt it! + +/** + * Get preiod from select channel + * + * \a dev channel + */ +pwm_period_t pwm_hw_getPeriod(PwmDev dev) +{ + /* + * Put here a code to get period value of select + * PWM channel + */ + + return 0 +} + +/** + * Set pwm waveform frequecy. + * + * \a freq in Hz + */ +void pwm_hw_setFrequency(PwmDev dev, uint32_t freq) +{ + /* + * Put here a code to set frequency of select + * PWM channel + */ + +// TRACEMSG("PWM ch[%d] period[%d]", dev, period); +} + +/** + * Set pwm duty cycle. + * + * \a duty value 0 - 2^16 + */ +void pwm_hw_setDutyUnlock(PwmDev dev, uint16_t duty) +{ + /* + * Put here a code to set duty of select + * PWM channel + */ + +// TRACEMSG("PWM ch[%d] duty[%d], period[%ld]", dev, duty, *pwm_map[dev].period_reg); +} + + +/** + * Enable select pwm channel + */ +void pwm_hw_enable(PwmDev dev) +{ + /* + * Put here a code to enable + * a select PWM channel + */ +} + +/** + * Disable select pwm channel + */ +void pwm_hw_disable(PwmDev dev) +{ + /* + * Put here a code to disable + * a select PWM channel + */ +} + + +/** + * Init pwm. + */ +void pwm_hw_init(void) +{ + /* + * Put here a code to init + * a PWM hawdware + */ +} + diff --git a/bertos/cpu/avr/drv/pwm_avr.h b/bertos/cpu/avr/drv/pwm_avr.h index 81aeb0ab..022cfba7 100644 --- a/bertos/cpu/avr/drv/pwm_avr.h +++ b/bertos/cpu/avr/drv/pwm_avr.h @@ -38,11 +38,35 @@ * */ -#include - -#if CPU_AVR - #warning TODO:No AVR implementation of PWM. -/*#elif Add other AVR families here */ -#else - #error Unknown CPU -#endif +#ifndef DRV_PWM_AVR_H +#define DRV_PWM_AVR_H + +#include "pwm_map.h" + +#include "appconfig.h" + +#define PWM_HW_MAX_PRESCALER_STEP 10 +#define PWM_HW_MAX_PERIOD 0xFFFF + +/** + * Type definition for pwm period. + */ +typedef uint16_t pwm_period_t; + +/** + * Structur definition for pwm driver. + */ +typedef struct PwmChannel +{ + /* */ +} PwmChannel; + + +void pwm_hw_init(void); +void pwm_hw_setFrequency(PwmDev dev, uint32_t freq); +void pwm_hw_setDutyUnlock(PwmDev dev, uint16_t duty); +void pwm_hw_disable(PwmDev dev); +void pwm_hw_enable(PwmDev dev); +pwm_period_t pwm_hw_getPeriod(PwmDev dev); + +#endif /* DRV_ADC_AT91_H */ -- 2.25.1