Skip to content

Commit e1995db

Browse files
committed
[NUC472/M453] Fix spi_master_transfer failed as bit width is 32
1 parent 1370533 commit e1995db

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

targets/TARGET_NUVOTON/TARGET_M451/spi_api.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,12 @@ static uint8_t spi_get_data_width(spi_t *obj)
709709
{
710710
SPI_T *spi_base = (SPI_T *) NU_MODBASE(obj->spi.spi);
711711

712-
return ((spi_base->CTL & SPI_CTL_DWIDTH_Msk) >> SPI_CTL_DWIDTH_Pos);
712+
uint32_t data_width = ((spi_base->CTL & SPI_CTL_DWIDTH_Msk) >> SPI_CTL_DWIDTH_Pos);
713+
if (data_width == 0) {
714+
data_width = 32;
715+
}
716+
717+
return data_width;
713718
}
714719

715720
static int spi_is_tx_complete(spi_t *obj)

targets/TARGET_NUVOTON/TARGET_NUC472/spi_api.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,12 @@ static uint8_t spi_get_data_width(spi_t *obj)
702702
{
703703
SPI_T *spi_base = (SPI_T *) NU_MODBASE(obj->spi.spi);
704704

705-
return ((spi_base->CTL & SPI_CTL_DWIDTH_Msk) >> SPI_CTL_DWIDTH_Pos);
705+
uint32_t data_width = ((spi_base->CTL & SPI_CTL_DWIDTH_Msk) >> SPI_CTL_DWIDTH_Pos);
706+
if (data_width == 0) {
707+
data_width = 32;
708+
}
709+
710+
return data_width;
706711
}
707712

708713
static int spi_is_tx_complete(spi_t *obj)

0 commit comments

Comments
 (0)