drivers/timers/mcp794xx.c: Rename the module to mcp794xx.
This commit is contained in:
parent
92104149e8
commit
d0b4a018bf
@ -222,23 +222,23 @@ config PCF85263_I2C_FREQUENCY
|
|||||||
|
|
||||||
endif # RTC_PCF85263
|
endif # RTC_PCF85263
|
||||||
|
|
||||||
config RTC_MCP7941X
|
config RTC_MCP794XX
|
||||||
bool "MCP7941X RTC Driver"
|
bool "MCP794XX RTC Driver"
|
||||||
default n
|
default n
|
||||||
select I2C
|
select I2C
|
||||||
select RTC_DATETIME
|
select RTC_DATETIME
|
||||||
depends on RTC_EXTERNAL
|
depends on RTC_EXTERNAL
|
||||||
---help---
|
---help---
|
||||||
Enables support for the Microchip MCP7941X I2C RTC timer.
|
Enables support for the Microchip MCP794XX I2C RTC timer.
|
||||||
|
|
||||||
if RTC_MCP7941X
|
if RTC_MCP794XX
|
||||||
|
|
||||||
config MCP7941X_I2C_FREQUENCY
|
config MCP794XX_I2C_FREQUENCY
|
||||||
int "MCP7941X I2C frequency"
|
int "MCP794XX I2C frequency"
|
||||||
default 400000
|
default 400000
|
||||||
range 1 400000
|
range 1 400000
|
||||||
|
|
||||||
endif # RTC_MCP7941X
|
endif # RTC_MCP794XX
|
||||||
endif # RTC
|
endif # RTC
|
||||||
|
|
||||||
menuconfig WATCHDOG
|
menuconfig WATCHDOG
|
||||||
|
@ -81,8 +81,8 @@ ifeq ($(CONFIG_RTC_PCF85263),y)
|
|||||||
TMRVPATH = :timers
|
TMRVPATH = :timers
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_RTC_MCP7941X),y)
|
ifeq ($(CONFIG_RTC_MCP794XX),y)
|
||||||
CSRCS += mcp7941x.c
|
CSRCS += mcp794xx.c
|
||||||
TMRDEPPATH = --dep-path timers
|
TMRDEPPATH = --dep-path timers
|
||||||
TMRVPATH = :timers
|
TMRVPATH = :timers
|
||||||
endif
|
endif
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/timers/mcp7941x.c
|
* drivers/timers/mcp794xx.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2019 Abdelatif Guettouche. All rights reserved.
|
* Copyright (C) 2019 Abdelatif Guettouche. All rights reserved.
|
||||||
* Author: 2019 Abdelatif Guettouche <abdelatif.guettouche@gmail.com>
|
* Author: 2019 Abdelatif Guettouche <abdelatif.guettouche@gmail.com>
|
||||||
@ -50,11 +50,11 @@
|
|||||||
|
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/i2c/i2c_master.h>
|
#include <nuttx/i2c/i2c_master.h>
|
||||||
#include <nuttx/timers/mcp7941x.h>
|
#include <nuttx/timers/mcp794xx.h>
|
||||||
|
|
||||||
#include "mcp7941x.h"
|
#include "mcp794xx.h"
|
||||||
|
|
||||||
#ifdef CONFIG_RTC_MCP7941X
|
#ifdef CONFIG_RTC_MCP794XX
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
@ -71,24 +71,24 @@
|
|||||||
# error CONFIG_RTC_HIRES must NOT be set with this driver
|
# error CONFIG_RTC_HIRES must NOT be set with this driver
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef CONFIG_MCP7941X_I2C_FREQUENCY
|
#ifndef CONFIG_MCP794XX_I2C_FREQUENCY
|
||||||
# error CONFIG_MCP7941X_I2C_FREQUENCY is not configured
|
# error CONFIG_MCP794XX_I2C_FREQUENCY is not configured
|
||||||
# define CONFIG_MCP7941X_I2C_FREQUENCY 400000
|
# define CONFIG_MCP794XX_I2C_FREQUENCY 400000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_MCP7941X_I2C_FREQUENCY > 400000
|
#if CONFIG_MCP794XX_I2C_FREQUENCY > 400000
|
||||||
# error CONFIG_MCP7941X_I2C_FREQUENCY is out of range
|
# error CONFIG_MCP794XX_I2C_FREQUENCY is out of range
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Types
|
* Private Types
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* This structure describes the state of the MCP7941x chip.
|
/* This structure describes the state of the MCP794XX chip.
|
||||||
* Only a single RTC is supported.
|
* Only a single RTC is supported.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct mcp7941x_dev_s
|
struct mcp794xx_dev_s
|
||||||
{
|
{
|
||||||
FAR struct i2c_master_s *i2c; /* Contained reference to the I2C bus driver. */
|
FAR struct i2c_master_s *i2c; /* Contained reference to the I2C bus driver. */
|
||||||
uint8_t addr; /* The I2C device address. */
|
uint8_t addr; /* The I2C device address. */
|
||||||
@ -106,9 +106,9 @@ volatile bool g_rtc_enabled = false;
|
|||||||
* Private Data
|
* Private Data
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/* The state of the MCP7941x chip. Only a single RTC is supported */
|
/* The state of the MCP794XX chip. Only a single RTC is supported */
|
||||||
|
|
||||||
static struct mcp7941x_dev_s g_mcp7941x;
|
static struct mcp794xx_dev_s g_mcp794xx;
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Functions
|
* Private Functions
|
||||||
@ -200,14 +200,14 @@ static int rtc_bcd2bin(uint8_t value)
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: mcp7941x_rtc_initialize
|
* Name: mcp794xx_rtc_initialize
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initialize the hardware RTC per the selected configuration. This
|
* Initialize the hardware RTC per the selected configuration. This
|
||||||
* function is called once during the OS initialization sequence by board-
|
* function is called once during the OS initialization sequence by board-
|
||||||
* specific logic.
|
* specific logic.
|
||||||
*
|
*
|
||||||
* After mcp7941x_rtc_initialize() is called, the OS function
|
* After mcp794xx_rtc_initialize() is called, the OS function
|
||||||
* clock_synchronize() should also be called to synchronize the system
|
* clock_synchronize() should also be called to synchronize the system
|
||||||
* timer to a hardware RTC. That operation is normally performed
|
* timer to a hardware RTC. That operation is normally performed
|
||||||
* automatically by the system during clock initialization. However, when
|
* automatically by the system during clock initialization. However, when
|
||||||
@ -215,21 +215,21 @@ static int rtc_bcd2bin(uint8_t value)
|
|||||||
* synchronize the system timer to the RTC when the RTC becomes available.
|
* synchronize the system timer to the RTC when the RTC becomes available.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* i2c - An instance of the I2C interface used to access the MCP7941x
|
* i2c - An instance of the I2C interface used to access the MCP794XX
|
||||||
* device
|
* device
|
||||||
* addr - The (7-bit) I2C address of the MCP7941x device
|
* addr - The (7-bit) I2C address of the MCP794XX device
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Zero (OK) on success; a negated errno on failure
|
* Zero (OK) on success; a negated errno on failure
|
||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int mcp7941x_rtc_initialize(FAR struct i2c_master_s *i2c, uint8_t addr)
|
int mcp794xx_rtc_initialize(FAR struct i2c_master_s *i2c, uint8_t addr)
|
||||||
{
|
{
|
||||||
/* Remember the i2c device and claim that the RTC is enabled */
|
/* Remember the i2c device and claim that the RTC is enabled */
|
||||||
|
|
||||||
g_mcp7941x.i2c = i2c;
|
g_mcp794xx.i2c = i2c;
|
||||||
g_mcp7941x.addr = addr;
|
g_mcp794xx.addr = addr;
|
||||||
g_rtc_enabled = true;
|
g_rtc_enabled = true;
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
@ -292,10 +292,10 @@ int up_rtc_getdatetime(FAR struct tm *tp)
|
|||||||
* The chip increments the address to read from after each read.
|
* The chip increments the address to read from after each read.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
secaddr = MCP7941X_REG_TIME_SEC;
|
secaddr = MCP794XX_REG_RTCSEC;
|
||||||
|
|
||||||
msg[0].frequency = CONFIG_MCP7941X_I2C_FREQUENCY;
|
msg[0].frequency = CONFIG_MCP794XX_I2C_FREQUENCY;
|
||||||
msg[0].addr = g_mcp7941x.addr;
|
msg[0].addr = g_mcp794xx.addr;
|
||||||
msg[0].flags = I2C_M_NOSTOP;
|
msg[0].flags = I2C_M_NOSTOP;
|
||||||
msg[0].buffer = &secaddr;
|
msg[0].buffer = &secaddr;
|
||||||
msg[0].length = 1;
|
msg[0].length = 1;
|
||||||
@ -304,22 +304,22 @@ int up_rtc_getdatetime(FAR struct tm *tp)
|
|||||||
* (Seconds, minutes, hours, wday, date, month and year)
|
* (Seconds, minutes, hours, wday, date, month and year)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
msg[1].frequency = CONFIG_MCP7941X_I2C_FREQUENCY;
|
msg[1].frequency = CONFIG_MCP794XX_I2C_FREQUENCY;
|
||||||
msg[1].addr = g_mcp7941x.addr;
|
msg[1].addr = g_mcp794xx.addr;
|
||||||
msg[1].flags = I2C_M_READ;
|
msg[1].flags = I2C_M_READ;
|
||||||
msg[1].buffer = buffer;
|
msg[1].buffer = buffer;
|
||||||
msg[1].length = 7;
|
msg[1].length = 7;
|
||||||
|
|
||||||
/* Read the seconds register again */
|
/* Read the seconds register again */
|
||||||
|
|
||||||
msg[2].frequency = CONFIG_MCP7941X_I2C_FREQUENCY;
|
msg[2].frequency = CONFIG_MCP794XX_I2C_FREQUENCY;
|
||||||
msg[2].addr = g_mcp7941x.addr;
|
msg[2].addr = g_mcp794xx.addr;
|
||||||
msg[2].flags = I2C_M_NOSTOP;
|
msg[2].flags = I2C_M_NOSTOP;
|
||||||
msg[2].buffer = &secaddr;
|
msg[2].buffer = &secaddr;
|
||||||
msg[2].length = 1;
|
msg[2].length = 1;
|
||||||
|
|
||||||
msg[3].frequency = CONFIG_MCP7941X_I2C_FREQUENCY;
|
msg[3].frequency = CONFIG_MCP794XX_I2C_FREQUENCY;
|
||||||
msg[3].addr = g_mcp7941x.addr;
|
msg[3].addr = g_mcp794xx.addr;
|
||||||
msg[3].flags = I2C_M_READ;
|
msg[3].flags = I2C_M_READ;
|
||||||
msg[3].buffer = &seconds;
|
msg[3].buffer = &seconds;
|
||||||
msg[3].length = 1;
|
msg[3].length = 1;
|
||||||
@ -330,46 +330,46 @@ int up_rtc_getdatetime(FAR struct tm *tp)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = I2C_TRANSFER(g_mcp7941x.i2c, msg, 4);
|
ret = I2C_TRANSFER(g_mcp794xx.i2c, msg, 4);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
rtcerr("ERROR: I2C_TRANSFER failed: %d\n", ret);
|
rtcerr("ERROR: I2C_TRANSFER failed: %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ((buffer[0] & MCP7941X_TIME_SEC_BCDMASK) >
|
while ((buffer[0] & MCP794XX_RTCSEC_BCDMASK) >
|
||||||
(seconds & MCP7941X_TIME_SEC_BCDMASK));
|
(seconds & MCP794XX_RTCSEC_BCDMASK));
|
||||||
|
|
||||||
/* Format the return time */
|
/* Format the return time */
|
||||||
/* Return seconds (0-59) */
|
/* Return seconds (0-59) */
|
||||||
|
|
||||||
tp->tm_sec = rtc_bcd2bin(buffer[0] & MCP7941X_TIME_SEC_BCDMASK);
|
tp->tm_sec = rtc_bcd2bin(buffer[0] & MCP794XX_RTCSEC_BCDMASK);
|
||||||
|
|
||||||
/* Return minutes (0-59) */
|
/* Return minutes (0-59) */
|
||||||
|
|
||||||
tp->tm_min = rtc_bcd2bin(buffer[1] & MCP7941X_TIME_MIN_BCDMASK);
|
tp->tm_min = rtc_bcd2bin(buffer[1] & MCP794XX_RTCMIN_BCDMASK);
|
||||||
|
|
||||||
/* Return hour (0-23). This assumes 24-hour time was set. */
|
/* Return hour (0-23). This assumes 24-hour time was set. */
|
||||||
|
|
||||||
tp->tm_hour = rtc_bcd2bin(buffer[2] & MCP7941X_TIME_HOUR_BCDMASK);
|
tp->tm_hour = rtc_bcd2bin(buffer[2] & MCP794XX_RTCHOUR_BCDMASK);
|
||||||
|
|
||||||
#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED)
|
#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED)
|
||||||
/* Return the day of the week (0-6) */
|
/* Return the day of the week (0-6) */
|
||||||
|
|
||||||
tp->tm_wday = (rtc_bcd2bin(buffer[3]) & MCP7941X_TIME_DAY_BCDMASK) - 1;
|
tp->tm_wday = (rtc_bcd2bin(buffer[3]) & MCP794XX_RTCWKDAY_BCDMASK) - 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Return the day of the month (1-31) */
|
/* Return the day of the month (1-31) */
|
||||||
|
|
||||||
tp->tm_mday = rtc_bcd2bin(buffer[4] & MCP7941X_TIME_DATE_BCDMASK);
|
tp->tm_mday = rtc_bcd2bin(buffer[4] & MCP794XX_RTCDATE_BCDMASK);
|
||||||
|
|
||||||
/* Return the month (0-11) */
|
/* Return the month (0-11) */
|
||||||
|
|
||||||
tp->tm_mon = rtc_bcd2bin(buffer[5] & MCP7941X_TIME_MONTH_BCDMASK) - 1;
|
tp->tm_mon = rtc_bcd2bin(buffer[5] & MCP794XX_RTCMTH_BCDMASK) - 1;
|
||||||
|
|
||||||
/* Return the years since 1900 */
|
/* Return the years since 1900 */
|
||||||
|
|
||||||
tp->tm_year = rtc_bcd2bin(buffer[6] & MCP7941X_TIME_YEAR_BCDMASK);
|
tp->tm_year = rtc_bcd2bin(buffer[6] & MCP794XX_RTCYEAR_BCDMASK);
|
||||||
|
|
||||||
rtc_dumptime(tp, "Returning");
|
rtc_dumptime(tp, "Returning");
|
||||||
return OK;
|
return OK;
|
||||||
@ -440,11 +440,11 @@ int up_rtc_settime(FAR const struct timespec *tp)
|
|||||||
/* Construct the message */
|
/* Construct the message */
|
||||||
/* Write starting with the seconds register */
|
/* Write starting with the seconds register */
|
||||||
|
|
||||||
buffer[0] = MCP7941X_REG_TIME_SEC;
|
buffer[0] = MCP794XX_REG_RTCSEC;
|
||||||
|
|
||||||
/* Save seconds (0-59) converted to BCD. And set the ST. */
|
/* Save seconds (0-59) converted to BCD. And set the ST. */
|
||||||
|
|
||||||
buffer[1] = rtc_bin2bcd(newtm.tm_sec) | MCP7941X_TIME_SEC_ST;
|
buffer[1] = rtc_bin2bcd(newtm.tm_sec) | MCP794XX_RTCSEC_ST;
|
||||||
|
|
||||||
/* Save minutes (0-59) converted to BCD */
|
/* Save minutes (0-59) converted to BCD */
|
||||||
|
|
||||||
@ -457,9 +457,9 @@ int up_rtc_settime(FAR const struct timespec *tp)
|
|||||||
/* Save the day of the week (1-7) and enable VBAT. */
|
/* Save the day of the week (1-7) and enable VBAT. */
|
||||||
|
|
||||||
#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED)
|
#if defined(CONFIG_LIBC_LOCALTIME) || defined(CONFIG_TIME_EXTENDED)
|
||||||
buffer[4] = rtc_bin2bcd(newtm.tm_wday + 1) | MCP7941X_TIME_DAY_VBATEN;
|
buffer[4] = rtc_bin2bcd(newtm.tm_wday + 1) | MCP794XX_RTCWKDAY_VBATEN;
|
||||||
#else
|
#else
|
||||||
buffer[4] = 1 | MCP7941X_TIME_DAY_VBATEN;
|
buffer[4] = 1 | MCP794XX_RTCWKDAY_VBATEN;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Save the day of the month (1-31) */
|
/* Save the day of the month (1-31) */
|
||||||
@ -476,24 +476,24 @@ int up_rtc_settime(FAR const struct timespec *tp)
|
|||||||
|
|
||||||
/* Setup the I2C message */
|
/* Setup the I2C message */
|
||||||
|
|
||||||
msg[0].frequency = CONFIG_MCP7941X_I2C_FREQUENCY;
|
msg[0].frequency = CONFIG_MCP794XX_I2C_FREQUENCY;
|
||||||
msg[0].addr = g_mcp7941x.addr;
|
msg[0].addr = g_mcp794xx.addr;
|
||||||
msg[0].flags = 0;
|
msg[0].flags = 0;
|
||||||
msg[0].buffer = buffer;
|
msg[0].buffer = buffer;
|
||||||
msg[0].length = 8;
|
msg[0].length = 8;
|
||||||
|
|
||||||
/* Read back the seconds register */
|
/* Read back the seconds register */
|
||||||
|
|
||||||
secaddr = MCP7941X_REG_TIME_SEC;
|
secaddr = MCP794XX_REG_RTCSEC;
|
||||||
|
|
||||||
msg[1].frequency = CONFIG_MCP7941X_I2C_FREQUENCY;
|
msg[1].frequency = CONFIG_MCP794XX_I2C_FREQUENCY;
|
||||||
msg[1].addr = g_mcp7941x.addr;
|
msg[1].addr = g_mcp794xx.addr;
|
||||||
msg[1].flags = I2C_M_NOSTOP;
|
msg[1].flags = I2C_M_NOSTOP;
|
||||||
msg[1].buffer = &secaddr;
|
msg[1].buffer = &secaddr;
|
||||||
msg[1].length = 1;
|
msg[1].length = 1;
|
||||||
|
|
||||||
msg[2].frequency = CONFIG_MCP7941X_I2C_FREQUENCY;
|
msg[2].frequency = CONFIG_MCP794XX_I2C_FREQUENCY;
|
||||||
msg[2].addr = g_mcp7941x.addr;
|
msg[2].addr = g_mcp794xx.addr;
|
||||||
msg[2].flags = I2C_M_READ;
|
msg[2].flags = I2C_M_READ;
|
||||||
msg[2].buffer = &seconds;
|
msg[2].buffer = &seconds;
|
||||||
msg[2].length = 1;
|
msg[2].length = 1;
|
||||||
@ -504,17 +504,17 @@ int up_rtc_settime(FAR const struct timespec *tp)
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
ret = I2C_TRANSFER(g_mcp7941x.i2c, msg, 3);
|
ret = I2C_TRANSFER(g_mcp794xx.i2c, msg, 3);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
rtcerr("ERROR: I2C_TRANSFER failed: %d\n", ret);
|
rtcerr("ERROR: I2C_TRANSFER failed: %d\n", ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while ((buffer[1] & MCP7941X_TIME_SEC_BCDMASK) >
|
while ((buffer[1] & MCP794XX_RTCSEC_BCDMASK) >
|
||||||
(seconds & MCP7941X_TIME_SEC_BCDMASK));
|
(seconds & MCP794XX_RTCSEC_BCDMASK));
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_RTC_MCP7941X */
|
#endif /* CONFIG_RTC_MCP794XX */
|
@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/timers/mcp7941x.h
|
* drivers/timers/mcp794xx.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2019 Abdelatif Guettouche. All rights reserved.
|
* Copyright (C) 2019 Abdelatif Guettouche. All rights reserved.
|
||||||
* Author: 2019 Abdelatif Guettouche <abdelatif.guettouche@gmail.com>
|
* Author: 2019 Abdelatif Guettouche <abdelatif.guettouche@gmail.com>
|
||||||
@ -37,58 +37,58 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef __DRIVERS_TIMERS_MCP7941X_H
|
#ifndef __DRIVERS_TIMERS_MCP794XX_H
|
||||||
#define __DRIVERS_TIMERS_MCP7941X_H
|
#define __DRIVERS_TIMERS_MCP794XX_H
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define MCP7941X_REG_TIME_SEC 0x00 /* Seconds register. */
|
#define MCP794XX_REG_RTCSEC 0x00 /* Seconds register. */
|
||||||
# define MCP7941X_TIME_SEC_10SEC (7 << 4)
|
# define MCP794XX_RTCSEC_10SEC (7 << 4)
|
||||||
# define MCP7941X_TIME_SEC_ST (1 << 7)
|
# define MCP794XX_RTCSEC_ST (1 << 7)
|
||||||
# define MCP7941X_TIME_SEC_BCDMASK 0x7F
|
# define MCP794XX_RTCSEC_BCDMASK 0x7F
|
||||||
|
|
||||||
#define MCP7941X_REG_TIME_MIN 0x01 /* Minutes register. */
|
#define MCP794XX_REG_RTCMIN 0x01 /* Minutes register. */
|
||||||
# define MCP7941X_TIME_MIN_10MIN (7 << 4)
|
# define MCP794XX_RTCMIN_10MIN (7 << 4)
|
||||||
# define MCP7941X_TIME_MIN_BCDMASK 0x7F
|
# define MCP794XX_RTCMIN_BCDMASK 0x7F
|
||||||
|
|
||||||
#define MCP7941X_REG_TIME_HOUR 0x02 /* Hours register. */
|
#define MCP794XX_REG_RTCHOUR 0x02 /* Hours register. */
|
||||||
# define MCP7941X_TIME_HOUR_10HOUR (3 << 4)
|
# define MCP794XX_RTCHOUR_10HOUR (3 << 4)
|
||||||
# define MCP7941X_TIME_HOUR_AMPM (1 << 5)
|
# define MCP794XX_RTCHOUR_AMPM (1 << 5)
|
||||||
# define MCP7941X_TIME_HOUR_1224 (1 << 6)
|
# define MCP794XX_RTCHOUR_1224 (1 << 6)
|
||||||
# define MCP7941X_TIME_HOUR_BCDMASK 0x3F
|
# define MCP794XX_RTCHOUR_BCDMASK 0x3F
|
||||||
|
|
||||||
#define MCP7941X_REG_TIME_DAY 0x03 /* Day register. */
|
#define MCP794XX_REG_RTCWKDAY 0x03 /* Day register. */
|
||||||
# define MCP7941X_TIME_DAY_VBATEN (1 << 3)
|
# define MCP794XX_RTCWKDAY_VBATEN (1 << 3)
|
||||||
# define MCP7941X_TIME_DAY_VBAT (1 << 4)
|
# define MCP794XX_RTCWKDAY_PWRFAIL (1 << 4)
|
||||||
# define MCP7941X_TIME_DAY_OSCON (1 << 5)
|
# define MCP794XX_RTCWKDAY_OSRUN (1 << 5)
|
||||||
# define MCP7941X_TIME_DAY_BCDMASK 0x07
|
# define MCP794XX_RTCWKDAY_BCDMASK 0x07
|
||||||
|
|
||||||
#define MCP7941X_REG_TIME_DATE 0x04 /* Date register. */
|
#define MCP794XX_REG_RTCDATE 0x04 /* Date register. */
|
||||||
# define MCP7941X_TIME_DATE_10DATE (3 << 4)
|
# define MCP794XX_RTCDATE_10DATE (3 << 4)
|
||||||
# define MCP7941X_TIME_DATE_BCDMASK 0x3F
|
# define MCP794XX_RTCDATE_BCDMASK 0x3F
|
||||||
|
|
||||||
#define MCP7941X_REG_TIME_MONTH 0x05 /* Month register. */
|
#define MCP794XX_REG_RTCMTH 0x05 /* Month register. */
|
||||||
# define MCP7941X_TIME_MONTH_10MONTH (1 << 4)
|
# define MCP794XX_RTCMTH_10MONTH (1 << 4)
|
||||||
# define MCP7941X_TIME_MONTH_LP (1 << 5)
|
# define MCP794XX_RTCMTH_LPYR (1 << 5)
|
||||||
# define MCP7941X_TIME_MONTH_BCDMASK 0x1F
|
# define MCP794XX_RTCMTH_BCDMASK 0x1F
|
||||||
|
|
||||||
#define MCP7941X_REG_TIME_YEAR 0x06 /* Year register. */
|
#define MCP794XX_REG_RTCYEAR 0x06 /* Year register. */
|
||||||
# define MCP7941X_TIME_YEAR_10YEAR (15 << 4)
|
# define MCP794XX_RTCYEAR_10YEAR (15 << 4)
|
||||||
# define MCP7941X_TIME_YEAR_BCDMASK 0xFF
|
# define MCP794XX_RTCYEAR_BCDMASK 0xFF
|
||||||
|
|
||||||
#define MCP7941X_REG_CTRL 0x07 /* Control register. */
|
#define MCP794XX_REG_CONTROL 0x07 /* Control register. */
|
||||||
# define MCP7941X_CTRL_RS0 (1 << 0)
|
# define MCP794XX_CONTROL_SQWFS0 (1 << 0)
|
||||||
# define MCP7941X_CTRL_RS1 (1 << 1)
|
# define MCP794XX_CONTROL_SQWFS1 (1 << 1)
|
||||||
# define MCP7941X_CTRL_RS2 (1 << 2)
|
# define MCP794XX_CONTROL_CRSTRIM (1 << 2)
|
||||||
# define MCP7941X_CTRL_EXTOSC (1 << 3)
|
# define MCP794XX_CONTROL_EXTOSC (1 << 3)
|
||||||
# define MCP7941X_CTRL_ALM0 (1 << 4)
|
# define MCP794XX_CONTROL_ALM0EN (1 << 4)
|
||||||
# define MCP7941X_CTRL_ALM1 (1 << 5)
|
# define MCP794XX_CONTROL_ALM1EN (1 << 5)
|
||||||
# define MCP7941X_CTRL_SQWE (1 << 6)
|
# define MCP794XX_CONTROL_SQWEN (1 << 6)
|
||||||
# define MCP7941X_CTRL_OUT (1 << 7)
|
# define MCP794XX_CONTROL_OUT (1 << 7)
|
||||||
|
|
||||||
#define MCP7941X_REG_CALIB 0x08 /* Calibration register. */
|
#define MCP794XX_REG_OSCTRIM 0x08 /* Calibration register. */
|
||||||
#define MCP7941X_REG_ID 0x09 /* ID register. */
|
# define MCP794XX_OSCTRIM_SIGN (1 << 7)
|
||||||
|
|
||||||
#endif /* __DRIVERS_TIMERS_MCP7941X_H */
|
#endif /* __DRIVERS_TIMERS_MCP794XX_H */
|
@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* include/nuttx/timers/mcp7941x.h
|
* include/nuttx/timers/mcp794xx.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2019 Abdelatif Guettouche. All rights reserved.
|
* Copyright (C) 2019 Abdelatif Guettouche. All rights reserved.
|
||||||
* Author: 2019 Abdelatif Guettouche <abdelatif.guettouche@gmail.com>
|
* Author: 2019 Abdelatif Guettouche <abdelatif.guettouche@gmail.com>
|
||||||
@ -37,8 +37,8 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef __INCLUDE_NUTTX_TIMERS_MCP7941X_H
|
#ifndef __INCLUDE_NUTTX_TIMERS_MCP794XX_H
|
||||||
#define __INCLUDE_NUTTX_TIMERS_MCP7941X_H
|
#define __INCLUDE_NUTTX_TIMERS_MCP794XX_H
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
@ -46,7 +46,7 @@
|
|||||||
|
|
||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#ifdef CONFIG_RTC_MCP7941X
|
#ifdef CONFIG_RTC_MCP794XX
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
@ -61,14 +61,14 @@ extern "C"
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: mcp7941x_rtc_initialize
|
* Name: mcp794xx_rtc_initialize
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* Initialize the hardware RTC per the selected configuration. This
|
* Initialize the hardware RTC per the selected configuration. This
|
||||||
* function is called once during the OS initialization sequence by board-
|
* function is called once during the OS initialization sequence by board-
|
||||||
* specific logic.
|
* specific logic.
|
||||||
*
|
*
|
||||||
* After mcp7941x_rtc_initialize() is called, the OS function
|
* After mcp794xx_rtc_initialize() is called, the OS function
|
||||||
* clock_synchronize() should also be called to synchronize the system
|
* clock_synchronize() should also be called to synchronize the system
|
||||||
* timer to a hardware RTC. That operation is normally performed
|
* timer to a hardware RTC. That operation is normally performed
|
||||||
* automatically by the system during clock initialization. However, when
|
* automatically by the system during clock initialization. However, when
|
||||||
@ -76,9 +76,9 @@ extern "C"
|
|||||||
* synchronize the system timer to the RTC when the RTC becomes available.
|
* synchronize the system timer to the RTC when the RTC becomes available.
|
||||||
*
|
*
|
||||||
* Input Parameters:
|
* Input Parameters:
|
||||||
* i2c - An instance of the I2C interface used to access the MCP7941x
|
* i2c - An instance of the I2C interface used to access the MCP794XX
|
||||||
* device
|
* device
|
||||||
* addr - The (7-bit) I2C address of the MCP7941x device
|
* addr - The (7-bit) I2C address of the MCP794XX device
|
||||||
*
|
*
|
||||||
* Returned Value:
|
* Returned Value:
|
||||||
* Zero (OK) on success; a negated errno on failure
|
* Zero (OK) on success; a negated errno on failure
|
||||||
@ -86,12 +86,12 @@ extern "C"
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
struct i2c_master_s; /* Forward reference */
|
struct i2c_master_s; /* Forward reference */
|
||||||
int mcp7941x_rtc_initialize(FAR struct i2c_master_s *i2c, uint8_t addr);
|
int mcp794xx_rtc_initialize(FAR struct i2c_master_s *i2c, uint8_t addr);
|
||||||
|
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* CONFIG_RTC_MCP7941X */
|
#endif /* CONFIG_RTC_MCP794XX */
|
||||||
#endif /* __INCLUDE_NUTTX_TIMERS_MCP7941X_H */
|
#endif /* __INCLUDE_NUTTX_TIMERS_MCP794XX_H */
|
Loading…
Reference in New Issue
Block a user