along with simavr. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef AVR_TIMER_H_
-#define AVR_TIMER_H_
+#ifndef __AVR_TIMER_H__
+#define __AVR_TIMER_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif
#include "sim_avr.h"
// Get the internal IRQ corresponding to the INT
#define AVR_IOCTL_TIMER_GETIRQ(_name) AVR_IOCTL_DEF('t','m','r',(_name))
-// Waweform generation modes
+// Waveform generation modes
enum {
avr_timer_wgm_none = 0, // invalid mode
avr_timer_wgm_normal,
avr_timer_wgm_ctc,
avr_timer_wgm_pwm,
avr_timer_wgm_fast_pwm,
+ avr_timer_wgm_fc_pwm,
};
// Compare output modes
#define AVR_TIMER_WGM_FASTPWM8() { .kind = avr_timer_wgm_fast_pwm, .size=8 }
#define AVR_TIMER_WGM_FASTPWM9() { .kind = avr_timer_wgm_fast_pwm, .size=9 }
#define AVR_TIMER_WGM_FASTPWM10() { .kind = avr_timer_wgm_fast_pwm, .size=10 }
+#define AVR_TIMER_WGM_FCPWM8() { .kind = avr_timer_wgm_fc_pwm, .size=8 }
+#define AVR_TIMER_WGM_FCPWM9() { .kind = avr_timer_wgm_fc_pwm, .size=9 }
+#define AVR_TIMER_WGM_FCPWM10() { .kind = avr_timer_wgm_fc_pwm, .size=10 }
#define AVR_TIMER_WGM_OCPWM() { .kind = avr_timer_wgm_pwm, .top = avr_timer_wgm_reg_ocra }
#define AVR_TIMER_WGM_ICPWM() { .kind = avr_timer_wgm_pwm, .top = avr_timer_wgm_reg_icr }
typedef struct avr_timer_t {
avr_io_t io;
char name;
+ uint16_t trace_flags;
+
avr_regbit_t disabled; // bit in the PRR
avr_io_addr_t r_tcnt, r_icr;
avr_regbit_t cs[4];
uint8_t cs_div[16];
avr_regbit_t as2; // asynchronous clock 32khz
+ avr_regbit_t icp; // input capture pin, to link IRQs
+ avr_regbit_t ices; // input capture edge select
struct {
avr_int_vector_t interrupt; // interrupt vector
avr_timer_wgm_t mode;
uint64_t tov_cycles;
- uint64_t tov_base; // we we last were called
+ uint64_t tov_base; // when we last were called
uint16_t tov_top; // current top value to calculate tnct
} avr_timer_t;
void avr_timer_init(avr_t * avr, avr_timer_t * port);
-#endif /* AVR_TIMER_H_ */
+#ifdef __cplusplus
+};
+#endif
+
+#endif /*__AVR_TIMER_H__*/