diff options
Diffstat (limited to 'os/hal/platforms/LPC13xx/spi_lld.c')
-rw-r--r-- | os/hal/platforms/LPC13xx/spi_lld.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/os/hal/platforms/LPC13xx/spi_lld.c b/os/hal/platforms/LPC13xx/spi_lld.c index c158fee2a..b6950ff39 100644 --- a/os/hal/platforms/LPC13xx/spi_lld.c +++ b/os/hal/platforms/LPC13xx/spi_lld.c @@ -40,6 +40,11 @@ SPIDriver SPID1;
#endif
+#if LPC13xx_SPI_USE_SSP1 || defined(__DOXYGEN__)
+/** @brief SPI2 driver identifier.*/
+SPIDriver SPID2;
+#endif
+
/*===========================================================================*/
/* Driver local variables. */
/*===========================================================================*/
@@ -143,6 +148,22 @@ CH_IRQ_HANDLER(VectorF4) { }
#endif
+#if LPC13xx_SPI_USE_SSP1 || defined(__DOXYGEN__)
+/**
+ * @brief SSP1 interrupt handler.
+ *
+ * @isr
+ */
+CH_IRQ_HANDLER(Vector124) {
+
+ CH_IRQ_PROLOGUE();
+
+ spi_serve_interrupt(&SPID2);
+
+ CH_IRQ_EPILOGUE();
+}
+#endif
+
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
@@ -168,6 +189,14 @@ void spi_lld_init(void) { LPC_IOCON->PIO0_8 = 0xC1; /* MISO0 without resistors. */
LPC_IOCON->PIO0_9 = 0xC1; /* MOSI0 without resistors. */
#endif /* LPC13xx_SPI_USE_SSP0 */
+
+#if LPC13xx_SPI_USE_SSP1
+ spiObjectInit(&SPID2);
+ SPID2.ssp = LPC_SSP1;
+ LPC_IOCON->PIO2_1 = 0xC2; /* SCK1 without resistors. */
+ LPC_IOCON->PIO2_2 = 0xC2; /* MISO1 without resistors. */
+ LPC_IOCON->PIO2_3 = 0xC2; /* MOSI1 without resistors. */
+#endif /* LPC13xx_SPI_USE_SSP0 */
}
/**
@@ -190,6 +219,15 @@ void spi_lld_start(SPIDriver *spip) { CORTEX_PRIORITY_MASK(LPC13xx_SPI_SSP0_IRQ_PRIORITY));
}
#endif
+#if LPC13xx_SPI_USE_SSP1
+ if (&SPID2 == spip) {
+ LPC_SYSCON->SSP1CLKDIV = LPC13xx_SPI_SSP1CLKDIV;
+ LPC_SYSCON->SYSAHBCLKCTRL |= (1 << 18);
+ LPC_SYSCON->PRESETCTRL |= 4;
+ nvicEnableVector(SSP1_IRQn,
+ CORTEX_PRIORITY_MASK(LPC13xx_SPI_SSP1_IRQ_PRIORITY));
+ }
+#endif
}
/* Configuration.*/
spip->ssp->CR1 = 0;
@@ -220,6 +258,14 @@ void spi_lld_stop(SPIDriver *spip) { nvicDisableVector(SSP0_IRQn);
}
#endif
+#if LPC13xx_SPI_USE_SSP1
+ if (&SPID2 == spip) {
+ LPC_SYSCON->PRESETCTRL &= ~4;
+ LPC_SYSCON->SYSAHBCLKCTRL &= ~(1 << 18);
+ LPC_SYSCON->SSP1CLKDIV = 0;
+ nvicDisableVector(SSP1_IRQn);
+ }
+#endif
}
}
|