From 32e3f51bc0f4248019379fe784d38c7fb770f952 Mon Sep 17 00:00:00 2001 From: hackbard Date: Sun, 4 Oct 2009 22:37:30 +0200 Subject: [PATCH] basic implementation done ... --- led_plex/convert_font.c | 60 ++++++++++ led_plex/fonts.asm | 256 ++++++++++++++++++++++++++++++++++++++++ led_plex/main.asm | 197 +++++++++++++++++++++++++++++-- led_plex/port.asm | 118 ++++++++++++++++-- led_plex/timer.asm | 21 ++++ 5 files changed, 637 insertions(+), 15 deletions(-) create mode 100644 led_plex/convert_font.c create mode 100644 led_plex/fonts.asm diff --git a/led_plex/convert_font.c b/led_plex/convert_font.c new file mode 100644 index 0000000..33f7897 --- /dev/null +++ b/led_plex/convert_font.c @@ -0,0 +1,60 @@ +/* + * convert_font.c - convert linux console 8x8 font data + * + * author: hackbard@hackdaworld.org + * + * usage: + * + * first you have to adjust this file two times (see comments!) + * + * build: gcc -Wall -o convert_font convert_font.c -I/usr/src/linux/include + * + * ./convert_font > fonts.asm + * + * ONLY 8x8 FONTS SUPPORTED! + * + */ + +#define _GNU_SOURCE +#include +#include +#include +#include +#include + +typedef unsigned int u32; + +// put your font data here! +#include "/usr/src/linux/drivers/video/console/font_pearl_8x8.c" + +int main(int argc,char **argv) { + + unsigned char *font_data; + int font,col,row; + + // adjust the font data pointer here! + font_data=(unsigned char *)fontdata_pearl8x8; + + for(font=0;font<=0x7f;font++) { + + /* print the font number */ + printf("; %d 0x%02x",font,font); + if((font>0x1f)&(font<0x7f)) + printf(" %c\n",font); + else + printf("\n"); + printf(".db "); + + /* print the array content of the font */ + for(col=0;col<8;col++) { + printf("0b"); + for(row=0;row<8;row++) + printf("%c",((font_data[font*8+row]>>(7-col))&1)?'1':'0'); + if(col!=7) printf(", "); + else printf("\n"); + + } + } + + return 0; +} diff --git a/led_plex/fonts.asm b/led_plex/fonts.asm new file mode 100644 index 0000000..3826896 --- /dev/null +++ b/led_plex/fonts.asm @@ -0,0 +1,256 @@ +; 0 0x00 +.db 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000 +; 1 0x01 +.db 0b01111110, 0b10000001, 0b10101001, 0b10001101, 0b10001101, 0b10101001, 0b10000001, 0b01111110 +; 2 0x02 +.db 0b01111110, 0b11111111, 0b11010111, 0b11110011, 0b11110011, 0b11010111, 0b11111111, 0b01111110 +; 3 0x03 +.db 0b01110000, 0b11111000, 0b11111100, 0b01111110, 0b11111100, 0b11111000, 0b01110000, 0b00000000 +; 4 0x04 +.db 0b00010000, 0b00111000, 0b01111100, 0b11111110, 0b01111100, 0b00111000, 0b00010000, 0b00000000 +; 5 0x05 +.db 0b00011100, 0b01011100, 0b11111001, 0b11111111, 0b11111001, 0b01011100, 0b00011100, 0b00000000 +; 6 0x06 +.db 0b00011000, 0b00111100, 0b01111101, 0b11111111, 0b01111101, 0b00111100, 0b00011000, 0b00000000 +; 7 0x07 +.db 0b00000000, 0b00000000, 0b00011000, 0b00111100, 0b00111100, 0b00011000, 0b00000000, 0b00000000 +; 8 0x08 +.db 0b11111111, 0b11111111, 0b11100111, 0b11000011, 0b11000011, 0b11100111, 0b11111111, 0b11111111 +; 9 0x09 +.db 0b00000000, 0b00111100, 0b01100110, 0b01000010, 0b01000010, 0b01100110, 0b00111100, 0b00000000 +; 10 0x0a +.db 0b11111111, 0b11000011, 0b10011001, 0b10111101, 0b10111101, 0b10011001, 0b11000011, 0b11111111 +; 11 0x0b +.db 0b00001110, 0b00011111, 0b00010001, 0b00010001, 0b10111111, 0b11111110, 0b11100000, 0b11110000 +; 12 0x0c +.db 0b00000000, 0b01110010, 0b11111010, 0b10001111, 0b10001111, 0b11111010, 0b01110010, 0b00000000 +; 13 0x0d +.db 0b00000011, 0b00000111, 0b11111111, 0b11111110, 0b10100000, 0b10100000, 0b11100000, 0b11100000 +; 14 0x0e +.db 0b00000011, 0b11111111, 0b11111110, 0b10100000, 0b10100000, 0b10100110, 0b11111110, 0b11111100 +; 15 0x0f +.db 0b01011010, 0b01011010, 0b00111100, 0b11100111, 0b11100111, 0b00111100, 0b01011010, 0b01011010 +; 16 0x10 +.db 0b11111110, 0b01111100, 0b01111100, 0b00111000, 0b00111000, 0b00010000, 0b00010000, 0b00000000 +; 17 0x11 +.db 0b00010000, 0b00010000, 0b00111000, 0b00111000, 0b01111100, 0b01111100, 0b11111110, 0b00000000 +; 18 0x12 +.db 0b00000000, 0b00100100, 0b01100110, 0b11111111, 0b11111111, 0b01100110, 0b00100100, 0b00000000 +; 19 0x13 +.db 0b00000000, 0b11111010, 0b11111010, 0b00000000, 0b00000000, 0b11111010, 0b11111010, 0b00000000 +; 20 0x14 +.db 0b01100000, 0b11110000, 0b10010000, 0b11111110, 0b11111110, 0b10000000, 0b11111110, 0b11111110 +; 21 0x15 +.db 0b00000010, 0b01011001, 0b11111101, 0b10100101, 0b10100101, 0b10111111, 0b10011010, 0b01000000 +; 22 0x16 +.db 0b00000000, 0b00001110, 0b00001110, 0b00001110, 0b00001110, 0b00001110, 0b00001110, 0b00000000 +; 23 0x17 +.db 0b00000001, 0b00101001, 0b01101101, 0b11111111, 0b11111111, 0b01101101, 0b00101001, 0b00000001 +; 24 0x18 +.db 0b00000000, 0b00100000, 0b01100000, 0b11111110, 0b11111110, 0b01100000, 0b00100000, 0b00000000 +; 25 0x19 +.db 0b00000000, 0b00001000, 0b00001100, 0b11111110, 0b11111110, 0b00001100, 0b00001000, 0b00000000 +; 26 0x1a +.db 0b00010000, 0b00010000, 0b00010000, 0b01010100, 0b01111100, 0b00111000, 0b00010000, 0b00000000 +; 27 0x1b +.db 0b00010000, 0b00111000, 0b01111100, 0b01010100, 0b00010000, 0b00010000, 0b00010000, 0b00000000 +; 28 0x1c +.db 0b00111100, 0b00111100, 0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00000100, 0b00000000 +; 29 0x1d +.db 0b00010000, 0b00111000, 0b01111100, 0b00010000, 0b00010000, 0b01111100, 0b00111000, 0b00010000 +; 30 0x1e +.db 0b00001100, 0b00011100, 0b00111100, 0b01111100, 0b01111100, 0b00111100, 0b00011100, 0b00001100 +; 31 0x1f +.db 0b01100000, 0b01110000, 0b01111000, 0b01111100, 0b01111100, 0b01111000, 0b01110000, 0b01100000 +; 32 0x20 +.db 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000, 0b00000000 +; 33 0x21 ! +.db 0b00000000, 0b00000000, 0b01110000, 0b11111010, 0b11111010, 0b01110000, 0b00000000, 0b00000000 +; 34 0x22 " +.db 0b00000000, 0b11000000, 0b11000000, 0b00000000, 0b11000000, 0b11000000, 0b00000000, 0b00000000 +; 35 0x23 # +.db 0b00101000, 0b11111110, 0b11111110, 0b00101000, 0b11111110, 0b11111110, 0b00101000, 0b00000000 +; 36 0x24 $ +.db 0b00000000, 0b00100100, 0b01110100, 0b11010110, 0b11010110, 0b01011100, 0b01001000, 0b00000000 +; 37 0x25 % +.db 0b01100010, 0b01100110, 0b00001100, 0b00011000, 0b00110000, 0b01100110, 0b01000110, 0b00000000 +; 38 0x26 & +.db 0b00001100, 0b01111110, 0b11110010, 0b10011010, 0b11101100, 0b01011110, 0b00010010, 0b00000000 +; 39 0x27 ' +.db 0b00000000, 0b00000000, 0b00100000, 0b11100000, 0b11000000, 0b00000000, 0b00000000, 0b00000000 +; 40 0x28 ( +.db 0b00000000, 0b00000000, 0b00111000, 0b01111100, 0b11000110, 0b10000010, 0b00000000, 0b00000000 +; 41 0x29 ) +.db 0b00000000, 0b00000000, 0b10000010, 0b11000110, 0b01111100, 0b00111000, 0b00000000, 0b00000000 +; 42 0x2a * +.db 0b00010000, 0b01010100, 0b01111100, 0b00111000, 0b00111000, 0b01111100, 0b01010100, 0b00010000 +; 43 0x2b + +.db 0b00000000, 0b00010000, 0b00010000, 0b01111100, 0b01111100, 0b00010000, 0b00010000, 0b00000000 +; 44 0x2c , +.db 0b00000000, 0b00000000, 0b00000001, 0b00000111, 0b00000110, 0b00000000, 0b00000000, 0b00000000 +; 45 0x2d - +.db 0b00000000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00010000, 0b00000000 +; 46 0x2e . +.db 0b00000000, 0b00000000, 0b00000000, 0b00000110, 0b00000110, 0b00000000, 0b00000000, 0b00000000 +; 47 0x2f / +.db 0b00000010, 0b00000110, 0b00001100, 0b00011000, 0b00110000, 0b01100000, 0b11000000, 0b10000000 +; 48 0x30 0 +.db 0b01111100, 0b11111110, 0b10011010, 0b10111010, 0b10110010, 0b11111110, 0b01111100, 0b00000000 +; 49 0x31 1 +.db 0b00000000, 0b01000000, 0b01000000, 0b11111110, 0b11111110, 0b00000000, 0b00000000, 0b00000000 +; 50 0x32 2 +.db 0b01000010, 0b11000110, 0b10001110, 0b10011010, 0b10110010, 0b11100010, 0b01000010, 0b00000000 +; 51 0x33 3 +.db 0b01000100, 0b11000110, 0b10000010, 0b10010010, 0b10010010, 0b11111110, 0b01101100, 0b00000000 +; 52 0x34 4 +.db 0b00011000, 0b00111000, 0b01101000, 0b11001000, 0b11111110, 0b11111110, 0b00001000, 0b00000000 +; 53 0x35 5 +.db 0b11100100, 0b11100110, 0b10100010, 0b10100010, 0b10100010, 0b10111110, 0b10011100, 0b00000000 +; 54 0x36 6 +.db 0b00111100, 0b01111110, 0b11010010, 0b10010010, 0b10010010, 0b00011110, 0b00001100, 0b00000000 +; 55 0x37 7 +.db 0b10000000, 0b10000110, 0b10001110, 0b10011000, 0b10110000, 0b11100000, 0b11000000, 0b00000000 +; 56 0x38 8 +.db 0b01101100, 0b11111110, 0b10010010, 0b10010010, 0b10010010, 0b11111110, 0b01101100, 0b00000000 +; 57 0x39 9 +.db 0b01100000, 0b11110000, 0b10010010, 0b10010010, 0b10010110, 0b11111100, 0b01111000, 0b00000000 +; 58 0x3a : +.db 0b00000000, 0b00000000, 0b00000000, 0b01100110, 0b01100110, 0b00000000, 0b00000000, 0b00000000 +; 59 0x3b ; +.db 0b00000000, 0b00000000, 0b00000001, 0b01100111, 0b01100110, 0b00000000, 0b00000000, 0b00000000 +; 60 0x3c < +.db 0b00000000, 0b00010000, 0b00111000, 0b01101100, 0b11000110, 0b10000010, 0b00000000, 0b00000000 +; 61 0x3d = +.db 0b00000000, 0b00100100, 0b00100100, 0b00100100, 0b00100100, 0b00100100, 0b00100100, 0b00000000 +; 62 0x3e > +.db 0b00000000, 0b00000000, 0b10000010, 0b11000110, 0b01101100, 0b00111000, 0b00010000, 0b00000000 +; 63 0x3f ? +.db 0b00000000, 0b01000000, 0b11000000, 0b10001010, 0b10011010, 0b11110000, 0b01100000, 0b00000000 +; 64 0x40 @ +.db 0b01111100, 0b11111110, 0b10000010, 0b10111010, 0b10111010, 0b11111010, 0b01111000, 0b00000000 +; 65 0x41 A +.db 0b00011110, 0b00111110, 0b01101000, 0b11001000, 0b01101000, 0b00111110, 0b00011110, 0b00000000 +; 66 0x42 B +.db 0b11111110, 0b11111110, 0b10010010, 0b10010010, 0b10010010, 0b11111110, 0b01101100, 0b00000000 +; 67 0x43 C +.db 0b01111100, 0b11111110, 0b10000010, 0b10000010, 0b10000010, 0b11000110, 0b01000100, 0b00000000 +; 68 0x44 D +.db 0b11111110, 0b11111110, 0b10000010, 0b10000010, 0b10000010, 0b11111110, 0b01111100, 0b00000000 +; 69 0x45 E +.db 0b11111110, 0b11111110, 0b10010010, 0b10010010, 0b10010010, 0b10000010, 0b10000010, 0b00000000 +; 70 0x46 F +.db 0b11111110, 0b11111110, 0b10010000, 0b10010000, 0b10010000, 0b10000000, 0b10000000, 0b00000000 +; 71 0x47 G +.db 0b01111100, 0b11111110, 0b10000010, 0b10000010, 0b10010010, 0b11011110, 0b01011100, 0b00000000 +; 72 0x48 H +.db 0b11111110, 0b11111110, 0b00010000, 0b00010000, 0b00010000, 0b11111110, 0b11111110, 0b00000000 +; 73 0x49 I +.db 0b00000000, 0b10000010, 0b10000010, 0b11111110, 0b11111110, 0b10000010, 0b10000010, 0b00000000 +; 74 0x4a J +.db 0b00001100, 0b00001110, 0b00000010, 0b00000010, 0b00000010, 0b11111110, 0b11111100, 0b00000000 +; 75 0x4b K +.db 0b11111110, 0b11111110, 0b00010000, 0b00111000, 0b01101100, 0b11000110, 0b10000010, 0b00000000 +; 76 0x4c L +.db 0b11111110, 0b11111110, 0b00000010, 0b00000010, 0b00000010, 0b00000010, 0b00000010, 0b00000000 +; 77 0x4d M +.db 0b11111110, 0b01111110, 0b00110000, 0b00011000, 0b00110000, 0b01111110, 0b11111110, 0b00000000 +; 78 0x4e N +.db 0b11111110, 0b11111110, 0b01100000, 0b00110000, 0b00011000, 0b11111110, 0b11111110, 0b00000000 +; 79 0x4f O +.db 0b01111100, 0b11111110, 0b10000010, 0b10000010, 0b10000010, 0b11111110, 0b01111100, 0b00000000 +; 80 0x50 P +.db 0b11111110, 0b11111110, 0b10010000, 0b10010000, 0b10010000, 0b11110000, 0b01100000, 0b00000000 +; 81 0x51 Q +.db 0b01111100, 0b11111110, 0b10001010, 0b10001110, 0b10000110, 0b11111111, 0b01111101, 0b00000000 +; 82 0x52 R +.db 0b11111110, 0b11111110, 0b10010000, 0b10011000, 0b10011100, 0b11110110, 0b01100010, 0b00000000 +; 83 0x53 S +.db 0b01000100, 0b11100110, 0b10110010, 0b10010010, 0b10011010, 0b11001110, 0b01000100, 0b00000000 +; 84 0x54 T +.db 0b00000000, 0b10000000, 0b10000000, 0b11111110, 0b11111110, 0b10000000, 0b10000000, 0b00000000 +; 85 0x55 U +.db 0b11111100, 0b11111110, 0b00000010, 0b00000010, 0b00000010, 0b11111110, 0b11111100, 0b00000000 +; 86 0x56 V +.db 0b11000000, 0b11110000, 0b00111100, 0b00001110, 0b00001110, 0b00111100, 0b11110000, 0b11000000 +; 87 0x57 W +.db 0b11111110, 0b11111110, 0b00001100, 0b00011000, 0b00001100, 0b11111110, 0b11111110, 0b00000000 +; 88 0x58 X +.db 0b10000010, 0b11000110, 0b01101100, 0b00111000, 0b00111000, 0b01101100, 0b11000110, 0b10000010 +; 89 0x59 Y +.db 0b11000000, 0b11100000, 0b00110000, 0b00011110, 0b00011110, 0b00110000, 0b11100000, 0b11000000 +; 90 0x5a Z +.db 0b10000010, 0b10000110, 0b10001110, 0b10011010, 0b10110010, 0b11100010, 0b11000010, 0b00000000 +; 91 0x5b [ +.db 0b00000000, 0b00000000, 0b11111110, 0b11111110, 0b10000010, 0b10000010, 0b00000000, 0b00000000 +; 92 0x5c \ +.db 0b10000000, 0b11000000, 0b01100000, 0b00110000, 0b00011000, 0b00001100, 0b00000110, 0b00000010 +; 93 0x5d ] +.db 0b00000000, 0b00000000, 0b10000010, 0b10000010, 0b11111110, 0b11111110, 0b00000000, 0b00000000 +; 94 0x5e ^ +.db 0b00010000, 0b00110000, 0b01100000, 0b11000000, 0b01100000, 0b00110000, 0b00010000, 0b00000000 +; 95 0x5f _ +.db 0b00000001, 0b00000001, 0b00000001, 0b00000001, 0b00000001, 0b00000001, 0b00000001, 0b00000000 +; 96 0x60 ` +.db 0b00000000, 0b00000000, 0b00000000, 0b11000000, 0b11100000, 0b00100000, 0b00000000, 0b00000000 +; 97 0x61 a +.db 0b00000100, 0b00101110, 0b00101010, 0b00101010, 0b00101010, 0b00111110, 0b00011110, 0b00000000 +; 98 0x62 b +.db 0b11111110, 0b11111110, 0b00100010, 0b00100010, 0b00100010, 0b00111110, 0b00011100, 0b00000000 +; 99 0x63 c +.db 0b00011100, 0b00111110, 0b00100010, 0b00100010, 0b00100010, 0b00110110, 0b00010100, 0b00000000 +; 100 0x64 d +.db 0b00011100, 0b00111110, 0b00100010, 0b00100010, 0b00100010, 0b11111110, 0b11111110, 0b00000000 +; 101 0x65 e +.db 0b00011100, 0b00111110, 0b00101010, 0b00101010, 0b00101010, 0b00111010, 0b00011000, 0b00000000 +; 102 0x66 f +.db 0b00010000, 0b01111110, 0b11111110, 0b10010000, 0b10000000, 0b11000000, 0b01000000, 0b00000000 +; 103 0x67 g +.db 0b00011000, 0b00111101, 0b00100101, 0b00100101, 0b00100101, 0b00111111, 0b00111110, 0b00000000 +; 104 0x68 h +.db 0b11111110, 0b11111110, 0b00100000, 0b00100000, 0b00100000, 0b00111110, 0b00011110, 0b00000000 +; 105 0x69 i +.db 0b00000000, 0b00000000, 0b00100000, 0b10111110, 0b10111110, 0b00000000, 0b00000000, 0b00000000 +; 106 0x6a j +.db 0b00000010, 0b00000011, 0b00000001, 0b00000001, 0b00000001, 0b10111111, 0b10111110, 0b00000000 +; 107 0x6b k +.db 0b11111110, 0b11111110, 0b00001000, 0b00011100, 0b00110110, 0b00100010, 0b00000000, 0b00000000 +; 108 0x6c l +.db 0b00000000, 0b00000000, 0b10000000, 0b11111110, 0b11111110, 0b00000000, 0b00000000, 0b00000000 +; 109 0x6d m +.db 0b00111110, 0b00111110, 0b00110000, 0b00011000, 0b00110000, 0b00111110, 0b00011110, 0b00000000 +; 110 0x6e n +.db 0b00111110, 0b00111110, 0b00100000, 0b00100000, 0b00100000, 0b00111110, 0b00011110, 0b00000000 +; 111 0x6f o +.db 0b00011100, 0b00111110, 0b00100010, 0b00100010, 0b00100010, 0b00111110, 0b00011100, 0b00000000 +; 112 0x70 p +.db 0b00111111, 0b00111111, 0b00100100, 0b00100100, 0b00100100, 0b00111100, 0b00011000, 0b00000000 +; 113 0x71 q +.db 0b00011000, 0b00111100, 0b00100100, 0b00100100, 0b00100100, 0b00111111, 0b00111111, 0b00000000 +; 114 0x72 r +.db 0b00111110, 0b00111110, 0b00010000, 0b00100000, 0b00100000, 0b00110000, 0b00010000, 0b00000000 +; 115 0x73 s +.db 0b00010010, 0b00111010, 0b00101010, 0b00101010, 0b00101010, 0b00101110, 0b00100100, 0b00000000 +; 116 0x74 t +.db 0b00000000, 0b00100000, 0b11111100, 0b11111110, 0b00100010, 0b00100110, 0b00000100, 0b00000000 +; 117 0x75 u +.db 0b00111100, 0b00111110, 0b00000010, 0b00000010, 0b00000010, 0b00111110, 0b00111100, 0b00000000 +; 118 0x76 v +.db 0b00111000, 0b00111100, 0b00000110, 0b00000010, 0b00000110, 0b00111100, 0b00111000, 0b00000000 +; 119 0x77 w +.db 0b00111100, 0b00111110, 0b00000110, 0b00001100, 0b00000110, 0b00111110, 0b00111100, 0b00000000 +; 120 0x78 x +.db 0b00100010, 0b00110110, 0b00011100, 0b00001000, 0b00011100, 0b00110110, 0b00100010, 0b00000000 +; 121 0x79 y +.db 0b00100000, 0b00110001, 0b00011011, 0b00001110, 0b00001100, 0b00011000, 0b00110000, 0b00100000 +; 122 0x7a z +.db 0b00100010, 0b00100110, 0b00101110, 0b00101010, 0b00111010, 0b00110010, 0b00100010, 0b00000000 +; 123 0x7b { +.db 0b00000000, 0b00010000, 0b00010000, 0b01111100, 0b11101110, 0b10000010, 0b10000010, 0b00000000 +; 124 0x7c | +.db 0b00000000, 0b00000000, 0b00000000, 0b11111110, 0b11111110, 0b00000000, 0b00000000, 0b00000000 +; 125 0x7d } +.db 0b00000000, 0b10000010, 0b10000010, 0b11101110, 0b01111100, 0b00010000, 0b00010000, 0b00000000 +; 126 0x7e ~ +.db 0b01000000, 0b10000000, 0b10000000, 0b11000000, 0b01000000, 0b01000000, 0b10000000, 0b00000000 +; 127 0x7f +.db 0b00001110, 0b00011110, 0b00110010, 0b01100010, 0b00110010, 0b00011110, 0b00001110, 0b00000000 diff --git a/led_plex/main.asm b/led_plex/main.asm index b27f65f..8d9145b 100644 --- a/led_plex/main.asm +++ b/led_plex/main.asm @@ -9,11 +9,15 @@ .include "../include/tn2313def.inc" ; defines +.def zero = r1 +.def one = r2 .def tmp1 = r16 .def tmp2 = r17 .def uart_rxtx = r18 .def hc595_sink = r19 .def hc595_source = r20 +.def column = r21 +.def count = r22 ; ; interrupts @@ -92,27 +96,63 @@ INIT: ; timer0 interrupt enable rcall TIMER0_INT_INIT + ; timer1 init + rcall TIMER1_INIT + + ; timer1 interrupt enable + rcall TIMER1_INT_INIT + ; uart init rcall UART_INIT ; uart interrupt enable rcall UART_INT_RX_INIT + ; zero and one initialization + ldi tmp1,0 + mov zero,tmp1 + ldi tmp1,1 + mov one,tmp1 + ; set stackpointer ldi tmp1,low(RAMEND) out SPL,tmp1 - ; global interrupt enable - sei + ; framebuffer init: Z :) + ldi ZL,low(FB_C) + ldi ZH,high(FB_C) + ldi tmp1,0xff + st Z+,tmp1 + ldi tmp1,0xc3 + st Z+,tmp1 + ldi tmp1,0xa5 + st Z+,tmp1 + ldi tmp1,0x99 + st Z+,tmp1 + ldi tmp1,0x99 + st Z+,tmp1 + ldi tmp1,0xa5 + st Z+,tmp1 + ldi tmp1,0xc3 + st Z+,tmp1 + ldi tmp1,0xff + st Z,tmp1 + + ; led init + ldi hc595_sink,0x00 + ldi hc595_source,0x01 + ldi column,0 + rcall SET_HC595 + + ; more init + ldi count,0x21 ; signal ready output ldi uart_rxtx,0x68 rcall UART_TX - ; led init - ldi hc595_sink,0xff - ldi hc595_source,0x01 - rcall SET_HC595 + ; global interrupt enable + sei MAIN: @@ -131,21 +171,150 @@ MAIN: ; T1_OVF: + + ; + ; write font into framebuffer sram + ; + +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x21 + rcall UART_TX +.endif + ; calculate address + + ; font base address + ldi ZL,low(FONTS*2) + ldi ZH,high(FONTS*2) +.ifdef DEBUG_PORTS + mov uart_rxtx,ZH + rcall UART_TX + mov uart_rxtx,ZL + rcall UART_TX + ldi uart_rxtx,0x2d + rcall UART_TX +.endif + + ; framebuffer base address + ldi YL,low(FB_C) + ldi YH,high(FB_C) +.ifdef DEBUG_PORTS + mov uart_rxtx,YH + rcall UART_TX + mov uart_rxtx,YL + rcall UART_TX + ldi uart_rxtx,0x2d + rcall UART_TX +.endif + + ; font offset + mov XL,count + ldi XH,0 + ; times 8 == 3 left shifts + rol XL + rol XH + rol XL + rol XH + rol XL + rol XH +.ifdef DEBUG_PORTS + mov uart_rxtx,XH + rcall UART_TX + mov uart_rxtx,XL + rcall UART_TX + ldi uart_rxtx,0x2d + rcall UART_TX +.endif + + ; final font address + add ZL,XL + adc ZH,zero + add ZH,XH +.ifdef DEBUG_PORTS + mov uart_rxtx,ZH + rcall UART_TX + mov uart_rxtx,ZL + rcall UART_TX + ldi uart_rxtx,0x2d + rcall UART_TX + mov uart_rxtx,count + rcall UART_TX +.endif + + ; move font data into framebuffer + lpm tmp1,Z+ + st Y+,tmp1 + lpm tmp1,Z+ + st Y+,tmp1 + lpm tmp1,Z+ + st Y+,tmp1 + lpm tmp1,Z+ + st Y+,tmp1 + lpm tmp1,Z+ + st Y+,tmp1 + lpm tmp1,Z+ + st Y+,tmp1 + lpm tmp1,Z+ + st Y+,tmp1 + lpm tmp1,Z + st Y,tmp1 + + ; TESTING + ; increment test counter + inc count + cpi count,0x80 + brne EXIT_T1_OVF + ldi count,0x21 + +EXIT_T1_OVF: + reti T0_OVF: ; debug output cbi PORTD,3 - + ; shift source rol hc595_source + inc column + cpi column,8 + brne SINK_UPDATE + ldi column,0 + ldi hc595_source,1 ; update sink +SINK_UPDATE: + + ldi ZL,low(FB_C) + ldi ZH,high(FB_C) + add ZL,column + adc ZH,zero + ld hc595_sink,Z + +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x2d + rcall UART_TX + ldi uart_rxtx,0x3e + rcall UART_TX + ldi uart_rxtx,0x30 + add uart_rxtx,column + rcall UART_TX + ldi uart_rxtx,0x3a + rcall UART_TX + ldi uart_rxtx,0x20 + rcall UART_TX +.endif ; set hc595 rcall SET_HC595 +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x0a + rcall UART_TX + ldi uart_rxtx,0x0d + rcall UART_TX +.endif + ; debug output sbi PORTD,3 @@ -154,3 +323,17 @@ T0_OVF: UART_RECEIVE: reti +; include fonts +FONTS: +.include "fonts.asm" + +; +; sram +; + +.dseg + +; current framebuffer content +FB_C: .byte 8 + + diff --git a/led_plex/port.asm b/led_plex/port.asm index 7109c3c..f57bda9 100644 --- a/led_plex/port.asm +++ b/led_plex/port.asm @@ -43,14 +43,26 @@ SET_HC595: ; storage clock -> low cbi PORTB,1 + ; zero to everything ... + cbi PORTB,3 ; clear hc595 registers + sbi PORTB,1 ; store shift register data + cbi PORTB,1 ; release hc595 register clear + sbi PORTB,3 ; storage clock -> low + ; source driver ; clock -> low cbi PORTB,2 ; set ser line cbi PORTD,6 - sbrc hc595_source,7 + sbrc hc595_source,0 sbi PORTD,6 +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x30 + sbrc hc595_source,0 + ldi uart_rxtx,0x31 + rcall UART_TX +.endif ; clock -> high sbi PORTB,2 @@ -58,8 +70,14 @@ SET_HC595: cbi PORTB,2 ; set ser line cbi PORTD,6 - sbrc hc595_source,6 + sbrc hc595_source,1 sbi PORTD,6 +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x30 + sbrc hc595_source,1 + ldi uart_rxtx,0x31 + rcall UART_TX +.endif ; clock -> high sbi PORTB,2 @@ -67,8 +85,14 @@ SET_HC595: cbi PORTB,2 ; set ser line cbi PORTD,6 - sbrc hc595_source,5 + sbrc hc595_source,2 sbi PORTD,6 +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x30 + sbrc hc595_source,2 + ldi uart_rxtx,0x31 + rcall UART_TX +.endif ; clock -> high sbi PORTB,2 @@ -76,8 +100,14 @@ SET_HC595: cbi PORTB,2 ; set ser line cbi PORTD,6 - sbrc hc595_source,4 + sbrc hc595_source,3 sbi PORTD,6 +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x30 + sbrc hc595_source,3 + ldi uart_rxtx,0x31 + rcall UART_TX +.endif ; clock -> high sbi PORTB,2 @@ -85,8 +115,14 @@ SET_HC595: cbi PORTB,2 ; set ser line cbi PORTD,6 - sbrc hc595_source,3 + sbrc hc595_source,4 sbi PORTD,6 +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x30 + sbrc hc595_source,4 + ldi uart_rxtx,0x31 + rcall UART_TX +.endif ; clock -> high sbi PORTB,2 @@ -94,8 +130,14 @@ SET_HC595: cbi PORTB,2 ; set ser line cbi PORTD,6 - sbrc hc595_source,2 + sbrc hc595_source,5 sbi PORTD,6 +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x30 + sbrc hc595_source,5 + ldi uart_rxtx,0x31 + rcall UART_TX +.endif ; clock -> high sbi PORTB,2 @@ -103,8 +145,14 @@ SET_HC595: cbi PORTB,2 ; set ser line cbi PORTD,6 - sbrc hc595_source,1 + sbrc hc595_source,6 sbi PORTD,6 +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x30 + sbrc hc595_source,6 + ldi uart_rxtx,0x31 + rcall UART_TX +.endif ; clock -> high sbi PORTB,2 @@ -112,8 +160,14 @@ SET_HC595: cbi PORTB,2 ; set ser line cbi PORTD,6 - sbrc hc595_source,0 + sbrc hc595_source,7 sbi PORTD,6 +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x30 + sbrc hc595_source,7 + ldi uart_rxtx,0x31 + rcall UART_TX +.endif ; clock -> high sbi PORTB,2 @@ -125,6 +179,12 @@ SET_HC595: cbi PORTD,6 sbrc hc595_sink,7 sbi PORTD,6 +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x30 + sbrc hc595_sink,7 + ldi uart_rxtx,0x31 + rcall UART_TX +.endif ; clock -> high sbi PORTB,2 @@ -134,6 +194,12 @@ SET_HC595: cbi PORTD,6 sbrc hc595_sink,6 sbi PORTD,6 +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x30 + sbrc hc595_sink,6 + ldi uart_rxtx,0x31 + rcall UART_TX +.endif ; clock -> high sbi PORTB,2 @@ -143,6 +209,12 @@ SET_HC595: cbi PORTD,6 sbrc hc595_sink,5 sbi PORTD,6 +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x30 + sbrc hc595_sink,5 + ldi uart_rxtx,0x31 + rcall UART_TX +.endif ; clock -> high sbi PORTB,2 @@ -152,6 +224,12 @@ SET_HC595: cbi PORTD,6 sbrc hc595_sink,4 sbi PORTD,6 +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x30 + sbrc hc595_sink,4 + ldi uart_rxtx,0x31 + rcall UART_TX +.endif ; clock -> high sbi PORTB,2 @@ -161,6 +239,12 @@ SET_HC595: cbi PORTD,6 sbrc hc595_sink,3 sbi PORTD,6 +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x30 + sbrc hc595_sink,3 + ldi uart_rxtx,0x31 + rcall UART_TX +.endif ; clock -> high sbi PORTB,2 @@ -170,6 +254,12 @@ SET_HC595: cbi PORTD,6 sbrc hc595_sink,2 sbi PORTD,6 +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x30 + sbrc hc595_sink,2 + ldi uart_rxtx,0x31 + rcall UART_TX +.endif ; clock -> high sbi PORTB,2 @@ -179,6 +269,12 @@ SET_HC595: cbi PORTD,6 sbrc hc595_sink,1 sbi PORTD,6 +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x30 + sbrc hc595_sink,1 + ldi uart_rxtx,0x31 + rcall UART_TX +.endif ; clock -> high sbi PORTB,2 @@ -188,6 +284,12 @@ SET_HC595: cbi PORTD,6 sbrc hc595_sink,0 sbi PORTD,6 +.ifdef DEBUG_PORTS + ldi uart_rxtx,0x30 + sbrc hc595_sink,0 + ldi uart_rxtx,0x31 + rcall UART_TX +.endif ; clock -> high sbi PORTB,2 diff --git a/led_plex/timer.asm b/led_plex/timer.asm index c61967a..9ef24ac 100644 --- a/led_plex/timer.asm +++ b/led_plex/timer.asm @@ -3,11 +3,23 @@ TIMER0_INIT: ; clock select +.ifdef DEBUG_PORTS + ldi tmp1,0x03 +.else ldi tmp1,0x02 +.endif out TCCR0B,tmp1 ret +TIMER1_INIT: + + ; clock select + ldi tmp1,0x04 + out TCCR1B,tmp1 + + ret + TIMER0_INT_INIT: ; overflow interrupt @@ -16,3 +28,12 @@ TIMER0_INT_INIT: ret +TIMER1_INT_INIT: + + ; overflow interrupt + in tmp1,TIMSK + ori tmp1,(1<<7) + out TIMSK,tmp1 + + ret + -- 2.39.2