Skip to content

Commit 571e890

Browse files
committed
[Nuvoton] Remove dead code with '#if 0' in SPI
1 parent 707de87 commit 571e890

File tree

4 files changed

+5
-57
lines changed

4 files changed

+5
-57
lines changed

targets/TARGET_NUVOTON/TARGET_M451/spi_api.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,8 @@ void spi_master_transfer(spi_t *obj, const void *tx, size_t tx_length, void *rx,
413413
* To fix it, we don't enable SPI TX/RX threshold interrupts but keep SPI vector handler set to be called
414414
* in PDMA TX/RX transfer done interrupt handlers (spi_dma_handler_tx/spi_dma_handler_rx).
415415
*/
416-
#if 0
417-
spi_enable_vector_interrupt(obj, handler, 1);
418-
#else
419416
NVIC_SetVector(modinit->irq_n, handler);
420-
#endif
417+
421418
/* Order to enable PDMA TX/RX functions
422419
*
423420
* H/W spec: In SPI Master mode with full duplex transfer, if both TX and RX PDMA functions are
@@ -428,17 +425,9 @@ void spi_master_transfer(spi_t *obj, const void *tx, size_t tx_length, void *rx,
428425
*
429426
* With the above conflicts, we enable PDMA TX/RX functions simultaneously.
430427
*/
431-
#if 0
432-
SPI_TRIGGER_RX_PDMA(((SPI_T *) NU_MODBASE(obj->spi.spi)));
433-
SPI_TRIGGER_TX_PDMA(((SPI_T *) NU_MODBASE(obj->spi.spi)));
434-
#else
435428
spi_base->PDMACTL |= (SPI_PDMACTL_TXPDMAEN_Msk | SPI_PDMACTL_RXPDMAEN_Msk);
436-
#endif
437429

438430
/* Don't enable SPI TX/RX threshold interrupts as commented above */
439-
#if 0
440-
spi_master_enable_interrupt(obj, 1);
441-
#endif
442431
}
443432
}
444433

targets/TARGET_NUVOTON/TARGET_M480/spi_api.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -426,11 +426,8 @@ void spi_master_transfer(spi_t *obj, const void *tx, size_t tx_length, void *rx,
426426
* To fix it, we don't enable SPI TX/RX threshold interrupts but keep SPI vector handler set to be called
427427
* in PDMA TX/RX transfer done interrupt handlers (spi_dma_handler_tx/spi_dma_handler_rx).
428428
*/
429-
#if 0
430-
spi_enable_vector_interrupt(obj, handler, 1);
431-
#else
432429
NVIC_SetVector(modinit->irq_n, handler);
433-
#endif
430+
434431
/* Order to enable PDMA TX/RX functions
435432
*
436433
* H/W spec: In SPI Master mode with full duplex transfer, if both TX and RX PDMA functions are
@@ -441,17 +438,9 @@ void spi_master_transfer(spi_t *obj, const void *tx, size_t tx_length, void *rx,
441438
*
442439
* With the above conflicts, we enable PDMA TX/RX functions simultaneously.
443440
*/
444-
#if 0
445-
SPI_TRIGGER_RX_PDMA(((SPI_T *) NU_MODBASE(obj->spi.spi)));
446-
SPI_TRIGGER_TX_PDMA(((SPI_T *) NU_MODBASE(obj->spi.spi)));
447-
#else
448441
spi_base->PDMACTL |= (SPI_PDMACTL_TXPDMAEN_Msk | SPI_PDMACTL_RXPDMAEN_Msk);
449-
#endif
450442

451443
/* Don't enable SPI TX/RX threshold interrupts as commented above */
452-
#if 0
453-
spi_master_enable_interrupt(obj, 1);
454-
#endif
455444
}
456445
}
457446

