7 #include "driver_console.h"
8 #include "driver_audio.h"
9 #include "driver_led.h"
11 #define H8_3069F_ISCR ((volatile uint8 *)0xFEE014)
12 #define H8_3069F_IER ((volatile uint8 *)0xFEE015)
13 #define H8_3069F_ISR ((volatile uint8 *)0xFEE016)
15 #define H8_3069F_TSTR ((volatile uint8 *)0xFFFF60)
16 #define H8_3069F_TISRC ((volatile uint8 *)0xFFFF66)
17 #define H8_3069F_16TCR0 ((volatile uint8 *)0xFFFF68)
18 #define H8_3069F_TIOR0 ((volatile uint8 *)0xFFFF69)
19 #define H8_3069F_16TCNT0H ((volatile uint8 *)0xFFFF6A)
20 #define H8_3069F_16TCNT0L ((volatile uint8 *)0xFFFF6B)
22 #define MAX_BIT_COUNT (64)
31 static uint16 bitcnt = 0;
32 static uint16 tmrovf = 0;
33 static uint8 data[MAX_BIT_COUNT / 8];
34 static ir_state_t irs = WaitLeader;
36 static void remocon_intr_edge(void)
40 *H8_3069F_16TCNT0H = 0;
41 *H8_3069F_16TCNT0L = 0;
42 *H8_3069F_TSTR |= (1 << 0);
48 *H8_3069F_16TCNT0H = 0;
49 *H8_3069F_16TCNT0L = 0;
53 if (bitcnt < MAX_BIT_COUNT) {
54 if ((bitcnt % 8) == 0) {
58 ((*H8_3069F_16TCNT0H) << 8) |
59 ((*H8_3069F_16TCNT0L) << 0);
60 if (tmrval > 0x1077) {
61 data[bitcnt / 8] |= (1 << (bitcnt % 8));
65 *H8_3069F_16TCNT0H = 0;
66 *H8_3069F_16TCNT0L = 0;
79 static void remocon_intr_tovf(void)
81 *H8_3069F_TISRC &= ~(1 << 0);
83 *H8_3069F_TSTR &= ~(1 << 0);
86 int task_ir(int argc, char *argv[])
88 kz_setintr(SOFTVEC_TYPE_IR_EDGE, remocon_intr_edge);
89 kz_setintr(SOFTVEC_TYPE_IR_TOVF, remocon_intr_tovf);
90 *H8_3069F_ISCR |= (1 << 4);
91 *H8_3069F_IER |= (1 << 4);
93 *H8_3069F_TISRC |= (1 << 4);
94 *H8_3069F_16TCR0 = 0x03;
101 for (i = 0; i < bitcnt; i++) {
102 if (data[i / 8] & (1 << (i % 8))) {