the program have one sensor acs712 and moduleds1302
Dependencies: FATFileSystem mbed
DS1302 Class Reference
Library to make use of the DS1302 timekeeping IC. More...
#include <DS1302.h>
Public Types | |
enum | |
Register map. More... | |
Public Member Functions | |
DS1302 (PinName SCLK, PinName IO, PinName CE) | |
Create a new DS1302 object. | |
void | set_time (time_t t) |
Set the current time. | |
time_t | time (time_t *t=NULL) |
Get the current time. | |
void | storeByte (char address, char data) |
Store a byte in the battery-backed RAM. | |
char | recallByte (char address) |
Recall a byte from the battery-backed RAM. | |
char | readReg (char reg) |
Read a register. | |
void | writeReg (char reg, char val) |
Write a register. |
Detailed Description
Library to make use of the DS1302 timekeeping IC.
The library functions the same as the standard mbed time function, only now you have to first make a DS1302 object and apply the functions on the object.
Example code:
#define SCLK PTC5 #define IO PTC4 #define CE PTC3 //Comment this line if the DS1302 is already running #define INITIAL_RUN #include "mbed.h" #include "DS1302.h" DS1302 clk(SCLK, IO, PTC3); int main() { #ifdef INITIAL_RUN clk.set_time(1256729737); #endif char storedByte = clk.recallByte(0); printf("Stored byte was %d, now increasing by one\r\n", storedByte); clk.storeByte(0, storedByte + 1); while(1) { time_t seconds = clk.time(NULL); printf("Time as a basic string = %s\r", ctime(&seconds)); wait(1); } }
See for example http://mbed.org/handbook/Time for general usage of C time functions.
Trickle charging is not supported
Definition at line 51 of file DS1302.h.
Member Enumeration Documentation
Constructor & Destructor Documentation
DS1302 | ( | PinName | SCLK, |
PinName | IO, | ||
PinName | CE | ||
) |
Create a new DS1302 object.
- Parameters:
-
SCLK the pin to which SCLK is connectd IO the pin to which IO is connectd CE the pin to which CE is connected (also called RST)
Definition at line 3 of file DS1302.cpp.
Member Function Documentation
char readReg | ( | char | reg ) |
Read a register.
Only required to for example manually set trickle charge register
- Parameters:
-
reg register to read
- Returns:
- contents of the register
Definition at line 61 of file DS1302.cpp.
char recallByte | ( | char | address ) |
Recall a byte from the battery-backed RAM.
- Parameters:
-
address address where to retrieve the data (0-30)
- Returns:
- the stored data
Definition at line 53 of file DS1302.cpp.
void set_time | ( | time_t | t ) |
Set the current time.
Initialises and sets the time of the DS1302 to the time represented by the number of seconds since January 1, 1970 (the UNIX timestamp).
- Parameters:
-
t Number of seconds since January 1, 1970 (the UNIX timestamp)
Definition at line 11 of file DS1302.cpp.
void storeByte | ( | char | address, |
char | data | ||
) |
Store a byte in the battery-backed RAM.
- Parameters:
-
address address where to store the data (0-30) data the byte to store
Definition at line 45 of file DS1302.cpp.
time_t time | ( | time_t * | t = NULL ) |
Get the current time.
Use other functions to convert this value, see: http://mbed.org/handbook/Time
- Parameters:
-
t ignored, supply NULL
- Returns:
- number of seconds since January 1, 1970
Definition at line 23 of file DS1302.cpp.
void writeReg | ( | char | reg, |
char | val | ||
) |
Write a register.
Only required to for example manually set trickle charge register
- Parameters:
-
reg register to write val contents of the register to write
Definition at line 74 of file DS1302.cpp.
Generated on Wed Jul 13 2022 05:59:47 by 1.7.2