library to communicate with the Maxim DS1307 I2C RTC IC (API) More...
Go to the source code of this file.
Macros | |
#define | RTC_DS1307_I2C I2C1 |
I2C peripheral. More... | |
#define | RTC_DS1307_I2C_RCC RCC_I2C1 |
I2C peripheral clock. | |
#define | RTC_DS1307_I2C_PORT_RCC RCC_GPIOB |
I2C I/O peripheral clock. | |
#define | RTC_DS1307_I2C_PORT GPIOB |
I2C I/O peripheral port. | |
#define | RTC_DS1307_I2C_PIN_SDA GPIO_I2C1_SDA |
I2C peripheral data pin (PB7) | |
#define | RTC_DS1307_I2C_PIN_SCL GPIO_I2C1_SCL |
I2C peripheral clock pin (PB6) | |
#define | RTC_DS1307_I2C_ADDR 0x68 |
DS1307 I2C address (fixed to 0b1101000) | |
#define | RTC_DS1307_SQUARE_WAVE_TICKS (RTC_DS1307_SQUARE_WAVE_FREQUENCY/256) |
number of square wave tics before setting rtc_ds1307_tic_flag | |
#define | RTC_DS1307_SQUARE_WAVE_FREQUENCY 4096 |
square wave output frequency from the RTC IC | |
#define | RTC_DS1307_SQUARE_WAVE_TIMER TIM2 |
timer peripheral | |
#define | RTC_DS1307_SQUARE_WAVE_TIMER_RCC RCC_TIM2 |
timer peripheral clock | |
#define | RTC_DS1307_SQUARE_WAVE_TIMER_IC TIM_IC1 |
input capture channel (for TIM2_CH1) | |
#define | RTC_DS1307_SQUARE_WAVE_TIMER_IN TIM_IC_IN_TI1 |
input capture input source (TIM2_CH1 becomes TI1, then TI1F, then TI1FP1) | |
#define | RTC_DS1307_SQUARE_WAVE_TIMER_TS TIM_SMCR_TS_IT1FP1 |
input capture trigger (actually TI1FP1) | |
#define | RTC_DS1307_SQUARE_WAVE_TIMER_IRQ NVIC_TIM2_IRQ |
timer interrupt | |
#define | RTC_DS1307_SQUARE_WAVE_TIMER_ISR tim2_isr |
timer interrupt service routine | |
#define | RTC_DS1307_SQUARE_WAVE_GPIO_RCC RCC_GPIOA |
timer port peripheral clock (TIM2_CH1 on PA0) | |
#define | RTC_DS1307_SQUARE_WAVE_GPIO_PORT GPIOA |
timer port (TIM2_CH1 on PA0) | |
#define | RTC_DS1307_SQUARE_WAVE_GPIO_PIN GPIO_TIM2_CH1_ETR |
timer pin input, connect to RTC IC square wave output (TIM2_CH1 on PA0) | |
Functions | |
void | rtc_ds1307_setup (void) |
setup communication with RTC IC configure the I2C port defined in the sources | |
bool | rtc_ds1307_oscillator_disabled (void) |
verify if oscillator is disabled More... | |
uint16_t | rtc_ds1307_read_square_wave (void) |
read square wave output frequency (in Hz) More... | |
uint8_t | rtc_ds1307_read_seconds (void) |
read seconds from RTC IC More... | |
uint8_t | rtc_ds1307_read_minutes (void) |
read minutes from RTC IC More... | |
uint8_t | rtc_ds1307_read_hours (void) |
read hours from RTC IC More... | |
uint8_t | rtc_ds1307_read_day (void) |
read day from RTC IC More... | |
uint8_t | rtc_ds1307_read_date (void) |
read date from RTC IC More... | |
uint8_t | rtc_ds1307_read_month (void) |
read month from RTC IC More... | |
uint8_t | rtc_ds1307_read_year (void) |
read year from RTC IC More... | |
uint8_t * | rtc_ds1307_read_time (void) |
read time from RTC IC More... | |
bool | rtc_ds1307_oscillator_disable (void) |
disable RTC IC oscillator More... | |
bool | rtc_ds1307_oscillator_enable (void) |
enable RTC IC oscillator More... | |
bool | rtc_ds1307_write_square_wave (uint16_t frequency) |
write square wave output frequency (in Hz) More... | |
bool | rtc_ds1307_write_seconds (uint8_t seconds) |
write seconds into RTC IC More... | |
bool | rtc_ds1307_write_minutes (uint8_t minutes) |
write minutes into RTC IC More... | |
bool | rtc_ds1307_write_hours (uint8_t hours) |
write hours into RTC IC More... | |
bool | rtc_ds1307_write_day (uint8_t day) |
write day into RTC IC More... | |
bool | rtc_ds1307_write_date (uint8_t date) |
write date into RTC IC More... | |
bool | rtc_ds1307_write_month (uint8_t month) |
write month into RTC IC More... | |
bool | rtc_ds1307_write_year (uint8_t year) |
write year into RTC IC More... | |
bool | rtc_ds1307_write_time (uint8_t seconds, uint8_t minutes, uint8_t hours, uint8_t day, uint8_t date, uint8_t month, uint8_t year) |
write time into RTC IC More... | |
Variables | |
volatile uint32_t | rtc_ds1307_ticks |
increment on SQUARE_WAVE_TICS square wave ticks | |
volatile bool | rtc_ds1307_tick_flag |
set on SQUARE_WAVE_TICS square wave ticks | |
library to communicate with the Maxim DS1307 I2C RTC IC (API)
Definition in file rtc_ds1307.h.
bool rtc_ds1307_oscillator_disable | ( | void | ) |
disable RTC IC oscillator
Definition at line 285 of file rtc_ds1307.c.
bool rtc_ds1307_oscillator_disabled | ( | void | ) |
verify if oscillator is disabled
Definition at line 133 of file rtc_ds1307.c.
bool rtc_ds1307_oscillator_enable | ( | void | ) |
enable RTC IC oscillator
Definition at line 293 of file rtc_ds1307.c.
uint8_t rtc_ds1307_read_date | ( | void | ) |
read date from RTC IC
Definition at line 198 of file rtc_ds1307.c.
uint8_t rtc_ds1307_read_day | ( | void | ) |
read day from RTC IC
Definition at line 189 of file rtc_ds1307.c.
uint8_t rtc_ds1307_read_hours | ( | void | ) |
read hours from RTC IC
Definition at line 172 of file rtc_ds1307.c.
uint8_t rtc_ds1307_read_minutes | ( | void | ) |
read minutes from RTC IC
Definition at line 163 of file rtc_ds1307.c.
uint8_t rtc_ds1307_read_month | ( | void | ) |
read month from RTC IC
Definition at line 207 of file rtc_ds1307.c.
uint8_t rtc_ds1307_read_seconds | ( | void | ) |
read seconds from RTC IC
Definition at line 154 of file rtc_ds1307.c.
uint16_t rtc_ds1307_read_square_wave | ( | void | ) |
read square wave output frequency (in Hz)
Definition at line 140 of file rtc_ds1307.c.
uint8_t* rtc_ds1307_read_time | ( | void | ) |
read time from RTC IC
Definition at line 224 of file rtc_ds1307.c.
uint8_t rtc_ds1307_read_year | ( | void | ) |
read year from RTC IC
Definition at line 216 of file rtc_ds1307.c.
bool rtc_ds1307_write_date | ( | uint8_t | date | ) |
write date into RTC IC
[in] | date | day of the month (1-31) |
Definition at line 370 of file rtc_ds1307.c.
bool rtc_ds1307_write_day | ( | uint8_t | day | ) |
write day into RTC IC
[in] | day | day of the week (1-7, 1 is Sunday) |
Definition at line 360 of file rtc_ds1307.c.
bool rtc_ds1307_write_hours | ( | uint8_t | hours | ) |
write hours into RTC IC
[in] | hours | number of hours (0-23) |
Definition at line 350 of file rtc_ds1307.c.
bool rtc_ds1307_write_minutes | ( | uint8_t | minutes | ) |
write minutes into RTC IC
[in] | minutes | number of minutes (0-59) |
Definition at line 340 of file rtc_ds1307.c.
bool rtc_ds1307_write_month | ( | uint8_t | month | ) |
write month into RTC IC
[in] | month | month of the year (1-12) |
Definition at line 380 of file rtc_ds1307.c.
bool rtc_ds1307_write_seconds | ( | uint8_t | seconds | ) |
write seconds into RTC IC
[in] | seconds | number of seconds (0-59) |
Definition at line 326 of file rtc_ds1307.c.
bool rtc_ds1307_write_square_wave | ( | uint16_t | frequency | ) |
write square wave output frequency (in Hz)
[in] | frequency | square wave output frequency in Hz (0 to disable, 1, 4096, 8192, 32768) |
Definition at line 301 of file rtc_ds1307.c.
bool rtc_ds1307_write_time | ( | uint8_t | seconds, |
uint8_t | minutes, | ||
uint8_t | hours, | ||
uint8_t | day, | ||
uint8_t | date, | ||
uint8_t | month, | ||
uint8_t | year | ||
) |
write time into RTC IC
[in] | seconds | number of seconds (0-59) |
[in] | minutes | number of minutes (0-59) |
[in] | hours | number of hours (0-23) |
[in] | day | day of the week (1-7, 1 is Sunday) |
[in] | date | day of the month (1-31) |
[in] | month | month of the year (1-12) |
[in] | year | year of the century (00-99) |
Definition at line 400 of file rtc_ds1307.c.
bool rtc_ds1307_write_year | ( | uint8_t | year | ) |
write year into RTC IC
[in] | year | year of the century (00-99) |
Definition at line 390 of file rtc_ds1307.c.