ESP8266 ILI9341 display support code with printf sources, wire-frame viewer and custom fonts  1.0
ESP8266ILI9341DisplayProject
Macros | Functions
rtc.h File Reference

Go to the source code of this file.

Macros

#define DS1307   0xd0
 

Functions

MEMSPACE uint8_t BINtoBCD (uint8_t data)
 Convert number >= 0 and <= 99 to BCD. More...
 
MEMSPACE uint8_t BCDtoBIN (uint8_t data)
 Convert two "digit" BCD number to binary. More...
 
MEMSPACE int8_t rtc_run_test (void)
 Check if the DS1307 device is running. More...
 
MEMSPACE int rtc_run (int run)
 Set DS1307 run state. More...
 
MEMSPACE uint8_t rtc_init (int force, time_t seconds)
 Initialize DS1307 rtc if not initialied - or if forced. More...
 
MEMSPACE uint8_t rtc_write (tm_t *t)
 Set DS1307 RTC from POSIX struct tm * structure. More...
 
MEMSPACE uint8_t rtc_read (tm_t *t)
 Read DS1307 RTC into POSIX struct tm * structure. More...
 

Macro Definition Documentation

#define DS1307   0xd0

Definition at line 16 of file rtc.h.

Referenced by rtc_init(), rtc_read(), rtc_run(), rtc_run_test(), and rtc_write().

Function Documentation

MEMSPACE uint8_t BCDtoBIN ( uint8_t  data)

Convert two "digit" BCD number to binary.

Parameters
[in]dataBCD number.
  • number >= 0 and <= 99 to BCD
Returns
Binary value.

Definition at line 48 of file rtc.c.

Referenced by rtc_read().

MEMSPACE uint8_t BINtoBCD ( uint8_t  data)

Convert number >= 0 and <= 99 to BCD.

  • BCD format has each hex nibble has a digit 0 .. 9
Parameters
[in]datanumber to convert.
Returns
BCD value
Warning
we assume the number is in range.

Definition at line 36 of file rtc.c.

Referenced by rtc_write().

MEMSPACE uint8_t rtc_init ( int  force,
time_t  seconds 
)

Initialize DS1307 rtc if not initialied - or if forced.

Parameters
[in]forceforce initialiation flag.
  • If 1 then alwasy force initialiation.
[in]secondsPOSIX EPOCH time in seconds.
Returns
1 on success.
0 on fail.

Definition at line 121 of file rtc.c.

Referenced by initialize_clock(), and setdate_r().

MEMSPACE uint8_t rtc_read ( tm_t t)

Read DS1307 RTC into POSIX struct tm * structure.

Parameters
[out]tstruct tm * POSIX time returned.
Returns
1 on sucess.
0 on fail.

Definition at line 238 of file rtc.c.

Referenced by display_clock(), initialize_clock(), and rtc_read().

MEMSPACE int rtc_run ( int  run)

Set DS1307 run state.

Parameters
[in]runstate.
  • 1 = run.
  • 0 = stop.
  • -1 = check run state.
Returns
run state 0/1 on success.
-1 on error.

Definition at line 87 of file rtc.c.

Referenced by rtc_init().

MEMSPACE int8_t rtc_run_test ( void  )

Check if the DS1307 device is running.

  • display error if read error occurs.
Returns
1 if running.
0 if not running.
-1 on error.

Definition at line 63 of file rtc.c.

MEMSPACE uint8_t rtc_write ( tm_t t)

Set DS1307 RTC from POSIX struct tm * structure.

Parameters
[in]tPOSIX struct tm * time to set.
Returns
1 on sucess.
0 on fail.

Definition at line 189 of file rtc.c.

Referenced by rtc_init().