Skip to content

Commit ac46099

Browse files
committed
[sam] Fix SPI bug in handling of CPHA/CPOL
1 parent 3f3ff3d commit ac46099

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/modm/platform/spi/sam/spi_master.hpp.in

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,10 @@ public:
105105

106106
static void
107107
setDataMode(DataMode mode) {
108-
uint32_t value = (uint32_t)mode ^ 2; // Flip CPHA bit
109-
Regs()->SPI_CSR[0] = (Regs()->SPI_CSR[0] & ~(SPI_CSR_CPOL | SPI_CSR_NCPHA)) | (value << SPI_CSR_CPOL_Pos);
108+
uint32_t value = (uint32_t)mode ^ 1; // Flip CPHA bit
109+
Regs()->SPI_CSR[0] = (Regs()->SPI_CSR[0] & ~(SPI_CSR_CPOL | SPI_CSR_NCPHA)) |
110+
(((value & 2) >> 1) << SPI_CSR_CPOL_Pos) |
111+
((value & 1) << SPI_CSR_NCPHA_Pos);
110112
}
111113

112114
static void

0 commit comments

Comments
 (0)