-
Notifications
You must be signed in to change notification settings - Fork 0
/
intel8254.h
34 lines (25 loc) · 1.08 KB
/
intel8254.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* Copyright (C) 2018 Thomas R. Dial
* All Rights Reserved
*
* Routines for initialization and communicating with an Intel 8254 Timer.
*/
#ifndef INTEL8254_H_INCLUDED_
#define INTEL8254_H_INCLUDED_
#include "status.h"
#include <xc.h>
// Initialize the Intel 8254 timer to a known state.
status_t intel_8254_init();
// Load a new divisor into timer zero for square-wave clock generation.
//void intel_8254_set_timer0(unsigned char lsb, unsigned char msb);
//#define NOPWAIT() Nop(); Nop(); Nop(); Nop(); Nop();
// Below for 16mhz Master Clock
// TODO(tdial): Ensure delays are long enough for the 8254.)
// This defines the delay in cycles needed between operations on the 8254.
// I suspect that when I moved to 16mhz I didn't do the calculations correctly.
// This delay must be verified against the data sheet.
#define NOPWAIT() Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop(); Nop()
inline void intel_write_timer(unsigned char timer,
unsigned char lsb,
unsigned char msb);
#endif // INTEL8254_H_INCLUDED_