Subversion Repositories group.electronics

Rev

Rev 91 | Rev 93 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 91 Rev 92
Line 30... Line 30...
30
	uint8_t buttons;
30
	uint8_t buttons;
31
	uint8_t waitup;
31
	uint8_t waitup;
32
	uint8_t timer;
32
	uint8_t timer;
33
} debounce;
33
} debounce;
34
 
34
 
-
 
35
volatile struct {
-
 
36
	uint8_t data;
-
 
37
	union {
-
 
38
		uint8_t led_method:1;
-
 
39
		uint8_t other:1;
-
 
40
		uint8_t reserved:6;
-
 
41
	};
-
 
42
} config;
-
 
43
 
35
uint8_t currleds = 1;
44
uint8_t currleds = 1;
36
static uchar    idleRate;           /* in 4 ms units */
45
static uchar    idleRate;           /* in 4 ms units */
37
volatile uint8_t tmr0_ovf = 0;
46
volatile uint8_t tmr0_ovf = 0;
38
volatile uint32_t systime = 0;
47
volatile uint32_t systime = 0;
39
 
48
 
Line 84... Line 93...
84
		case USBRQ_HID_SET_IDLE:
93
		case USBRQ_HID_SET_IDLE:
85
			idleRate = rq->wValue.bytes[1];
94
			idleRate = rq->wValue.bytes[1];
86
			return 0;
95
			return 0;
87
		case USB_GET_LED_STATE: // send data to PC
96
		case USB_GET_LED_STATE: // send data to PC
88
			usbMsgPtr = currleds;
97
			usbMsgPtr = currleds;
89
			//currleds = 1;
-
 
90
			return sizeof(currleds);
98
			return sizeof(currleds);
91
		case USB_SET_LED_STATE: // modify reply buffer
99
		case USB_SET_LED_STATE: // modify reply buffer
92
			currleds = rq->wValue.bytes[0];
100
			currleds = rq->wValue.bytes[0];
93
			return 0;
101
			return 0;
94
        }
102
        }
Line 166... Line 174...
166
 
174
 
167
    reportBuffer.axis[0] = 0xfffd;
175
    reportBuffer.axis[0] = 0xfffd;
168
    reportBuffer.axis[1] = 0xfffd;
176
    reportBuffer.axis[1] = 0xfffd;
169
    reportBuffer.buttons = 0x00;
177
    reportBuffer.buttons = 0x00;
170
 
178
 
-
 
179
	config.led_method = 1;
171
	setLeds(currleds);
180
	setLeds(currleds);
172
 
181
 
-
 
182
 
173
    for(;;){
183
    for(;;){
174
        wdt_reset();
184
        wdt_reset();
175
        usbPoll();
185
        usbPoll();
176
 
186
 
177
	uint8_t pressed = getKey();
187
	uint8_t pressed = getKey();
-
 
188
 
-
 
189
	if (config.led_method != rbi(PORTB, 5)) {
-
 
190
		config.led_method = rbi(PORTB, 5);
-
 
191
	}
-
 
192
 
-
 
193
	if (config.led_method == 1)
178
	//doButtons(pressed);	
194
		doButtons(pressed);
-
 
195
 
179
	setLeds(currleds);
196
	setLeds(currleds);
180
 
197
 
181
        if(usbInterruptIsReady()){ 
198
        if(usbInterruptIsReady()){ 
182
                reportBuffer.buttons = pressed;
199
                reportBuffer.buttons = pressed;
183
		usbSendHidReport(&reportBuffer, sizeof(reportBuffer));
200
		usbSendHidReport(&reportBuffer, sizeof(reportBuffer));
Line 233... Line 250...
233
                                        cbi(currleds,0);
250
                                        cbi(currleds,0);
234
 
251
 
235
                                sbi(currleds, i);
252
                                sbi(currleds, i);
236
                        }
253
                        }
237
                }
254
                }
238
                setLeds(currleds);
255
                //setLeds(currleds);
239
                debounce.waitup = 1;
256
                debounce.waitup = 1;
240
        }
257
        }
241
}
258
}
242
 
259
 
243
// Gnd = PC0, PC1
260
// Gnd = PC0, PC1
Line 277... Line 294...
277
                systime++;
294
                systime++;
278
                tmr0_ovf = 0;
295
                tmr0_ovf = 0;
279
 
296
 
280
		if (debounce.timer != 0)
297
		if (debounce.timer != 0)
281
			debounce.timer--;
298
			debounce.timer--;
-
 
299
 
282
        }
300
        }
283
}
301
}