Skip to content

Commit 975acdf

Browse files
committed
Add clock phase argument to smartpin SPI object
Followed Rev 5 06-11-2020 Jon Titus, Page 56 of 63 Verified with logic analyser.
1 parent 1468c8b commit 975acdf

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

libraries/community/p2/All/jm_ez_spi/jm_ez_spi.spin2

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ pub null()
4545

4646

4747
pub start(sdipin, sdopin, sckpin, khz) : result | m, x
48+
pub start(sdipin, sdopin, sckpin, khz, cpha) : result | m, x
4849

4950
'' Configure P2 smart pins for SPI coms
5051
'' -- sdipin is input from external device (-1 if not used)
@@ -69,6 +70,7 @@ pub start(sdipin, sdopin, sckpin, khz) : result | m, x
6970
if (sdo >= 0)
7071
m := P_OE | P_SYNC_TX ' spi tx mode
7172
m |= ((sck-sdo) & %111) << 24 ' add SCK offset (B pin)
73+
m |= cpha << 27 ' set clock phase
7274
x := %1_00000 | (8-1) ' start/stop mode, 8 bits
7375
pinstart(sdo, m, x, 0) ' configure smart pin
7476
pinf(sdo) ' disable until used
@@ -77,6 +79,7 @@ pub start(sdipin, sdopin, sckpin, khz) : result | m, x
7779
x.word[0] := 2 #> (clkfreq / (khz*1000)) <# $FFFF ' ticks in period
7880
x.word[1] := x.word[0] >> 1 ' ticks in low cycle (50%)
7981
pinstart(sck, m, x, 0) ' configure smart pin
82+
m |= cpha << 14 ' set clock phase
8083

8184
setup := true
8285

0 commit comments

Comments
 (0)