Changeset 8e1fb41 in avrstuff


Ignore:
Timestamp:
Jul 23, 2014, 7:31:42 PM (10 years ago)
Author:
Adrien Destugues <pulkomandy@…>
Branches:
main
Children:
4fbae10
Parents:
9e3cc04
Message:

Start modifying PCW code for XT.

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

Location:
kbd/xtk/code
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kbd/xtk/code/Makefile

    r9e3cc04 r8e1fb41  
    11CC := $(shell { which avr-gcc || which avr-gcc-x86; } 2>/dev/null)
    22OBJCOPY := $(shell { which avr-objcopy || which avr-objcopy-x86; } 2>/dev/null)
     3AVRDUDE := $(shell { which avrdude || which avrdude-x86; } 2>/dev/null)
    34
    45keyboard.hex: keyboard.bin
    5         $(OBJCOPY) -j .text -j .data -O ihex keyboard.bin keyboard.hex
     6        $(OBJCOPY) -j .text -j .data -O ihex $^ $@
    67
    78keyboard.bin: keyboard.o main.o
    8         $(CC) keyboard.o main.o -o keyboard.bin -mmcu=atmega8 -Os
     9        $(CC) $^ -o $@ -mmcu=atmega8 -Os
    910
    10 main.o: main.c ../../libs/usart/usart.h ../../libs/ps2_keyboard/ps2_keyboard.h
    11         $(CC) -std=c99 -c main.c -mmcu=atmega8 -Os -o main.o -mmcu=atmega8 -Os
     11main.o: main.c ../../../libs/ps2_keyboard/ps2_keyboard.h
     12        $(CC) -std=c99 -c $< -mmcu=atmega8 -Os -o $@ -mmcu=atmega8 -Os
    1213
    13 keyboard.o: ../../libs/ps2_keyboard/ps2_keyboard.c ../../libs/ps2_keyboard/ps2_keyboard.h ../../libs/ps2_keyboard/keymap.h
    14         $(CC) -DCALLBACK="callback();" -c ../../libs/ps2_keyboard/ps2_keyboard.c -mmcu=atmega8 -Os -o keyboard.o
     14keyboard.o: ../../../libs/ps2_keyboard/ps2_keyboard.c ../../../libs/ps2_keyboard/ps2_keyboard.h ../../../libs/ps2_keyboard/keymap.h
     15        $(CC) -DCALLBACK="callback();" -c $< -mmcu=atmega8 -Os -o $@
     16
     17flash: keyboard.hex
     18        $(AVRDUDE) -c usbasp -p atmega8 -Uflash:w:$^
  • kbd/xtk/code/keyboard.hex

    r9e3cc04 r8e1fb41  
    1818:100110003F15243F3F3F01A60716051482A513276C
    1919:1001200006A3A204103F11241FBECFE5D4E0DEBF1A
    20 :10013000CDBF10E0A0E6B0E001C01D92A637B10728
    21 :10014000E1F7BFD024C15CCF1F920F920FB60F9280
     20:10013000CDBF10E0A0E6B0E001C01D92A736B10728
     21:10014000E1F7A5D0E3C05CCF1F920F920FB60F92DC
    2222:1001500011242F933F934F935F936F937F938F93CC
    23 :100160009F93AF93BF93EF93FF9382B390E489275C
    24 :1001700082BB83994EC080916200811108C084992E
    25 :1001800026C081E0809362001092610027C0209118
    26 :100190006100283090F4849B0CC03091640081E0B1
    27 :1001A00090E0022E01C0880F0A94EAF7382B3093B2
    28 :1001B00064002F5F209361002CC0283021F489E077
    29 :1001C0008093610026C010926200109261008091BD
    30 :1001D0006400803F31F481E08093650010926400F8
    31 :1001E00018C09091640080916500923149F48111AA
    32 :1001F00004C081E0809360000CC01092600002C0D7
    33 :10020000882319F01092650004C081E08093630098
    34 :1002100037D0FF91EF91BF91AF919F918F917F91D7
    35 :100220006F915F914F913F912F910F900FBE0F9063
    36 :100230001F901895E82FF0E0EA5DFF4F84919091B0
    37 :100240006000911180520895809163008823E1F34A
    38 :1002500010926300809164000895109262001092E1
    39 :100260006400109261008B98839A85B7886085BF7F
    40 :1002700085B78B7F85BF8BB780688BBF78940895D7
    41 :10028000E3DFE82FF0E0EA55FF4FE491809165004D
    42 :10029000AE2FA295AF70EF70B0E0AA59BF4F21E02A
    43 :1002A00030E00E2E01C0220F0A94EAF7882329F0CD
    44 :1002B00020958C9128232C9308958C91822B8C93DC
    45 :1002C0000895CBDF18BA86E087BB8E9A8FEF9FEF39
    46 :1002D00064E068BB20E22A95F1F718BA40E24A953B
    47 :1002E000F1F768BBE0E2EA95F1F718BAF0E2FA95A7
    48 :1002F000F1F724E030E021503109C0F0AC01022ECA
    49 :1003000002C0559547950A94E2F740FF02C068BBCA
    50 :1003100001C018BA40E24A95F1F7C19AE0E4EA95C3
    51 :10032000F1F718BAF0E7FA95F1F7E5CFE7EDF0E06D
    52 :100330003197F1F700C0000028E030E0FC01EF70D9
    53 :10034000FF27EA59FF4F21503109C8F0408150E0A2
    54 :10035000022E02C0559547950A94E2F740FF02C06D
    55 :1003600068BB01C018BA40E24A95F1F7C19A40E46F
    56 :100370004A95F1F718BA40E74A95F1F7E4CF0196AC
    57 :10038000803191050CF4A5CF8FEF9FEFA2CFF894A9
    58 :02039000FFCF9D
     23:100160009F93AF93BF93EF93FF9383994EC080917A
     24:100170006200811108C0849926C081E080936200EA
     25:100180001092610027C020916100283090F4849B78
     26:100190000CC03091640081E090E0022E01C0880F15
     27:1001A0000A94EAF7382B309364002F5F20936100A4
     28:1001B0002CC0283021F489E08093610026C0109281
     29:1001C00062001092610080916400803F31F481E010
     30:1001D000809366001092640018C090916400809132
     31:1001E0006600923149F4811104C081E0809360007F
     32:1001F0000CC01092600002C0882319F010926600B3
     33:1002000004C081E08093630037D0FF91EF91BF91EC
     34:10021000AF919F918F917F916F915F914F913F919E
     35:100220002F910F900FBE0F901F901895E82FF0E0C0
     36:10023000EA5DFF4F84919091600091118052089582
     37:10024000809163008823E1F3109263008091640041
     38:1002500008951092620010926400109261008B98D1
     39:10026000839A85B7886085BF85B78B7F85BF8BB73D
     40:1002700080688BBF78940895E3DF109265008091C9
     41:100280006600882319F080E88093650008958FEF59
     42:1002900080936500DEDF18BA17BA8E9A20E43FEF2C
     43:1002A00082B3822782BB809165008F3F09F4FFCF24
     44:1002B000CF5F30936500B99A4AE74A95F1F700C0DD
     45:1002C000BA9880E38A95F1F788E090E0B998E7E082
     46:1002D000F1E03197F1F700C00000B99AFAE7FA951A
     47:1002E000F1F700C0C0FF02C0BA9801C0BA9A40E35B
     48:1002F0004A95F1F7C6950197009741F7B99887E0BD
     49:1003000091E00197F1F700C00000CACFF894FFCF49
    5950:00000001FF
  • kbd/xtk/code/main.c

    r9e3cc04 r8e1fb41  
    55#include <util/delay.h>
    66
    7 #include "../../libs/ps2_keyboard/ps2_keyboard.h"
     7#include "../../../libs/ps2_keyboard/ps2_keyboard.h"
    88
    9 uint8_t keys[16];
     9static uint8_t key;
    1010
    1111const uint8_t pcw[128] PROGMEM = {
     
    2525{
    2626        uint8_t key_code = 0;
    27         key_code = read_char(); // TODO this is blocking function
     27        key_code = read_char(); // TODO this function is blocking. Can it disturb main?
    2828
    29         uint8_t decode = pgm_read_byte(&(pcw[key_code]));
     29        key = 0 /*pgm_read_byte(&(pcw[key_code]))*/;
    3030        if(release)
    31                 keys[decode >> 4] &= ~(1 << (decode & 0xF));
    32         else
    33                 keys[decode >> 4] |= 1 << (decode & 0xF);
     31                key |= 0x80;
    3432}
    3533
    3634
    3735int main() {
    38   init_keyboard();
     36        key = 0xFF;
     37        init_keyboard(); // PS/2 KBD handler
    3938
    40   // PCW init - configure pins directions
    41   PORTB = 0;
    42   DDRB = 0x6; // PB1 and PB2 as outputs
     39        // PCW init - configure pins directions
     40        PORTB = 0;
     41        DDRB = 0; // PB2 and PB1 as inputs (floating)
    4342
    44   //debug LED - output
    45   DDRD |= (1<<PD6);
     43        //debug LED - output
     44        DDRD |= (1<<PD6);
    4645
     46        static const int PCLK = 2;
     47        static const int PDAT = 4;
    4748
    48   while(1) {
    49         for(int idx = -1; idx < 16; idx++)
    50         {
    51                 // send data to PCW
    52                
    53                 // Start pulse
    54                 PORTB = 4;
    55                 _delay_us(6);
    56                 PORTB = 0;
    57                 _delay_us(6);
    58                 PORTB = 4;
    59                 _delay_us(6);
    60                 PORTB = 0;
    61                 _delay_us(6);
     49        uint8_t k;
     50        while(1) {
     51#if 0
     52                while ((PINB & 2) == 0)
     53                        ; // Wait for PC to be ready to receive data
     54#endif
    6255
    63                 // Address
    64                 for(int j = 4; --j >= 0;)
     56PORTD ^= (1<<PD6);
     57                while(key == 0xFF)
     58                        ; // Wait for data to send
     59
     60                k = k+1; /*key;*/ // local copy so we can receive another code from PS/2
     61                // before we're done sending this one.
     62                key = 0xFF;
     63
     64                // SEND START BIT
     65                DDRB |= PCLK; // CLK LOW
     66                _delay_us(23);
     67                DDRB &= ~PDAT; // DAT HI
     68                _delay_us(9);
     69
     70                for(int i = 0; i < 8; i++)
    6571                {
    66                         if(idx & (1<<j))
    67                                 PORTB = 4;
     72                        DDRB &= ~PCLK; // CLK HI
     73                        _delay_us(66);
     74                        DDRB |= PCLK; // CLK LOW
     75                        _delay_us(23);
     76                        if (k & 1)
     77                                DDRB &= ~PDAT;
    6878                        else
    69                                 PORTB = 0;
     79                                DDRB |= PDAT;
    7080
    71                         // Clock
    72                         _delay_us(6);
    73                         PORTB |= 2;
    74                         _delay_us(12);
    75                         PORTB = 0;
    76                         _delay_us(21);
     81                        _delay_us(9);
     82
     83                        k >>= 1;
    7784                }
    7885
    79                 // One "empty" clock cycle
    80                 _delay_us(21 + 33);
     86                DDRB &= ~PCLK; // CLK HI
     87                _delay_us(66);
    8188
    82                 // Data
    83                 for(int j = 8; --j >= 0;)
    84                 {
    85                         if (keys[idx & 0xF] & (1 << j))
    86                                 PORTB = 4;
    87                         else
    88                                 PORTB = 0;
     89        }
    8990
    90                         // Clock
    91                         _delay_us(6);
    92                         PORTB |= 2;
    93                         _delay_us(12);
    94                         PORTB = 0;
    95                         _delay_us(21);
    96                 }
    97         }
    98   }
    99  
    100   return 0;
     91        return 0;
    10192}
    10293
Note: See TracChangeset for help on using the changeset viewer.