Skip to content

Commit 06245f3

Browse files
lpawelczMaureenHelm
authored andcommitted
drivers: spi: gecko: add support for CPOL and CPHA
This commit adds support for CPOL/CPHA configuration in the Gecko SPI driver. Signed-off-by: Pawel Czarnecki <[email protected]>
1 parent f1d3011 commit 06245f3

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

drivers/spi/spi_gecko.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,6 @@ static int spi_config(const struct device *dev,
9595
return -ENOTSUP;
9696
}
9797

98-
if (config->operation & (SPI_MODE_CPOL | SPI_MODE_CPHA)) {
99-
LOG_ERR("Only supports CPOL=CPHA=0");
100-
return -ENOTSUP;
101-
}
102-
10398
if (config->operation & SPI_OP_MODE_SLAVE) {
10499
LOG_ERR("Slave mode not supported");
105100
return -ENOTSUP;
@@ -112,6 +107,20 @@ static int spi_config(const struct device *dev,
112107
gecko_config->base->CTRL &= ~USART_CTRL_LOOPBK;
113108
}
114109

110+
/* Set CPOL */
111+
if (config->operation & SPI_MODE_CPOL) {
112+
gecko_config->base->CTRL |= USART_CTRL_CLKPOL;
113+
} else {
114+
gecko_config->base->CTRL &= ~USART_CTRL_CLKPOL;
115+
}
116+
117+
/* Set CPHA */
118+
if (config->operation & SPI_MODE_CPHA) {
119+
gecko_config->base->CTRL |= USART_CTRL_CLKPHA;
120+
} else {
121+
gecko_config->base->CTRL &= ~USART_CTRL_CLKPHA;
122+
}
123+
115124
/* Set word size */
116125
gecko_config->base->FRAME = usartDatabits8
117126
| USART_FRAME_STOPBITS_DEFAULT

0 commit comments

Comments
 (0)