Fri, 18 Apr 2014 01:34:20 -0600
added RTC emulation (attempts to set the date are ignored, and the year is currently hardcoded to 1987 because UNIX PC SysV has a few Y2K bugs)
1 #ifndef _TC8250_H
2 #define _TC8250_H
4 #include <stdbool.h>
5 #include <stddef.h>
6 #include <stdint.h>
7 #include <stdio.h>
9 typedef struct {
10 bool chip_enable;
11 bool address_latch_enable;
12 bool write_enable;
13 uint8_t address;
14 uint8_t seconds_offset;
15 uint8_t minutes_offset;
16 uint8_t hours_offset;
17 uint8_t days_offset;
18 uint8_t months_offset;
19 uint8_t years_offset;
20 uint8_t weekday_offset;
21 } TC8250_CTX;
23 void tc8250_init(TC8250_CTX *ctx);
24 void tc8250_set_chip_enable(TC8250_CTX *ctx, bool enabled);
25 void tc8250_set_address_latch_enable(TC8250_CTX *ctx, bool enabled);
26 void tc8250_set_write_enable(TC8250_CTX *ctx, bool enabled);
27 uint8_t tc8250_read_reg(TC8250_CTX *ctx);
28 void tc8250_write_reg(TC8250_CTX *ctx, uint8_t val);
30 enum {
31 ONE_SEC_DIGT = 0x0, /* 1 sec digit */
32 TEN_SEC_DIGT = 0x1, /* 10 sec digit */
33 ONE_MIN_DIGT = 0x2, /* 1 minute digit */
34 TEN_MIN_DIGT = 0x3, /* 10 minutes digit */
35 ONE_HR_DIGT = 0x4, /* 1 hour digit */
36 TEN_HR_DIGT = 0x5, /* 10 hours digit */
37 ONE_DAY_DIGT = 0x6, /* 1 day digit */
38 TEN_DAY_DIGT = 0x7, /* 10 days digit */
39 ONE_MNTH_DIGT = 0x8, /* 1 month digit */
40 TEN_MNTH_DIGT = 0x9, /* 10 month digit */
41 ONE_YR_DIGT = 0xa, /* 1 year digit */
42 TEN_YR_DIGT = 0xb, /* 10 year digit */
43 WEEK_DAY = 0xc, /* day of the week */
44 TOUT_CONTROL = 0xd, /* Tout control */
45 PROTECT_KEY = 0xe, /* protection key */
46 RTC_STATUS = 0xf /* real time clock status */
47 };
48 #endif