Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NuttX RTOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
NuttX RTOS
Commits
9a1ca0d4
Commit
9a1ca0d4
authored
9 years ago
by
Gregory Nutt
Browse files
Options
Downloads
Patches
Plain Diff
Add support for DS1302 and DS3232 RTC chips
parent
367d8020
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
configs
+1
-1
1 addition, 1 deletion
configs
drivers/timers/Kconfig
+11
-1
11 additions, 1 deletion
drivers/timers/Kconfig
drivers/timers/ds3231.h
+42
-13
42 additions, 13 deletions
drivers/timers/ds3231.h
with
54 additions
and
15 deletions
configs
@
2a5172fb
Subproject commit
388c
af
6
34
66f447ce0fc6924dc50e79b9ba70cf8
Subproject commit
2a5172fbb37ada3f8119c99
af34
a1bbf70120ee3
This diff is collapsed.
Click to expand it.
drivers/timers/Kconfig
+
11
−
1
View file @
9a1ca0d4
...
...
@@ -133,7 +133,7 @@ config RTC_EXTERNAL
early in the boot sequence.
config RTC_DSXXXX
bool "DS130
7
/DS323x RTC Driver"
bool "DS130
x
/DS323x RTC Driver"
default n
select I2C
select I2C_TRANSFER
...
...
@@ -148,6 +148,11 @@ choice
prompt "Maxim Integrated RTC"
default RTC_DS3231
config RTC_DS1302
bool "DS1302"
---help---
Enables support for the Maxim Integrated DS1307 serial RTC timer.
config RTC_DS1307
bool "DS1307"
---help---
...
...
@@ -158,6 +163,11 @@ config RTC_DS3231
---help---
Enables support for the Maxim Integrated DS3231 I2C RTC timer.
config RTC_DS3232
bool "DS3232"
---help---
Enables support for the Maxim Integrated DS3232 I2C RTC timer.
config RTC_DS3234
bool "DS3234"
depends on EXPERIMENTAL
...
...
This diff is collapsed.
Click to expand it.
drivers/timers/ds3231.h
+
42
−
13
View file @
9a1ca0d4
...
...
@@ -54,8 +54,8 @@
# define DSXXXX_TIME_10SEC_MASK (7 << DSXXXX_TIME_10SEC_SHIFT)
# define DSXXXX_TIME_10SEC(n) ((uint8_t)(n) << DSXXXX_TIME_10SEC_SHIFT)
# define DSXXXX_TIME_SEC_BCDMASK (DSXXXX_TIME_SEC_MASK | DSXXXX_TIME_10SEC_MASK)
#ifdef
CONFIG_RTC_DS1307
# define DS130
7
_TIME_CH (1 << 7)
/* Bit 7: Clock halt */
#if
def
ined(CONFIG_RTC_DS1302) || defined(
CONFIG_RTC_DS1307
)
# define DS130
x
_TIME_CH (1 << 7)
/* Bit 7: Clock halt */
#endif
#define DSXXXX_TIME_MINR 0x01
/* Minutes register */
...
...
@@ -110,7 +110,7 @@
# define DSXXXX_TIME_10MONTH_MASK (1 << DSXXXX_TIME_10MONTH_SHIFT)
# define DSXXXX_TIME_10MONTH(n) ((uint8_t)(n) << DSXXXX_TIME_10MONTH_SHIFT)
# define DSXXXX_TIME_MONTH_BCDMASK (DSXXXX_TIME_MONTH_MASK | DSXXXX_TIME_10MONTH_MASK)
#if defined(CONFIG_RTC_DS3231) || defined(CONFIG_RTC_DS3234)
#if defined(CONFIG_RTC_DS3231) ||
defined(CONFIG_RTC_DS3232) ||
defined(CONFIG_RTC_DS3234)
# define DS323X_TIME_CENTURY_SHIFT 7
/* Bit 7: Century Indication */
# define DS323X_TIME_CENTURY_MASK (1 << DS323X_TIME_CENTURY_SHIFT)
# define DS323X_TIME_1900 ((uint8_t)(0) << DS323X_TIME_CENTURY_SHIFT)
...
...
@@ -126,6 +126,31 @@
# define DSXXXX_TIME_10YEAR(n) ((uint8_t)(n) << DSXXXX_TIME_10YEAR_SHIFT)
# define DSXXXX_TIME_YEAR_BCDMASK (DSXXXX_TIME_YEAR_MASK | DSXXXX_TIME_10YEAR_MASK)
#ifdef CONFIG_RTC_DS1302
# define DS1302_CR 0x07
/* Control register */
# define DS1302_CR_WP (1 << 7)
/* Bit 7: Write protect */
# define DS1302_TCR 0x08
/* Trickle charge register */
# define DS1302_TCR_RS_SHIFT (0)
/* Bits 0-1: Range select */
# define DS1302_TCR_RS_MASK (3 << DS1302_TCR_RS_SHIFT)
# define DS1302_TCR_RS(n) ((uint8_t)(n) << DS1302_TCR_RS_SHIFT)
# define DS1302_TCR_DS_SHIFT (4)
/* Bits 2-3: Diode select */
# define DS1302_TCR_DS_MASK (3 << DS1302_TCR_DS_SHIFT)
# define DS1302_TCR_DS(n) ((uint8_t)(n) << DS1302_TCR_DS_SHIFT)
# define DS1302_TCR_TCS_SHIFT (4)
/* Bits 4-7: Trickle charge select */
# define DS1302_TCR_TCS_MASK (15 << DS1302_TCR_TCS_SHIFT)
# define DS1302_TCR_TCS(n) ((uint8_t)(n) << DS1302_TCR_TCS_SHIFT)
# define DS1302_TCR_DISABLED (DS1302_TCR_RS(0) | define DS1302_TCR_DS(0) | define DS1302_TCR_TCS(0))
# define DS1302_TCR_1DIODE_2OHM (DS1302_TCR_RS(1) | define DS1302_TCR_DS(1) | define DS1302_TCR_TCS(10))
# define DS1302_TCR_1DIODE_4OHM (DS1302_TCR_RS(2) | define DS1302_TCR_DS(1) | define DS1302_TCR_TCS(10))
# define DS1302_TCR_1DIODE_8OHM (DS1302_TCR_RS(3) | define DS1302_TCR_DS(1) | define DS1302_TCR_TCS(10))
# define DS1302_TCR_2DIODE_2OHM (DS1302_TCR_RS(1) | define DS1302_TCR_DS(2) | define DS1302_TCR_TCS(10))
# define DS1302_TCR_2DIODE_4OHM (DS1302_TCR_RS(2) | define DS1302_TCR_DS(2) | define DS1302_TCR_TCS(10))
# define DS1302_TCR_2DIODE_8OHM (DS1302_TCR_RS(3) | define DS1302_TCR_DS(2) | define DS1302_TCR_TCS(10))
# define DS1302_TCR_INIT (DS1302_TCR_RS(0) | define DS1302_TCR_DS(3) | define DS1302_TCR_TCS(5))
#endif
#ifdef CONFIG_RTC_DS1307
# define DS1307_CR 0x07
/* Control register */
# define DS1307_CR_RS_SHIFT (3)
/* Bits 0-1: Rate selection */
...
...
@@ -139,7 +164,7 @@
# define DS1307_RAM_BASE 0x08
/* 0x08-0x3f: 56x8 RAM */
#endif
#if defined(CONFIG_RTC_DS3231) || defined(CONFIG_RTC_DS3234)
#if defined(CONFIG_RTC_DS3231) ||
defined(CONFIG_RTC_DS3232) ||
defined(CONFIG_RTC_DS3234)
# define DS323X_ALARM1_SECR 0x07
/* Alarm1 seconds register */
# define DS323X_ALARM1_SEC_SHIFT 0
/* Bits 0-3: Seconds, range 0-9 */
# define DS323X_ALARM1_SEC_MASK (15 << DS323X_ALARM1_SEC_SHIFT)
...
...
@@ -281,14 +306,14 @@
# define DS323X_CSR_A2F (1 << 1)
/* Bit 1: Alarm 2 flag */
# define DS323X_CSR_BSY (1 << 2)
/* Bit 2: Busy */
# define DS323X_CSR_EN32kHz (1 << 3)
/* Bit 3: Enable 32kHz output */
# ifdef
CONFIG_RTC_DS3234
# define DS323
4
_CSR_CRATE_SHIFT (4)
/* Bits 4-5: Conversion rate */
# define DS323
4
_CSR_CRATE_MASK (3 << DS323
4
_CSR_CRATE_SHIFT)
# define DS323
4
_CSR_CRATE_64SEC (0 << DS323
4
_CSR_CRATE_SHIFT)
# define DS323
4
_CSR_CRATE_128SEC (1 << DS323
4
_CSR_CRATE_SHIFT)
# define DS323
4
_CSR_CRATE_256SEC (2 << DS323
4
_CSR_CRATE_SHIFT)
# define DS323
4
_CSR_CRATE_512SEC (3 << DS323
4
_CSR_CRATE_SHIFT)
# define DS323
4
_CSR_BB32KHZ (1 << 6)
/* Bit 6: Battery-Backed 32kHz Output */
# if
def
ined(CONFIG_RTC_DS3232) || defined(
CONFIG_RTC_DS3234
)
# define DS323
x
_CSR_CRATE_SHIFT (4)
/* Bits 4-5: Conversion rate */
# define DS323
x
_CSR_CRATE_MASK (3 << DS323
x
_CSR_CRATE_SHIFT)
# define DS323
x
_CSR_CRATE_64SEC (0 << DS323
x
_CSR_CRATE_SHIFT)
# define DS323
x
_CSR_CRATE_128SEC (1 << DS323
x
_CSR_CRATE_SHIFT)
# define DS323
x
_CSR_CRATE_256SEC (2 << DS323
x
_CSR_CRATE_SHIFT)
# define DS323
x
_CSR_CRATE_512SEC (3 << DS323
x
_CSR_CRATE_SHIFT)
# define DS323
x
_CSR_BB32KHZ (1 << 6)
/* Bit 6: Battery-Backed 32kHz Output */
# endif
# define DS323X_CSR_OSF (1 << 7)
/* Bit 7: Oscillator stop flag */
...
...
@@ -298,7 +323,11 @@
# define DS323X_TMPLR 0x12
/* LSB of temp register (2-bits) */
# define DS323X_TMPLR_MASK 0xc0
/* Bits 6-7: LSB of temp register (2-bits) */
#endif
/* CONFIG_RTC_DS3231 || CONFIG_RTC_DS3234 */
#endif
/* CONFIG_RTC_DS3231 || CONFIG_RTC_DS3232 || CONFIG_RTC_DS3234 */
#ifdef CONFIG_RTC_DS3232
# define DS3232_SRAM_BASE 0x14
/* 0x14-0xff: SRAM */
#endif
/* CONFIG_RTC_DS3232 */
#ifdef CONFIG_RTC_DS3234
# define DS3234_SRAM_ADDRR 0x98
/* SRAM address register */
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment