MP3 1.0
This is the Doxygen document for ECE391 MP3.
Loading...
Searching...
No Matches
rtc.h
Go to the documentation of this file.
1
10#ifndef RTC_H
11#define RTC_H
12
13#include "terminal.h"
14
15#define RTC_INDEX (0x70) // Port to specify register to interact with
16#define RTC_DATA (0x71) // Port to specify where read or written data comes from or goes to
17#define NMI_MASK (0x80) // Bit to disable/enable NMI in setup
18#define PIE_MASK (0x40) // Bit to disable/enable periodic interrupts
19#define MAX_CLK (0x06) // Set reg A bits {RS3, RS2, RS1, RS0} = 0110 for 1024Hz clk according to data sheet
20#define SQWE_MASK (0x80) // Bit to enable square wave
21
22// RTC status register offsets
23#define REG_A (0x0A)
24#define REG_B (0x0B)
25#define REG_C (0x0C)
26
27
28void rtcInit();
29
47int setRate(int rate);
48
57char translateRateToBits(int rate);
58
72unsigned char isPowerOfTwo(int x);
73
82int32_t rtcOpen(const uint8_t* filename);
83
92
106int rtcRead(int32_t fd, void* buf, int32_t nbytes);
107
122int rtcWrite(int32_t fd, const void* buf, int32_t nbytes);
123
132
140
141
142#endif // RTC_H
uint32_t counterRTC[MAX_NUM_TERMINALS]
Counter array for active terminals, tracking RTC interrupt counts.
Definition: rtc.h:131
int32_t rtcOpen(const uint8_t *filename)
Sets the RTC to its slowest rate. (2Hz)
Definition: rtc.c:207
int32_t rtcClose(int32_t fd)
Needed per MP spec.
Definition: rtc.c:220
int rtcRead(int32_t fd, void *buf, int32_t nbytes)
Other functions will use this to tell when an RTC interrupt occurs.
Definition: rtc.c:238
unsigned char isPowerOfTwo(int x)
Checks if a number is a power of two.
Definition: rtc.c:190
int setRate(int rate)
Set the interrupt rate of the RTC.
Definition: rtc.c:110
void rtcInit()
Initializes RTC.
Definition: rtc.c:30
int rtcWrite(int32_t fd, const void *buf, int32_t nbytes)
Set the rate of the RTC thru a sys call.
Definition: rtc.c:261
char translateRateToBits(int rate)
Translates given RTC rate to corresponding bits to write in register A.
Definition: rtc.c:148
uint32_t ratesRTC[MAX_NUM_TERMINALS]
Array storing the target rates for each active terminal.
Definition: rtc.h:139
Header files for terminal.c.
#define MAX_NUM_TERMINALS
Definition: terminal.h:13
int int32_t
Definition: types.h:18
unsigned int uint32_t
Definition: types.h:19
unsigned char uint8_t
Definition: types.h:25