Changeset c7cc629 in avrstuff
- Timestamp:
- Jul 31, 2014, 5:58:50 PM (10 years ago)
- Branches:
- main
- Children:
- ea32107
- Parents:
- d31c2f5
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
kbd/ps2toserial/code/main.c
rd31c2f5 rc7cc629 2 2 3 3 #include "../../../libs/ps2_keyboard/ps2_keyboard.h" 4 #include "../../../libs/ps2_keyboard/keymap.h" 4 5 #include "../../../libs/usart/usart.h" 6 7 8 char render_scan_code(uint8_t data){ 9 char to_ret = pgm_read_byte(&(keymap[data])); //grab character from array 10 if(shift) to_ret -= 0x20; 11 return to_ret; 12 } 13 5 14 6 15 int main() { -
libs/ps2_keyboard/keymap.h
rd31c2f5 rc7cc629 1 2 #include <avr/pgmspace.h> 3 4 // TODO move to a .c file. 1 5 const char keymap[128] PROGMEM = { 2 6 // 0 1 2 3 4 5 6 7 8 9 A B C D E F -
libs/ps2_keyboard/ps2_keyboard.c
rd31c2f5 rc7cc629 1 // keyboard.c 2 // ps/2 keyboard decoder on ATMega8 3 // copyright 2010, Adrien Destugues <pulkomandy@pulkomandy.ath.cx> 4 // MIT Licence 1 // ps/2 keyboard decoder on ATMega8, ATMega48 2 // Copyright 2010-2014, Adrien Destugues <pulkomandy@pulkomandy.tk> 3 // This file is distributed under the terms of the MIT Licence. 5 4 6 5 // Parts borrowed from : … … 8 7 // for NerdKits with ATmega168 9 8 // hevans@nerdkits.com 10 //11 // Designed for use with the USB NerdKit running with ATMega168. Datasheet page12 // numbers refer to ATMega168 datasheet.13 14 #define F_CPU 16000000UL15 9 16 10 #include <avr/io.h> 17 11 #include <avr/interrupt.h> 18 #include <avr/pgmspace.h>19 #include <util/delay.h>20 21 #include "keymap.h"22 12 23 13 … … 29 19 30 20 //PIN configuration 21 #define PS2_PORT PIND 31 22 #define PS2_CLK PD3 /* Also INT1 */ 32 #define PS2_PORT PIND33 23 #define PS2_DATA PD4 34 24 … … 37 27 static uint8_t started; 38 28 static uint8_t bit_count; 39 static uint8_t shift;40 29 static uint8_t caps_lock; 41 30 static uint8_t extended; 31 32 uint8_t shift; 42 33 uint8_t release; 43 34 … … 103 94 104 95 105 char render_scan_code(uint8_t data){106 char to_ret = pgm_read_byte(&(keymap[data])); //grab character from array107 if(shift) to_ret -= 0x20;108 return to_ret;109 }110 111 112 96 uint8_t read_char(){ 113 97 while(!char_waiting); … … 127 111 PS2_PORT |= (1<<PS2_CLK); 128 112 129 // PCMSK |= (1<<PIND3); 113 // FIXME we can use the "pin change" interrupt rather than INT0/INT1 when not 114 // on the old clumsy ATMega8. This would allow for any pin to be used. 115 // PCMSK |= (1<<PIND3); 130 116 MCUCR |= (1<<ISC11); // Falling edge 131 117 MCUCR &= ~(1<<ISC10); 132 118 #ifdef __AVR_ATmega48P__ 133 119 EIMSK |= (1<<INT1); 134 #else 120 #else // ATmega8 135 121 GIMSK |= (1<<INT1); 136 122 #endif -
libs/ps2_keyboard/ps2_keyboard.h
rd31c2f5 rc7cc629 9 9 // Convert a keycode to a printable ASCII char 10 10 11 extern uint8_t shift; 11 12 extern uint8_t release;
Note:
See TracChangeset
for help on using the changeset viewer.