9 #define PIT_FREQ 1193182
14 DRIFT_REINJECT_GRADUAL
,
18 class PITChannel
: public Device
23 void write_back_command(uint8_t val
);
24 void write_control(uint8_t val
);
25 void write_counter(uint8_t val
);
28 void marshal(Marshaller
*m
, const char *name
);
31 void set_drift_mode(DriftMode mode
);
36 int64_t get_next_transition_time(uint64_t current_time
);
37 void irq_timer_update(uint64_t current_time
);
38 void on_irq_timer(void);
39 int get_out1(int64_t current_time
);
40 void load_count(int val
);
41 void latch_count(void);
42 uint16_t get_count(void);
43 void update_irq(uint64_t current_time
);
45 uint32_t count
; /* can be 65536 */
46 uint16_t latched_count
;
47 uint8_t count_latched
;
48 uint8_t status_latched
;
55 uint8_t bcd
; /* not supported */
56 uint8_t gate
; /* timer start */
57 int64_t count_load_time
;
59 int64_t next_transition_time
;
66 class PIT
: public Device
69 PIT(DriftMode mode
= DRIFT_DROP
);
71 void marshal(Marshaller
*m
, const char *name
);
73 void write(uint8_t addr
, uint8_t val
);
74 uint8_t read(uint8_t addr
);
76 OutputPin
&get_irq(void);
81 PITChannel channels
[3];
84 static inline void marshal(Marshaller
*m
, const char *name
, DriftMode
*mode
)
86 uint32_t val
= (int)*mode
;
87 marshal(m
, name
, &val
);
88 *mode
= (DriftMode
)val
;