diff --git a/Micropendous/Firmware/VirtualSerial_LCD/Descriptors.c b/Micropendous/Firmware/VirtualSerial_LCD/Descriptors.c index 828266b3..cae6d34c 100644 --- a/Micropendous/Firmware/VirtualSerial_LCD/Descriptors.c +++ b/Micropendous/Firmware/VirtualSerial_LCD/Descriptors.c @@ -192,9 +192,9 @@ const USB_Descriptor_String_t PROGMEM LanguageString = */ const USB_Descriptor_String_t PROGMEM ManufacturerString = { - .Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String}, + .Header = {.Size = USB_STRING_LEN(20), .Type = DTYPE_String}, - .UnicodeString = L"Dean Camera" + .UnicodeString = L"www.micropendous.org" }; /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, @@ -203,9 +203,9 @@ const USB_Descriptor_String_t PROGMEM ManufacturerString = */ const USB_Descriptor_String_t PROGMEM ProductString = { - .Header = {.Size = USB_STRING_LEN(13), .Type = DTYPE_String}, + .Header = {.Size = USB_STRING_LEN(30), .Type = DTYPE_String}, - .UnicodeString = L"LUFA CDC Demo" + .UnicodeString = L"VirtualSerial HD44780 LCD Demo" }; /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" diff --git a/Micropendous/Firmware/VirtualSerial_LCD/VirtualSerial_LCD.c b/Micropendous/Firmware/VirtualSerial_LCD/VirtualSerial_LCD.c index 423f9930..b84665be 100644 --- a/Micropendous/Firmware/VirtualSerial_LCD/VirtualSerial_LCD.c +++ b/Micropendous/Firmware/VirtualSerial_LCD/VirtualSerial_LCD.c @@ -37,7 +37,7 @@ * the demo and is responsible for the initial application hardware configuration. */ -#include "VirtualSerial.h" +#include "VirtualSerial_LCD.h" // Global buffer for use with STDIO functions @@ -79,6 +79,9 @@ USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface = */ static FILE USBSerialStream; +// global variable for use with HD44780 LCD display +volatile uint8_t lcd_character_count; +volatile uint8_t lcd_current_line; /** Main program entry point. This routine contains the overall program flow, including initial * setup of all components and the main program loop. @@ -107,14 +110,14 @@ int main(void) /** Configures the board hardware and chip peripherals for the demo's functionality. */ void SetupHardware(void) { - /* Disable watchdog if enabled by bootloader/fuses */ + // Disable watchdog if enabled by bootloader/fuses MCUSR &= ~(1 << WDRF); wdt_disable(); - /* Disable clock division */ + // Disable clock division clock_prescale_set(clock_div_1); - /* Disable JTAG; allows upper nibble of Port F to be used as GPIO */ + // Disable JTAG; allows upper nibble of Port F to be used as GPIO #if ( defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB647__) || \ defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB646__) || \ defined(__AVR_ATmega16U4__) || defined(__AVR_ATmega32U4__) || \ @@ -122,7 +125,26 @@ void SetupHardware(void) JTAG_DISABLE(); #endif - /* Hardware Initialization */ + + // Hardware Initialization + // 16-bit Timer1 Initialization + TCCR1A = 0; //start the timer + //TCCR1B = (1 << CS10); // no Timer1 prescaling, use CLK + TCCR1B = (1 << CS12); // prescale Timer1 by CLK/256 + // 8000000 / 256 = 31250 ticks per second + // 16-bit = 2^16 = 65536 maximum ticks for Timer1 + // 65536 / 31250 =~ 2.1 + // so Timer1 will overflow back to 0 about every 2 seconds + uint16_t Timer1Val = TCNT1; // get current Timer1 value + Timer1Val = 345; + + // AVRlib HD44780 LCD initialization + lcdInit(); + rprintfInit(lcdDataWrite); // direct rprintf to LCD + lcdClear(); // clear the LCD + rprintf("GO AVRlib!"); + + // Hardware Initialization LEDs_Init(); LEDs_TurnOnLEDs(LEDS_LED1); DISABLE_VOLTAGE_TXRX(); // used on Micropendous REV1/2 boards @@ -160,23 +182,62 @@ void EVENT_USB_Device_ControlRequest(void) } +uint16_t firstNumber = 12345; void MainTask(void) { - int count = 0; + int tempInt = 0; + uint8_t tempChar = 0; - // If the host has sent data then echo it back - // Throughput is maximized if the full EP buffer is read and sent each time - // Throughput approaches CDC_TXRX_EPSIZE kbytes/second and depends on transfer size from host - if ((count = fread(&buffer, 1, CDC_TXRX_EPSIZE, &USBSerialStream)) > 0) { - fwrite(&buffer, 1, count, &USBSerialStream); + // example usage + if (firstNumber == 12345) { + lcdClear(); + rprintfChar('#'); // print a single character to the LCD + // print a value to the LCD in Base-10 using 5 digits. It is FALSE that the + // number can be negative (so it is positive) and use '0' to pad to 5 digits + rprintfNum(10, 5, FALSE, '0', firstNumber); + rprintf(" ABC"); // print some text to the LCD + lcdGotoXY(0, 1); // go to the first character of the second line (counting starts at 0) + lcdProgressBar(100, 255, 16); // display a progress bar of 100/255 using 16 characters from current XY position + lcdGotoXY(0, 0); // return to start position + firstNumber = 0; // do not run this if (...) code again + } + + // while there are characters in the USB stream, write them to LCD + // Each character is written sequentially, + // first to the top line, then to the next, etc... + while ((tempInt = fgetc(&USBSerialStream)) > 0) + { + tempChar = (uint8_t)tempInt; + // send char back for echo'ing on terminal + fputc(tempChar, &USBSerialStream); + + lcd_character_count++; + rprintfChar(tempChar); // print char to the LCD + // once we hit the end of a single line, loop to next line + if (lcd_character_count >= LCD_LINE_LENGTH) + { + lcd_character_count = 0; + lcd_current_line++; + // once we hit the end of the last line, loop to the first line + if (lcd_current_line >= LCD_LINES) + { + lcd_current_line = 0; + } + + lcdGotoXY(0, lcd_current_line); + } } - // If HWB Button is pressed then send formatted strings + // If HWB Button is pressed then send formatted strings over VirtualSerial and to LCD if (Buttons_GetStatus()) { fprintf_P(&USBSerialStream, PSTR("\r\nHWB has been pressed!\r\n")); // send a constant string stored in FLASH - fprintf(&USBSerialStream, "PORTD = %3x\r\n", PIND); // send a string that is dynamic and stored in SRAM + fprintf(&USBSerialStream, "PORTB = %3x\r\n", PINB); // send a string that is dynamic and stored in SRAM + rprintf("PORTB=0x"); + // print a value to the LCD in Base-16 (Hex) using 2 digits. It is FALSE that the + // number can be negative (so it is positive) and use '0' to pad to 2 digits + rprintfNum(16, 2, FALSE, '0', PINB); } } diff --git a/Micropendous/Firmware/VirtualSerial_LCD/VirtualSerial_LCD.h b/Micropendous/Firmware/VirtualSerial_LCD/VirtualSerial_LCD.h index 8fc06ef4..3de379c3 100644 --- a/Micropendous/Firmware/VirtualSerial_LCD/VirtualSerial_LCD.h +++ b/Micropendous/Firmware/VirtualSerial_LCD/VirtualSerial_LCD.h @@ -33,8 +33,8 @@ * Header file for VirtualSerial.c. */ -#ifndef _VIRTUALSERIAL_H_ -#define _VIRTUALSERIAL_H_ +#ifndef _VIRTUALSERIAL_LCD_H_ +#define _VIRTUALSERIAL_LCD_H_ /* Includes: */ #include @@ -50,6 +50,12 @@ #include #include + #include "global.h" + #include "lcdconf.h" + #include + #include + #include + /* Macros: */ /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ #define LEDMASK_USB_NOTREADY LEDS_LED1 @@ -72,5 +78,5 @@ void EVENT_USB_Device_ConfigurationChanged(void); void EVENT_USB_Device_ControlRequest(void); -#endif +#endif // _VIRTUALSERIAL_LCD_H_ diff --git a/Micropendous/Firmware/VirtualSerial_LCD/VirtualSerial_LCD_MICROPENDOUS_REV2.hex b/Micropendous/Firmware/VirtualSerial_LCD/VirtualSerial_LCD_MICROPENDOUS_REV2.hex new file mode 100644 index 00000000..d1c70cf9 --- /dev/null +++ b/Micropendous/Firmware/VirtualSerial_LCD/VirtualSerial_LCD_MICROPENDOUS_REV2.hex @@ -0,0 +1,549 @@ +:1000000011C100002EC100002CC100002AC1000057 +:1000100028C1000026C1000024C1000022C1000048 +:1000200020C100001EC100003DC4000008C5000042 +:1000300018C1000016C1000014C1000012C1000068 +:100040000C948D0D0C942B0D0C945C0D0AC10000CA +:100050000C94FA0C06C1000004C100000C94A30C1F +:1000600000C10000FEC00000FCC00000FAC000009B +:10007000F8C00000F6C00000F4C00000F2C00000AC +:10008000F0C00000EEC00000ECC00000EAC00000BC +:10009000E8C00000E6C00000474F204156526C699E +:1000A00062210020414243000D0A48574220686106 +:1000B00073206265656E2070726573736564210DCF +:1000C0000A00504F5254423D3078003E03560069BA +:1000D0000072007400750061006C005300650072CE +:1000E00000690061006C00200048004400340034C6 +:1000F0000037003800300020004C0043004400204E +:1001000000440065006D006F0000002A037700774F +:100110000077002E006D006900630072006F0070B0 +:100120000065006E0064006F00750073002E006FA4 +:10013000007200670000000403090409023E000287 +:100140000100C03209040000010202010005240080 +:100150001001042402060524060001070582030895 +:1001600000FF09040100020A000000070504021054 +:1001700000050705830210000512011001020000AE +:1001800008EB03442001000102DC0130313233343A +:10019000353637383941424344454600001F000098 +:1001A00000001F00001F101010101F00001F181863 +:1001B00018181F00001F1C1C1C1C1F00001F1E1EE7 +:1001C0001E1E1F00001F1F1F1F1F1F0003070F1FE2 +:1001D0000F070300001F1F1F1F1F1F001B1B1B1BE0 +:1001E0001B1B1B00181C1E1F1E1C18000004040EE5 +:1001F0000E1F1F00001F1F0E0E0404000000000051 +:1002000000000000000E1915130E0000000E151559 +:10021000150E0000000E1315190E0000000E111F20 +:10022000110E000011241FBECFEFD0E2DEBFCDBF04 +:1002300011E0A0E0B1E0E6EFF1E200E00BBF02C0A8 +:1002400007900D92AC33B107D9F71BBE11E0ACE3B8 +:10025000B1E001C01D92A538B107E1F70CD10C94B3 +:10026000F910CECE84B7877F84BF88E10FB6F894AB +:1002700080936000109260000FBE80E090E020E864 +:100280000FB6F89420936100809361000FBE85B78C +:10029000806890E00FB6F89485BF0FBE85BF1092BE +:1002A000800084E08093810080918400909185009B +:1002B0000E94120C8FE49BE024D70E94CA0B00D04E +:1002C0000F9281E0EDB7FEB7818388E990E09383D8 +:1002D0008283DCD7219A299A299A73986B9A6C9A0F +:1002E000749A77986F9A0F900F900F90C0C22998C8 +:1002F0000895299A089580E191E010D6882311F09D +:1003000090E001C092E085B18D7F892B85B9089579 +:1003100080E191E056C5EF92FF920F931F93CF9328 +:10032000DF9380910E0190910F0120E389339207B2 +:1003300009F057C00E94CA0B83E2E8D6E0900E0194 +:10034000F0900F0100E010E08AE065E040E020E37B +:10035000F7D600D00F9281E0ADB7BEB711968C935F +:10036000119783EA90E013969C938E9312978ED701 +:100370000F900F900F9080E061E00E94CC0B84E61C +:1003800090E06FEF70E040E10E94490C80E060E097 +:100390000E94CC0B10920F0110920E0122C0802FF0 +:1003A00090E0BE010E945F0E80915A018F5F8093A2 +:1003B0005A01802FABD680915A01803190F0109273 +:1003C0005A0180915B018F5F80935B0180915B019B +:1003D000823010F010925B0160915B0180E00E941E +:1003E000CC0BCCE3D1E0CE010E94F40D8C011816A9 +:1003F0001906ACF28CB182FD37C000D000D0EDB749 +:10040000FEB7D283C18388EA90E0948383830E94FD +:10041000430E23B100D0EDB7FEB73196ADB7BEB7EE +:100420001296DC93CE93119780E091E093838283C0 +:10043000248315820E94340E0F900F900F9081E05C +:10044000EDB7FEB7818382EC90E0938382831ED761 +:10045000E3B00F900F900F90FF2400E010E080E1D8 +:1004600062E040E020E36CD6DF91CF911F910F91C5 +:10047000FF90EF900895F6DE80E191E06CE371E08B +:100480002CD6789448DF80E191E0D1D57ED4FACFA4 +:10049000923029F0933041F09130E9F417C08EE3A7 +:1004A00090E0EBE3F1E01BC0813041F0813018F0C7 +:1004B000823089F406C0E7E3F1E005C0EBE0F1E04B +:1004C00002C0EBECF0E0849190E009C082E190E0A2 +:1004D000E9E7F1E004C080E090E0E0E0F0E0DA017C +:1004E0001196FC93EE930895209177013091780155 +:1004F0002617370720F4B901FC0120E037C0611549 +:100500007105D1F72091E8002E772093E800F4CF11 +:1005100080917001882309F43FC08530C9F1809132 +:10052000E80083FD37C08091E80082FD2BC08091F8 +:10053000E80080FF1BC08091F2009091F30006C09C +:1005400021912093F1006150704001966115710571 +:1005500019F088309105A0F321E08830910509F069 +:1005600020E08091E8008E778093E80061157105A6 +:1005700079F6222369F606C080917001882361F024 +:10058000853061F08091E80082FFF6CF80E0089529 +:1005900083E0089581E0089582E0089583E008955E +:1005A00020917701309178012617370720F4B9019F +:1005B000FC0120E038C061157105D1F72091E800F9 +:1005C0002E772093E800F4CF80917001882309F4FE +:1005D00040C08530D1F18091E80083FD38C0809122 +:1005E000E80082FD2CC08091E80080FF1CC0809153 +:1005F000F2009091F30007C024912093F10031960E +:100600006150704001966115710519F088309105AF +:1006100098F321E08830910509F020E08091E8000E +:100620008E778093E8006115710571F6222361F6DB +:1006300006C080917001882361F0853061F080915F +:10064000E80082FFF6CF80E0089583E0089581E01E +:10065000089582E0089583E00895982F2AC090932A +:10066000E900981739F07091EC002091ED0050915D +:10067000F00003C0242F762F50E021FF19C03091E5 +:10068000EB003E7F3093EB003091ED003D7F3093E7 +:10069000ED003091EB0031603093EB007093EC0093 +:1006A0002093ED005093F0002091EE0027FF08C04A +:1006B0009F5F9730A0F28F708093E90081E00895EA +:1006C00080E008950F931F93CF93DF93162FEC01D3 +:1006D00000E02AC09881992329F16B81E981FA8190 +:1006E0002C81892F8F70873018F56295660F660F01 +:1006F000607C991F9927991F692B223010F096E092 +:1007000001C092E028E030E040E003C04F5F220FDC +:10071000331F2E173F07D0F34295407F492B9DDFB3 +:10072000882331F00F5F25960117A1F681E001C003 +:1007300080E0DF91CF911F910F9108958091710119 +:1007400087FF13C004C0809170018823B9F08091A5 +:10075000E80082FFF8CF8091E8008B778093E80073 +:10076000089580917001882349F08091E80080FF0E +:10077000F8CF8091E8008E778093E800089580910B +:10078000E4009091E50045E601C0C9012091EC002C +:1007900020FF23C02091E80020FD15C020917001AA +:1007A000222399F0253099F02091EB0025FD11C00E +:1007B0002091E4003091E5002817390739F34150C2 +:1007C00021F784E0089580E0089582E0089583E0B1 +:1007D000089581E0089580E008952091E80022FFC7 +:1007E000DDCFF9CF0F931F93CF93DF934ED055D02A +:1007F000C8EDD0E088818F7788838881806888837E +:1008000088818F7D8883E7EDF0E080818068808338 +:1008100019BC1092700110926C0110926E0110922E +:100820006D0100EE10E0F80180818B7F808388816C +:100830008160888380E060E042E00FDFE1EEF0E07D +:1008400080818E7F8083E2EEF0E080818160808312 +:10085000808188608083F80180818E7F8083888199 +:1008600080618883DF91CF911F910F910895E8ED0A +:10087000F0E080818F7E8083E7EDF0E08081816011 +:10088000808381E080936F01ADCFE8EDF0E080815F +:100890008C7F80831092E20008951092DA0010920B +:1008A000E10008951F920F920FB60F920BB60F92B0 +:1008B00011242F933F934F935F936F937F938F9365 +:1008C0009F93AF93BF93EF93FF938091E10082FFDB +:1008D0000AC08091E20082FF06C08091E1008B7F18 +:1008E0008093E10051D28091DA0080FF1DC0809199 +:1008F000D80080FF19C08091DA008E7F8093DA00E3 +:100900008091D90080FF0CC084E189BD86E189BD5A +:1009100009B400FEFDCF81E080937001E8DC04C0E3 +:1009200019BC10927001E5DC8091E10080FF18C0D5 +:100930008091E20080FF14C08091E2008E7F80935E +:10094000E2008091E20080618093E2008091D80013 +:1009500080628093D80019BC85E08093700114D226 +:100960008091E10084FF2DC08091E20084FF29C0C6 +:1009700084E189BD86E189BD09B400FEFDCF809187 +:10098000D8008F7D8093D8008091E1008F7E809386 +:10099000E1008091E2008F7E8093E2008091E2008E +:1009A00081608093E20080916C01882321F4809122 +:1009B000E30087FF02C084E001C081E08093700102 +:1009C000E3D18091E10083FF27C08091E20083FFA3 +:1009D00023C08091E100877F8093E10082E08093D3 +:1009E000700110926C018091E1008E7F8093E10094 +:1009F0008091E2008E7F8093E2008091E20080612E +:100A00008093E20080E060E042E027DE8091F00029 +:100A100088608093F000B8D1FF91EF91BF91AF91C2 +:100A20009F918F917F916F915F914F913F912F9106 +:100A30000F900BBE0F900FBE0F901F9018951F9236 +:100A40000F920FB60F920BB60F9211242F933F9374 +:100A50004F935F936F937F938F939F93AF93BF93C6 +:100A6000CF93EF93FF93C091E900CF708091EC009A +:100A70001092E9008091F000877F8093F0007894D5 +:100A80001DD01092E9008091F00088608093F00002 +:100A9000C093E900FF91EF91CF91BF91AF919F91EA +:100AA0008F917F916F915F914F913F912F910F9017 +:100AB0000BBE0F900FBE0F901F9018951F93CF93F2 +:100AC000DF93CDB7DEB7AC970FB6F894DEBF0FBE9D +:100AD000CDBF80E0E1E7F1E09091F10091938F5F6D +:100AE0008830D1F715DC8091E80083FF35C1809113 +:100AF000710120917201253009F484C0263040F440 +:100B00002130A1F1213070F0233009F025C12EC031 +:100B1000283009F4F3C0293009F402C1263009F065 +:100B20001BC193C0803821F0823809F015C108C07C +:100B300080916D0190916E01992371F082600CC0DB +:100B4000809175018F708093E9009091EB0081E0B6 +:100B500095FF80E01092E9009091E800977F9093D4 +:100B6000E8008093F1001092F100D3C0882319F0BF +:100B7000823009F0F1C090E08F719070009729F0F9 +:100B80008230910509F0E8C00BC08091730181307B +:100B900009F0E2C0233009F080E080936E012CC0A0 +:100BA00080917301882341F5209175012F7009F41C +:100BB000D3C02093E9008091EB0080FF1DC080919D +:100BC0007201833021F48091EB00806213C0809128 +:100BD000EB0080618093EB0081E090E002C0880F21 +:100BE000991F2A95E2F78093EA001092EA0080911B +:100BF000EB0088608093EB001092E9008091E800A0 +:100C0000877F8AC0882309F0A7C0109173011F77DE +:100C10008091E3008078812B8093E3008091E8004D +:100C2000877F8093E8008ADD8091E80080FFFCCF19 +:100C30008091E30080688093E300112311F083E04A +:100C400001C082E08093700187C08058823008F034 +:100C500083C0809173019091740123E08C3D9207D1 +:100C6000A9F583E08C838AE28B835FB7F894DE0179 +:100C7000139680E090E04EE061E2E42FF0E06093B4 +:100C80005700E49180FF03C0E295EF704F5FEF7073 +:100C90002E2F30E0EA3018F0295C3F4F02C0205D73 +:100CA0003F4F13963C932E931297019612968431E0 +:100CB000910519F75FBF8091E800877F8093E80076 +:100CC000CE0103966AE270E00FDC12C060917501FC +:100CD000AE014F5F5F4FDCDBBC01009709F43CC005 +:100CE0008091E800877F8093E80089819A8158DCB1 +:100CF0008091E8008B778093E8002EC0803861F502 +:100D00008091E800877F8093E80080916C01809358 +:100D1000F1008091E8008E778093E8000FDD1CC021 +:100D20008823D1F4909173019230B0F48091E8005F +:100D3000877F8093E80090936C0100DD80916C01C7 +:100D4000882321F48091E30087FF02C084E001C082 +:100D500081E080937001CFDA8091E80083FF0AC0C0 +:100D60008091E800877F8093E8008091EB008062AB +:100D70008093EB00AC960FB6F894DEBF0FBECDBFEC +:100D8000DF91CF911F9108950895CF9380917001C5 +:100D90008823A9F08091E9008F709091EC0090FF7A +:100DA00002C0C0E801C0C0E0C82B1092E9008091E9 +:100DB000E80083FF01C082DECF70C093E900CF91CD +:100DC0000895CF93DF93EC018091E80083FFA3C0E7 +:100DD000888190E0209175013091760128173907BC +:100DE00009F099C080917201813269F0823220F459 +:100DF000803209F090C03CC0823209F46BC083326B +:100E000009F089C07AC080917101813A09F083C0EC +:100E10008091E800877F8093E8008091E80080FF60 +:100E2000FCCF8C899D89AE89BF898093F100492FC1 +:100E30005A2F6B2F77274093F100AD016627772754 +:100E40004093F1008B2F9927AA27BB278093F100AD +:100E5000888D8093F100898D8093F1008A8D809335 +:100E6000F1008091E8008E778093E80067DC53C042 +:100E700080917101813209F04EC08091E800877F36 +:100E80008093E80005C080917001882309F443C075 +:100E90008091E80082FFF7CF3091F1002091F100BE +:100EA0009091F1008091F1003C8B2D8B9E8B8F8B6C +:100EB0008091F100888F8091F100898F8091F100FD +:100EC0008A8F8091E8008B778093E80037DCCE0131 +:100ED00017D121C0809171018132E9F48091E8003D +:100EE000877F8093E8002ADC8091730190917401E0 +:100EF000998B888BCE0104D10EC080917101813213 +:100F000051F48091E800877F8093E80017DCCE01E0 +:100F100060917301F5D0DF91CF910895CF93DF9366 +:100F2000EC014096FC018BE0DF011D928A95E9F708 +:100F300082E08C83898783E08E87CE01019661E011 +:100F4000C1DB882359F0CE01069661E0BBDB882324 +:100F500029F0CE010B9661E0B5DB01C080E0DF91A6 +:100F6000CF910895CF93FC01C62F809170018430FA +:100F7000E9F44489558966897789411551056105E8 +:100F80007105A1F081818F708093E9008091E80064 +:100F900085FD08C08091E8008E778093E800EFDB44 +:100FA000882329F4C093F10080E001C082E0CF9152 +:100FB0000895282FFB0184859585622FD3DF882330 +:100FC00019F08FEF9FEF089580E090E00895FC0105 +:100FD00080917001843029F5448955896689778923 +:100FE0004115510561057105E1F081818F70809394 +:100FF000E9008091F2009091F3000097A1F09091A8 +:10100000E8008091E8008E778093E80095FD0DC0A0 +:10101000B6DB882359F49091E8009E779093E8001E +:10102000089582E0089580E0089580E00895209179 +:101030007001243099F4FC014489558966897789C7 +:10104000411551056105710549F021812F702093EB +:10105000E9002091E80020FF01C0B9CF0895FC010C +:1010600080917001843051F544895589668977896A +:10107000411551056105710509F186818F708093D5 +:10108000E9008091E80082FF1CC08091F2009091FD +:10109000F300009721F08091F10090E002C08FEF03 +:1010A0009FEF2091F2003091F3002115310559F4A2 +:1010B0002091E8002B772093E80008958FEF9FEFB1 +:1010C00008958FEF9FEF0895FC0184859585C7DF14 +:1010D00097FF02C08EEF9FEF0895FB012EE0DB012A +:1010E0001D922A95E9F723E0238329ED37E0318724 +:1010F000208724E638E03387228795878487089500 +:10110000089590934B0180934A010895CF93C82F7F +:101110008A3031F4E0914A01F0914B018DE009955C +:10112000E0914A01F0914B018C2F0995CF910895E0 +:10113000E82FF0E0EF70F070E557FE4F8491E6CFB6 +:101140002F923F924F925F926F927F928F929F92D7 +:10115000AF92BF92CF92DF92EF92FF920F931F93C5 +:10116000CF93DF93CDB7DEB7A0970FB6F894DEBF6D +:101170000FBECDBF282EA62EB42E722E6701780189 +:10118000442351F0F7FE08C066277727CB016C197E +:101190007D098E099F0902C0C701B6016A2C6A94B5 +:1011A00021E0BB2009F420E0621A18A23324442471 +:1011B0005524A2019101F6D4DC01CB01FC01EF70B2 +:1011C000F070E557FE4FE491EF8FC901DA012EE18F +:1011D000822E912C8C0E9D1E062D1CC00097A10501 +:1011E000B10591F0BC01CD01A2019101DBD4DC017C +:1011F000CB01FC01EF70F070E557FE4FE491D40194 +:10120000EC93C901DA0102C0F40170820150089424 +:1012100081089108002311F78E01015E1F4F061906 +:101220001109BB20C1F001501040F7FE02C08DE251 +:101230000AC0C114D104E104F10421F08BE2F801E9 +:10124000808309C080E2D8018C9305C0F8018191A8 +:101250008F015CDFAA94AA20C9F7A0960FB6F89474 +:10126000DEBF0FBECDBFDF91CF911F910F91FF90D9 +:10127000EF90DF90CF90BF90AF909F908F907F9036 +:101280006F905F904F903F902F9008954F925F9294 +:101290006F927F928F929F92AF92BF92CF92DF9286 +:1012A000EF92FF920F931F93CF93DF930F92CDB7DF +:1012B000DEB78C88CD88DE8867E1E62EF12CEC0E57 +:1012C000FD1E7AE0472E512C19C08823A1F480E03E +:1012D00090E00F90DF91CF911F910F91FF90EF90D1 +:1012E000DF90CF90BF90AF909F908F907F906F9046 +:1012F0005F904F9008950ADF57017501D60111964E +:10130000F601882019F06D01849102C080816D0181 +:101310008532D9F69D012F5F3F4F882021F069016A +:10132000FD01849102C08C916901843629F08837CF +:1013300081F0833601F706C05AE0652E712C00E17A +:1013400017E20CC0F701808122E030E0E20EF31ECC +:10135000D2CF40E1642E712C00E010E132E0A32EE8 +:10136000B12CAE0CBF1CF701E080F180843699F4FB +:10137000F7FE0EC0F094E194F108F3948DE2C6DE1E +:1013800007C0C801B201FAD38B016230710518F0B1 +:10139000E016F106B0F3C701B801F0D3982E862FFE +:1013A0009983C6DEE92C9981F92EC801B301E6D3F1 +:1013B0008B016115710579F7A0CF589859985A9803 +:1013C000509A519A529A8AB18F708AB98BB1806FB4 +:1013D0008BB9089558988AB18F708AB98BB1806F94 +:1013E0008BB9599A5A9A66C05A98000000000000BA +:1013F00000000000000000000000000000000000ED +:1014000000000000000000000000000000000000DC +:1014100000000000000000000000000000000000CC +:1014200000005A9A000000000000000000000000C8 +:1014300000000000000000000000000000000000AC +:10144000000000000000000000000000000000009C +:101450000000000000000000000000005A9800009A +:10146000000000000000000000000000000000007C +:10147000000000000000000000000000000000006C +:10148000000000000000000000000000000000005C +:101490000000000000005A9A000000000000000058 +:1014A000000000000000000000000000000000003C +:1014B000000000000000000000000000000000002C +:1014C000000000000000000000000000000000001C +:1014D0004F998ACF5A980895CF93DF930F92CDB743 +:1014E000DEB7898377DF589859985A9A9AB1906FE6 +:1014F0009AB92BB18981982F907F2F70922B9BB92D +:1015000000000000000000000000000000000000DB +:1015100000000000000000000000000000000000CB +:1015200000000000000000000000000000000000BB +:1015300000000000000000005A98000000000000B9 +:10154000000000000000000000000000000000009B +:10155000000000000000000000000000000000008B +:10156000000000000000000000000000000000007B +:1015700000005A9A9BB18295807F9F70892B8BB90E +:10158000000000000000000000000000000000005B +:10159000000000000000000000000000000000004B +:1015A000000000000000000000000000000000003B +:1015B00000000000000000005A988AB18F708AB9BC +:1015C0008BB1806F8BB90F90DF91CF91089502DFBF +:1015D0008AB18F708AB98BB1806F8BB95898599A3C +:1015E0005A9A000000000000000000000000000007 +:1015F00000000000000000000000000000000000EB +:1016000000000000000000000000000000000000DA +:101610000000000000000000000089B1807F5A989F +:1016200000000000000000000000000000000000BA +:1016300000000000000000000000000000000000AA +:10164000000000000000000000000000000000009A +:1016500000000000000000005A9A00000000000096 +:10166000000000000000000000000000000000007A +:10167000000000000000000000000000000000006A +:10168000000000000000000000000000000000005A +:10169000000099B15A9892959F70892B0895CF9325 +:1016A000DF930F92CDB7DEB7898394DE589A5998AD +:1016B0005A9A9AB1906F9AB92BB18981982F907FDD +:1016C0002F70922B9BB9000000000000000000006A +:1016D000000000000000000000000000000000000A +:1016E00000000000000000000000000000000000FA +:1016F00000000000000000000000000000005A98F8 +:1017000000000000000000000000000000000000D9 +:1017100000000000000000000000000000000000C9 +:1017200000000000000000000000000000000000B9 +:1017300000000000000000005A9A9BB18295807F53 +:101740009F70892B8BB90000000000000000000092 +:101750000000000000000000000000000000000089 +:101760000000000000000000000000000000000079 +:1017700000000000000000000000000000005A9877 +:101780008AB18F708AB98BB1806F8BB90F90DF915E +:10179000CF91089581E0A0CE623031F0633031F016 +:1017A000613029F4805C03C08C5E01C08C5A806873 +:1017B00093CECF92DF92FF920F931F93CF93DF933D +:1017C0000F92CDB7DEB78C01F42E698300DF982F1E +:1017D0009F77FF0CFF0CFF0C6981660F660F660F89 +:1017E000CC24DD24060F111D8C2D8F0D8064998370 +:1017F00073DEF801EC0DFD1D849151DF0894C11CCE +:10180000D11C998188E0C816D10471F7892F8068AE +:1018100063DE0F90DF91CF911F910F91FF90DF90CA +:10182000CF900895CF93DF93C8DD88E255DE81E045 +:1018300053DE80E69AEE86D086E04EDE8CE04CDE0B +:1018400082E04ADE80E848DECCE9D1E0CE0160E00B +:1018500040E0AFDFCE0161E041E0ABDFCE0162E00E +:1018600042E0A7DFCE0163E043E0A3DFCE0164E006 +:1018700044E09FDFCE0165E045E09BDFCE0166E0FE +:1018800046E097DFCE0167E047E093DFDF91CF913D +:1018900008958F929F92AF92BF92CF92DF92EF9274 +:1018A000FF921F93CF93DF93C42F9C01220F331F0E +:1018B000280F391F220F331F4C2F50E0249FC001E7 +:1018C000259F900D349F900D112458D14B01AA24CF +:1018D000BB24C501B40126E030E040E050E062D115 +:1018E000162FCC24DD247601D0E01EC0D701C6011E +:1018F0000596A11DB11D88169906AA06BB0638F4E7 +:101900008C149D04AE04BF0420F0812F03C085E039 +:1019100001C080E0C4DEDF5F86E090E0A0E0B0E0E0 +:10192000C80ED91EEA1EFB1EDC1701F7DF91CF910E +:101930001F91FF90EF90DF90CF90BF90AF909F905E +:101940008F90089508951F920F920FB60F920BB6C5 +:101950000F9211242F933F934F935F936F937F9335 +:101960008F939F93AF93BF93EF93FF9380917901F0 +:1019700090917A01A0917B01B0917C010196A11D0B +:10198000B11D8093790190937A01A0937B01B0936C +:101990007C0180917D0190917E01A0917F01B091A9 +:1019A00080010196A11DB11D80937D0190937E0160 +:1019B000A0937F01B093800180914C0190914D01E3 +:1019C000009729F0E0914C01F0914D010995FF91AC +:1019D000EF91BF91AF919F918F917F916F915F91A7 +:1019E0004F913F912F910F900BBE0F900FBE0F9014 +:1019F0001F9018951F920F920FB60F920BB60F9271 +:101A000011242F933F934F935F936F937F938F9303 +:101A10009F93AF93BF93EF93FF9380914E0190916B +:101A20004F01009729F0E0914E01F0914F01099587 +:101A3000FF91EF91BF91AF919F918F917F916F91A6 +:101A40005F914F913F912F910F900BBE0F900FBE62 +:101A50000F901F9018951F920F920FB60F920BB612 +:101A60000F9211242F933F934F935F936F937F9324 +:101A70008F939F93AF93BF93EF93FF938091500108 +:101A800090915101009729F0E0915001F09151019E +:101A90000995FF91EF91BF91AF919F918F917F91A8 +:101AA0006F915F914F913F912F910F900BBE0F90CF +:101AB0000FBE0F901F9018951F920F920FB60F92A6 +:101AC0000BB60F9211242F933F934F935F936F9315 +:101AD0007F938F939F93AF93BF93EF93FF938091E7 +:101AE000520190915301009729F0E0915201F09139 +:101AF00053010995FF91EF91BF91AF919F918F9104 +:101B00007F916F915F914F913F912F910F900BBEFD +:101B10000F900FBE0F901F9018951F920F920FB647 +:101B20000F920BB60F9211242F933F934F935F9315 +:101B30006F937F938F939F93AF93BF93EF93FF9395 +:101B40008091540190915501009729F0E091540142 +:101B5000F09155010995FF91EF91BF91AF919F9140 +:101B60008F917F916F915F914F913F912F910F9046 +:101B70000BBE0F900FBE0F901F901895AA1BBB1B9A +:101B800051E107C0AA1FBB1FA617B70710F0A61B7D +:101B9000B70B881F991F5A95A9F780959095BC019E +:101BA000CD010895A1E21A2EAA1BBB1BFD010DC099 +:101BB000AA1FBB1FEE1FFF1FA217B307E407F507FD +:101BC00020F0A21BB30BE40BF50B661F771F881FD9 +:101BD000991F1A9469F760957095809590959B016F +:101BE000AC01BD01CF010895CF93DF93EC012B81B0 +:101BF00020FF35C026FF09C02F7B2B838E819F815C +:101C000001969F838E838A8128C022FF0FC0E881BE +:101C1000F9818081992787FD9095009719F42062BA +:101C20002B831DC03196F983E88311C0EA85FB85BB +:101C3000CE01099597FF0BC02B813FEF8F3F930794 +:101C400011F480E101C080E2822B8B8308C02E81D9 +:101C50003F812F5F3F4F3F832E8390E002C08FEF85 +:101C60009FEFDF91CF910895CF93DF93CDB7DEB78C +:101C7000AE01475F5F4F8D819E816F8178854BD02C +:101C8000DF91CF9108950F931F93CF93DF93CDB73B +:101C9000DEB70F811885AE01455F5F4FF801838184 +:101CA00088608383C80169857A8535D0F8012381EE +:101CB000277F2383DF91CF911F910F9108950F9379 +:101CC0001F93CF93DF938C01EB018B8181FF1BC0AE +:101CD00082FF0DC02E813F818C819D81281739079D +:101CE00064F4E881F9810193F983E88306C0E8850B +:101CF000F985802F0995009731F48E819F81019697 +:101D00009F838E8302C00FEF1FEFC801DF91CF9139 +:101D10001F910F9108952F923F924F925F926F9271 +:101D20007F928F929F92AF92BF92CF92DF92EF926B +:101D3000FF920F931F93CF93DF93CDB7DEB72D970D +:101D40000FB6F894DEBF0FBECDBF3C017D876C8718 +:101D50005A01FC0117821682838181FFBBC12E01CB +:101D60000894411C511CF3019381EC85FD8593FD82 +:101D7000859193FF8191FD87EC87882309F4A6C1A3 +:101D8000853241F493FD859193FF8191FD87EC8726 +:101D9000853221F490E0B30192DFE5CFFF24EE24F9 +:101DA00010E01032B0F48B3269F08C3228F48032BB +:101DB00051F0833271F40BC08D3239F0803349F425 +:101DC00011602CC01260146029C0186027C0106117 +:101DD00025C017FD2EC0282F20532A3098F416FF57 +:101DE00008C08F2D880FF82EFF0CFF0CF80EF20E96 +:101DF00015C08E2D880FE82EEE0CEE0CE80EE20ECC +:101E000010620CC08E3221F416FD60C1106406C051 +:101E10008C3611F4106802C0883659F4EC85FD85C3 +:101E200093FD859193FF8191FD87EC87882309F0CD +:101E3000B8CF982F9554933018F09052933038F4CF +:101E400024E030E0A20EB31E3FE339830FC0833697 +:101E500031F0833781F0833509F056C021C0F50198 +:101E60008081898322E030E0A20EB31E21E0C22EE1 +:101E7000D12C420113C092E0292E312C2A0C3B1C9C +:101E8000F5018080918016FF03C06F2D70E002C0C5 +:101E90006FEF7FEFC40144D16C0151011F7714C073 +:101EA00082E0282E312C2A0C3B1CF5018080918089 +:101EB00016FF03C06F2D70E002C06FEF7FEFC4010B +:101EC00024D16C011068510113FD1AC005C080E2D5 +:101ED00090E0B301F4DEEA948E2D90E0C816D906A6 +:101EE000B0F30EC0F40117FD859117FF81914F01EA +:101EF00090E0B301E4DEE110EA940894C108D1084F +:101F0000C114D10479F7DFC0843611F0893649F560 +:101F1000F50117FF07C080819181A281B38124E080 +:101F200030E008C080819181AA2797FDA095BA2F43 +:101F300022E030E0A20EB31E012F0F76B7FF08C0DB +:101F4000B095A095909581959F4FAF4FBF4F00687A +:101F5000BC01CD01A2012AE030E0EDD0D82ED4188A +:101F60003EC0853721F41F7E2AE030E020C0197F73 +:101F70008F36A9F0803720F4883509F0A7C00BC050 +:101F8000803721F0883709F0A1C001C0106114FF2B +:101F900009C0146007C014FF08C0166006C028E01E +:101FA00030E005C020E130E002C020E132E0F50180 +:101FB00017FF07C0608171818281938144E050E006 +:101FC00006C06081718180E090E042E050E0A40EA4 +:101FD000B51EA201B0D0D82ED418012F0F7706FF5E +:101FE00009C00E7FDF1430F404FF06C002FD04C0F8 +:101FF0000F7E02C01D2D01C01F2D802F90E004FF19 +:102000000CC0FE01ED0DF11D2081203311F4097E7D +:1020100009C002FF06C01E5F05C086789070009759 +:1020200009F01F5F802E992403FD11C000FF0CC032 +:10203000FD2C1E1548F4FE0CF11A1E2D05C080E281 +:1020400090E0B3013CDE1F5F1E15C8F304C01E15EF +:1020500010F4E11A01C0EE2484FE0EC080E390E08B +:10206000B3012DDE82FE1DC081FE03C088E590E035 +:1020700010C088E790E00DC0C4018678907000978A +:1020800081F081FC02C080E201C08BE207FD8DE29D +:1020900090E0B30114DE05C080E390E0B3010FDEF1 +:1020A000FA94DF14C8F3DA94F201ED0DF11D80818A +:1020B00090E0B30104DEDD20B1F705C080E290E0DE +:1020C000B301FDDDEA94EE20C9F74DCEF301868120 +:1020D000978102C08FEF9FEF2D960FB6F894DEBF69 +:1020E0000FBECDBFDF91CF911F910F91FF90EF9069 +:1020F000DF90CF90BF90AF909F908F907F906F9028 +:102100005F904F903F902F900895FC010590615093 +:1021100070400110D8F7809590958E0F9F1F0895FD +:10212000FC016150704001900110D8F780959095A6 +:102130008E0F9F1F0895FA01AA27283051F12031F0 +:1021400081F1E8946F936E7F6E5F7F4F8F4F9F4F4B +:10215000AF4FB1E03ED0B4E03CD0670F781F891F8D +:102160009A1FA11D680F791F8A1F911DA11D6A0F5B +:10217000711D811D911DA11D20D009F468943F910E +:102180002AE0269F11243019305D3193DEF6CF010D +:102190000895462F4770405D4193B3E00FD0C9F7D3 +:1021A000F6CF462F4F70405D4A3318F0495D31FD40 +:1021B0004052419302D0A9F7EACFB4E0A695979593 +:1021C000879577956795BA95C9F700976105710569 +:1021D00008959B01AC010A2E0694579547953795B3 +:1021E0002795BA95C9F7620F731F841F951FA01D0D +:0621F0000895F894FFCFF2 +:1021F600504F525442203D202533780D0A00393085 +:102206000083100000010410000001820800000194 +:102216000000000000000000000000A120000000F7 +:0C222600000200A1010000000000000008 +:00000001FF diff --git a/Micropendous/Firmware/VirtualSerial_LCD/global.h b/Micropendous/Firmware/VirtualSerial_LCD/global.h new file mode 100644 index 00000000..f687207c --- /dev/null +++ b/Micropendous/Firmware/VirtualSerial_LCD/global.h @@ -0,0 +1,33 @@ + +//***************************************************************************** +// +// File Name : 'global.h' +// Title : AVR project global include +// Author : Pascal Stang +// Created : 7/12/2001 +// Revised : 9/30/2002 +// Version : 1.1 +// Target MCU : Atmel AVR series +// Editor Tabs : 4 +// +// Description : This include file is designed to contain items useful to all +// code files and projects. +// +// This code is distributed under the GNU Public License +// which can be found at http://www.gnu.org/licenses/gpl.txt +// +//***************************************************************************** + +#ifndef GLOBAL_H +#define GLOBAL_H + +// global AVRLIB defines +#include +// global AVRLIB types definitions +#include + +// project/system dependent defines + +#define CYCLES_PER_US ((F_CPU+500000)/1000000) // cpu cycles per microsecond + +#endif diff --git a/Micropendous/Firmware/VirtualSerial_LCD/lcdconf.h b/Micropendous/Firmware/VirtualSerial_LCD/lcdconf.h new file mode 100644 index 00000000..a1479699 --- /dev/null +++ b/Micropendous/Firmware/VirtualSerial_LCD/lcdconf.h @@ -0,0 +1,127 @@ +/*! \file lcdconf.h \brief Character LCD driver configuration. */ +//***************************************************************************** +// +// File Name : 'lcdconf.h' +// Title : Character LCD driver for HD44780/SED1278 displays +// (usable in mem-mapped, or I/O mode) +// Author : Pascal Stang - Copyright (C) 2000-2002 +// Created : 11/22/2000 +// Revised : 4/30/2002 +// Version : 1.1 +// Target MCU : Atmel AVR series +// Editor Tabs : 4 +// +// This code is distributed under the GNU Public License +// which can be found at http://www.gnu.org/licenses/gpl.txt +// +//***************************************************************************** + +#ifndef LCDCONF_H +#define LCDCONF_H + +// Define type of interface used to access the LCD +// LCD_MEMORY_INTERFACE: +// To use this mode you must supply the necessary hardware to connect the +// LCD to the CPU's memory bus. The CONTROL and DATA registers of the LCD +// (HD44780 chip) must appear in the CPU's memory map. This mode is faster +// than the port interface but requires a little extra hardware to make it +// work. It is especially useful when your CPU is already configured to +// use an external memory bus for other purposes (like accessing memory). +// +// LCD_PORT_INTERFACE: +// This mode allows you to connect the control and data lines of the LCD +// directly to the I/O port pins (no interfacing hardware is needed), +// but it generally runs slower than the LCD_MEMORY_INTERFACE. +// Depending on your needs, when using the LCD_PORT_INTERFACE, the LCD may +// be accessed in 8-bit or 4-bit mode. In 8-bit mode, one whole I/O port +// (pins 0-7) is required for the LCD data lines, but transfers are faster. +// In 4-bit mode, only I/O port pins 4-7 are needed for data lines, but LCD +// access is slower. In either mode, three additional port pins are +// required for the LCD interface control lines (RS, R/W, and E). + +// Enable one of the following interfaces to your LCD +//#define LCD_MEMORY_INTERFACE +#define USE_4BIT_LCD_INTERFACE +#define LCD_PORT_INTERFACE + +// LCD display geometry +// change these definitions to adapt settings +#define LCD_LINES 2 // visible lines +#define LCD_LINE_LENGTH 16 // line length (in characters) + + +// Enter the parameters for your chosen interface +// if you chose the LCD_PORT_INTERFACE: +#ifdef USE_4BIT_LCD_INTERFACE + #ifdef LCD_PORT_INTERFACE + #ifndef LCD_CTRL_PORT + // port and pins you will use for control lines + #define LCD_CTRL_PORT PORTD + #define LCD_CTRL_DDR DDRD + #define LCD_CTRL_RS 0 + #define LCD_CTRL_RW 1 + #define LCD_CTRL_E 2 + #endif + #ifndef LCD_DATA_POUT + // port you will use for data lines + #define LCD_DATA_POUT PORTD + #define LCD_DATA_PIN PIND + #define LCD_DATA_DDR DDRD + // access mode you will use (default is 8bit unless 4bit is selected) + #define LCD_DATA_4BIT + #endif + #endif +#else // USE 8BIT LCD INTERFACE + #ifdef LCD_PORT_INTERFACE + #ifndef LCD_CTRL_PORT + // port and pins you will use for control lines + #define LCD_CTRL_PORT PORTC + #define LCD_CTRL_DDR DDRC + #define LCD_CTRL_RS 7 + #define LCD_CTRL_RW 6 + #define LCD_CTRL_E 5 + #endif + #ifndef LCD_DATA_POUT + // port you will use for data lines + #define LCD_DATA_POUT PORTB + #define LCD_DATA_PIN PINB + #define LCD_DATA_DDR DDRB + #endif + #endif +#endif + + +// if you chose the LCD_MEMORY_INTERFACE: +#ifdef LCD_MEMORY_INTERFACE + #ifndef LCD_CTRL_ADDR + // CPU memory address of the LCD control register + #define LCD_CTRL_ADDR 0x1000 + #endif + #ifndef LCD_DATA_ADDR + // CPU memory address of the LCD data register + #define LCD_DATA_ADDR 0x1001 + #endif +#endif + + +// cursor position to DDRAM mapping +#define LCD_LINE0_DDRAMADDR 0x00 +#define LCD_LINE1_DDRAMADDR 0x40 +#define LCD_LINE2_DDRAMADDR 0x14 +#define LCD_LINE3_DDRAMADDR 0x54 + +// LCD delay +// This delay affects how quickly accesses are made to the LCD controller. +// The HD44780 LCD controller requires an access time of at least 1us. +// LCD_DELAY should be scaled to take at least half that time (500us). +// Each NOP takes 1 CPU clock cycle to execute. Thus, at 4MHz, you should +// use at least 2 NOPs, at 8MHz at least 4 NOPs, etc. +// You can also use the delay_us(xx) command for longer access times. + +// LCD_DELAY is now automatically set in lcd.h, +// however, if you define it here, this definition will override the automatic setting + +// use this for a fail-safe delay +// #define LCD_DELAY delay_us(5); + +#endif // LCDCONF_H diff --git a/Micropendous/Firmware/VirtualSerial_LCD/makefile b/Micropendous/Firmware/VirtualSerial_LCD/makefile index 67518f4b..8adee50d 100644 --- a/Micropendous/Firmware/VirtualSerial_LCD/makefile +++ b/Micropendous/Firmware/VirtualSerial_LCD/makefile @@ -17,10 +17,12 @@ BOARD = MICROPENDOUS_REV2 F_CPU = 16000000 F_USB = $(F_CPU) OPTIMIZATION = s -TARGET = VirtualSerial -SRC = $(TARGET).c Descriptors.c $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS) +TARGET = VirtualSerial_LCD +AVRLIB_PATH = ../../libs/avrlib +SRC = $(TARGET).c Descriptors.c $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS) \ + $(AVRLIB_PATH)/rprintf.c $(AVRLIB_PATH)/lcd.c $(AVRLIB_PATH)/timer.c LUFA_PATH = ../../libs/LUFA/LUFA -CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/ +CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/ -I$(AVRLIB_PATH) LD_FLAGS = CDC_BOOTLOADER_PORT = /dev/ttyACM0 #CDC_BOOTLOADER_PORT = COM5 diff --git a/Micropendous/libs/LUFA/LUFA/Drivers/Board/AVR8/MICROPENDOUS/LEDs.h b/Micropendous/libs/LUFA/LUFA/Drivers/Board/AVR8/MICROPENDOUS/LEDs.h index 44b35038..0a4ba584 100644 --- a/Micropendous/libs/LUFA/LUFA/Drivers/Board/AVR8/MICROPENDOUS/LEDs.h +++ b/Micropendous/libs/LUFA/LUFA/Drivers/Board/AVR8/MICROPENDOUS/LEDs.h @@ -131,46 +131,56 @@ #if !defined(__DOXYGEN__) static inline void LEDs_Init(void) { - _BOARD_LED_DDR |= LEDS_ALL_LEDS; - _BOARD_LED_PORT &= ~LEDS_ALL_LEDS; + //_BOARD_LED_DDR |= LEDS_ALL_LEDS; + //_BOARD_LED_PORT &= ~LEDS_ALL_LEDS; + DDRB |= (1 << PB1); + PORTB |= (1 << PB1); } static inline void LEDs_Disable(void) { - _BOARD_LED_DDR &= ~LEDS_ALL_LEDS; - _BOARD_LED_PORT &= ~LEDS_ALL_LEDS; + //_BOARD_LED_DDR &= ~LEDS_ALL_LEDS; + //_BOARD_LED_PORT &= ~LEDS_ALL_LEDS; + DDRB &= ~(1 << PB1); + PORTB &= ~(1 << PB1); } static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) { - _BOARD_LED_PORT |= LEDMask; + //_BOARD_LED_PORT |= LEDMask; + PORTB |= LEDMask; } static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) { - _BOARD_LED_PORT &= ~LEDMask; + //_BOARD_LED_PORT &= ~LEDMask; + PORTB &= ~LEDMask; } static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) { - _BOARD_LED_PORT = ((_BOARD_LED_PORT & ~LEDS_ALL_LEDS) | LEDMask); + //_BOARD_LED_PORT = ((_BOARD_LED_PORT & ~LEDS_ALL_LEDS) | LEDMask); + PORTB = ((_BOARD_LED_PORT & ~LEDS_ALL_LEDS) | LEDMask); } static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask) { - _BOARD_LED_PORT = ((_BOARD_LED_PORT & ~LEDMask) | ActiveMask); + //_BOARD_LED_PORT = ((_BOARD_LED_PORT & ~LEDMask) | ActiveMask); + PORTB = ((_BOARD_LED_PORT & ~LEDMask) | ActiveMask); } static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) { - _BOARD_LED_PIN = LEDMask; + //_BOARD_LED_PIN = LEDMask; + PORTB = LEDMask; } static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; static inline uint8_t LEDs_GetLEDs(void) { - return (_BOARD_LED_PORT & LEDS_ALL_LEDS); + //return (_BOARD_LED_PORT & LEDS_ALL_LEDS); + return (PORTB & (1 << PB0)); } #endif diff --git a/Micropendous/libs/avrlib/avrlibdefs.h b/Micropendous/libs/avrlib/avrlibdefs.h index a8dea503..3a9900fb 100644 --- a/Micropendous/libs/avrlib/avrlibdefs.h +++ b/Micropendous/libs/avrlib/avrlibdefs.h @@ -69,15 +69,28 @@ #define GNUC_PACKED __attribute__((packed)) // port address helpers -#define DDR(x) ((x)-1) // address of data direction register of port x -#define PIN(x) ((x)-2) // address of input register of port x +#ifndef DDR + #define DDR(x) ((x)-1) // address of data direction register of port x +#endif +#ifndef PIN + #define PIN(x) ((x)-2) // address of input register of port x +#endif // MIN/MAX/ABS macros -#define MIN(a,b) ((ab)?(a):(b)) -#define ABS(x) ((x>0)?(x):(-x)) +#ifndef MIN + #define MIN(a,b) ((ab)?(a):(b)) +#endif +#ifndef ABS + #define ABS(x) ((x>0)?(x):(-x)) +#endif // constants -#define PI 3.14159265359 - +#ifndef PI + #define PI 3.14159265359 #endif + +#endif // AVRLIBDEFS_H + diff --git a/Micropendous/libs/avrlib/lcd.c b/Micropendous/libs/avrlib/lcd.c index ce902a73..302501d3 100644 --- a/Micropendous/libs/avrlib/lcd.c +++ b/Micropendous/libs/avrlib/lcd.c @@ -25,7 +25,7 @@ #include "lcd.h" // custom LCD characters -unsigned char __attribute__ ((progmem)) LcdCustomChar[] = +unsigned const char __attribute__ ((progmem)) LcdCustomChar[] = { 0x00, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x00, // 0. 0/5 full progress block 0x00, 0x1F, 0x10, 0x10, 0x10, 0x10, 0x1F, 0x00, // 1. 1/5 full progress block @@ -419,7 +419,7 @@ void lcdPrintData(char* data, u08 nBytes) } } -#if (!defined(__AVR_AT90USB162__) && !defined(__AVR_AT90USB82__)) +#if (!defined(__AVR_AT90USB162__) && !defined(__AVR_AT90USB82__)) void lcdProgressBar(u16 progress, u16 maxprogress, u08 length) { u08 i; diff --git a/Micropendous/libs/avrlib/lcd.h b/Micropendous/libs/avrlib/lcd.h index a825ede5..ca89f073 100644 --- a/Micropendous/libs/avrlib/lcd.h +++ b/Micropendous/libs/avrlib/lcd.h @@ -103,7 +103,7 @@ #define LCD_MODE_DEFAULT ((1< is the value the bargraph should indicate // is the value at the end of the bargraph // is the number of LCD characters that the bargraph should cover -#if (!defined(__AVR_AT90USB162__) && !defined(__AVR_AT90USB82__)) -void lcdProgressBar(u16 progress, u16 maxprogress, u08 length); +#if (!defined(__AVR_AT90USB162__) && !defined(__AVR_AT90USB82__)) +void lcdProgressBar(u16 progress, u16 maxprogress, u08 length); #endif #endif diff --git a/Micropendous/libs/avrlib/rprintf.c b/Micropendous/libs/avrlib/rprintf.c index 55c8baff..c36f608a 100644 --- a/Micropendous/libs/avrlib/rprintf.c +++ b/Micropendous/libs/avrlib/rprintf.c @@ -42,7 +42,7 @@ //static char HexChars[] = "0123456789ABCDEF"; // use this to store hex conversion in program memory //static prog_char HexChars[] = "0123456789ABCDEF"; -static char __attribute__ ((progmem)) HexChars[] = "0123456789ABCDEF"; +static const char __attribute__ ((progmem)) HexChars[] = "0123456789ABCDEF"; #define hexchar(x) pgm_read_byte( HexChars+((x)&0x0f) ) //#define hexchar(x) ((((x)&0x0F)>9)?((x)+'A'-10):((x)+'0')) @@ -116,7 +116,7 @@ void rprintfStrLen(char str[], unsigned int start, unsigned int len) // *** rprintfProgStr *** // prints a null-terminated string stored in program ROM -void rprintfProgStr(const prog_char str[]) +void rprintfProgStr(const char *str) { // print a string stored in program memory register char c; diff --git a/Micropendous/libs/avrlib/rprintf.h b/Micropendous/libs/avrlib/rprintf.h index e5ac0432..d40a23a6 100644 --- a/Micropendous/libs/avrlib/rprintf.h +++ b/Micropendous/libs/avrlib/rprintf.h @@ -82,7 +82,7 @@ void rprintfStrLen(char str[], unsigned int start, unsigned int len); //! prints a string stored in program rom /// \note This function does not actually store your string in /// program rom, but merely reads it assuming you stored it properly. -void rprintfProgStr(const prog_char str[]); +void rprintfProgStr(const char str[]); //! Using the function rprintfProgStrM(...) automatically causes /// your string to be stored in ROM, thereby not wasting precious RAM. diff --git a/Micropendous/libs/avrlib/timer.c b/Micropendous/libs/avrlib/timer.c index fedebbf4..7dc57361 100644 --- a/Micropendous/libs/avrlib/timer.c +++ b/Micropendous/libs/avrlib/timer.c @@ -28,10 +28,10 @@ // Program ROM constants // the prescale division values stored in order of timer control register index // STOP, CLK, CLK/8, CLK/64, CLK/256, CLK/1024 -unsigned short __attribute__ ((progmem)) TimerPrescaleFactor[] = {0,1,8,64,256,1024}; +unsigned const short __attribute__ ((progmem)) TimerPrescaleFactor[] = {0,1,8,64,256,1024}; // the prescale division values stored in order of timer control register index // STOP, CLK, CLK/8, CLK/32, CLK/64, CLK/128, CLK/256, CLK/1024 -unsigned short __attribute__ ((progmem)) TimerRTCPrescaleFactor[] = {0,1,8,32,64,128,256,1024}; +unsigned const short __attribute__ ((progmem)) TimerRTCPrescaleFactor[] = {0,1,8,32,64,128,256,1024}; // Global variables // time registers diff --git a/Micropendous/libs/avrlib/xmodem.c b/Micropendous/libs/avrlib/xmodem.c index a87244d4..f2220aed 100644 --- a/Micropendous/libs/avrlib/xmodem.c +++ b/Micropendous/libs/avrlib/xmodem.c @@ -18,7 +18,7 @@ #include #include "rprintf.h" #include "timer.h" - + #include "xmodem.h" //#define XMODEM_BUFFER_SIZE 128 diff --git a/Micropendous/libs/avrlib/xmodem.h b/Micropendous/libs/avrlib/xmodem.h index 7d40ff49..71c799da 100644 --- a/Micropendous/libs/avrlib/xmodem.h +++ b/Micropendous/libs/avrlib/xmodem.h @@ -32,7 +32,7 @@ #ifndef XMODEM_H #define XMODEM_H - + // xmodem control characters #define SOH 0x01 #define STX 0x02