git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@2290 35acf78f-673a-0410-8e92-d51de3d6d3f4

master
gdisirio 2010-10-25 17:02:24 +00:00
parent 19ca2c7515
commit 63b9ef1051
1 changed files with 17 additions and 3 deletions

View File

@ -21,6 +21,18 @@
#include "hal.h"
#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);
@ -40,17 +52,19 @@ static SPIConfig spicfg = {
*/
static WORKING_AREA(waThread1, 128);
static msg_t Thread1(void *arg) {
uint8_t digit = 0;
uint8_t i = 0;
(void)arg;
while (TRUE) {
spiSelect(&SPID1);
spiStartSend(&SPID1, 1, &digit);
digit++;
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;
}