aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms/LPC13xx/spi_lld.c
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/platforms/LPC13xx/spi_lld.c')
-rw-r--r--os/hal/platforms/LPC13xx/spi_lld.c28
1 files changed, 20 insertions, 8 deletions
diff --git a/os/hal/platforms/LPC13xx/spi_lld.c b/os/hal/platforms/LPC13xx/spi_lld.c
index d7dd8f17f..1a98a7a15 100644
--- a/os/hal/platforms/LPC13xx/spi_lld.c
+++ b/os/hal/platforms/LPC13xx/spi_lld.c
@@ -59,10 +59,16 @@ static void ssp_fifo_preload(SPIDriver *spip) {
while(((ssp->SR & SR_TNF) != 0) && (n > 0)) {
if (spip->spd_txptr != NULL) {
- if ((ssp->CR0 & CR0_DSSMASK) > CR0_DSS8BIT)
- ssp->DR = *(uint16_t *)spip->spd_txptr++;
- else
- ssp->DR = *(uint8_t *)spip->spd_txptr++;
+ if ((ssp->CR0 & CR0_DSSMASK) > CR0_DSS8BIT) {
+ const uint16_t *p = spip->spd_txptr;
+ ssp->DR = *p++;
+ spip->spd_txptr = p;
+ }
+ else {
+ const uint8_t *p = spip->spd_txptr;
+ ssp->DR = *p++;
+ spip->spd_txptr = p;
+ }
}
else
ssp->DR = 0xFFFFFFFF;
@@ -87,10 +93,16 @@ static void spi_serve_interrupt(SPIDriver *spip) {
ssp->ICR = ICR_RT | ICR_ROR;
while ((ssp->SR & SR_RNE) != 0) {
if (spip->spd_rxptr != NULL) {
- if ((ssp->CR0 & CR0_DSSMASK) > CR0_DSS8BIT)
- *(uint16_t *)spip->spd_rxptr++ = ssp->DR;
- else
- *(uint8_t *)spip->spd_rxptr++ = ssp->DR;
+ if ((ssp->CR0 & CR0_DSSMASK) > CR0_DSS8BIT) {
+ uint16_t *p = spip->spd_rxptr;
+ *p++ = ssp->DR;
+ spip->spd_rxptr = p;
+ }
+ else {
+ uint8_t *p = spip->spd_rxptr;
+ *p++ = ssp->DR;
+ spip->spd_rxptr = p;
+ }
}
else
(void)ssp->DR;