Name
CYGPKG_DEVICES_WALLCLOCK_DALLAS_DS1390
— eCos Support for the Dallas DS1390 Serial Real-Time Clock
Description
This package
CYGPKG_DEVICES_WALLCLOCK_DALLAS_DS1390
provides a
device driver for the wallclock device in the Dallas DS1390 Serial
Real-Time Clock chips. The driver can also be used
with any other chips that provide the same interface to the clock
hardware.
The package will usually be loaded into the configuration automatically whenever selecting a target which contains a compatible chip. By default it will provide the standard eCos wallclock device, although another implementation such as software emulation may be selected if desired. The only other configuration options related to this package allow users to change the compiler flags. If the application does not actually use the wallclock device, directly or indirectly, then the code should get removed automatically at link-time to ensure that the application does not suffer any unnecessary overheads.
Functionality
This wallclock device driver package implements the standard
functionality required by the generic wallclock support
CYGPKG_IO_WALLCLOCK
. The functionality is not
normally accessed directly. Instead it is used by the C library time
package to implement standard calls such as time
and gmtime
. The eCos C library also provides a
non-standard function cyg_libc_time_settime
for
changing the current wallclock setting. In addition RedBoot provides
a date command which interacts with the wallclock
device.
Porting
The DS1390 driver uses the SPI driver API defined by the
package CYGPKG_IO_SPI
. A suitable SPI device driver
must be available for the target. The platform HAL must
provide a cyg_spi_device structure
cyg_spi_wallclock_ds1390
. The platform HAL should
initialize this structure and any associated SPI driver specific
struture with the correct phase, polarity and chip select parameters
for this device.
In addition the DS1390 device driver package
CYGPKG_DEVICES_WALLCLOCK_DALLAS_DS1390
should be
included in the CDL target entry so that it gets loaded automatically
whenever eCos is configured for that target.
Extra API Calls
In addition to the standard wallclock API calls, this driver exports a
number of additional functions to permit direct access to additional
features of the device. A header,
cyg/io/wallclock/ds1390.h
is available to define
this API.
-
cyg_uint8 cyg_ds1390_read_reg( int addr )
-
Read and return a single 8-bit register from the DS1390,
addr
should be in the range 0x00 to 0x0F. -
void cyg_ds1390_write_reg( int addr, int val )
-
Write a single 8-bit register to the DS1390,
addr
should be in the range 0x00 to 0x0F andval
in the range 0x00 to 0xFF. -
void cyg_ds1390_set_control( cyg_uint8 val )
-
Write the DS1390 control register with the content of
val
. -
cyg_uint8 cyg_ds1390_get_control( void )
- Read and return the value of the DS1390 control register.
-
void cyg_ds1390_set_status( cyg_uint8 val )
-
Write the DS1390 status register with the content of
val
. -
cyg_uint8 cyg_ds1390_get_status( void )
- Read and return the value of the DS1390 control register.
-
void cyg_ds1390_set_charger( cyg_uint8 val )
-
Write the DS1390 trickle-charge register with the content of
val
. -
cyg_uint8 cyg_ds1390_get_charger( void )
- Read and return the value of the DS1390 trickle-charge register.
-
int cyg_wallclock_set_alarm( cyg_uint32 secs )
-
Set the DS1390 alarm to trigger when the wallclock time matches the
value of
secs
. The DS1390 alarm will match only up to days of the month, so the alarm cannot be set more than one month in the future. This function only initializes the DS1390 to generate the alarm interrupt; it is the responsibility of the caller to attach an ISR to the appropriate vector and unmask it in the interrupt controller.
2024-03-18 | Open Publication License |