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_TSTR |= (1 << 0);
49 if (bitcnt < MAX_BIT_COUNT) {
50 if ((bitcnt % 8) == 0) {
54 ((*H8_3069F_16TCNT0H) << 8) |
55 ((*H8_3069F_16TCNT0L) << 0);
56 if (tmrval > 0x1077) {
57 data[bitcnt / 8] |= (1 << (bitcnt % 8));
66 *H8_3069F_TSTR &= ~(1 << 0);
71 *H8_3069F_16TCNT0H = 0;
72 *H8_3069F_16TCNT0L = 0;
75 static void remocon_intr_tovf(void)
77 *H8_3069F_TISRC &= ~(1 << 0);
79 *H8_3069F_TSTR &= ~(1 << 0);
82 int task_ir(int argc, char *argv[])
84 kz_setintr(SOFTVEC_TYPE_IR_EDGE, remocon_intr_edge);
85 kz_setintr(SOFTVEC_TYPE_IR_TOVF, remocon_intr_tovf);
86 *H8_3069F_ISCR |= (1 << 4);
87 *H8_3069F_IER |= (1 << 4);
89 *H8_3069F_TISRC |= (1 << 4);
90 *H8_3069F_16TCR0 = 0x03;
97 for (i = 0; i < bitcnt; i++) {
98 if (data[i / 8] & (1 << (i % 8))) {