49 lines
810 B
C
Executable File
49 lines
810 B
C
Executable File
#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(uint8_t *value) {
|
|
int i;
|
|
*value = P7->IN;
|
|
}
|
|
|
|
void ir_read_off() {
|
|
P5->OUT &= ~0x08;
|
|
P9->OUT &= ~0x04;
|
|
}
|
|
|
|
void test_ir(void) {
|
|
uint8_t ir_value;
|
|
|
|
while (1) {
|
|
ir_ready_ready();
|
|
ir_read_value(&ir_value);
|
|
print_binary(ir_value);
|
|
printf("\n");
|
|
ir_read_off();
|
|
}
|
|
}
|