| 
    FastArduino v1.10
    
   C++ library to build fast but small Arduino/AVR projects 
   | 
 
I2C device driver for the DS1307 RTC chip. More...
#include <fastarduino/devices/ds1307.h>


Classes | |
| class | DisableOutputFuture | 
| Create a future to be used by asynchronous method disable_output(DisableOutputFuture&).  More... | |
| class | EnableOutputFuture | 
| Create a future to be used by asynchronous method enable_output(EnableOutputFuture&).  More... | |
| class | GetRam1Future | 
| Create a future to be used by asynchronous method get_ram(GetRam1Future&).  More... | |
| class | GetRamFuture | 
| Create a future to be used by asynchronous method get_ram(GetRamFuture<SIZE>&).  More... | |
| class | HaltClockFuture | 
| Create a future to be used by asynchronous method halt_clock(HaltClockFuture&).  More... | |
| class | SetRam1Future | 
| Create a future to be used by asynchronous method set_ram(SetRam1Future&).  More... | |
| class | SetRamFuture | 
| Create a future to be used by asynchronous method set_ram(SetRamFuture<SIZE>&).  More... | |
Public Types | |
| using | SetDatetimeFuture = TWriteRegisterFuture< TIME_ADDRESS, tm, DatetimeConverterToDevice > | 
| Create a future to be used by asynchronous method set_datetime(SetDatetimeFuture&).  More... | |
| using | GetDatetimeFuture = TReadRegisterFuture< TIME_ADDRESS, tm, DatetimeConverterFromDevice > | 
| Create a future to be used by asynchronous method get_datetime(GetDatetimeFuture&).  More... | |
  Public Types inherited from i2c::I2CDevice< MANAGER > | |
| using | MANAGER = MANAGER | 
| the type of I2C Manager that can handle this device.  More... | |
Public Member Functions | |
| DS1307 (MANAGER &manager) | |
| Create a new device driver for a DS1307 chip.  More... | |
| int | set_datetime (SetDatetimeFuture &future) | 
| Change date and time of the RTC chip connected to this driver.  More... | |
| int | get_datetime (GetDatetimeFuture &future) | 
| Get the current date and time from the RTC chip.  More... | |
| template<uint8_t SIZE> | |
| int | set_ram (SetRamFuture< SIZE > &future) | 
| Set several cells of the chip internal RAM to specified values.  More... | |
| int | set_ram (SetRam1Future &future) | 
| Set one cell of the chip internal RAM to the specified value.  More... | |
| template<uint8_t SIZE> | |
| int | get_ram (GetRamFuture< SIZE > &future) | 
| Get values of several cells from the chip internal RAM.  More... | |
| int | get_ram (GetRam1Future &future) | 
| Get the value of one cell of the chip internal RAM.  More... | |
| int | halt_clock (HaltClockFuture &future) | 
| Disable the RTC oscillator, hence the time will not be updated anymore.  More... | |
| int | enable_output (EnableOutputFuture &future) | 
| Enable square wave output to the SQW/OUT pin of the RTC chip.  More... | |
| int | disable_output (DisableOutputFuture &future) | 
| Enable square wave output to the SQW/OUT pin of the RTC chip.  More... | |
| bool | set_datetime (const tm &datetime) | 
| Change date and time of the RTC chip connected to this driver.  More... | |
| bool | get_datetime (tm &datetime) | 
| Get the current date and time from the RTC chip.  More... | |
| bool | halt_clock () | 
| Disable the RTC oscillator, hence the time will not be updated anymore.  More... | |
| bool | enable_output (SquareWaveFrequency frequency=SquareWaveFrequency::FREQ_1HZ) | 
| Enable square wave output to the SQW/OUT pin of the RTC chip.  More... | |
| bool | disable_output (bool output_value=false) | 
| Disable square wave output to the SQW/OUT pin of the RTC chip.  More... | |
| bool | set_ram (uint8_t address, uint8_t data) | 
| Set one cell of the chip internal RAM to the specified value.  More... | |
| uint8_t | get_ram (uint8_t address) | 
| Get the value of one cell of the chip internal RAM.  More... | |
| template<uint8_t SIZE> | |
| bool | set_ram (uint8_t address, const uint8_t(&data)[SIZE]) | 
| Set several cells of the chip internal RAM to specified values.  More... | |
| template<uint8_t SIZE> | |
| bool | get_ram (uint8_t address, uint8_t(&data)[SIZE]) | 
| Get values of several cells from the chip internal RAM.  More... | |
| template<typename T > | |
| bool | set_ram (uint8_t address, const T &data) | 
| Write any type of data to the chip internal RAM.  More... | |
| template<typename T > | |
| bool | get_ram (uint8_t address, T &data) | 
| Read any type of data from the chip internal RAM.  More... | |
Static Public Member Functions | |
| static constexpr uint8_t | ram_size () | 
| Get the size of the additional RAM size of the chip.  More... | |
Additional Inherited Members | |
  Protected Types inherited from i2c::I2CDevice< MANAGER > | |
