Changeset 112


Ignore:
Timestamp:
31/07/2014 17:58:50 (4 years ago)
Author:
pulkomandy
Message:

Move the ASCII keymap out of ps2_keyboard.c.

It is used only by the serial converter, so save some flashspace for other projects.

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • kbd/ps2toserial/code/main.c

    r103 r112  
    22
    33#include "../../../libs/ps2_keyboard/ps2_keyboard.h"
     4#include "../../../libs/ps2_keyboard/keymap.h"
    45#include "../../../libs/usart/usart.h"
     6
     7
     8char 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
    514
    615int main() {
  • libs/ps2_keyboard/keymap.h

    r1 r112  
     1
     2#include <avr/pgmspace.h>
     3
     4// TODO move to a .c file.
    15const char keymap[128] PROGMEM = {
    26//   0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
  • libs/ps2_keyboard/ps2_keyboard.c

    r100 r112  
    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.
    54
    65// Parts borrowed from :
     
    87// for NerdKits with ATmega168
    98// hevans@nerdkits.com
    10 //
    11 // Designed for use with the USB NerdKit running with ATMega168. Datasheet page
    12 // numbers refer to ATMega168 datasheet.
    13 
    14 #define F_CPU 16000000UL
    159
    1610#include <avr/io.h>
    1711#include <avr/interrupt.h>
    18 #include <avr/pgmspace.h>
    19 #include <util/delay.h>
    20 
    21 #include "keymap.h"
    2212
    2313
     
    2919
    3020//PIN configuration
     21#define PS2_PORT PIND
    3122#define PS2_CLK PD3 /* Also INT1 */
    32 #define PS2_PORT PIND
    3323#define PS2_DATA PD4
    3424
     
    3727static uint8_t started;
    3828static uint8_t bit_count;
    39 static uint8_t shift;
    4029static uint8_t caps_lock;
    4130static uint8_t extended;
     31
     32uint8_t shift;
    4233uint8_t release;
    4334
     
    10394
    10495
    105 char render_scan_code(uint8_t data){
    106   char to_ret = pgm_read_byte(&(keymap[data])); //grab character from array
    107   if(shift) to_ret -= 0x20;
    108   return to_ret;
    109 }
    110 
    111 
    11296uint8_t read_char(){
    11397  while(!char_waiting);
     
    127111  PS2_PORT |= (1<<PS2_CLK);
    128112
    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);
    130116  MCUCR |= (1<<ISC11); // Falling edge
    131117  MCUCR &= ~(1<<ISC10);
    132118#ifdef __AVR_ATmega48P__
    133119  EIMSK |= (1<<INT1);
    134 #else
     120#else // ATmega8
    135121  GIMSK |= (1<<INT1);
    136122#endif
  • libs/ps2_keyboard/ps2_keyboard.h

    r93 r112  
    99        // Convert a keycode to a printable ASCII char
    1010
     11extern uint8_t shift;
    1112extern uint8_t release;
Note: See TracChangeset for help on using the changeset viewer.