Subversion Repositories group.electronics

Rev

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

Rev 79 Rev 80
Line 164... Line 164...
164
    calibrationValue = eeprom_read_byte(0); /* calibration value from last time */
164
    calibrationValue = eeprom_read_byte(0); /* calibration value from last time */
165
    if(calibrationValue != 0xff){
165
    if(calibrationValue != 0xff){
166
        OSCCAL = calibrationValue;
166
        OSCCAL = calibrationValue;
167
    }
167
    }
168
 
168
 
-
 
169
  /*
-
 
170
  DDR : 1 = Output, 0 = Input
-
 
171
  PORT: 1 = Pullup for Input, otherwise set output
-
 
172
  PIN : Read input pin
-
 
173
  */
-
 
174
  /*
-
 
175
 
-
 
176
        PA0     - Output        - ButtonPad 1
-
 
177
        PA1     - Output        - ButtonPad 0
-
 
178
        PA2     - Output        - Reset
-
 
179
  */
-
 
180
  DDRD          = 0B00000000;
-
 
181
  PORTD         = 0B00000000;
-
 
182
  /*
-
 
183
        PB0     - Output                - LED 0
-
 
184
        PB1     - Output                - LED 1
-
 
185
        PB2     - Output                - LED 2
-
 
186
        PB3     - Output                - LED 3
-
 
187
        PB4     - Output                - LED 4
-
 
188
        PB5     - Output                - LED 5
-
 
189
        PB6     - Output                - LED 6
-
 
190
        PB7     - Output                - LED 7
-
 
191
  */
-
 
192
  DDRB          = 0B00000000;
-
 
193
  PORTB         = 0B00000000;
-
 
194
  /*
-
 
195
 
-
 
196
        PD0     - Output        - ButtonPad Gnd1
-
 
197
        PD1     - Output        - ButtonPad Gnd2
-
 
198
        PD2     - Output        - USB D+
-
 
199
        PD3     - Output        - USB D-
-
 
200
        PD4     - Output        - ButtonPad 2
-
 
201
        PD5     - Output        - ButtonPad 3
-
 
202
        PD6     - Output        - Select Switch
-
 
203
  */
-
 
204
  DDRD          = 0B01000000;
-
 
205
  PORTD         = 0B00000000;
-
 
206
 
-
 
207
 
169
    odDebugInit();
208
    odDebugInit();
170
    usbDeviceDisconnect();
209
    usbDeviceDisconnect();
171
    for(i=0;i<20;i++){  /* 300 ms disconnect */
210
    for(i=0;i<20;i++){  /* 300 ms disconnect */
172
        _delay_ms(15);
211
        _delay_ms(15);
173
    }
212
    }
Line 178... Line 217...
178
 
217
 
179
    TIMSK = (1<<TOIE0);                    // Enable timer overflow
218
    TIMSK = (1<<TOIE0);                    // Enable timer overflow
180
    TCNT0 = 0x00;                           // Set Timer0 initial value to 0
219
    TCNT0 = 0x00;                           // Set Timer0 initial value to 0
181
    TCCR0B = (1<< CS01) ;                   // /1 prescaler
220
    TCCR0B = (1<< CS01) ;                   // /1 prescaler
182
 
221
 
183
    DDRB          = 0B00000001;
-
 
184
    PORTB         = 0B00000000;
-
 
185
 
-
 
186
    usbInit();
222
    usbInit();
187
    sei();
223
    sei();
188
 
224
 
189
    reportBuffer.axis0 = 0;
225
    reportBuffer.axis0 = 0;
190
    reportBuffer.axis1 = 0;
226
    reportBuffer.axis1 = 0;
191
    reportBuffer.buttons = 0;
227
    reportBuffer.buttons = 0;
192
 
228
 
-
 
229
	PORTB = 0xaa;
-
 
230
 
193
    for(;;){    /* main event loop */
231
    for(;;){    /* main event loop */
194
        wdt_reset();
232
        wdt_reset();
195
        usbPoll();
233
        usbPoll();
196
 
234
 
-
 
235
	
-
 
236
 
197
        if(usbInterruptIsReady()){ 
237
        if(usbInterruptIsReady()){ 
198
 
238
 
199
		// ReportBuffer logic here
239
		// ReportBuffer logic here
200
 
240
 
201
		usbSendHidReport(&reportBuffer, sizeof(reportBuffer));
241
		usbSendHidReport(&reportBuffer, sizeof(reportBuffer));
Line 219... Line 259...
219
 
259
 
220
        // Clear the mask so we know we've delth with it
260
        // Clear the mask so we know we've delth with it
221
        pcInt[pcint].mask = 0;
261
        pcInt[pcint].mask = 0;
222
}
262
}
223
 
263
 
224
ISR(PCINT0_vect) {
264
ISR(PCINT_vect) {
225
        pcInterrupt(0);
265
        pcInterrupt(0);
226
}
266
}
227
 
267
 
228
ISR(TIMER0_OVF_vect) {
268
ISR(TIMER0_OVF_vect) {
229
        tmr0_ovf++;
269
        tmr0_ovf++;