Skip to content

Commit 2198cb2

Browse files
committed
ss_spi.c: fix CTRLR0 write in ss_spi_set_data_mode()
This fixes two existing issues with the current implementation; 1. The value to be written (ctrl) is completely overwritten on line 107, erasing the previous modifications (perhaps instead of a bitwise-OR?) 2. On the same line- the 'dataMode' value should be shifted by 4, not by 6 (see Quark SE C1000 datasheet, Table 229 "Detailed Description of Control Register 0 (CTRLR0) for reference)
1 parent c353f4c commit 2198cb2

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

system/libarc32_arduino101/drivers/spi_priv.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@
6060
#define SPI_NDF_SET_MASK (0x0000ffff)
6161
#define SPI_SRL_SET_MASK (0xfffff7ff)
6262
#define SPI_TMOD_SET_MASK (0xfffffcff)
63-
#define SPI_SCPL_SET_MASK (0xffffff7f)
64-
#define SPI_SCPH_SET_MASK (0xffffffbf)
63+
#define SPI_SCPL_SET_MASK (0x80)
64+
#define SPI_SCPH_SET_MASK (0x40)
6565
#define SPI_DFS_SET_MASK (0xfffffff0)
6666

6767
#define SPI_CLK_ENABLED (1 << 15)

system/libarc32_arduino101/drivers/ss_spi.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@ void ss_spi_set_data_mode(SPI_CONTROLLER controller_id, uint8_t dataMode)
103103

104104
/* Set frame size, bus mode and transfer mode */
105105
ctrl = READ_ARC_REG(dev->reg_base + CTRL);
106-
ctrl &= (SPI_SCPL_SET_MASK & SPI_SCPH_SET_MASK);
107-
ctrl = (dataMode << 6);
106+
ctrl |= (SPI_SCPL_SET_MASK | SPI_SCPH_SET_MASK);
107+
ctrl |= (dataMode & 0xFC) << 4;
108108
WRITE_ARC_REG(ctrl, dev->reg_base + CTRL);
109109

110110
/* re-enable controller */
-1.76 KB
Binary file not shown.

0 commit comments

Comments
 (0)