altos/lpc: Allow for alternate SPI SCLK0 pin usage
authorKeith Packard <keithp@keithp.com>
Mon, 20 May 2013 03:25:13 +0000 (20:25 -0700)
committerKeith Packard <keithp@keithp.com>
Mon, 20 May 2013 03:39:19 +0000 (20:39 -0700)
SPI SCLK0 can appear on three different pins; let the application
configure which one it wants.

Signed-off-by: Keith Packard <keithp@keithp.com>
src/easymini-v0.1/ao_pins.h
src/lpc/ao_spi_lpc.c
src/lpc/lpc.h

index 5bcd4673c9d5c0f1954473c099a2fa6d08026c3e..2307d7d2c580badeb541d65467456e9734b984af 100644 (file)
@@ -53,6 +53,7 @@
 /* SPI */
 
 #define HAS_SPI_0              1
+#define SPI_SCK0_P0_6          1
 #define HAS_SPI_1              1
 #define SPI_SCK1_P1_15         1
 #define SPI_MISO1_P0_22                1
index 7c830053d90557def4e3a104c89b397b1cea6355..12d448723cdb81cb722c64ea06df140622ada329 100644 (file)
@@ -125,7 +125,21 @@ ao_spi_init(void)
 {
 #if HAS_SPI_0
        /* Configure pins */
-       lpc_ioconf.pio0_6 = ao_lpc_alternate(LPC_IOCONF_FUNC_SCK0);
+#if SPI_SCK0_P0_6
+       lpc_ioconf.pio0_6 = ao_lpc_alternate(LPC_IOCONF_FUNC_PIO0_6_SCK0);
+#define HAS_SCK0
+#endif
+#if SPI_SCK0_P0_10
+       lpc_ioconf.pio0_10 = ao_lpc_alternate(LPC_IOCONF_FUNC_PIO0_10_SCK0);
+#define HAS_SCK0
+#endif
+#if SPI_SCK0_P1_29
+       lpc_ioconf.pio1_29 = ao_lpc_alternate(LPC_IOCONF_FUNC_PIO1_29_SCK0);
+#define HAS_SCK0
+#endif
+#ifndef HAS_SCK0
+#error "No pin specified for SCK0"
+#endif
        lpc_ioconf.pio0_8 = ao_lpc_alternate(LPC_IOCONF_FUNC_MISO0);
        lpc_ioconf.pio0_9 = ao_lpc_alternate(LPC_IOCONF_FUNC_MOSI0);
 
index 1b48fcc9f493186e3791839236a2fd3f1bb8fcf2..49034c1c564e71107ff5586c5acdbe74fb3c621c 100644 (file)
@@ -131,7 +131,7 @@ extern struct lpc_ioconf lpc_ioconf;
 /* PIO0_6 */
 #define  LPC_IOCONF_FUNC_PIO0_6                0
 #define  LPC_IOCONF_FUNC_USB_CONNECT   1
-#define  LPC_IOCONF_FUNC_SCK0          2
+#define  LPC_IOCONF_FUNC_PIO0_6_SCK0   2
 
 /* PIO0_7 */
 #define  LPC_IOCONF_FUNC_PIO0_7                0
@@ -150,7 +150,7 @@ extern struct lpc_ioconf lpc_ioconf;
 /* PIO0_10 */
 #define  LPC_IOCONF_FUNC_SWCLK         0
 #define  LPC_IOCONF_FUNC_PIO0_10       1
-#define  LPC_IOCONF_FUNC_SCK0          2
+#define  LPC_IOCONF_FUNC_PIO0_10_SCK0  2
 #define  LPC_IOCONF_FUNC_CT16B0_MAT2   3
 
 /* PIO0_11 */