Changeset c7cc629 in avrstuff


Ignore:
Timestamp:
Jul 31, 2014, 5:58:50 PM (10 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
ea32107
Parents:
d31c2f5
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.

git-svn-id: svn://pulkomandy.tk/avrstuff@112 c6672c3c-f6b6-47f9-9001-1fd6b12fecbe

Files:
4 edited

Legend:

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

    rd31c2f5 rc7cc629  
    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

    rd31c2f5 rc7cc629  
     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

    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.
    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

    rd31c2f5 rc7cc629  
    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.