From: Kevin Townsend Date: Tue, 14 Jun 2011 10:46:14 +0000 (+0200) Subject: Upgrade to v0.92 X-Git-Url: https://git.rohieb.name/hackover2013-badge-firmware.git/commitdiff_plain/43b7092bd42d639a527b32dae4af87e37528ef57?ds=inline Upgrade to v0.92 --- diff --git a/ChangeLog.txt b/ChangeLog.txt index b7ab346..3135a34 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,10 @@ v0.9.2 - Ongoing ================ +- Added ISL12022M RTC Driver (/drivers/rtc/isl12022m) +- Fixed a bug drawing filled circles with lcdDrawVLine +- Added CLI command to toggle LCD backlight +- Added rounded rectangle command to CLI - Added CFG_INTERFACE_DROPCR to projectconfig.h to ignore CR (\r) characters in incoming data for the CLI diff --git a/Makefile b/Makefile index 57e7680..789305a 100644 --- a/Makefile +++ b/Makefile @@ -26,7 +26,7 @@ VPATH += project/commands OBJS += cmd_chibi_addr.o cmd_chibi_tx.o cmd_uart.o OBJS += cmd_i2ceeprom_read.o cmd_i2ceeprom_write.o cmd_lm75b_gettemp.o OBJS += cmd_sysinfo.o cmd_sd_dir.o cmd_tswait.o cmd_orientation.o -OBJS += cmd_tsthreshhold.o +OBJS += cmd_tsthreshhold.o cmd_backlight.o VPATH += project/commands/drawing OBJS += cmd_button.o cmd_circle.o cmd_clear.o cmd_line.o cmd_pixel.o @@ -49,6 +49,10 @@ OBJS += eeprom.o mcp24aa.o VPATH += drivers/sensors/lm75b OBJS += lm75b.o +# ISL12022M RTC +VPATH += drivers/rtc/isl12022m +OBJS += isl12022m.o + # TFT LCD support VPATH += drivers/lcd/tft drivers/lcd/tft/hw drivers/lcd/tft/fonts VPATH += drivers/lcd/tft/dialogues diff --git a/build/codelite/LPC1343 Workspace.tags b/build/codelite/LPC1343 Workspace.tags index 87d277c..ce7c0c6 100644 Binary files a/build/codelite/LPC1343 Workspace.tags and b/build/codelite/LPC1343 Workspace.tags differ diff --git a/build/codelite/LPC1343 Workspace.workspace.session b/build/codelite/LPC1343 Workspace.workspace.session index 043e2f6..9b71f5c 100644 --- a/build/codelite/LPC1343 Workspace.workspace.session +++ b/build/codelite/LPC1343 Workspace.workspace.session @@ -1,24 +1,18 @@ - - - + + + - - - + + + - - - - - - - - - + + + diff --git a/build/codelite/LPC1343_CodeBase.project b/build/codelite/LPC1343_CodeBase.project index a7dade6..582d2f6 100644 --- a/build/codelite/LPC1343_CodeBase.project +++ b/build/codelite/LPC1343_CodeBase.project @@ -226,6 +226,12 @@ + + + + + + @@ -269,6 +275,7 @@ + diff --git a/build/crossworks/LPC1343_CodeBase.hzp b/build/crossworks/LPC1343_CodeBase.hzp index 0bab7e7..2f55d51 100644 --- a/build/crossworks/LPC1343_CodeBase.hzp +++ b/build/crossworks/LPC1343_CodeBase.hzp @@ -202,6 +202,10 @@ + + + + @@ -265,6 +269,11 @@ + + + + + @@ -327,6 +336,7 @@ + diff --git a/build/crossworks/LPC1343_CodeBase.hzs b/build/crossworks/LPC1343_CodeBase.hzs index e4030ae..9eb6627 100644 --- a/build/crossworks/LPC1343_CodeBase.hzs +++ b/build/crossworks/LPC1343_CodeBase.hzs @@ -19,6 +19,13 @@ + + + + + + + @@ -54,8 +61,7 @@ - - + - + diff --git a/core/i2c/i2c.h b/core/i2c/i2c.h index 9ed49be..4e700a4 100644 --- a/core/i2c/i2c.h +++ b/core/i2c/i2c.h @@ -39,7 +39,7 @@ #define FAST_MODE_PLUS 0 -#define I2C_BUFSIZE 6 +#define I2C_BUFSIZE 16 #define MAX_TIMEOUT 0x00FFFFFF #define I2CMASTER 0x01 diff --git a/drivers/chibi/chb.c b/drivers/chibi/chb.c index e5a56dd..2c02f1a 100644 --- a/drivers/chibi/chb.c +++ b/drivers/chibi/chb.c @@ -104,7 +104,8 @@ static U8 chb_gen_hdr(U8 *hdr, U16 addr, U8 len) /**************************************************************************/ U8 chb_write(U16 addr, U8 *data, U8 len) { - U8 status, frm_len, hdr_len, hdr[CHB_HDR_SZ + 1]; + // U8 status, frm_len, hdr_len, hdr[CHB_HDR_SZ + 1]; + U8 status, frm_len, hdr[CHB_HDR_SZ + 1]; while (len > 0) { @@ -113,7 +114,8 @@ U8 chb_write(U16 addr, U8 *data, U8 len) frm_len = (len > CHB_MAX_PAYLOAD) ? CHB_MAX_PAYLOAD : len; // gen frame header - hdr_len = chb_gen_hdr(hdr, addr, frm_len); + // hdr_len = chb_gen_hdr(hdr, addr, frm_len); + chb_gen_hdr(hdr, addr, frm_len); // send data to chip status = chb_tx(hdr, data, frm_len); diff --git a/drivers/chibi/chb_drvr.c b/drivers/chibi/chb_drvr.c index c56531a..4147725 100644 --- a/drivers/chibi/chb_drvr.c +++ b/drivers/chibi/chb_drvr.c @@ -178,7 +178,7 @@ U16 chb_reg_read16(U8 addr) /**************************************************************************/ void chb_reg_write(U8 addr, U8 val) { - U8 dummy; + // U8 dummy; /* Add the Register Write command to the address. */ addr |= 0xC0; @@ -187,8 +187,10 @@ void chb_reg_write(U8 addr, U8 val) CHB_SPI_ENABLE(); /*Send Register address and write register content.*/ - dummy = chb_xfer_byte(addr); - dummy = chb_xfer_byte(val); + // dummy = chb_xfer_byte(addr); + // dummy = chb_xfer_byte(val); + chb_xfer_byte(addr); + chb_xfer_byte(val); CHB_SPI_DISABLE(); CHB_LEAVE_CRIT(); @@ -247,7 +249,8 @@ void chb_reg_read_mod_write(U8 addr, U8 val, U8 mask) /**************************************************************************/ void chb_frame_write(U8 *hdr, U8 hdr_len, U8 *data, U8 data_len) { - U8 i, dummy; + //U8 i, dummy; + U8 i; // dont allow transmission longer than max frame size if ((hdr_len + data_len) > 127) @@ -260,18 +263,21 @@ void chb_frame_write(U8 *hdr, U8 hdr_len, U8 *data, U8 data_len) CHB_SPI_ENABLE(); // send fifo write command - dummy = chb_xfer_byte(CHB_SPI_CMD_FW); + // dummy = chb_xfer_byte(CHB_SPI_CMD_FW); + chb_xfer_byte(CHB_SPI_CMD_FW); // write hdr contents to fifo for (i=0; i [ ]'" }, { "C", 0, 0, 0, cmd_calibrate , "Calibrate Touch Screen" , CMD_NOPARAMS }, { "F", 0, 1, 0, cmd_clear , "Fill" , "'F []'" }, + { "g", 2, 2, 0, cmd_getpixel , "Get Pixel" , "'g '" }, { "l", 5, 7, 0, cmd_line , "Line" , "'l [ ]'" }, + { "L", 1, 1, 0, cmd_backlight , "Backlight" , "'L <0|1>'" }, { "o", 0, 1, 0, cmd_orientation , "LCD Orientation" , "'o [<0|1>]'" }, { "p", 3, 3, 0, cmd_pixel , "Draw Pixel" , "'p '" }, { "P", 9, 9, 0, cmd_progress , "Progress Bar" , "'P <%> '" }, { "r", 5, 7, 0, cmd_rectangle , "Rectangle" , "'r [ ]'" }, - { "R", 2, 2, 0, cmd_getpixel , "Read Pixel" , "'R '" }, + { "R", 7, 7, 0, cmd_rectangleround , "Rounded Rectangle" , "'R '" }, { "s", 2, 99, 0, cmd_textw , "Text Width" , "'s '" }, { "t", 5, 99, 0, cmd_text , "Text" , "'t '" }, { "T", 0, 0, 0, cmd_gettext , "Text Dialogue" , CMD_NOPARAMS }, diff --git a/project/commands/cmd_sysinfo.c b/project/commands/cmd_sysinfo.c index 36b66e9..ead3aa8 100644 --- a/project/commands/cmd_sysinfo.c +++ b/project/commands/cmd_sysinfo.c @@ -91,7 +91,7 @@ void cmd_sysinfo(uint8_t argc, char **argv) #ifdef CFG_PRINTF_UART uart_pcb_t *pcb = uartGetPCB(); - printf("%-25s : %d %s", "UART Baud Rate", pcb->baudrate, CFG_PRINTF_NEWLINE); + printf("%-25s : %u %s", "UART Baud Rate", (unsigned int)(pcb->baudrate), CFG_PRINTF_NEWLINE); #endif // TFT LCD Settings (if CFG_TFTLCD enabled) diff --git a/project/commands/cmd_uart.c b/project/commands/cmd_uart.c index 8e634f4..74ad470 100644 --- a/project/commands/cmd_uart.c +++ b/project/commands/cmd_uart.c @@ -78,9 +78,18 @@ void cmd_uart(uint8_t argc, char **argv) // Display the current baud rate #ifdef CFG_PRINTF_UART uart_pcb_t *pcb = uartGetPCB(); - printf("%d%s", pcb->baudrate, CFG_PRINTF_NEWLINE); + printf("%u%s", (unsigned int)(pcb->baudrate), CFG_PRINTF_NEWLINE); #else - printf("UART not initialised (using USBCDC)%s", CFG_PRINTF_NEWLINE); + // Try to get UART from EEPROM + uint32_t uartEEPROM = eepromReadU32(CFG_EEPROM_UART_SPEED); + if ((uartEEPROM < 9600) || (uartEEPROM > 115200)) + { + printf("UART not set in EEPROM%s", CFG_PRINTF_NEWLINE); + } + else + { + printf("%u%s", uartEEPROM, CFG_PRINTF_NEWLINE); + } #endif } } diff --git a/project/commands/drawing/cmd_rectangle.c b/project/commands/drawing/cmd_rectangle.c index 581d864..2750d1d 100644 --- a/project/commands/drawing/cmd_rectangle.c +++ b/project/commands/drawing/cmd_rectangle.c @@ -94,4 +94,39 @@ void cmd_rectangle(uint8_t argc, char **argv) } } +/**************************************************************************/ +/*! + Displays a rectangle with rounded corners on the LCD. +*/ +/**************************************************************************/ +void cmd_rectangleround(uint8_t argc, char **argv) +{ + int32_t x1, y1, x2, y2, c, radius, corners; + + // Convert supplied parameters + getNumber (argv[0], &x1); + getNumber (argv[1], &y1); + getNumber (argv[2], &x2); + getNumber (argv[3], &y2); + getNumber (argv[4], &c); + getNumber (argv[5], &radius); + getNumber (argv[6], &corners); + + // ToDo: Validate data! + if (c < 0 || c > 0xFFFF) + { + printf("Invalid Color%s", CFG_PRINTF_NEWLINE); + return; + } + + if ((radius == 0) || (corners == 0) || (corners > 5)) + { + drawRectangleFilled(x1, y1, x2, y2, (uint16_t)c); + } + else + { + drawRectangleRounded(x1, y1, x2, y2, (uint16_t)c, radius, corners); + } +} + #endif diff --git a/project/commands/drawing/cmd_text.c b/project/commands/drawing/cmd_text.c index ac3bc7c..871d5e0 100644 --- a/project/commands/drawing/cmd_text.c +++ b/project/commands/drawing/cmd_text.c @@ -48,6 +48,12 @@ #include "drivers/lcd/tft/drawing.h" #include "drivers/lcd/tft/fonts/dejavusans9.h" + // Only include this w/UART since there isn't enough space otherwise! + #ifdef CFG_PRINTF_UART + #include "drivers/lcd/tft/fonts/dejavusansmono8.h" + #include "drivers/lcd/tft/fonts/dejavusansbold9.h" + #endif + /**************************************************************************/ /*! Displays the supplied text on the LCD. @@ -77,8 +83,24 @@ void cmd_text(uint8_t argc, char **argv) } *data_ptr++ = '\0'; - // Only Vera Mono 9 is used by default - drawString((uint16_t)x, (uint16_t)y, (uint16_t)color, &dejaVuSans9ptFontInfo, (char *)&data); + // Only include this w/UART since there isn't enough space otherwise! + #ifdef CFG_PRINTF_UART + switch (font) + { + case 1: // DejaVu Sans Mono 8 + drawString((uint16_t)x, (uint16_t)y, (uint16_t)color, &dejaVuSansMono8ptFontInfo, (char *)&data); + break; + case 2: // DejaVu Sans Bold 9 + drawString((uint16_t)x, (uint16_t)y, (uint16_t)color, &dejaVuSansBold9ptFontInfo, (char *)&data); + break; + default: // DejaVu Sans 9 + drawString((uint16_t)x, (uint16_t)y, (uint16_t)color, &dejaVuSans9ptFontInfo, (char *)&data); + break; + } + #else + // Always use Vera Mono 9 is used by default + drawString((uint16_t)x, (uint16_t)y, (uint16_t)color, &dejaVuSans9ptFontInfo, (char *)&data); + #endif } #endif diff --git a/project/commands/drawing/cmd_textw.c b/project/commands/drawing/cmd_textw.c index 53d57d3..d116b77 100644 --- a/project/commands/drawing/cmd_textw.c +++ b/project/commands/drawing/cmd_textw.c @@ -48,6 +48,12 @@ #include "drivers/lcd/tft/drawing.h" #include "drivers/lcd/tft/fonts/dejavusans9.h" + // Only include this w/UART since there isn't enough space otherwise! + #ifdef CFG_PRINTF_UART + #include "drivers/lcd/tft/fonts/dejavusansmono8.h" + #include "drivers/lcd/tft/fonts/dejavusansbold9.h" + #endif + /**************************************************************************/ /*! Returns the width of the supplied text in pixels. @@ -73,8 +79,25 @@ void cmd_textw(uint8_t argc, char **argv) } *data_ptr++ = '\0'; - // User Vera Mono 9 by default for now - printf("%d %s", drawGetStringWidth(&dejaVuSans9ptFontInfo, data), CFG_PRINTF_NEWLINE); + // Only include this w/UART since there isn't enough space otherwise! + #ifdef CFG_PRINTF_UART + switch (font) + { + case 1: // DejaVu Sans Mono 8 + printf("%d %s", drawGetStringWidth(&dejaVuSansMono8ptFontInfo, data), CFG_PRINTF_NEWLINE); + break; + case 2: // DejaVu Sans Bold 9 + printf("%d %s", drawGetStringWidth(&dejaVuSansBold9ptFontInfo, data), CFG_PRINTF_NEWLINE); + break; + default: // DejaVu Sans 9 + printf("%d %s", drawGetStringWidth(&dejaVuSans9ptFontInfo, data), CFG_PRINTF_NEWLINE); + break; + } + #else + // Always use DejaVu Sans 9 by default + printf("%d %s", drawGetStringWidth(&dejaVuSans9ptFontInfo, data), CFG_PRINTF_NEWLINE); + #endif + return; } diff --git a/project/commands/drawing/cmd_tswait.c b/project/commands/drawing/cmd_tswait.c index 6a75183..e43e5b4 100644 --- a/project/commands/drawing/cmd_tswait.c +++ b/project/commands/drawing/cmd_tswait.c @@ -80,12 +80,12 @@ void cmd_tswait(uint8_t argc, char **argv) if (error == TS_ERROR_NONE) { // A valid touch event occurred ... parse data - printf("%d, %d%s",(int)data.xlcd, (int)data.ylcd, CFG_PRINTF_NEWLINE); + printf("%d,%d%s",(int)data.xlcd, (int)data.ylcd, CFG_PRINTF_NEWLINE); } else { // Display error code - printf("%d %s", (int)error, CFG_PRINTF_NEWLINE); + printf("%d%s", (int)error, CFG_PRINTF_NEWLINE); } return; diff --git a/projectconfig.h b/projectconfig.h index 88fddba..28269c8 100644 --- a/projectconfig.h +++ b/projectconfig.h @@ -102,6 +102,28 @@ **************************************************************************/ +/************************************************************************** + I2C Addresses + ----------------------------------------------------------------------- + The following addresses are used by the different I2C sensors included + in the code base [1] + + HEX BINARY + ==== ======== + ISL12022M (RTC) 0xDE 1101111x + ISL12022M (SRAM) 0xAE 1010111x + LM75B 0x90 1001000x + MCP24AA 0xA0 1010000x + MCP4725 0xC0 1100000x + TSL2561 0x72 0111001x + TCS3414 0x72 0111001x + + [1] Alternative addresses may exists, but the addresses listed in this + table are the values used in the code base + + **************************************************************************/ + + /*========================================================================= FIRMWARE VERSION SETTINGS -----------------------------------------------------------------------*/ @@ -162,7 +184,7 @@ #endif #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART - #define CFG_UART_BAUDRATE (9600) + #define CFG_UART_BAUDRATE (57600) #define CFG_UART_BUFSIZE (512) #endif @@ -355,13 +377,13 @@ #ifdef CFG_BRD_LPC1343_REFDESIGN // #define CFG_PRINTF_UART #define CFG_PRINTF_USBCDC - #define CFG_PRINTF_NEWLINE "\n" + #define CFG_PRINTF_NEWLINE "\r\n" #endif #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB // #define CFG_PRINTF_UART #define CFG_PRINTF_USBCDC - #define CFG_PRINTF_NEWLINE "\n" + #define CFG_PRINTF_NEWLINE "\r\n" #endif #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART @@ -373,7 +395,7 @@ #ifdef CFG_BRD_LPC1343_802154USBSTICK // #define CFG_PRINTF_UART #define CFG_PRINTF_USBCDC - #define CFG_PRINTF_NEWLINE "\n" + #define CFG_PRINTF_NEWLINE "\r\n" #endif /*=========================================================================*/ @@ -429,10 +451,10 @@ #define CFG_INTERFACE_MAXMSGSIZE (256) #define CFG_INTERFACE_PROMPT "LPC1343 >> " #define CFG_INTERFACE_SILENTMODE (0) - #define CFG_INTERFACE_DROPCR (1) + #define CFG_INTERFACE_DROPCR (0) #define CFG_INTERFACE_ENABLEIRQ (0) - #define CFG_INTERFACE_IRQPORT (2) - #define CFG_INTERFACE_IRQPIN (0) + #define CFG_INTERFACE_IRQPORT (0) + #define CFG_INTERFACE_IRQPIN (7) #define CFG_INTERFACE_SHORTERRORS (0) #define CFG_INTERFACE_CONFIRMREADY (0) #endif @@ -442,10 +464,10 @@ #define CFG_INTERFACE_MAXMSGSIZE (256) #define CFG_INTERFACE_PROMPT "LCD >> " #define CFG_INTERFACE_SILENTMODE (0) - #define CFG_INTERFACE_DROPCR (1) + #define CFG_INTERFACE_DROPCR (0) #define CFG_INTERFACE_ENABLEIRQ (0) - #define CFG_INTERFACE_IRQPORT (2) - #define CFG_INTERFACE_IRQPIN (0) + #define CFG_INTERFACE_IRQPORT (0) + #define CFG_INTERFACE_IRQPIN (7) #define CFG_INTERFACE_SHORTERRORS (0) #define CFG_INTERFACE_CONFIRMREADY (0) #define CFG_INTERFACE_SHORTERRORS_UNKNOWNCOMMAND "?" @@ -461,10 +483,10 @@ #define CFG_INTERFACE_SILENTMODE (1) #define CFG_INTERFACE_DROPCR (1) #define CFG_INTERFACE_ENABLEIRQ (1) - #define CFG_INTERFACE_IRQPORT (2) - #define CFG_INTERFACE_IRQPIN (0) + #define CFG_INTERFACE_IRQPORT (0) + #define CFG_INTERFACE_IRQPIN (7) #define CFG_INTERFACE_SHORTERRORS (1) - #define CFG_INTERFACE_CONFIRMREADY (1) + #define CFG_INTERFACE_CONFIRMREADY (0) #define CFG_INTERFACE_SHORTERRORS_UNKNOWNCOMMAND "?" #define CFG_INTERFACE_SHORTERRORS_TOOMANYARGS ">" #define CFG_INTERFACE_SHORTERRORS_TOOFEWARGS "<" @@ -476,10 +498,10 @@ #define CFG_INTERFACE_MAXMSGSIZE (256) #define CFG_INTERFACE_PROMPT "CMD >> " #define CFG_INTERFACE_SILENTMODE (0) - #define CFG_INTERFACE_DROPCR (1) + #define CFG_INTERFACE_DROPCR (0) #define CFG_INTERFACE_ENABLEIRQ (0) - #define CFG_INTERFACE_IRQPORT (2) - #define CFG_INTERFACE_IRQPIN (0) + #define CFG_INTERFACE_IRQPORT (0) + #define CFG_INTERFACE_IRQPIN (7) #define CFG_INTERFACE_SHORTERRORS (0) #define CFG_INTERFACE_CONFIRMREADY (0) #endif @@ -541,7 +563,7 @@ #if defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB || defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART #define CFG_I2CEEPROM - #define CFG_I2CEEPROM_SIZE (4096) + #define CFG_I2CEEPROM_SIZE (3072) #endif #ifdef CFG_BRD_LPC1343_802154USBSTICK @@ -586,6 +608,7 @@ #define CFG_EEPROM_RESERVED (0x00FF) // Protect first 256 bytes of memory #define CFG_EEPROM_CHIBI_IEEEADDR (uint16_t)(0x0000) // 8 #define CFG_EEPROM_CHIBI_SHORTADDR (uint16_t)(0x0009) // 2 + #define CFG_EEPROM_UART_SPEED (uint16_t)(0x0020) // 4 #define CFG_EEPROM_TOUCHSCREEN_CALIBRATED (uint16_t)(0x0030) // 1 #define CFG_EEPROM_TOUCHSCREEN_CAL_AN (uint16_t)(0x0031) // 4 #define CFG_EEPROM_TOUCHSCREEN_CAL_BN (uint16_t)(0x0035) // 4 @@ -595,7 +618,6 @@ #define CFG_EEPROM_TOUCHSCREEN_CAL_FN (uint16_t)(0x0045) // 4 #define CFG_EEPROM_TOUCHSCREEN_CAL_DIVIDER (uint16_t)(0x0049) // 4 #define CFG_EEPROM_TOUCHSCREEN_THRESHHOLD (uint16_t)(0x004D) // 1 - #define CFG_EEPROM_UART_SPEED (uint16_t)(0x0020) // 4 /*=========================================================================*/