aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/platforms/LPC13xx/spi_lld.c
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-05-20 09:16:12 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2012-05-20 09:16:12 +0000
commit31149b2ffb6b73f7d9c6f1e0c2e69c7f244e831d (patch)
treeb207dfb2b3b2e68cf48409d5e51898514303217f /os/hal/platforms/LPC13xx/spi_lld.c
parent9be1c67db2a0004db4458d0b5fa7fd31c1868a34 (diff)
downloadChibiOS-31149b2ffb6b73f7d9c6f1e0c2e69c7f244e831d.tar.gz
ChibiOS-31149b2ffb6b73f7d9c6f1e0c2e69c7f244e831d.tar.bz2
ChibiOS-31149b2ffb6b73f7d9c6f1e0c2e69c7f244e831d.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4220 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/platforms/LPC13xx/spi_lld.c')
-rw-r--r--os/hal/platforms/LPC13xx/spi_lld.c46
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
}
}