Subversion Repositories group.electronics

Rev

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

Rev 75 Rev 76
Line 23... Line 23...
23
#define NULL    ((void *)0)
23
#define NULL    ((void *)0)
24
#endif
24
#endif
25
 
25
 
26
/* ------------------------------------------------------------------------- */
26
/* ------------------------------------------------------------------------- */
27
 
27
 
28
//static uchar    reportBuffer[6];    /* buffer for HID reports */
-
 
29
volatile int16_t  axis[3];
-
 
30
 
-
 
31
struct {
28
struct {
32
	union {
29
	union {
33
		int16_t axis[3];
30
		int16_t axis[3];
34
		struct {
31
		struct {
35
			int16_t axis0:16;
32
			int16_t axis0:16;
36
			int16_t axis1:16;
33
			int16_t axis1:16;
37
			int16_t axis2:16;
34
			int16_t axis2:16;
38
		};
35
		};
-
 
36
		uint8_t buttons;
-
 
37
		struct {
-
 
38
			int8_t b1:1;
-
 
39
			int8_t b2:2;
-
 
40
			int8_t reserved:6;
-
 
41
		};
39
	};
42
	};
40
} reportBuffer;
43
} reportBuffer;
41
 
44
 
42
 
45
 
43
volatile struct {
46
volatile struct {
Line 201... Line 204...
201
  PORTB         = 0B00000000;
204
  PORTB         = 0B00000000;
202
 
205
 
203
    usbInit();
206
    usbInit();
204
    sei();
207
    sei();
205
 
208
 
206
    axis[0] = 0;
209
    reportBuffer.axis0 = 0;
207
    axis[1] = 0;
210
    reportBuffer.axis1 = 0;
208
    axis[2] = 0;
211
    reportBuffer.axis2 = 0;
-
 
212
    reportBuffer.buttons = 0;
-
 
213
 
209
 
214
 
210
    reportBuffer.axis0 = axis[0];
-
 
211
    reportBuffer.axis1 = axis[1];
-
 
212
    reportBuffer.axis2 = axis[2];
-
 
213
 
215
 
214
 
216
 
215
    //reportBuffer[1] = 0xff;
-
 
216
 
217
 
217
    for(;;){    /* main event loop */
218
    for(;;){    /* main event loop */
218
        wdt_reset();
219
        wdt_reset();
219
        usbPoll();
220
        usbPoll();
220
 
221
 
221
        if(usbInterruptIsReady()){ 
222
        if(usbInterruptIsReady()){ 
222
            //usbSetInterrupt(reportBuffer, sizeof(reportBuffer));
-
 
223
		usbSendHidReport(&reportBuffer, sizeof(reportBuffer));
223
		usbSendHidReport(&reportBuffer, sizeof(reportBuffer));
224
        }
224
        }
225
    }
225
    }
226
    return 0;
226
    return 0;
227
}
227
}
Line 240... Line 240...
240
        // Check which pin caused the interrupt. If they both
240
        // Check which pin caused the interrupt. If they both
241
        //  equal 0, the pin that interrupted is the direction
241
        //  equal 0, the pin that interrupted is the direction
242
        if (rbi(pcInt[pcint].current, PCINT3) == 0
242
        if (rbi(pcInt[pcint].current, PCINT3) == 0
243
                && rbi(pcInt[pcint].current, PCINT4) == 0
243
                && rbi(pcInt[pcint].current, PCINT4) == 0
244
                && rbi(pcInt[pcint].mask, PCINT4) ) {
244
                && rbi(pcInt[pcint].mask, PCINT4) ) {
-
 
245
 
245
                        if (reportBuffer.axis2 < 32500)
246
                        if (reportBuffer.axis2 < 32500)
246
                                reportBuffer.axis2 += 200;
247
                                reportBuffer.axis2 += 200;
-
 
248
 
-
 
249
 
247
        } else if (rbi(pcInt[pcint].current, PCINT3) == 0
250
        } else if (rbi(pcInt[pcint].current, PCINT3) == 0
248
                && rbi(pcInt[pcint].current, PCINT4) == 0
251
                && rbi(pcInt[pcint].current, PCINT4) == 0
249
                && rbi(pcInt[pcint].mask, PCINT3) ) {
252
                && rbi(pcInt[pcint].mask, PCINT3) ) {
-
 
253
 
250
                        if (reportBuffer.axis2 > -32500)
254
                        if (reportBuffer.axis2 > -32500)
251
                                reportBuffer.axis2 -= 200;
255
                                reportBuffer.axis2 -= 200;
-
 
256
 
-
 
257
 
252
        }
258
        }
253
 
259
 
254
        // Clear the mask so we know we've delth with it
260
        // Clear the mask so we know we've delth with it
255
        pcInt[pcint].mask = 0;
261
        pcInt[pcint].mask = 0;
256
}
262
}