3 #include "task_display.h"
9 #define H8_3069F_ISCR ((volatile uint8 *)0xFEE014)
10 #define H8_3069F_IER ((volatile uint8 *)0xFEE015)
11 #define H8_3069F_ISR ((volatile uint8 *)0xFEE016)
13 #define H8_3069F_TSTR ((volatile uint8 *)0xFFFF60)
14 #define H8_3069F_TISRC ((volatile uint8 *)0xFFFF66)
15 #define H8_3069F_16TCR0 ((volatile uint8 *)0xFFFF68)
16 #define H8_3069F_TIOR0 ((volatile uint8 *)0xFFFF69)
17 #define H8_3069F_16TCNT0H ((volatile uint8 *)0xFFFF6A)
18 #define H8_3069F_16TCNT0L ((volatile uint8 *)0xFFFF6B)
20 #define MAX_BIT_COUNT (64)
22 #define TCNT_COUNT_START() (*H8_3069F_TSTR |= (1 << 0))
23 #define TCNT_COUNT_STOP() (*H8_3069F_TSTR &= ~(1 << 0))
24 #define TCNT_COUNT_VALUE() (((*H8_3069F_16TCNT0H) << 8) | ((*H8_3069F_16TCNT0L) << 0))
25 #define TCNT_COUNT_RESET() \
27 *H8_3069F_16TCNT0H = 0; \
28 *H8_3069F_16TCNT0L = 0; \
31 #define TCR0_SETUP() (*H8_3069F_16TCR0 = 0x03)
32 #define TMRINT_ENABLE() (*H8_3069F_TISRC |= (1 << 4))
33 #define TMRINT_FLAG_CLEAR() (*H8_3069F_TISRC &= ~(1 << 0))
34 #define IRQ4_ENABLE() \
36 (*H8_3069F_ISCR |= (1 << 4)); \
37 (*H8_3069F_IER |= (1 << 4)); \
47 static uint16 bitcnt = 0;
48 static uint16 tmrovf = 0;
49 static uint8 data[MAX_BIT_COUNT / 8];
50 static ir_state_t irs = WaitLeader;
52 static void remocon_intr_edge(void)
66 if (bitcnt < MAX_BIT_COUNT) {
67 if ((bitcnt % 8) == 0) {
70 uint16 tmrval = TCNT_COUNT_VALUE();
71 if (tmrval > 0x1077) {
72 data[bitcnt / 8] |= (1 << (bitcnt % 8));
90 static void remocon_intr_tovf(void)
98 int task_input(int argc, char *argv[])
100 int nx = 40, ny = 12;
105 kz_setintr(SOFTVEC_TYPE_IR_EDGE, remocon_intr_edge);
106 kz_setintr(SOFTVEC_TYPE_IR_TOVF, remocon_intr_tovf);
115 display_draw_logo( 0, 0, 2);
116 display_draw_box(0, 0, 121, 31, 1);
117 display_draw_text(40, 4, "KOZOS EXPBRD #00");
118 display_draw_logo(nx, ny, 0);
120 uint16 prev = 0, curr = 0;
124 int dir = (int)(curr & 0xff) - (int)(prev & 0xff);
127 display_led_write(1, 0);
128 display_led_toggle(0);
135 display_led_write(0, 0);
136 display_led_toggle(1);
144 display_draw_box(nx + 20, ny, nx + 20, ny + 16, 0);
145 display_draw_logo(nx, ny, 0);
146 display_led_toggle(3);
153 for (i = 0; i < bitcnt; i++) {
154 if (data[i / 8] & (1 << (i % 8))) {
163 display_led_toggle(2);