src/tc8250.h

changeset 151
b63a3999e2e7
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/tc8250.h	Fri Apr 18 01:34:20 2014 -0600
     1.3 @@ -0,0 +1,48 @@
     1.4 +#ifndef _TC8250_H
     1.5 +#define _TC8250_H
     1.6 +
     1.7 +#include <stdbool.h>
     1.8 +#include <stddef.h>
     1.9 +#include <stdint.h>
    1.10 +#include <stdio.h>
    1.11 +
    1.12 +typedef struct {
    1.13 +	bool chip_enable;
    1.14 +	bool address_latch_enable;
    1.15 +	bool write_enable;
    1.16 +	uint8_t address;
    1.17 +	uint8_t seconds_offset;
    1.18 +	uint8_t minutes_offset;
    1.19 +	uint8_t hours_offset;
    1.20 +	uint8_t days_offset;
    1.21 +	uint8_t months_offset;
    1.22 +	uint8_t years_offset;
    1.23 +	uint8_t weekday_offset;
    1.24 +} TC8250_CTX;
    1.25 +
    1.26 +void tc8250_init(TC8250_CTX *ctx);
    1.27 +void tc8250_set_chip_enable(TC8250_CTX *ctx, bool enabled);
    1.28 +void tc8250_set_address_latch_enable(TC8250_CTX *ctx, bool enabled);
    1.29 +void tc8250_set_write_enable(TC8250_CTX *ctx, bool enabled);
    1.30 +uint8_t tc8250_read_reg(TC8250_CTX *ctx);
    1.31 +void tc8250_write_reg(TC8250_CTX *ctx, uint8_t val);
    1.32 +
    1.33 +enum {
    1.34 +	ONE_SEC_DIGT  = 0x0, /* 1 sec digit */
    1.35 +	TEN_SEC_DIGT  = 0x1, /* 10 sec digit */
    1.36 +	ONE_MIN_DIGT  = 0x2, /* 1 minute digit */
    1.37 +	TEN_MIN_DIGT  = 0x3, /* 10 minutes digit */
    1.38 +	ONE_HR_DIGT   = 0x4, /* 1 hour digit */
    1.39 +	TEN_HR_DIGT   = 0x5, /* 10 hours digit */
    1.40 +	ONE_DAY_DIGT  = 0x6, /* 1 day digit */
    1.41 +	TEN_DAY_DIGT  = 0x7, /* 10 days digit */
    1.42 +	ONE_MNTH_DIGT = 0x8, /* 1 month digit */
    1.43 +	TEN_MNTH_DIGT = 0x9, /* 10 month digit */
    1.44 +	ONE_YR_DIGT   = 0xa, /* 1 year digit */
    1.45 +	TEN_YR_DIGT   = 0xb, /* 10 year digit */
    1.46 +	WEEK_DAY      = 0xc, /* day of the week */
    1.47 +	TOUT_CONTROL  = 0xd, /* Tout control */
    1.48 +	PROTECT_KEY   = 0xe, /* protection key */
    1.49 +	RTC_STATUS    = 0xf  /* real time clock status */
    1.50 +};
    1.51 +#endif