Skip to content

Commit 159570e

Browse files
authored
Merge pull request #212 from PropGit/ds1302_full
Ds1302 full
2 parents 1f3e9d3 + 8445146 commit 159570e

File tree

6 files changed

+164
-0
lines changed

6 files changed

+164
-0
lines changed

docs/p2.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ by Dave Hein
211211
## Recent Activity
212212
##### _Full details [here](https://github.com/parallaxinc/propeller/pulls?q=is%3Aclosed)._
213213

214+
* Added Dennis Gately's (and BR's) [DS1302 Full](https://github.com/parallaxinc/propeller/tree/master/libraries/community/p2/All/DS1302_full) object.
214215
* Added Jon "JonnyMac" McPhalen's [Quiic Twist](https://github.com/parallaxinc/propeller/tree/master/libraries/community/p2/All/jm_quiic_twist) object
215216
* Added Objects from Jon "JonnyMac" McPhalen
216217
* [AT24C32](https://github.com/parallaxinc/propeller/tree/master/libraries/community/p2/All/jm_at24c32)
Binary file not shown.
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
'' =================================================================================================
2+
''
3+
'' File....... DS1302_full_Demo.spin2
4+
'' Purpose.... Demonstrates interface of DS1302 Run Time Clock module driver (DS1302_full.spin2)
5+
'' Author..... Dennis Gately
6+
'' Copyright (C) 2020-2021
7+
'' -- see below for terms of use
8+
'' Dependencies... jm_fullduplexserial.spin2
9+
'' DS132_full.spin2
10+
'' Started.... 30 DEC 2020
11+
'' Updated.... 03 JAN 2021
12+
''
13+
'' =================================================================================================
14+
15+
16+
con { timing }
17+
18+
CLK_FREQ = 200_000_000 ' system freq as a constant
19+
MS_001 = CLK_FREQ / 1_000 ' ticks in 1ms
20+
US_001 = CLK_FREQ / 1_000_000 ' ticks in 1us
21+
22+
_clkfreq = CLK_FREQ ' set system clock
23+
24+
con { terminal }
25+
26+
BR_TERM = 230_400 ' terminal baud rate
27+
28+
#0, T_PST, T_ANSI ' terminal types
29+
30+
T_TYPE = T_PST
31+
32+
33+
con { fixed io pins }
34+
35+
RX1 = 63 { I } ' programming / debug
36+
TX1 = 62 { O }
37+
38+
SF_CS = 61 { O } ' serial flash
39+
SF_SCK = 60 { O }
40+
SF_SDO = 59 { O }
41+
SF_SDI = 58 { I }
42+
43+
SD_SCK = 61 { O } ' sd card
44+
SD_CS = 60 { O }
45+
SD_SDI = 59 { O }
46+
SD_SDO = 58 { I }
47+
48+
SDA1 = 55 { IO } ' i2c connections
49+
SCL1 = 54 { IO }
50+
51+
DS_clk = 28
52+
DS_data = 29
53+
DS_CE = 30
54+
55+
con { app io pins }
56+
57+
con
58+
59+
#true, ON, OFF
60+
#false, NO, YES
61+
62+
obj
63+
64+
term : "jm_fullduplexserial" ' * serial IO for terminal
65+
rtc : "DS1302_full" ' ds1302 Run Time Clock
66+
ansi : "jm_ansi" ' ANSI terminal control sequences
67+
68+
var
69+
70+
byte hour, minute, second, day, month, year, dow
71+
72+
pub main()| i
73+
74+
setup()
75+
76+
wait_for_terminal(true)
77+
78+
'' setDatetime test, un-comment to initialize to a specific date
79+
'' parameters are: _mth, _day, _year, _dow, _hr, _min, _sec
80+
''rtc.setDatetime( 1, 3, 21, 1, 16, 42, 10 )
81+
82+
term.str(string("DS1302_full_Demo"))
83+
term.tx(13)
84+
85+
rtc.readTime( @hour, @minute, @second ) ' read time from DS1302 RTC
86+
rtc.readDate( @day, @month, @year, @dow ) ' read date from DS1302 RTC
87+
88+
term.fstr3(string("Time: %d:%d:%d\n\r"), hour, minute, second)
89+
90+
term.fstr3(string("Date: %d/%d/%d\n\r"), month, day, year)
91+
92+
repeat
93+
94+
pub setup()| i
95+
96+
term.tstart(BR_TERM) ' start terminal io *
97+
98+
rtc.init( DS_clk, DS_data, DS_CE ) ' clock, data, chip-enable
99+
100+
pub wait_for_terminal(clear)
101+
102+
'' Wait for terminal to be open and key pressed
103+
' -- download to RAM with F10
104+
' -- F12 to open PST
105+
' -- Click [Enable] (if needed)
106+
' -- Press Enter
107+
108+
term.rxflush()
109+
term.rx()
110+
if (clear)
111+
if (T_TYPE == T_PST)
112+
term.tx(term.CLS)
113+
else
114+
term.str(ansi.hide_cursor())
115+
term.str(ansi.home())
116+
term.str(ansi.cls())
117+
118+
dat
119+
120+
con { license }
121+
122+
{{
123+
124+
Terms of Use: MIT License
125+
126+
Permission is hereby granted, free of charge, to any person obtaining a copy
127+
of this software and associated documentation files (the "Software"), to deal
128+
in the Software without restriction, including without limitation the rights
129+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
130+
copies of the Software, and to permit persons to whom the Software is
131+
furnished to do so, subject to the following conditions:
132+
133+
The above copyright notice and this permission notice shall be included in all
134+
copies or substantial portions of the Software.
135+
136+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
137+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
138+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
139+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
140+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
141+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
142+
SOFTWARE.
143+
}}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# DS1302_full
2+
3+
By: Dennis Gately based on BR's original in the Propeller 1 Object repo
4+
5+
Language: Spin2
6+
7+
Created: 03-JAN-2021
8+
9+
Category: protocol, sensor
10+
11+
Description:
12+
A full-featured DS1302 timekeeping chip driver. Based on the original Propeller 1 object by BR.
13+
14+
Converted DS1302_full.spin from the old OBEX to DS1302_full.spin2. This code compiles on PropTool 2.4.1 for P2 as well as in flexprop (version 5.0.5 beta). A demo/example is included.
15+
16+
License: MIT (see end of source code)

libraries/community/p2/Protocol/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[DS1302 Full](../All/DS1302_full)
2+
13
[ESP 32](../All/esp32)
24

35
[JM 1-Wire](../All/jm_1-wire)

libraries/community/p2/Sensor/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
[DS1302 Full](../All/DS1302_full)
2+
13
[JM Click 4-20mA_R/_T](../All/jm_click_4-20ma)
24

35
[JM Click RTC](../All/jm_click_rtc)

0 commit comments

Comments
 (0)