40 lines
698 B
C
40 lines
698 B
C
#include "ir.h"
|
|
|
|
#include "Clock.h"
|
|
|
|
void ir_init(void) {
|
|
P5->SEL0 &= ~0x08;
|
|
P5->SEL1 &= ~0x08;
|
|
P5->DIR |= 0x08;
|
|
P5->OUT &= ~0x08;
|
|
P9->SEL0 &= ~0x04;
|
|
P9->SEL1 &= ~0x04;
|
|
P9->DIR |= 0x04;
|
|
P9->OUT &= ~0x04;
|
|
P7->SEL0 &= ~0xff;
|
|
P7->SEL1 &= ~0xff;
|
|
P7->DIR &= ~0xff;
|
|
}
|
|
|
|
void ir_read_ready() {
|
|
P5->OUT |= 0x08;
|
|
P9->OUT |= 0x04;
|
|
P7->DIR = 0xff;
|
|
Clock_Delay1us(10);
|
|
P7->DIR = 0x00;
|
|
Clock_Delay1us(1000);
|
|
}
|
|
|
|
void ir_read_value(char *value) {
|
|
int i;
|
|
uint8_t port_value = P7->IN;
|
|
for (i = 0; i < 8; i++) {
|
|
value[i] = !!(port_value & (0x01 << i));
|
|
}
|
|
}
|
|
|
|
void ir_read_off() {
|
|
P5->OUT &= ~0x08;
|
|
P9->OUT &= ~0x04;
|
|
}
|