targets/TARGET_NUVOTON/TARGET_NANO100/spi_api.c

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,7 @@ void spi_init(spi_t *obj, PinName mosi, PinName miso, PinName sclk, PinName ssel
187187
* At initial time, asynchronous transfer is not on-going and so vector must
188188
* be cleared to zero for correct judgement. */
189189
/* NOTE: On NANO130, vector table is fixed in ROM and cannot be modified. */
190-
#if 0
191-
NVIC_SetVector(modinit->irq_n, 0);
192-
#else
193190
obj->spi.hdlr_async = 0;
194-
#endif
195191
#endif
196192

197193
// Mark this module to be inited.
@@ -479,12 +475,8 @@ void spi_master_transfer(spi_t *obj, const void *tx, size_t tx_length, void *rx,
479475
*
480476
* With the above conflicts, we enable PDMA TX/RX functions simultaneously.
481477
*/
482-
#if 0
483-
SPI_TRIGGER_RX_PDMA(((SPI_T *) NU_MODBASE(obj->spi.spi)));
484-
SPI_TRIGGER_TX_PDMA(((SPI_T *) NU_MODBASE(obj->spi.spi)));
485-
#else
486478
spi_base->DMA |= (SPI_DMA_TX_DMA_EN_Msk | SPI_DMA_RX_DMA_EN_Msk);
487-
#endif
479+
488480
PDMA_Trigger(obj->spi.dma_chn_id_rx);
489481
PDMA_Trigger(obj->spi.dma_chn_id_tx);
490482
}
@@ -558,13 +550,8 @@ uint8_t spi_active(spi_t *obj)
558550

559551
/* Vector will be cleared when asynchronous transfer is finished or aborted.
560552
Use it to judge if asynchronous transfer is on-going. */
561-
/* NOTE: On NANO130, vector table is fixed in ROM and cannot be modified. */
562-
#if 0
563-
uint32_t vec = NVIC_GetVector(modinit->irq_n);
564-
return vec ? 1 : 0;
565-
#else
553+
/* NOTE: On NANO130, vector table is fixed in ROM and cannot be modified. */
566554
return obj->spi.hdlr_async ? 1 : 0;
567-
#endif
568555
}
569556

570557
void SPI0_IRQHandler(void)
@@ -619,17 +606,11 @@ static void spi_enable_vector_interrupt(spi_t *obj, uint32_t handler, uint8_t en
619606
var->obj = obj;
620607
obj->spi.hdlr_async = handler;
621608
/* NOTE: On NANO130, vector table is fixed in ROM and cannot be modified. */
622-
#if 0
623-
NVIC_SetVector(modinit->irq_n, (uint32_t) var->vec);
624-
#endif
625609
NVIC_EnableIRQ(modinit->irq_n);
626610
}
627611
else {
628612
NVIC_DisableIRQ(modinit->irq_n);
629613
/* NOTE: On NANO130, vector table is fixed in ROM and cannot be modified. */
630-
#if 0
631-
NVIC_SetVector(modinit->irq_n, 0);
632-
#endif
633614
var->obj = NULL;
634615
obj->spi.hdlr_async = 0;
635616
}

targets/TARGET_NUVOTON/TARGET_NUC472/spi_api.c

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -416,11 +416,8 @@ void spi_master_transfer(spi_t *obj, const void *tx, size_t tx_length, void *rx,
416416
* To fix it, we don't enable SPI TX/RX threshold interrupts but keep SPI vector handler set to be called
417417
* in PDMA TX/RX transfer done interrupt handlers (spi_dma_handler_tx/spi_dma_handler_rx).
418418
*/
419-
#if 0
420-
spi_enable_vector_interrupt(obj, handler, 1);
421-
#else
422419
NVIC_SetVector(modinit->irq_n, handler);
423-
#endif
420+
424421
/* Order to enable PDMA TX/RX functions
425422
*
426423
* H/W spec: In SPI Master mode with full duplex transfer, if both TX and RX PDMA functions are
@@ -431,17 +428,9 @@ void spi_master_transfer(spi_t *obj, const void *tx, size_t tx_length, void *rx,
431428
*
432429
* With the above conflicts, we enable PDMA TX/RX functions simultaneously.
433430
*/
434-
#if 0
435-
SPI_TRIGGER_RX_PDMA(((SPI_T *) NU_MODBASE(obj->spi.spi)));
436-
SPI_TRIGGER_TX_PDMA(((SPI_T *) NU_MODBASE(obj->spi.spi)));
437-
#else
438431
spi_base->PDMACTL |= (SPI_PDMACTL_TXPDMAEN_Msk | SPI_PDMACTL_RXPDMAEN_Msk);
439-
#endif
440432

441433
/* Don't enable SPI TX/RX threshold interrupts as commented above */
442-
#if 0
443-
spi_master_enable_interrupt(obj, 1);
444-
#endif
445434
}
446435
}
447436

0 commit comments

Comments
 (0)