Real Time Clock Module with I2C Interface  0.3
⇒ back to Project Page
 All Data Structures Files Functions Variables Typedefs Macros Pages
saa1064.h
Go to the documentation of this file.
1 /****************************************************************************/
36 #ifndef SAA1064_H_INCLUDED
37 #define SAA1064_H_INCLUDED
38 
39 
40 /******************************************
41  \internal
42  Internal value definitions
43 *******************************************/
44 
45 
47 
48 //LED current
49 #define SAA1064_LED_CURRENT01 0x01 //LED current (0 0 1 == 0 * 12mA 0 * 6mA 1 * 3mA)
50 #define SAA1064_LED_CURRENT02 0x02 //LED current (0 1 0 == 0 * 12mA 1 * 6mA 0 * 3mA)
51 #define SAA1064_LED_CURRENT03 0x03 //LED current (0 1 1 == 0 * 12mA 1 * 6mA 1 * 3mA)
52 #define SAA1064_LED_CURRENT04 0x04 //LED current (1 0 0 == 0 * 12mA 0 * 6mA 0 * 3mA)
53 #define SAA1064_LED_CURRENT05 0x05 //LED current (1 0 1 == 1 * 12mA 0 * 6mA 1 * 3mA)
54 #define SAA1064_LED_CURRENT06 0x06 //LED current (1 1 0 == 1 * 12mA 1 * 6mA 0 * 3mA)
55 #define SAA1064_LED_CURRENT07 0x07 //LED current (1 1 1 == 1 * 12mA 1 * 6mA 1 * 3mA)
56 
57 //return values
59 #define SAA1064_IO_SUCCESS 0xe0 //i/o operation was successful
60 #define SAA1064_WRONG_ADDRESS 0xe1 //wrong I2C adress
61 #define SAA1064_WRONG_MODE 0xe2 //wrong value for display mode
62 #define SAA1064_INIT_ERROR 0xe3 //error during initialization of SAA1064 (invalid control byte data received)
63 #define SAA1064_IO_ERROR 0xe4 //error during SAA1064 I/O (internal/unknown error - e.g. wrong register length)
64 
65 
66 #define SAA1064_NUMBER_RETRIES 3 //number of retries if I2C Bus is blocked (see also I2C_RETRY_WAIT_US in "i2c.h")
67 
68 #define SAA1064_INIT_DELAY_MS 500.0 //delay during two initialization messages [ms]
69 #define SAA1064_DEMO_DELAY_MS 50.0 //delay during two demo messages [ms]
70 #define SAA1064_DEMO_LOOPS 5 //number of demo loops
71 
72 
74 #define SAA1064_STATIC_MODE 0x00 //static mode of SAA1064 (C0 = 0)
75 #define SAA1064_DYNAMIC_MODE 0x01 //dynamic mode of SAA1064 (C0 = 1)
76 
77 //address values
79 #define I2C_SAA1064_ADDRESS0 0x70 //I2C address (including write bit "0") for ADR Pin = 0 V
80 #define I2C_SAA1064_ADDRESS1 0x72 //I2C address (including write bit "0") for ADR Pin = 3/8 Vcc
81 #define I2C_SAA1064_ADDRESS2 0x74 //I2C address (including write bit "0") for ADR Pin = 5/8 Vcc
82 #define I2C_SAA1064_ADDRESS3 0x76 //I2C address (including write bit "0") for ADR Pin = Vcc
83 
84 #define I2C_SAA1064_NUMBER_REG 7 //number of data registers including address
85 #define I2C_SAA1064_NUMBER_STAT 2 //number of status registers including address
86 
87 
88 
89 
122 
123 
149 
150 
151 
152 #define BCD_TABLE_LENGTH 23 //number of entries in numbers_bcd_table
153 #define BCD_TABLE_DECIMAL_POINT_VALUE 20 //entry which contains the decimal point "."
154 #define BCD_TABLE_ERROR_VALUE 21 //entry which contains the error sign "-"
155 #define BCD_TABLE_OFF_VALUE 22 //entry which contains no output
156 #define BCD_DECIMAL_POINT_OFFSET 10 //offset value for all values with decimal point
157 
158 static const unsigned char numbers_bcd_table[] PROGMEM = {
159  0x3f, //0
160  0x06, //1
161  0x5b, //2
162  0x4f, //3
163  0x66, //4
164  0x6d, //5
165  0x7d, //6
166  0x07, //7
167  0x7f, //8
168  0x6f, //9
169  0xbf, //0.
170  0x86, //1.
171  0xdb, //2.
172  0xcf, //3.
173  0xe6, //4.
174  0xed, //5.
175  0xfd, //6.
176  0x87, //7.
177  0xff, //8.
178  0xef, //9.
179  0x80, //.
180  0x40, //- (displayed in case of an error)
181  0x00 // (display off)
182  };
183 
184 
185 
186 /******************************************
187  \internal
188  Function prototypes
189 *******************************************/
190 
191 uint8_t saa1064_init(uint8_t, uint8_t, uint8_t);
192 uint8_t saa1064_read_status(uint8_t, uint8_t *);
193 uint8_t saa1064_send_digits(uint8_t, uint8_t, uint8_t, uint16_t, uint8_t, uint8_t);
194 
195 
196 
197 #endif // SAA1064_H_INCLUDED