/* * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. See the file COPYING * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * Copyright (C) 2010 Frank van Maarseveen */ #ifndef _PWM1_H_ #define _PWM1_H_ #include "hardware.h" void pwm1_init(void); void pwm1_cleanup(void); /* * Read or write the duty cycle. Zero makes the output permanently low. * A too high value (especially 255) will blow up the electronics: keep * it below PWM1_MAX. */ __attribute__((always_inline)) static inline uint8_t pwm1_read(void) { return OCR1A; } __attribute__((always_inline)) static inline void pwm1_write(uint8_t dc) { #ifdef PWM1_MIN if (dc < PWM1_MIN) dc = PWM1_MIN; #endif #ifdef PWM1_MAX if (dc > PWM1_MAX) dc = PWM1_MAX; #endif OCR1A = dc; } #endif