| using | ABSTRACT_FUTURE = typename MANAGER::ABSTRACT_FUTURE | 
| The abstract base class of all futures to be defined for a device.  More... | |
| using | FUTURE = typename MANAGER::template FUTURE< OUT, IN > | 
| The template base class of all futures to be defined for a device.  More... | |
  Protected Member Functions inherited from i2c::I2CDevice< MANAGER > | |
| I2CDevice (MANAGER &manager, uint8_t device, UNUSED Mode< MODE > mode, bool auto_stop) | |
| Create a new I2C device.  More... | |
| I2CDevice (const I2CDevice &)=delete | |
| I2CDevice & | operator= (const I2CDevice &)=delete | 
| void | set_device (uint8_t device) | 
| Change the I2C address of this device.  More... | |
| int | launch_commands (ABSTRACT_FUTURE &future, utils::range< I2CLightCommand > commands) | 
Launch execution (asynchronously or synchronously, depending on MANAGER) of a chain of I2CLightCommand items (constructed with read() and write() methods).  More... | |
| int | async_read (F &future, bool stop=true) | 
| Helper method that asynchronously launches I2C commands for a simple Future performing one write followed by one read (typically for device register reading).  More... | |
| bool | sync_read (T &result) | 
| Helper method that launches I2C commands for a simple Future performing one write followed by one read (typically for device register reading); the method blocks until the end of the I2C transaction.  More... | |
| int | async_write (F &future, bool stop=true) | 
| Helper method that asynchronously launches I2C commands for a simple Future performing only one write (typically for device register writing).  More... | |
| int | async_multi_write (F &future, bool stop=true) | 
| Helper method that asynchronously launches I2C commands for a simple Future performing several register writes.  More... | |
| bool | sync_write (const T &value) | 
| Helper method that launches I2C commands for a simple Future performing only one write (typically for device register writing); the method blocks until the end of the I2C transaction.  More... | |
| bool | sync_write () | 
| Helper method that launches I2C commands for a simple Future performing only one write (typically for device register writing); the method blocks until the end of the I2C transaction.  More... | |
  Static Protected Member Functions inherited from i2c::I2CDevice< MANAGER > | |
| static constexpr I2CLightCommand | read (uint8_t read_count=0, bool finish_future=false, bool stop=false) | 
| Build a read I2CLightCommand that can be later pushed to the I2C Manager for proper handling.  More... | |
| static constexpr I2CLightCommand | write (uint8_t write_count=0, bool finish_future=false, bool stop=false) | 
| Build a write I2CLightCommand that can be later pushed to the I2C Manager for proper handling.  More... | |
I2C device driver for the DS1307 RTC chip.
Note that this chip only supports standard I2C mode (100 KHz).
| MANAGER | one of FastArduino available I2C Manager | 
| using devices::rtc::DS1307< MANAGER >::SetDatetimeFuture = TWriteRegisterFuture<TIME_ADDRESS, tm, DatetimeConverterToDevice> | 
Create a future to be used by asynchronous method set_datetime(SetDatetimeFuture&).
This is used by set_datetime() to pass input settings, and it shall be used by the caller to determine when the I2C transaction is finished.
| datetime | the new date/time to set on the RTC chip; all values must be properly set and be correct, in particular, note that tm::tm_wday must be set correctly by yourself (the RTC chip does not calculate it itself). | 
| using devices::rtc::DS1307< MANAGER >::GetDatetimeFuture = TReadRegisterFuture<TIME_ADDRESS, tm, DatetimeConverterFromDevice> | 
Create a future to be used by asynchronous method get_datetime(GetDatetimeFuture&).
This is used by get_datetime() to get device data, and it shall be used by the caller to determine when the I2C transaction is finished.
      
  | 
  inlineexplicit | 
      
  | 
  inlinestaticconstexpr | 
      
  | 
  inline | 
Change date and time of the RTC chip connected to this driver.
| future | a SetDatetimeFuture passed by the caller, that will be updated once the current I2C action is finished.  | 
| 0 | if no problem occurred during the preparation of I2C transaction | 
errors.
      
  | 
  inline | 
Get the current date and time from the RTC chip.
| future | a GetDatetimeFuture passed by the caller, that will be updated once the current I2C action is finished.  | 
| 0 | if no problem occurred during the preparation of I2C transaction | 
errors.
      
  | 
  inline | 
Set several cells of the chip internal RAM to specified values.
| SIZE | the number of bytes to be written; address + SIZE must be less than ram_size().  | 
| future | a SetRamFuture<SIZE> passed by the caller, that will be updated once the current I2C action is finished.  | 
| 0 | if no problem occurred during the preparation of I2C transaction | 
errors.
      
  | 
  inline | 
