diff options
author | NIIBE Yutaka <gniibe@fsij.org> | 2014-08-04 13:38:42 +0900 |
---|---|---|
committer | NIIBE Yutaka <gniibe@fsij.org> | 2014-12-10 18:50:10 +0900 |
commit | aeb8bd5a95051d081edc2423207319f718ae0691 (patch) | |
tree | e6ae2b0e9b3a0846d2614e54e5441a208b656c47 /example-fsm-55/hacker-emblem.c | |
parent | 447b11fd1c1311a6c2619bc57b8b4b334c52fa4d (diff) |
l55 and hh only.
Diffstat (limited to 'example-fsm-55/hacker-emblem.c')
-rw-r--r-- | example-fsm-55/hacker-emblem.c | 124 |
1 files changed, 73 insertions, 51 deletions
diff --git a/example-fsm-55/hacker-emblem.c b/example-fsm-55/hacker-emblem.c index b209ff9..bc9594e 100644 --- a/example-fsm-55/hacker-emblem.c +++ b/example-fsm-55/hacker-emblem.c @@ -149,39 +149,6 @@ static uint32_t l55[] = { DATA55 (0x10, 0x0c, 0x18, 0x00, 0x00), }; -static uint32_t gnu[] = { - DATA55 (0x00, 0x00, 0x00, 0x00, 0x00), - DATA55 (0x00, 0x01, 0x01, 0x01, 0x00), - DATA55 (0x01, 0x02, 0x02, 0x02, 0x01), - DATA55 (0x03, 0x04, 0x04, 0x04, 0x03), - DATA55 (0x07, 0x08, 0x09, 0x08, 0x07), - DATA55 (0x0e, 0x10, 0x13, 0x11, 0x0e), - DATA55 (0x1c, 0x00, 0x06, 0x02, 0x1c), - DATA55 (0x19, 0x01, 0x0d, 0x05, 0x19), - DATA55 (0x12, 0x03, 0x1a, 0x0a, 0x12), - DATA55 (0x04, 0x06, 0x15, 0x14, 0x04), - DATA55 (0x08, 0x0c, 0x0a, 0x09, 0x08), - DATA55 (0x11, 0x19, 0x15, 0x13, 0x11), - DATA55 (0x02, 0x12, 0x0a, 0x06, 0x02), - DATA55 (0x05, 0x05, 0x15, 0x0d, 0x04), - DATA55 (0x0a, 0x0a, 0x0a, 0x1a, 0x09), - DATA55 (0x14, 0x14, 0x14, 0x14, 0x13), - DATA55 (0x08, 0x08, 0x08, 0x08, 0x07), - DATA55 (0x11, 0x11, 0x11, 0x11, 0x0e), - DATA55 (0x02, 0x02, 0x02, 0x02, 0x1c), - DATA55 (0x04, 0x04, 0x04, 0x04, 0x18), - DATA55 (0x08, 0x08, 0x08, 0x08, 0x10), - DATA55 (0x11, 0x11, 0x11, 0x10, 0x01), - DATA55 (0x03, 0x03, 0x03, 0x00, 0x02), - DATA55 (0x06, 0x06, 0x06, 0x00, 0x04), - DATA55 (0x0c, 0x0c, 0x0c, 0x00, 0x08), - DATA55 (0x18, 0x18, 0x18, 0x00, 0x10), - DATA55 (0x10, 0x10, 0x10, 0x00, 0x00), - DATA55 (0x00, 0x00, 0x00, 0x00, 0x00), - DATA55 (0x00, 0x00, 0x00, 0x00, 0x00), - DATA55 (0x00, 0x00, 0x00, 0x00, 0x00), -}; - #define DATA55V(x0,x1,x2,x3,x4) (x0<<0)|(x1<<5)|(x2<<10)|(x3<< 15)|(x4<< 20) #define CHAR_SPC 0 @@ -205,16 +172,16 @@ static uint8_t hh[] = { }; struct { uint8_t width; uint32_t data; } chargen[] = { - { 5, 0 }, /* SPACE */ - { 5, DATA55V (0x1f, 0x04, 0x04, 0x04, 0x1f) }, /* H */ - { 5, DATA55V (0x07, 0x0a, 0x12, 0x0a, 0x07) }, /* A */ - { 5, DATA55V (0x1f, 0x14, 0x14, 0x14, 0x18) }, /* P */ - { 5, DATA55V (0x18, 0x04, 0x07, 0x04, 0x18) }, /* Y */ - { 5, DATA55V (0x0e, 0x11, 0x11, 0x11, 0x02) }, /* C */ - { 5, DATA55V (0x1f, 0x04, 0x0c, 0x12, 0x01) }, /* K */ + { 3, 0 }, /* SPACE */ + { 4, DATA55V (0x1f, 0x04, 0x04, 0x1f, 0x00) }, /* H */ + { 4, DATA55V (0x02, 0x15, 0x15, 0x0f, 0x00) }, /* A */ + { 4, DATA55V (0x1f, 0x14, 0x14, 0x08, 0x00) }, /* P */ + { 4, DATA55V (0x19, 0x05, 0x05, 0x1e, 0x00) }, /* Y */ + { 4, DATA55V (0x0e, 0x11, 0x11, 0x0a, 0x00) }, /* C */ + { 4, DATA55V (0x1f, 0x04, 0x0c, 0x13, 0x00) }, /* K */ { 3, DATA55V (0x11, 0x1f, 0x11, 0x00, 0x00) }, /* I */ - { 5, DATA55V (0x1f, 0x08, 0x04, 0x02, 0x1f) }, /* N */ - { 5, DATA55V (0x0e, 0x11, 0x11, 0x15, 0x06) }, /* G */ + { 4, DATA55V (0x1f, 0x08, 0x06, 0x1f, 0x00) }, /* N */ + { 4, DATA55V (0x0e, 0x11, 0x15, 0x07, 0x00) }, /* G */ { 2, DATA55V (0x1d, 0x1c, 0x00, 0x00, 0x00) }, /* ! */ }; @@ -244,9 +211,14 @@ happy_hacking (void) } +#define REPEAT_COUNT 10 + +static void setup_scr_sleepdeep (void); + int main (int argc, const char *argv[]) { + uint8_t count = 0; (void)argc; (void)argv; @@ -264,6 +236,7 @@ main (int argc, const char *argv[]) while (1) { unsigned int i; + uint8_t state_prev = state; if (state == 0) for (i = 0; i < SIZE55 (l55); i++) @@ -273,17 +246,66 @@ main (int argc, const char *argv[]) set_led_display (l55[i]); wait_for (500*1000); } - else if (state == 1) - for (i = 0; i < SIZE55 (gnu); i++) - { - if (user_button ()) - state = 2; - set_led_display (gnu[i]); - wait_for (250*1000); - } - else + if (state == 1) happy_hacking (); + + if (state_prev != state) + count = 0; + else + if (++count > REPEAT_COUNT) + break; } + setup_scr_sleepdeep (); + for (;;) + asm volatile ("wfi" : : : "memory"); + return 0; } + +struct SCB +{ + volatile uint32_t CPUID; + volatile uint32_t ICSR; + volatile uint32_t VTOR; + volatile uint32_t AIRCR; + volatile uint32_t SCR; + volatile uint32_t CCR; + volatile uint8_t SHP[12]; + volatile uint32_t SHCSR; + volatile uint32_t CFSR; + volatile uint32_t HFSR; + volatile uint32_t DFSR; + volatile uint32_t MMFAR; + volatile uint32_t BFAR; + volatile uint32_t AFSR; + volatile uint32_t PFR[2]; + volatile uint32_t DFR; + volatile uint32_t ADR; + volatile uint32_t MMFR[4]; + volatile uint32_t ISAR[5]; +}; + +#define SCS_BASE (0xE000E000) +#define SCB_BASE (SCS_BASE + 0x0D00) +static struct SCB *const SCB = ((struct SCB *const) SCB_BASE); + +#define SCB_SCR_SLEEPDEEP (1 << 2) + +struct PWR +{ + volatile uint32_t CR; + volatile uint32_t CSR; +}; +#define PWR_CR_PDDS 0x0002 +#define PWR_CR_CWUF 0x0004 + +#define PWR_BASE (APBPERIPH_BASE + 0x00007000) +#define PWR ((struct PWR *) PWR_BASE) + +static void setup_scr_sleepdeep (void) +{ + PWR->CR |= PWR_CR_CWUF; + PWR->CR |= PWR_CR_PDDS; + SCB->SCR |= SCB_SCR_SLEEPDEEP; +} |