Skip to content

Commit 7a50adb

Browse files
committed
adds spi polarity, phase, mode converter functions to lcd_utils
1 parent d29f0fa commit 7a50adb

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ext_mod/lcd_utils/src/lcd_utils.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ static mp_obj_t spi_mode_to_polarity_phase(mp_obj_t mode)
99
{
1010
uint8_t spi_mode = (uint8_t)mp_obj_get_int_truncated(mode);
1111
uint8_t polarity = (spi_mode >> 1) & 0x1;
12-
uint8_t phase = spi_mode & 0x01;
12+
uint8_t phase = spi_mode & 0x1;
1313
mp_obj_t tuple[2] = {
1414
mp_obj_new_int_from_uint(polarity),
1515
mp_obj_new_int_from_uint(phase),
@@ -24,6 +24,8 @@ static mp_obj_t spi_polarity_phase_to_mode(mp_obj_t polarity, mp_obj_t phase)
2424
{
2525
uint8_t spi_polarity = (uint8_t)mp_obj_get_int_truncated(polarity);
2626
uint8_t spi_phase = (uint8_t)mp_obj_get_int_truncated(phase);
27+
uint8_t spi_mode = ((spi_polarity & 0x1) << 1) | (spi_phase & 0x1);
28+
2729
return mp_obj_new_int_from_uint(spi_mode);
2830
}
2931

0 commit comments

Comments
 (0)