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)
65 if (bitcnt < MAX_BIT_COUNT) {
66 if ((bitcnt % 8) == 0) {
69 uint16 tmrval = TCNT_COUNT_VALUE();
70 if (tmrval > 0x1077) {
71 data[bitcnt / 8] |= (1 << (bitcnt % 8));
87 static void remocon_intr_tovf(void)
95 int task_input(int argc, char *argv[])
102 kz_setintr(SOFTVEC_TYPE_IR_EDGE, remocon_intr_edge);
103 kz_setintr(SOFTVEC_TYPE_IR_TOVF, remocon_intr_tovf);
108 uint16 prev = 0, curr = 0;
111 *
\e$B%m!<%?%j!<%(%s%3!<%@F~NO=hM}
\e(B
115 int dir = (int)(curr & 0xff) - (int)(prev & 0xff);
118 display_led_write(1, 0);
119 display_led_toggle(0);
126 display_led_write(0, 0);
127 display_led_toggle(1);
135 display_draw_box(nx + 20, ny, nx + 20, ny + 16, 0);
136 display_draw_logo(nx, ny, 0);
137 display_led_toggle(3);
141 *
\e$B%j%b%3%sF~NO=hM}
\e(B
150 display_led_toggle(2);
157 *
\e$B%9%$%C%AF~NO=hM}
\e(B