Set one cell of the chip internal RAM to the specified value.
| future | an SetRam1Future passed by the caller, that will be updated once the current I2C action is finished.  | 
| 0 | if no problem occurred during the preparation of I2C transaction | 
errors.
      
  | 
  inline | 
Get values of several cells from the chip internal RAM.
| SIZE | the number of bytes to read; address + SIZE must be less than ram_size().  | 
| future | an GetRamFuture passed by the caller, that will be updated once the current I2C action is finished.  | 
| 0 | if no problem occurred during the preparation of I2C transaction | 
errors.
      
  | 
  inline | 
Get the value of one cell of the chip internal RAM.
| future | an GetRam1Future passed by the caller, that will be updated once the current I2C action is finished.  | 
| 0 | if no problem occurred during the preparation of I2C transaction | 
errors.
      
  | 
  inline | 
Disable the RTC oscillator, hence the time will not be updated anymore.
If you want to re-enable the clock, you need to set a new date/time with set_datetime(). 
| future | a HaltClockFuture passed by the caller, that will be updated once the current I2C action is finished.  | 
| 0 | if no problem occurred during the preparation of I2C transaction | 
errors.
      
  | 
  inline | 
Enable square wave output to the SQW/OUT pin of the RTC chip.
| future | an EnableOutputFuture passed by the caller, that will be updated once the current I2C action is finished.  | 
| 0 | if no problem occurred during the preparation of I2C transaction | 
errors.
      
  | 
  inline | 
Enable square wave output to the SQW/OUT pin of the RTC chip.
| future | a DisableOutputFuture passed by the caller, that will be updated once the current I2C action is finished.  | 
| 0 | if no problem occurred during the preparation of I2C transaction | 
errors.
      
  | 
  inline | 
Change date and time of the RTC chip connected to this driver.
| datetime | the new date/time to set on the RTC chip; all values must be properly set and be correct, in particular, note that tm::tm_wday must be set correctly by yourself (the RTC chip does not calculate it itself).  | 
| true | if the operation succeeded | 
| false | if the operation failed | 
      
  | 
  inline | 
Get the current date and time from the RTC chip.
| datetime | a reference to a tm variable that will be filled with current date and time from the RTC chip  | 
| true | if the operation succeeded | 
| false | if the operation failed | 
      
  | 
  inline | 
Disable the RTC oscillator, hence the time will not be updated anymore.
If you want to re-enable the clock, you need to set a new date/time with set_datetime(). 
| true | if the operation succeeded | 
| false | if the operation failed | 
      
  | 
  inline | 
Enable square wave output to the SQW/OUT pin of the RTC chip.
| frequency | one of the supported RTC frequencies, defined in SquareWaveFrequency enum  | 
| true | if the operation succeeded | 
| false | if the operation failed | 
      
  | 
  inline | 
Disable square wave output to the SQW/OUT pin of the RTC chip.
| output_value | value to force on SQW/OUT pin | 
| true | if the operation succeeded | 
| false | if the operation failed | 
      
  | 
  inline | 
Set one cell of the chip internal RAM to the specified value.
| address | the address of the cell to write, must be between 0 and ram_size().  | 
| data | the value to put at address  | 
| true | if the operation succeeded | 
| false | if the operation failed | 
      
  | 
  inline | 
Get the value of one cell of the chip internal RAM.
| address | the address of the cell to read, must be between 0 and ram_size().  | 
address 
      
  | 
  inline | 
Set several cells of the chip internal RAM to specified values.
| SIZE | the number of bytes to be written; address + SIZE must be less than ram_size().  | 
| address | the address of the first cell to write, must be between 0 and ram_size().  | 
| data | pointer to a buffer containing the values to write | 
| true | if the operation succeeded | 
| false | if the operation failed | 
      
  | 
  inline | 
Get values of several cells from the chip internal RAM.
| SIZE | the number of bytes to read; address + SIZE must be less than ram_size().  | 
| address | the address of the first cell to read, must be between 0 and ram_size().  | 
| data | pointer to a buffer where read values will be copied | 
| true | if the operation succeeded | 
| false | if the operation failed | 
      
  | 
  inline | 
Write any type of data to the chip internal RAM.
| T | the type of data to be written | 
| address | the address where to write data, must be between 0 and ram_size() - sizeof(T).  | 
| data | the actual data of type T, to be written  | 
| true | if the operation succeeded | 
| false | if the operation failed | 
      
  | 
  inline | 
Read any type of data from the chip internal RAM.
Note that this method only copies bytes to a variable of some type, no constructor will be called; hence, it is preferrable to use only simple struct types.
| T | the type of data to be read | 
| address | the address where to find data to read, must be between 0 and ram_size() - sizeof(T).  | 
| data | a reference to a variable that will be copied the read content | 
| true | if the operation succeeded | 
| false | if the operation failed |