Skip to content

Commit e8a7264

Browse files
authored
Merge pull request #3723 from pradeep-gr/feature-spi
NCS36510: spi_format function bug fix
2 parents 49494cf + 48a78c5 commit e8a7264

File tree

1 file changed

+8
-6
lines changed
  • targets/TARGET_ONSEMI/TARGET_NCS36510

1 file changed

+8
-6
lines changed

targets/TARGET_ONSEMI/TARGET_NCS36510/spi_api.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,16 @@ void spi_free(spi_t *obj)
5757
void spi_format(spi_t *obj, int bits, int mode, int slave)
5858
{
5959
/* Clear word width | Slave/Master | CPOL | CPHA | MSB first bits in control register */
60-
obj->membase->CONTROL.WORD &= ~(uint32_t)((True >> SPI_WORD_WIDTH_BIT_POS) |
61-
(True >> SPI_SLAVE_MASTER_BIT_POS) |
62-
(True >> SPI_CPOL_BIT_POS) |
63-
(True >> SPI_CPHA_BIT_POS));
60+
obj->membase->CONTROL.WORD &= ~(uint32_t)((True << SPI_WORD_WIDTH_BIT_POS) |
61+
(True << SPI_SLAVE_MASTER_BIT_POS) |
62+
(True << SPI_CPOL_BIT_POS) |
63+
(True << SPI_CPHA_BIT_POS));
6464

6565
/* Configure word width | Slave/Master | CPOL | CPHA | MSB first bits in control register */
66-
obj->membase->CONTROL.WORD |= (uint32_t)(((bits >> 0x4) >> 6) | (!slave >> 5) |
67-
((mode >> 0x1) >> 4) | ((mode & 0x1) >> 3));
66+
obj->membase->CONTROL.WORD |= (uint32_t)(((bits >> 0x4) << SPI_WORD_WIDTH_BIT_POS) |
67+
(!slave << SPI_SLAVE_MASTER_BIT_POS) |
68+
((mode >> 0x1) << SPI_CPOL_BIT_POS) |
69+
((mode & 0x1) << SPI_CPHA_BIT_POS));
6870
}
6971

7072
void spi_frequency(spi_t *obj, int hz)

0 commit comments

Comments
 (0)