Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: PCF2127_Demo PCF2127_Hello
PCF2127 Class Reference
#include <PCF2127.h>
Public Types | |
| enum | RegisterName |
name of the PCF2127 registers More... | |
| enum | ErrorNum |
Error code. More... | |
Public Member Functions | |
| PCF2127 (PinName sda, PinName sdl, char vControl_1=Cntl1, char vControl_2=Cntl2, char vControl_3=Cntl1, char vCLKOUT_ctl=ClkOut) | |
| Create a PCF2127 instance connected to specified I2C pins with specified address. | |
| PCF2127 (I2C &i2c, char vControl_1=Cntl1, char vControl_2=Cntl2, char vControl_3=Cntl1, char vCLKOUT_ctl=ClkOut) | |
| Create a PCF2127 instance connected to specified I2C pins with specified address. | |
| ~PCF2127 () | |
| Destractor. | |
| int | is_init_required (void) |
| Clock integrity check. | |
| int | set_time (struct tm *dtp) |
| Set the time. | |
| int | set_time (time_t *tp) |
| Set the time. | |
| int | set_time (char *s) |
| Set the time. | |
| time_t | time (time_t *tp) |
| Get time of day. | |
| int | set_alarm (char addr, char s) |
| Register access interface with integer to BCD conversion. | |
| int | clear_intr (void) |
| Clear interrupt flag. | |
| int | RAM_write (int address, char *p, int size) |
| Writing data into RAM (for PCF2127 only) | |
| int | RAM_read (int address, char *p, int size) |
| Reading data from RAM (for PCF2127 only) | |
Detailed Description
PCF2127 class.
This is a driver code for the PPCF2127: "real time clock (RTC)" module which is including a Xtal and TCXO This class provides interface for PCF2127 operation and accessing its registers. Detail information is available on next URL. http://www.nxp.com/products/interface_and_connectivity/real_time_clocks/rtcs_with_temp_compensation/series/PCF2127.html
Example:
#include "mbed.h" #include "PCF2127.h" PCF2127 rtc( p28, p27 ); int main() { time_t t; printf( "PCF2127 demo started.\r\n" ); if ( rtc.is_init_required() ) { rtc.set_time( "2014 12 10 12 00 00" ); } while ( 1 ) { t = rtc.time( NULL ); printf( "%s\r", ctime( &t ) ); wait( 0.25 ); } }
Definition at line 56 of file PCF2127.h.
Member Enumeration Documentation
| enum RegisterName |
Constructor & Destructor Documentation
| PCF2127 | ( | PinName | sda, |
| PinName | sdl, | ||
| char | vControl_1 = Cntl1, |
||
| char | vControl_2 = Cntl2, |
||
| char | vControl_3 = Cntl1, |
||
| char | vCLKOUT_ctl = ClkOut |
||
| ) |
Create a PCF2127 instance connected to specified I2C pins with specified address.
- Parameters:
-
I2C_sda I2C-bus SDA pin I2C_scl I2C-bus SCL pin vControl_1 (option) data for Control_1 register (default setting generates interrupts by second and minute) vControl_2 (option) data for Control_2 register vControl_3 (option) data for Control_3 register (default setting of battery switch-over function as standard mode) vCLKOUT_ctl (option) data for CLKOUT_ctl register (default setting 1Hz output on CLKOUT pin) CLKOUT_ctl
Definition at line 23 of file PCF2127.cpp.
| PCF2127 | ( | I2C & | i2c, |
| char | vControl_1 = Cntl1, |
||
| char | vControl_2 = Cntl2, |
||
| char | vControl_3 = Cntl1, |
||
| char | vCLKOUT_ctl = ClkOut |
||
| ) |
Create a PCF2127 instance connected to specified I2C pins with specified address.
- Parameters:
-
i2c I2C object (instance) vControl_1 (option) data for Control_1 register (default setting generates interrupts by second and minute) vControl_2 (option) data for Control_2 register vControl_3 (option) data for Control_3 register (default setting of battery switch-over function as standard mode) vCLKOUT_ctl (option) data for CLKOUT_ctl register (default setting 1Hz output on CLKOUT pin)
Definition at line 29 of file PCF2127.cpp.
| ~PCF2127 | ( | ) |
Destractor.
Definition at line 35 of file PCF2127.cpp.
Member Function Documentation
| int clear_intr | ( | void | ) |
Clear interrupt flag.
Clears interrupt flags by writing 0x00 into Control_2 register
- Returns:
- Error code (NO_ERROR==0)
Definition at line 145 of file PCF2127.cpp.
| int is_init_required | ( | void | ) |
Clock integrity check.
- Returns:
- non-zero value if the clock was stopped (means need to set the time)
Definition at line 57 of file PCF2127.cpp.
| int RAM_read | ( | int | address, |
| char * | p, | ||
| int | size | ||
| ) |
Reading data from RAM (for PCF2127 only)
Read data from PCF2127 internal RAM
- Parameters:
-
address target address of internal RAM *p pointer to read data buffer size size of writing data
- Returns:
- Error code (NO_ERROR==0)
Definition at line 165 of file PCF2127.cpp.
| int RAM_write | ( | int | address, |
| char * | p, | ||
| int | size | ||
| ) |
Writing data into RAM (for PCF2127 only)
Write data into PCF2127 internal RAM
- Parameters:
-
address target address of internal RAM *p pointer to write data buffer size size of writing data
- Returns:
- Error code (NO_ERROR==0)
Definition at line 150 of file PCF2127.cpp.
| int set_alarm | ( | char | addr, |
| char | s | ||
| ) |
Register access interface with integer to BCD conversion.
- Parameters:
-
addr Register address s Integer data. Converted to BCD before writing inot the register.
- Returns:
- Error code (NO_ERROR==0)
Definition at line 136 of file PCF2127.cpp.
| int set_time | ( | struct tm * | dtp ) |
Set the time.
- Parameters:
-
dtp Pointer to struct tm
- Returns:
- Error code (NO_ERROR==0)
Definition at line 62 of file PCF2127.cpp.
| int set_time | ( | char * | s ) |
Set the time.
- Parameters:
-
s String data: The time information should be given in format of "YYYY MM DD HH MM SS"
- Returns:
- Error code (NO_ERROR==0)
Definition at line 86 of file PCF2127.cpp.
| int set_time | ( | time_t * | tp ) |
Set the time.
- Parameters:
-
tp pointer to time_t
- Returns:
- Error code (NO_ERROR==0)
Definition at line 81 of file PCF2127.cpp.
| time_t time | ( | time_t * | tp ) |
Get time of day.
This function works similar to "time()" in standard-C-library
- Parameters:
-
tp Pointer to time_t
- Returns:
- Error code (NO_ERROR==0)
Definition at line 104 of file PCF2127.cpp.
Generated on Wed Jul 13 2022 19:00:23 by
1.7.2
PCF2127 and PCF2129 High-accuracy RTC module