19 return _reg_r( Seconds ) & 0x80;
28 _reg_r( _100th_Seconds, bf,
sizeof( bf ) );
30 now_tm.tm_sec =
bcd2dec( bf[ 1 ] );
31 now_tm.tm_min =
bcd2dec( bf[ 2 ] );
32 now_tm.tm_hour =
bcd2dec( bf[ 3 ] );
33 now_tm.tm_mday =
bcd2dec( bf[ 4 ] );
34 now_tm.tm_mon =
bcd2dec( bf[ 6 ] ) - 1;
35 now_tm.tm_year =
bcd2dec( bf[ 7 ] ) + 100;
38 return mktime(&now_tm);
49 bf[ 1 ] =
dec2bcd( now_tmp->tm_sec );
50 bf[ 2 ] =
dec2bcd( now_tmp->tm_min );
51 bf[ 3 ] =
dec2bcd( now_tmp->tm_hour );
52 bf[ 4 ] =
dec2bcd( now_tmp->tm_mday );
53 bf[ 6 ] =
dec2bcd( now_tmp->tm_mon + 1 );
54 bf[ 7 ] =
dec2bcd( now_tmp->tm_year - 100 );
56 now_time = mktime( now_tmp );
57 cnv_tmp = localtime( &now_time );
58 bf[ 5 ] =
dec2bcd( cnv_tmp->tm_wday);
61 _bit_op8( SR_Reset, (uint8_t)(~0x80), 0x80 );
63 _reg_w( _100th_Seconds, bf,
sizeof( bf ) );
70 alarm( digit, val, 0 );
75 int v = (val == 0x80) ? 0x80 :
dec2bcd( val );
76 _reg_w( Second_alarm + digit, v );
77 _bit_op8( int_mask_reg[ int_sel ][ 0 ], ~0x04, 0x00 );
94 const int fst = ts_setting ? 0x80 : 0x00;
98 uint8_t reg = Timestp_ctl1 + num * r_ofst;
100 _bit_op8( reg, (uint8_t)(~0x80), fst );
101 _bit_op8( int_mask_reg[ int_sel ][ 1 ], ~(0x1 << (3 - num)), (0x0 << (3 - num)) );
103 _bit_op8( Control_5, ~(0x1 << (7 - num)), (0x1 << (7 - num)) );
108 const int r_ofst = 7;
112 uint8_t reg = Timestp_ctl1 + num * r_ofst;
115 _reg_r( reg, v,
sizeof( v ) );
119 ts_tm.tm_sec =
bcd2dec( v[ 1 ] );
120 ts_tm.tm_min =
bcd2dec( v[ 2 ] );
121 ts_tm.tm_hour =
bcd2dec( v[ 3 ] );
122 ts_tm.tm_mday =
bcd2dec( v[ 4 ] );
123 ts_tm.tm_mon =
bcd2dec( v[ 5 ] ) - 1;
124 ts_tm.tm_year =
bcd2dec( v[ 6 ] ) + 100;
127 return mktime(&ts_tm);
141 _reg_r( Control_2, rv, 3 );
143 if ( rv[ 0 ] & 0x90 )
144 _reg_w( Control_2, rv[ 0 ] & ~((rv[ 0 ] & 0x90) | 0x49) );
146 if ( rv[ 1 ] & 0x08 )
147 _reg_w( Control_3, rv[ 1 ] & ~(0x08) );
149 if ( rv[ 2 ] & 0xF0 )
150 _reg_w( Control_4, rv[ 2 ] & ~(rv[ 2 ] & 0xF0) );
159 _bit_op8( int_mask_reg[ int_sel ][ 0 ], ~0x30, 0x30 );
163 uint8_t v = (sel == EVERY_MINUTE) ? 0x02 : 0x01;
167 _bit_op8( int_mask_reg[ int_sel ][ 0 ], ~0x30, ~(v << 4) );
void timestamp(int num, timestanp_setting ts_setting, int int_sel=0)
void set(struct tm *now_tm)
void periodic_interrupt_enable(periodic_int_select sel, int int_sel=0)
bool oscillator_stop(void)
void alarm(alarm_setting digit, int val)
virtual void _reg_r(uint8_t reg, uint8_t *vp, int len)=0
virtual void _bit_op8(uint8_t reg, uint8_t mask, uint8_t val)=0
virtual void _reg_w(uint8_t reg, uint8_t *vp, int len)=0
static uint8_t dec2bcd(uint8_t v)
static uint8_t bcd2dec(uint8_t v)