mirror of
https://github.com/apache/nuttx.git
synced 2026-09-20 04:47:58 +08:00
drivers/timers/pcf85263.c: Add a driver for the NXP PCF85263 I2C RTC
This commit is contained in:
@@ -11129,4 +11129,7 @@
|
||||
(2015-11-19).
|
||||
* drivers/mtd/w25.c: Add support for byte write mode. From Ken Peit
|
||||
(2015-11-20).
|
||||
* drivers/timers/pcf85263.c and include/nuttx/times/pcf85263.h: Add
|
||||
a driver for the NXP PCF85263 I2C RTC. Untested on initial commit
|
||||
(2015-11-20).
|
||||
|
||||
|
||||
+20
-1
@@ -181,9 +181,28 @@ endchoice # Maxim Integrated RTC
|
||||
config DS3231_I2C_FREQUENCY
|
||||
int "DS1307/DS323x I2C frequency"
|
||||
default 400000
|
||||
range 1 4000000
|
||||
range 1 400000
|
||||
|
||||
endif # RTC_DSXXXX
|
||||
|
||||
config RTC_PCF85263
|
||||
bool "PCF85263 RTC Driver"
|
||||
default n
|
||||
select I2C
|
||||
select I2C_TRANSFER
|
||||
select RTC_EXTERNAL
|
||||
select RTC_DATETIME
|
||||
---help---
|
||||
Enables support for the Maxim Integrated DS3231 I2C RTC timer.
|
||||
|
||||
if RTC_PCF85263
|
||||
|
||||
config PCF85263_I2C_FREQUENCY
|
||||
int "PCF85263 I2C frequency"
|
||||
default 400000
|
||||
range 1 400000
|
||||
|
||||
endif # RTC_PCF85263
|
||||
endif # RTC
|
||||
|
||||
menuconfig WATCHDOG
|
||||
|
||||
@@ -57,6 +57,12 @@ ifeq ($(CONFIG_RTC_DSXXXX),y)
|
||||
TMRVPATH = :timers
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_RTC_PCF85263),y)
|
||||
CSRCS += pcf85263.c
|
||||
TMRDEPPATH = --dep-path timers
|
||||
TMRVPATH = :timers
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_RTC_DRIVER),y)
|
||||
CSRCS += rtc.c
|
||||
TMRDEPPATH = --dep-path timers
|
||||
|
||||
@@ -463,7 +463,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
|
||||
return -EINVAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
rtc_dumptime(&tm, "New time");
|
||||
|
||||
/* Construct the message */
|
||||
@@ -479,7 +479,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
|
||||
|
||||
buffer[2] = rtc_bin2bcd(newtm.tm_min);
|
||||
|
||||
/* Save hour (0-23) with 24-hour time indicatin */
|
||||
/* Save hour (0-23) with 24-hour time indication */
|
||||
|
||||
buffer[3] = rtc_bin2bcd(newtm.tm_hour) | DSXXXX_TIME_24;
|
||||
|
||||
@@ -491,7 +491,7 @@ int up_rtc_settime(FAR const struct timespec *tp)
|
||||
buffer[4] = 1;
|
||||
#endif
|
||||
|
||||
/* Save the day of the week (1-31) */
|
||||
/* Save the day of the month (1-31) */
|
||||
|
||||
buffer[5] = rtc_bin2bcd(newtm.tm_mday);
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -357,7 +357,7 @@
|
||||
# define PCF85263_CTL_OSC_CLKIV (1 << 7) /* Bit 7: Output clock inversion */
|
||||
|
||||
#define PCF85263_CTL_BATTERY_SWITCH 0x26 /* Battery switch control register */
|
||||
# define PCF85263_CTL_BATTERY_BSTH (1 << 0) /* Bit 0:
|
||||
# define PCF85263_CTL_BATTERY_BSTH (1 << 0) /* Bit 0: Threshold voltage control */
|
||||
# define PCF85263_CTL_BATTERY_BSM_SHIFT (1) /* Bits 1-2: Battery switch mode bits */
|
||||
# define PCF85263_CTL_BATTERY_BSM_MASK (3 << PCF85263_CTL_BATTERY_BSM_SHIFT)
|
||||
# define PCF85263_CTL_BATTERY_BSM_VTH (0 << PCF85263_CTL_BATTERY_BSM_SHIFT) /* Switching at the Vth level */
|
||||
@@ -453,7 +453,7 @@
|
||||
# define PCF85263_CTL_WDR_SHIFT (2) /* Bits 2-6: Watchdog register bits */
|
||||
# define PCF85263_CTL_WDR_MASK (31 << PCF85263_CTL_WDR_SHIFT)
|
||||
# define PCF85263_CTL_WDR(n) ((uint9_t)(n) << PCF85263_CTL_WDR_SHIFT)
|
||||
# define PCF85263_CTL_WDM (1 << 7) /* Bit 7: Watchdog mode
|
||||
# define PCF85263_CTL_WDM (1 << 7) /* Bit 7: Watchdog mode */
|
||||
|
||||
/* Stop */
|
||||
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/****************************************************************************
|
||||
* include/nuttx/timers/pcf85263.h
|
||||
*
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __INCLUDE_NUTTX_TIMERS_PCF85263_H
|
||||
#define __INCLUDE_NUTTX_TIMERS_PCF85263_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#ifdef CONFIG_RTC_PCF85263
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/************************************************************************************
|
||||
* Name: pcf85263_rtc_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the hardware RTC per the selected configuration. This function is
|
||||
* called once during the OS initialization sequence by board-specific logic.
|
||||
*
|
||||
* After pcf85263_rtc_initialize() is called, the OS function clock_synchronize()
|
||||
* should also be called to synchronize the system timer to a hardware RTC. That
|
||||
* operation is normally performed automatically by the system during clock
|
||||
* initialization. However, when an external RTC is used, the board logic will
|
||||
* need to explicitly re-synchronize the system timer to the RTC when the RTC
|
||||
* becomes available.
|
||||
*
|
||||
* Input Parameters:
|
||||
* None
|
||||
*
|
||||
* Returned Value:
|
||||
* Zero (OK) on success; a negated errno on failure
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
struct i2c_dev_s; /* Forward reference */
|
||||
int pcf85263_rtc_initialize(FAR struct i2c_dev_s *i2c);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* CONFIG_RTC_PCF85263 */
|
||||
#endif /* __INCLUDE_NUTTX_TIMERS_PCF85263_H */
|
||||
Reference in New Issue
Block a user