82 PROCESS(ir_process,
"IR receiver");
83 process_event_t ir_event_received;
85 #define SIR1 (P1OUT |= 0x01)
86 #define SIR0 (P1OUT &= 0xFE)
97 for(i = 0; i < 34; ++i) {
98 SIR1; SIR1; SIR1; SIR1;
99 SIR0; SIR0; SIR0; SIR0;
100 SIR0; SIR0; SIR0; SIR0;
111 for(i = 0; i < 34; ++i) {
112 SIR0; SIR0; SIR0; SIR0;
113 SIR0; SIR0; SIR0; SIR0;
114 SIR0; SIR0; SIR0; SIR0;
123 ir_send(
unsigned short data)
125 volatile unsigned short mask = 0x2000;
156 static void setErrorBit(
void);
157 static void clearErrorBit(
void);
158 static void setDataAvailableBit(
void);
159 static void clearDataAvailableBit(
void);
164 static unsigned int ir_pos;
165 static unsigned int recvdata;
166 static unsigned int recvdatabuffer;
167 static unsigned char ir_temp;
173 unsigned char recir_getCode(
void){
return (recvdata & 0x003F); }
174 unsigned char recir_getAddress(
void){
return ((recvdata & 0x07C0) >> 6); }
175 unsigned char recir_getToggle(
void){
return ((recvdata & 0x0800) >> 11); }
176 unsigned char recir_getError(
void){
return ((recvdata & 0x2000) >> 13); }
187 if(recvdata & 0x1000) {
188 clearDataAvailableBit();
198 static void setErrorBit(
void){ recvdata |= 0x2000; }
199 static void clearErrorBit(
void) { recvdata &= 0xDFFF; }
200 static void setDataAvailableBit(
void){ recvdata |= 0x1000; }
201 static void clearDataAvailableBit(
void){ recvdata &= 0xEFFF; }
205 interrupt(TIMERB1_VECTOR) Timer_B1 (
void) {
211 if(ir_temp && !(P1IN & 0x04)) {
213 recvdatabuffer = recvdatabuffer << 1;
214 }
else if(!ir_temp && (P1IN & 0x04)) {
215 recvdatabuffer = recvdatabuffer << 1;
221 recvdatabuffer = recvdatabuffer << 1;
224 ir_temp = P1IN & 0x04;
229 recvdatabuffer = recvdatabuffer >> 1;
231 if(!recir_getError() && ( (recvdatabuffer & 0x0FFF) != (recvdata & 0x0FFF) ) ){
232 recvdata = recvdatabuffer;
233 setDataAvailableBit();
269 if(P1IN & 0x04)
return;
276 TBCCR1 = TBR + BIT75;
293 TBCTL = TBSSEL1 + TBCLR;
304 if(ir_poll() == IR_DATA) {
305 unsigned short irdata;
306 irdata = ir_data() & 0x7ff;
307 process_post(PROCESS_BROADCAST, ir_event_received, (process_data_t)irdata);