aboutsummaryrefslogtreecommitdiffstats
path: root/demos/ARMCM3-LPC1343-GCC
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-10-28 18:39:40 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2010-10-28 18:39:40 +0000
commit3ea83706512a5051a185ac8ec4ba0094290a217d (patch)
treef252f07fed2ccf821729d9ec595695b90fb58f65 /demos/ARMCM3-LPC1343-GCC
parent29a259ba43607142487a0bceb8adf31d76286770 (diff)
downloadChibiOS-3ea83706512a5051a185ac8ec4ba0094290a217d.tar.gz
ChibiOS-3ea83706512a5051a185ac8ec4ba0094290a217d.tar.bz2
ChibiOS-3ea83706512a5051a185ac8ec4ba0094290a217d.zip
LPC13xx SPI driver.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2300 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'demos/ARMCM3-LPC1343-GCC')
-rw-r--r--demos/ARMCM3-LPC1343-GCC/halconf.h2
-rw-r--r--demos/ARMCM3-LPC1343-GCC/main.c37
2 files changed, 36 insertions, 3 deletions
diff --git a/demos/ARMCM3-LPC1343-GCC/halconf.h b/demos/ARMCM3-LPC1343-GCC/halconf.h
index 87d0f835d..2c3afda84 100644
--- a/demos/ARMCM3-LPC1343-GCC/halconf.h
+++ b/demos/ARMCM3-LPC1343-GCC/halconf.h
@@ -130,7 +130,7 @@
* @brief Enables the SPI subsystem.
*/
#if !defined(CH_HAL_USE_SPI) || defined(__DOXYGEN__)
-#define CH_HAL_USE_SPI FALSE
+#define CH_HAL_USE_SPI TRUE
#endif
/*
diff --git a/demos/ARMCM3-LPC1343-GCC/main.c b/demos/ARMCM3-LPC1343-GCC/main.c
index 45496acfc..092cecdbb 100644
--- a/demos/ARMCM3-LPC1343-GCC/main.c
+++ b/demos/ARMCM3-LPC1343-GCC/main.c
@@ -22,17 +22,49 @@
#include "test.h"
/*
+ * Conversion table from hex digit to 7 segments encoding, bit 5 controls the
+ * dot.
+ * 8 = LU, 4 = RL, 2 = D, 1 = RU, 8 = U, 4 = M, 2 = LL, 1 = L.
+ */
+static uint8_t digits[32] = {
+ 0x24, 0xAF, 0xE0, 0xA2, 0x2B, 0x32, 0x30, 0xA7,
+ 0x20, 0x22, 0x21, 0x38, 0x74, 0xA8, 0x70, 0x71,
+ 0x04, 0x8F, 0xC0, 0x82, 0x0B, 0x12, 0x10, 0x87,
+ 0x00, 0x02, 0x01, 0x18, 0x54, 0x88, 0x50, 0x51
+};
+
+static void endsend(SPIDriver *spip) {
+
+ spiUnselect(spip);
+}
+
+/* Maximum speed SPI configuration (1MHz, CPHA=0, CPOL=0).*/
+static SPIConfig spicfg = {
+ endsend,
+ GPIO1,
+ GPIO1_SPI0SEL,
+ CR0_DSS8BIT | CR0_FRFSPI | CR0_CLOCKRATE(0),
+ 72
+};
+
+/*
* Red LED blinker thread, times are in milliseconds.
*/
static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
+ uint8_t i = 0;
(void)arg;
while (TRUE) {
+ spiSelect(&SPID1);
+ spiStartSend(&SPID1, 1, &digits[i]);
palClearPad(GPIO0, GPIO0_LED2);
chThdSleepMilliseconds(500);
+ spiSelect(&SPID1);
+ spiStartSend(&SPID1, 1, &digits[i | 0x10]);
palSetPad(GPIO0, GPIO0_LED2);
chThdSleepMilliseconds(500);
+ i = (i + 1) & 15;
}
return 0;
}
@@ -78,9 +110,10 @@ int main(int argc, char **argv) {
(void)argv;
/*
- * Activates the serial driver 1 using the driver default configuration.
+ * Activates the SD1 and SPI1 drivers.
*/
- sdStart(&SD1, NULL);
+ sdStart(&SD1, NULL); /* Default: 38400,8,N,1. */
+ spiStart(&SPID1, &spicfg);
/*
* Creates the blinker threads.