Changeset bbcd1f8 in avrstuff
- Timestamp:
- Sep 7, 2019, 4:53:59 PM (5 years ago)
- Branches:
- main
- Children:
- 6f22754
- Parents:
- 38a6d09
- Location:
- grip2hid
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
grip2hid/Makefile
r38a6d09 rbbcd1f8 1 1 #Set vars 2 2 MCU=at90usb1287 3 COMPILE = avr-gcc -Wall - Os -Iusbdrv -I. -std=c99-mmcu=$(MCU) -DF_CPU=160000003 COMPILE = avr-gcc -Wall -Wextra -Werror -Os -Iusbdrv -I. -mmcu=$(MCU) -DF_CPU=16000000 4 4 PROJECT=grip2hid 5 5 … … 19 19 20 20 flash: $(PROJECT).hex 21 avrdude - c flip1 -p $(MCU) -Uflash:w:$^21 avrdude -u -c flip1 -p $(MCU) -Uflash:w:$^ 22 22 23 23 clean: -
grip2hid/main.cpp
r38a6d09 rbbcd1f8 43 43 private: 44 44 uint32_t word = 0; 45 uint 32_t count = 0;46 uint 32_t state = 0;45 uint8_t count = 0; 46 uint8_t state = 0; 47 47 }; 48 48 49 49 int main() { 50 50 wdt_enable(WDTO_2S); 51 // configure timer 0 for a rate of 16M/(256 * 256) = ~244Hz52 TCCR0A = 0; // timer 0 prescaler: 25653 TCCR0B = 4;54 51 55 52 // debug LEDs - output 56 53 DDRD |= 0xF0; 54 PORTD = 0; 57 55 58 56 // GrIP input 59 57 DDRB = 0; 58 uint8_t oldv = PINB; 60 59 61 PORTD = 0;62 60 GrIP pad; 63 61 … … 65 63 wdt_reset(); 66 64 67 // Wait for next bit 68 while(!(PINB & 2)); 69 while(PINB & 2); 65 uint8_t newv = PINB; 70 66 71 // Read bit 72 uint32_t bit = (PINB & 1) != 0; 73 pad.PushBit(bit); 67 if (!(newv & 2)) { // clock is down 68 if (oldv & 2) { // and it was up at previous read 69 // Read bit 70 uint32_t bit = (newv & 1) != 0; 71 pad.PushBit(bit); 72 } 73 } 74 oldv = newv; 74 75 } 75 76
Note:
See TracChangeset
for help on using the changeset viewer.