comparison ds1307.c @ 3:15d89caaf516

Add support for single UART devices, although untested apart from a compile. Doesn't break dual UART ones :) Also checks for PRR before setting it.
author darius@Inchoate
date Wed, 11 Mar 2009 17:28:39 +1030
parents 3879f487b661
children 3da232f97e81
comparison
equal deleted inserted replaced
2:43d3b2bef999 3:15d89caaf516
44 * Setup TWI interface 44 * Setup TWI interface
45 * 45 *
46 */ 46 */
47 int 47 int
48 ds1307_init(void) { 48 ds1307_init(void) {
49 #ifdef PRR
49 PRR &= _BV(PRTWI); /* Power TWI on - note that the 50 PRR &= _BV(PRTWI); /* Power TWI on - note that the
50 * datasheet says this is already 0 at 51 * datasheet says this is already 0 at
51 * power on.. */ 52 * power on.. */
53 #endif
52 TWSR = 0; /* TWI Prescaler = 1 */ 54 TWSR = 0; /* TWI Prescaler = 1 */
53 #if F_CPU < 3600000UL 55 #if F_CPU < 3600000UL
54 TWBR = 10; /* Smallest valid TWBR */ 56 TWBR = 10; /* Smallest valid TWBR */
55 #else 57 #else
56 TWBR = (F_CPU / 100000UL - 16) / 2; 58 TWBR = (F_CPU / 100000UL - 16) / 2;