From 15e15a25d1f49a6be409006506359cab519545fe Mon Sep 17 00:00:00 2001 From: Kevin Townsend Date: Tue, 24 May 2011 00:05:32 +0200 Subject: [PATCH] Various changes for smartlcd boards --- ChangeLog.txt | 12 ++ build/codelite/LPC1343 Workspace.tags | Bin 99328 -> 104448 bytes .../LPC1343 Workspace.workspace.session | 22 +- build/crossworks/LPC1343_CodeBase.hzs | 19 +- core/cmd/cmd.c | 19 ++ drivers/lcd/tft/drawing.c | 3 +- main.c | 131 +++++------ project/commands/drawing/cmd_pixel.c | 3 +- projectconfig.h | 204 ++++++++---------- 9 files changed, 202 insertions(+), 211 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 3280b0d..b7ab346 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,6 +1,18 @@ v0.9.2 - Ongoing ================ +- Added CFG_INTERFACE_DROPCR to projectconfig.h to + ignore CR (\r) characters in incoming data for + the CLI +- Added CFG_INTERFACE_SHORTERRORS to projectconfig.h + to only send short (1 char + new line) CLI error + messages rather than something verbose +- Added CFG_INTERFACE_CONFIRMREADY to projectconfig.h + to provide a character to indicate when a command + is complete in case the IRQ pin + (CFG_INTERFACE_ENABLEIRQ) can't be used +- Fixed a bug with reversed R and B bits when reading + a pixel from the LCD in CLI mode - Added lcdDrawPixels() to lcd.h and the current lcd drivers to render rows of raw lcd data much quicker than addressing consecutive pixels individually. diff --git a/build/codelite/LPC1343 Workspace.tags b/build/codelite/LPC1343 Workspace.tags index e2fc66b2428d50de71e3dc724e41f211e1a9e1de..87d277c9d015be97d4e4d3ee5dff77dd22d4ad80 100644 GIT binary patch delta 5201 zcmeHLeQ*=k5#N39^kG28HV_*d;SVUr0Y^3%!lWel1LN`$Y|Eq`Y>X`|*%rummUOl; z*vKc_K$1yOx3{}*ci&r$9=49YU_FxO$Oiqhfc;=>=_NXo3b2UQs?-*F7U#+q zX$SSu-SoS(l{V5bdYBH;&9pWqeNJk(OO)|7OUTAu18mqCVuM#?LnF_I9ReH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E!5aRGfH5_AvYby!FDWNCwwT;nNdC$-FYYIAO4S5H3;JJi*upqZ1N5mVSg z8lK)<57MD^ALW7;S1PKY18;lvo^sXagR=%BtRXe24c?POe^xp(dbGdr$bpfc!?`(l z117>!6G_w(11LjK7M2QuTj-jI9+S%H=rO@WUj5-TwBXA#VAx!S6$H1@iY$HK6fE_m MqSDo?bI?To10!BUzyJUM diff --git a/build/codelite/LPC1343 Workspace.workspace.session b/build/codelite/LPC1343 Workspace.workspace.session index d0bdde6..043e2f6 100644 --- a/build/codelite/LPC1343 Workspace.workspace.session +++ b/build/codelite/LPC1343 Workspace.workspace.session @@ -1,24 +1,24 @@ - - - + + + - + - + - - - + + + - - - + + + diff --git a/build/crossworks/LPC1343_CodeBase.hzs b/build/crossworks/LPC1343_CodeBase.hzs index 0ebdfbc..04c3ea5 100644 --- a/build/crossworks/LPC1343_CodeBase.hzs +++ b/build/crossworks/LPC1343_CodeBase.hzs @@ -19,6 +19,15 @@ + + + + + + + + + @@ -38,10 +47,10 @@ - - - + + + @@ -54,8 +63,8 @@ - - + + diff --git a/core/cmd/cmd.c b/core/cmd/cmd.c index ee5ccf4..36c55fc 100644 --- a/core/cmd/cmd.c +++ b/core/cmd/cmd.c @@ -121,6 +121,9 @@ void cmdRx(uint8_t c) switch (c) { case '\r': + #if CFG_INTERFACE_DROPCR == 1 + break; + #endif case '\n': // terminate the msg and reset the msg ptr. then send // it to the handler for processing. @@ -163,6 +166,9 @@ static void cmdMenu() printf(CFG_PRINTF_NEWLINE); printf(CFG_INTERFACE_PROMPT); #endif + #if CFG_INTERFACE_CONFIRMREADY == 1 + printf("%s%s", CFG_INTERFACE_CONFIRMREADY_TEXT, CFG_PRINTF_NEWLINE); + #endif } /**************************************************************************/ @@ -201,14 +207,22 @@ void cmdParse(char *cmd) else if ((argc - 1) < cmd_tbl[i].minArgs) { // Too few arguments supplied + #if CFG_INTERFACE_SHORTERRORS == 1 + printf ("%s%s", CFG_INTERFACE_SHORTERRORS_TOOFEWARGS, CFG_PRINTF_NEWLINE); + #else printf ("Too few arguments (%d expected)%s", cmd_tbl[i].minArgs, CFG_PRINTF_NEWLINE); printf ("%sType '%s ?' for more information%s%s", CFG_PRINTF_NEWLINE, cmd_tbl[i].command, CFG_PRINTF_NEWLINE, CFG_PRINTF_NEWLINE); + #endif } else if ((argc - 1) > cmd_tbl[i].maxArgs) { // Too many arguments supplied + #if CFG_INTERFACE_SHORTERRORS == 1 + printf ("%s%s", CFG_INTERFACE_SHORTERRORS_TOOMANYARGS, CFG_PRINTF_NEWLINE); + #else printf ("Too many arguments (%d maximum)%s", cmd_tbl[i].maxArgs, CFG_PRINTF_NEWLINE); printf ("%sType '%s ?' for more information%s%s", CFG_PRINTF_NEWLINE, cmd_tbl[i].command, CFG_PRINTF_NEWLINE, CFG_PRINTF_NEWLINE); + #endif } else { @@ -229,10 +243,15 @@ void cmdParse(char *cmd) return; } } + // Command not recognized + #if CFG_INTERFACE_SHORTERRORS == 1 + printf ("%s%s", CFG_INTERFACE_SHORTERRORS_UNKNOWNCOMMAND, CFG_PRINTF_NEWLINE); + #else printf("Command not recognized: '%s'%s%s", cmd, CFG_PRINTF_NEWLINE, CFG_PRINTF_NEWLINE); #if CFG_INTERFACE_SILENTMODE == 0 printf("Type '?' for a list of all available commands%s", CFG_PRINTF_NEWLINE); #endif + #endif cmdMenu(); } diff --git a/drivers/lcd/tft/drawing.c b/drivers/lcd/tft/drawing.c index cd612e6..61acdf5 100644 --- a/drivers/lcd/tft/drawing.c +++ b/drivers/lcd/tft/drawing.c @@ -970,7 +970,7 @@ uint16_t drawBGR2RGB(uint16_t color) r = (color>>11) & 0x1f; return( (b<<11) + (g<<5) + (r<<0) ); -} +} /**************************************************************************/ /*! @@ -1131,7 +1131,6 @@ void drawButton(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const F void drawIcon16(uint16_t x, uint16_t y, uint16_t color, uint16_t icon[]) { int i; - uint16_t row; for (i = 0; i<16; i++) { if (icon[i] & (0X8000)) drawPixel(x, y+i, color); diff --git a/main.c b/main.c index 2011970..8b75435 100644 --- a/main.c +++ b/main.c @@ -7,7 +7,7 @@ Software License Agreement (BSD License) - Copyright (c) 2010, microBuilder SARL + Copyright (c) 2011, microBuilder SARL All rights reserved. Redistribution and use in source and binary forms, with or without @@ -33,109 +33,78 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /**************************************************************************/ +#include #include +#include #include "projectconfig.h" #include "sysinit.h" -#include "drivers/sensors/pn532/pn532.h" -#include "drivers/sensors/pn532/pn532_drvr.h" +#include "core/gpio/gpio.h" +#include "core/systick/systick.h" + +#ifdef CFG_INTERFACE + #include "core/cmd/cmd.h" +#endif /**************************************************************************/ /*! - Main program entry point. After reset, normal code execution will - begin here. + Approximates a 1 millisecond delay using "nop". This is less + accurate than a dedicated timer, but is useful in certain situations. - Note: CFG_INTERFACE is normally enabled by default. If you wish to - enable the blinking LED code in main, you will need to open - projectconfig.h, comment out "#define CFG_INTERFACE" and - rebuild the project. + The number of ticks to delay depends on the optimisation level set + when compiling (-O). Depending on the compiler settings, one of the + two defined values for 'delay' should be used. */ /**************************************************************************/ -int main (void) +void delayms(uint32_t ms) { - #ifdef CFG_INTERFACE - //#error "CFG_INTERFACE must be disabled in projectconfig.h for this demo" - #endif - #if !defined CFG_PRINTF_USBCDC - #error "CFG_PRINTF_USBCDC must be enabled in projectconfig.h for this demo" - #endif + uint32_t delay = ms * ((CFG_CPU_CCLK / 100) / 45); // Release Mode (-Os) + // uint32_t delay = ms * ((CFG_CPU_CCLK / 100) / 120); // Debug Mode (No optimisations) + + while (delay > 0) + { + __asm volatile ("nop"); + delay--; + } +} +/**************************************************************************/ +/*! + Main program entry point. After reset, normal code execution will + begin here. +*/ +/**************************************************************************/ +int main(void) +{ // Configure cpu and mandatory peripherals systemInit(); - - // Wait 5 second for someone to open the USB connection for printf - systickDelay(5000); - - // Initialise the PN532 - pn532Init(); - byte_t response[256]; - size_t responseLen; - pn532_error_t error; - - // Setup command to initialise a single ISO14443A target at 106kbps - byte_t abtCommand[] = { PN532_COMMAND_INLISTPASSIVETARGET, 0x01, PN532_MODULATION_ISO14443A_106KBPS }; + uint32_t currentSecond, lastSecond; + currentSecond = lastSecond = 0; while (1) { - printf("%s", CFG_PRINTF_NEWLINE); - printf("Wait for an ISO14443A card (Mifare Classic, etc.)%s", CFG_PRINTF_NEWLINE); - - // Send the command - error = pn532Write(abtCommand, sizeof(abtCommand)); - - // Wait until we get a response or an unexpected error message - do - { - error = pn532Read(response, &responseLen); - systickDelay(25); - } - #ifdef PN532_UART - while (error == PN532_ERROR_RESPONSEBUFFEREMPTY); - #endif - #ifdef PN532_SPI - while ((error == PN532_ERROR_RESPONSEBUFFEREMPTY) || (error = PN532_ERROR_SPIREADYSTATUSTIMEOUT)); - #endif - - // Print the card details if possible - if (!error) + // Toggle LED once per second ... rollover = 136 years :) + currentSecond = systickGetSecondsActive(); + if (currentSecond != lastSecond) { - /* Response for ISO14443A 106KBPS (Mifare Classic, etc.) - See UM0701-02 section 7.3.5 for more information - - byte Description - ------------- ------------------------------------------ - b7 Tags Found - b8 Tag Number (only one used in this example) - b9..10 SENS_RES - b11 SEL_RES - b12 NFCID Length - b13..NFCIDLen NFCID - - SENS_RES SEL_RES Manufacturer/Card Type NFCID Len - -------- ------- ----------------------- --------- - 00 04 08 NXP Mifare Classic 1K 4 bytes */ - - printf("%s", CFG_PRINTF_NEWLINE); - printf("%-12s: %d %s", "Tags Found", response[7], CFG_PRINTF_NEWLINE); - printf("%-12s: %02X %02X %s", "SENS_RES", response[9], response[10], CFG_PRINTF_NEWLINE); - printf("%-12s: %02X %s", "SEL_RES", response[11], CFG_PRINTF_NEWLINE); - printf("%-12s: ", "NFCID"); - size_t pos; - for (pos=0; pos < response[12]; pos++) + lastSecond = currentSecond; + if (gpioGetValue(CFG_LED_PORT, CFG_LED_PIN) == CFG_LED_OFF) { - printf("%02x ", response[13 + pos]); + gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_ON); + } + else + { + gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_OFF); } - printf(CFG_PRINTF_NEWLINE); - } - else - { - // Oops .... something bad happened. Check 'error' - printf("Ooops! Error %02X %s", error, CFG_PRINTF_NEWLINE); } - // Wait at least one second before trying again - systickDelay(1000); + // Poll for CLI input if CFG_INTERFACE is enabled in projectconfig.h + #ifdef CFG_INTERFACE + cmdPoll(); + #endif } + + return 0; } diff --git a/project/commands/drawing/cmd_pixel.c b/project/commands/drawing/cmd_pixel.c index 9aeffb8..45a7432 100644 --- a/project/commands/drawing/cmd_pixel.c +++ b/project/commands/drawing/cmd_pixel.c @@ -83,7 +83,8 @@ void cmd_getpixel(uint8_t argc, char **argv) getNumber (argv[0], &x); getNumber (argv[1], &y); - uint16_t value = lcdGetPixel(x, y); + // Get pixel and switch R and B + uint16_t value = drawBGR2RGB(lcdGetPixel(x, y)); // Output the results printf("%d%s", value, CFG_PRINTF_NEWLINE); diff --git a/projectconfig.h b/projectconfig.h index 489064d..88fddba 100644 --- a/projectconfig.h +++ b/projectconfig.h @@ -48,8 +48,9 @@ are using by enabling one of the following definitions. The code base will then try to configure itself accordingly for that board. -----------------------------------------------------------------------*/ - // #define CFG_BRD_LPC1343_REFDESIGN - #define CFG_BRD_LPC1343_TFTLCDSTANDALONE + #define CFG_BRD_LPC1343_REFDESIGN + // #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB + // #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART // #define CFG_BRD_LPC1343_802154USBSTICK /*=========================================================================*/ @@ -120,17 +121,7 @@ other peripherals to determine timing. -----------------------------------------------------------------------*/ - #ifdef CFG_BRD_LPC1343_REFDESIGN - #define CFG_CPU_CCLK (72000000) // 1 tick = 13.88nS - #endif - - #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE - #define CFG_CPU_CCLK (72000000) // 1 tick = 13.88nS - #endif - - #ifdef CFG_BRD_LPC1343_802154USBSTICK - #define CFG_CPU_CCLK (72000000) // 1 tick = 13.88nS - #endif + #define CFG_CPU_CCLK (72000000) // 1 tick = 13.88nS /*=========================================================================*/ @@ -142,17 +133,7 @@ of the systick timer. -----------------------------------------------------------------------*/ - #ifdef CFG_BRD_LPC1343_REFDESIGN - #define CFG_SYSTICK_DELAY_IN_MS (1) - #endif - - #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE - #define CFG_SYSTICK_DELAY_IN_MS (1) - #endif - - #ifdef CFG_BRD_LPC1343_802154USBSTICK - #define CFG_SYSTICK_DELAY_IN_MS (1) - #endif + #define CFG_SYSTICK_DELAY_IN_MS (1) /*=========================================================================*/ @@ -175,11 +156,16 @@ #define CFG_UART_BUFSIZE (512) #endif - #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE + #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB #define CFG_UART_BAUDRATE (115200) #define CFG_UART_BUFSIZE (512) #endif + #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART + #define CFG_UART_BAUDRATE (9600) + #define CFG_UART_BUFSIZE (512) + #endif + #ifdef CFG_BRD_LPC1343_802154USBSTICK #define CFG_UART_BAUDRATE (115200) #define CFG_UART_BUFSIZE (512) @@ -200,7 +186,7 @@ // #define CFG_SSP0_SCKPIN_0_6 #endif - #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE + #if defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB || defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART #define CFG_SSP0_SCKPIN_2_11 // #define CFG_SSP0_SCKPIN_0_6 #endif @@ -229,7 +215,7 @@ #define CFG_LED_OFF (1) #endif - #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE + #if defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB || defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART #define CFG_LED_PORT (2) #define CFG_LED_PIN (10) #define CFG_LED_ON (0) @@ -276,7 +262,7 @@ #define CFG_SDCARD_CDPIN (0) #endif - #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE + #if defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB || defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART #define CFG_SDCARD #define CFG_SDCARD_READONLY (1) // Must be 0 or 1 #define CFG_SDCARD_CDPORT (3) @@ -324,7 +310,7 @@ #define CFG_USBCDC_BUFFERSIZE (256) #endif - #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE + #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB // #define CFG_USBHID #define CFG_USBCDC #define CFG_USBCDC_BAUDRATE (115200) @@ -332,6 +318,14 @@ #define CFG_USBCDC_BUFFERSIZE (256) #endif + #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART + // #define CFG_USBHID + // #define CFG_USBCDC + #define CFG_USBCDC_BAUDRATE (115200) + #define CFG_USBCDC_INITTIMEOUT (5000) + #define CFG_USBCDC_BUFFERSIZE (256) + #endif + #ifdef CFG_BRD_LPC1343_802154USBSTICK // #define CFG_USBHID #define CFG_USBCDC @@ -350,7 +344,7 @@ redirected to UART CFG_PRINTF_USBCDC Will cause all printf statements to be redirect to USB Serial - CFG_PRINTF_NEWLINE This should be either "\r\n" for Windows or + CFG_PRINTF_NEWLINE This is typically "\r\n" for Windows or "\n" for *nix Note: If no printf redirection definitions are present, all printf @@ -361,19 +355,25 @@ #ifdef CFG_BRD_LPC1343_REFDESIGN // #define CFG_PRINTF_UART #define CFG_PRINTF_USBCDC - #define CFG_PRINTF_NEWLINE "\r\n" + #define CFG_PRINTF_NEWLINE "\n" #endif - #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE + #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB // #define CFG_PRINTF_UART #define CFG_PRINTF_USBCDC - #define CFG_PRINTF_NEWLINE "\r\n" + #define CFG_PRINTF_NEWLINE "\n" + #endif + + #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART + #define CFG_PRINTF_UART + // #define CFG_PRINTF_USBCDC + #define CFG_PRINTF_NEWLINE "\n" #endif #ifdef CFG_BRD_LPC1343_802154USBSTICK // #define CFG_PRINTF_UART #define CFG_PRINTF_USBCDC - #define CFG_PRINTF_NEWLINE "\r\n" + #define CFG_PRINTF_NEWLINE "\n" #endif /*=========================================================================*/ @@ -397,6 +397,8 @@ is normally only desirable in a situation where another MCU is communicating with the LPC1343. + CFG_INTERFACE_DROPCR If this is set to 1 all incoming \r + characters will be dropped CFG_INTERFACE_ENABLEIRQ If this is set to 1 the IRQ pin will be set high when a command starts executing and will go low when the command has @@ -405,6 +407,17 @@ new command can safely be sent. CFG_INTERFACE_IRQPORT The gpio port for the IRQ/busy pin CFG_INTERFACE_IRQPIN The gpio pin number for the IRQ/busy pin + CFG_INTERFACE_SHORTERRORS If this is enabled only short 1 character + error messages will be returned (followed + by CFG_PRINTF_NEWLINE), rather than more + verbose error messages. The specific + characters used are defined below. + CFG_INTERFACE_CONFIRMREADY If this is set to 1 a text confirmation + will be sent when the command prompt is + ready for a new command. This is in + addition to CFG_INTERFACE_ENABLEIRQ if + this is also enabled. The character used + is defined below. NOTE: The command-line interface will use either USB-CDC or UART depending on whether @@ -416,19 +429,46 @@ #define CFG_INTERFACE_MAXMSGSIZE (256) #define CFG_INTERFACE_PROMPT "LPC1343 >> " #define CFG_INTERFACE_SILENTMODE (0) + #define CFG_INTERFACE_DROPCR (1) #define CFG_INTERFACE_ENABLEIRQ (0) #define CFG_INTERFACE_IRQPORT (2) #define CFG_INTERFACE_IRQPIN (0) + #define CFG_INTERFACE_SHORTERRORS (0) + #define CFG_INTERFACE_CONFIRMREADY (0) #endif - #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE + #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB #define CFG_INTERFACE #define CFG_INTERFACE_MAXMSGSIZE (256) #define CFG_INTERFACE_PROMPT "LCD >> " #define CFG_INTERFACE_SILENTMODE (0) + #define CFG_INTERFACE_DROPCR (1) + #define CFG_INTERFACE_ENABLEIRQ (0) + #define CFG_INTERFACE_IRQPORT (2) + #define CFG_INTERFACE_IRQPIN (0) + #define CFG_INTERFACE_SHORTERRORS (0) + #define CFG_INTERFACE_CONFIRMREADY (0) + #define CFG_INTERFACE_SHORTERRORS_UNKNOWNCOMMAND "?" + #define CFG_INTERFACE_SHORTERRORS_TOOMANYARGS ">" + #define CFG_INTERFACE_SHORTERRORS_TOOFEWARGS "<" + #define CFG_INTERFACE_CONFIRMREADY_TEXT "." + #endif + + #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART + #define CFG_INTERFACE + #define CFG_INTERFACE_MAXMSGSIZE (256) + #define CFG_INTERFACE_PROMPT "LCD >> " + #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_SHORTERRORS (1) + #define CFG_INTERFACE_CONFIRMREADY (1) + #define CFG_INTERFACE_SHORTERRORS_UNKNOWNCOMMAND "?" + #define CFG_INTERFACE_SHORTERRORS_TOOMANYARGS ">" + #define CFG_INTERFACE_SHORTERRORS_TOOFEWARGS "<" + #define CFG_INTERFACE_CONFIRMREADY_TEXT "." #endif #ifdef CFG_BRD_LPC1343_802154USBSTICK @@ -436,9 +476,12 @@ #define CFG_INTERFACE_MAXMSGSIZE (256) #define CFG_INTERFACE_PROMPT "CMD >> " #define CFG_INTERFACE_SILENTMODE (0) + #define CFG_INTERFACE_DROPCR (1) #define CFG_INTERFACE_ENABLEIRQ (0) #define CFG_INTERFACE_IRQPORT (2) #define CFG_INTERFACE_IRQPIN (0) + #define CFG_INTERFACE_SHORTERRORS (0) + #define CFG_INTERFACE_CONFIRMREADY (0) #endif /*=========================================================================*/ @@ -461,23 +504,9 @@ DEPENDENCIES: PWM output requires the use of 16-bit timer 1 and pin 1.9 (CT16B1_MAT0). -----------------------------------------------------------------------*/ - #ifdef CFG_BRD_LPC1343_REFDESIGN - // #define CFG_PWM - #define CFG_PWM_DEFAULT_PULSEWIDTH (CFG_CPU_CCLK / 1000) - #define CFG_PWM_DEFAULT_DUTYCYCLE (50) - #endif - - #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE - // #define CFG_PWM - #define CFG_PWM_DEFAULT_PULSEWIDTH (CFG_CPU_CCLK / 1000) - #define CFG_PWM_DEFAULT_DUTYCYCLE (50) - #endif - - #ifdef CFG_BRD_LPC1343_802154USBSTICK - // #define CFG_PWM - #define CFG_PWM_DEFAULT_PULSEWIDTH (CFG_CPU_CCLK / 1000) - #define CFG_PWM_DEFAULT_DUTYCYCLE (50) - #endif + // #define CFG_PWM + #define CFG_PWM_DEFAULT_PULSEWIDTH (CFG_CPU_CCLK / 1000) + #define CFG_PWM_DEFAULT_DUTYCYCLE (50) /*=========================================================================*/ @@ -492,17 +521,7 @@ DEPENDENCIES: STEPPER requires the use of pins 3.0-3 and 32-bit Timer 0. -----------------------------------------------------------------------*/ - #ifdef CFG_BRD_LPC1343_REFDESIGN - // #define CFG_STEPPER - #endif - - #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE - // #define CFG_STEPPER - #endif - - #ifdef CFG_BRD_LPC1343_802154USBSTICK - // #define CFG_STEPPER - #endif + // #define CFG_STEPPER /*=========================================================================*/ @@ -520,9 +539,9 @@ #define CFG_I2CEEPROM_SIZE (3072) #endif - #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE + #if defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB || defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART #define CFG_I2CEEPROM - #define CFG_I2CEEPROM_SIZE (3072) + #define CFG_I2CEEPROM_SIZE (4096) #endif #ifdef CFG_BRD_LPC1343_802154USBSTICK @@ -589,17 +608,7 @@ build (requires external HW) -----------------------------------------------------------------------*/ - #ifdef CFG_BRD_LPC1343_REFDESIGN - // #define CFG_LM75B - #endif - - #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE - // #define CFG_LM75B - #endif - - #ifdef CFG_BRD_LPC1343_802154USBSTICK - // #define CFG_LM75B - #endif + // #define CFG_LM75B /*=========================================================================*/ @@ -639,7 +648,7 @@ #define CFG_CHIBI_BUFFERSIZE (128) #endif - #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE + #if defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB || defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART // #define CFG_CHIBI #define CFG_CHIBI_MODE (0) // OQPSK_868MHZ #define CFG_CHIBI_POWER (0xE9) // CHB_PWR_EU2_3DBM @@ -701,7 +710,7 @@ #define CFG_TFTLCD_TS_KEYPADDELAY (100) #endif - #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE + #if defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB || defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART #define CFG_TFTLCD #define CFG_TFTLCD_INCLUDESMALLFONTS (0) #define CFG_TFTLCD_TS_DEFAULTTHRESHOLD (50) @@ -733,20 +742,8 @@ DEPENDENCIES: ST7565 requires the use of pins 2.1-6. DEPENDENCIES: SSD1306 requires the use of pins 2.1-6. -----------------------------------------------------------------------*/ - #ifdef CFG_BRD_LPC1343_REFDESIGN - // #define CFG_ST7565 - // #define CFG_SSD1306 - #endif - - #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE - // #define CFG_ST7565 - // #define CFG_SSD1306 - #endif - - #ifdef CFG_BRD_LPC1343_802154USBSTICK - // #define CFG_ST7565 - // #define CFG_SSD1306 - #endif + // #define CFG_ST7565 + // #define CFG_SSD1306 /*=========================================================================*/ @@ -767,20 +764,8 @@ NOTE: Please note that Printf can not be used to display 64-bit values (%lld)! -----------------------------------------------------------------------*/ - #ifdef CFG_BRD_LPC1343_REFDESIGN - // #define CFG_RSA - #define CFG_RSA_BITS (32) - #endif - - #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE - // #define CFG_RSA - #define CFG_RSA_BITS (32) - #endif - - #ifdef CFG_BRD_LPC1343_802154USBSTICK - // #define CFG_RSA - #define CFG_RSA_BITS (32) - #endif + // #define CFG_RSA + #define CFG_RSA_BITS (32) /*=========================================================================*/ @@ -794,11 +779,8 @@ =========================================================================*/ -#if !defined CFG_BRD_LPC1343_REFDESIGN && !defined CFG_BRD_LPC1343_TFTLCDSTANDALONE && !defined CFG_BRD_LPC1343_802154USBSTICK - #error "You must defined a target board (CFG_BRD_LPC1343_REFDESIGN or CFG_BRD_LPC1343_TFTLCDSTANDALONE or CFG_BRD_LPC1343_802154USBSTICK)" -#endif -#if (defined CFG_BRD_LPC1343_REFDESIGN && defined CFG_BRD_LPC1343_TFTLCDSTANDALONE) || (defined CFG_BRD_LPC1343_TFTLCDSTANDALONE && defined CFG_BRD_LPC1343_802154USBSTICK) || (defined CFG_BRD_LPC1343_REFDESIGN && defined CFG_BRD_LPC1343_802154USBSTICK) - #error "Only one target board can be defined at a time" +#if !defined CFG_BRD_LPC1343_REFDESIGN && !defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB && !defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART && !defined CFG_BRD_LPC1343_802154USBSTICK + #error "You must defined a target board (CFG_BRD_LPC1343_REFDESIGN or CFG_BRD_LPC1343_TFTLCDSTANDALONE or CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART or CFG_BRD_LPC1343_802154USBSTICK)" #endif #if defined CFG_PRINTF_USBCDC && defined CFG_PRINTF_UART -- 2.20.1