Skip to content

Commit 15e15a2

Browse files
author
Kevin Townsend
committed
Various changes for smartlcd boards
1 parent 3046bd0 commit 15e15a2

File tree

9 files changed

+202
-211
lines changed

9 files changed

+202
-211
lines changed

ChangeLog.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,18 @@
11
v0.9.2 - Ongoing
22
================
33

4+
- Added CFG_INTERFACE_DROPCR to projectconfig.h to
5+
ignore CR (\r) characters in incoming data for
6+
the CLI
7+
- Added CFG_INTERFACE_SHORTERRORS to projectconfig.h
8+
to only send short (1 char + new line) CLI error
9+
messages rather than something verbose
10+
- Added CFG_INTERFACE_CONFIRMREADY to projectconfig.h
11+
to provide a character to indicate when a command
12+
is complete in case the IRQ pin
13+
(CFG_INTERFACE_ENABLEIRQ) can't be used
14+
- Fixed a bug with reversed R and B bits when reading
15+
a pixel from the LCD in CLI mode
416
- Added lcdDrawPixels() to lcd.h and the current lcd
517
drivers to render rows of raw lcd data much quicker
618
than addressing consecutive pixels individually.
5 KB
Binary file not shown.

build/codelite/LPC1343 Workspace.workspace.session

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<Session Name="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase\build\codelite\LPC1343 Workspace.workspace">
3-
<int Value="1" Name="m_selectedTab"/>
4-
<wxString Value="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase\build\codelite\LPC1343 Workspace.workspace" Name="m_workspaceName"/>
2+
<Session Name="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\build\codelite\LPC1343 Workspace.workspace">
3+
<int Value="2" Name="m_selectedTab"/>
4+
<wxString Value="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\build\codelite\LPC1343 Workspace.workspace" Name="m_workspaceName"/>
55
<TabInfoArray Name="TabInfoArray">
66
<TabInfo>
7-
<wxString Value="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase\Makefile" Name="FileName"/>
7+
<wxString Value="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" Name="FileName"/>
88
<int Value="0" Name="FirstVisibleLine"/>
9-
<int Value="22" Name="CurrentLine"/>
9+
<int Value="35" Name="CurrentLine"/>
1010
<wxArrayString Name="Bookmarks"/>
1111
</TabInfo>
1212
<TabInfo>
13-
<wxString Value="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase\main.c" Name="FileName"/>
14-
<int Value="66" Name="FirstVisibleLine"/>
15-
<int Value="45" Name="CurrentLine"/>
13+
<wxString Value="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\Makefile" Name="FileName"/>
14+
<int Value="0" Name="FirstVisibleLine"/>
15+
<int Value="11" Name="CurrentLine"/>
1616
<wxArrayString Name="Bookmarks"/>
1717
</TabInfo>
1818
<TabInfo>
19-
<wxString Value="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase\projectconfig.h" Name="FileName"/>
20-
<int Value="18" Name="FirstVisibleLine"/>
21-
<int Value="50" Name="CurrentLine"/>
19+
<wxString Value="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\drivers\lcd\tft\drawing.c" Name="FileName"/>
20+
<int Value="1123" Name="FirstVisibleLine"/>
21+
<int Value="1146" Name="CurrentLine"/>
2222
<wxArrayString Name="Bookmarks"/>
2323
</TabInfo>
2424
</TabInfoArray>

build/crossworks/LPC1343_CodeBase.hzs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,15 @@
1919
<ProjectSessionItem path="LPC1343_CodeBase" name="unnamed" />
2020
<ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase" name="unnamed" />
2121
<ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files" name="unnamed" />
22+
<ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;core" name="unnamed" />
23+
<ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;core;cmd" name="unnamed" />
24+
<ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers" name="unnamed" />
25+
<ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers;lcd" name="unnamed" />
26+
<ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers;lcd;tft" name="unnamed" />
27+
<ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers;lcd;tft;hw" name="unnamed" />
28+
<ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;project" name="unnamed" />
29+
<ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;project;commands" name="unnamed" />
30+
<ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;project;commands;drawing" name="unnamed" />
2231
</Project>
2332
<Register1>
2433
<RegisterWindow openNodes="GPIO2;SSP0/SSP0CR0;SSP0/SSP0CR1;SSP0/SSP0CPSR;SYSCON" binaryNodes="GPIO1/GPIO1DATA;GPIO2/GPIO2DATA;GPIO2/GPIO2DIR;GPIO3/GPIO3DATA" hiddenNodes="" unsignedNodes="" visibleGroups="GPIO2;SSP0;GPIO1;CPU;GPIO3;SCB;SYSCON" decimalNodes="" octalNodes="" asciiNodes="" />
@@ -38,10 +47,10 @@
3847
</TraceWindow>
3948
<Watch1>
4049
<Watches active="1" update="Each Second" >
41-
<Watchpoint linenumber="66" radix="10" name="msTicks" expression="msTicks" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/core/systick/systick.c" />
42-
<Watchpoint linenumber="138" radix="16" name="timer32_0_counter" expression="timer32_0_counter" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/core/timer32/timer32.c" />
43-
<Watchpoint linenumber="155" radix="-1" name="xTickCount" expression="xTickCount" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/freertos/tasks.c" />
4450
<Watchpoint linenumber="155" radix="16" name="Tick" expression="Tick" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/freertos/tasks.c" />
51+
<Watchpoint linenumber="155" radix="-1" name="xTickCount" expression="xTickCount" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/freertos/tasks.c" />
52+
<Watchpoint linenumber="138" radix="16" name="timer32_0_counter" expression="timer32_0_counter" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/core/timer32/timer32.c" />
53+
<Watchpoint linenumber="66" radix="10" name="msTicks" expression="msTicks" filename="c:/documents and settings/kevin/my documents/my dropbox/microbuilder/code/lpc1343/lpc1343_codebase/core/systick/systick.c" />
4554
</Watches>
4655
</Watch1>
4756
<Watch2>
@@ -54,8 +63,8 @@
5463
<Watches active="0" update="Never" />
5564
</Watch4>
5665
<Files>
57-
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="71" debugPath="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase\main.c" y="17" path="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase\main.c" left="0" selected="1" name="unnamed" top="0" />
58-
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase\projectconfig.h" y="281" path="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase\projectconfig.h" left="0" selected="0" name="unnamed" top="247" />
66+
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" y="0" path="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" left="0" selected="1" name="unnamed" top="84" />
67+
<SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="45" debugPath="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\projectconfig.h" y="433" path="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\projectconfig.h" left="0" selected="0" name="unnamed" top="421" />
5968
</Files>
6069
<ARMCrossStudioWindow activeProject="LPC1343_CodeBase" autoConnectTarget="Segger J-Link" debugSearchFileMap="" fileDialogInitialDirectory="C:\Users\Kevin\Documents\My Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase\drivers\lcd" fileDialogDefaultFilter="*.c" autoConnectCapabilities="388991" debugSearchPath="" buildConfiguration="THUMB Flash Release" />
6170
</session>

core/cmd/cmd.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ void cmdRx(uint8_t c)
121121
switch (c)
122122
{
123123
case '\r':
124+
#if CFG_INTERFACE_DROPCR == 1
125+
break;
126+
#endif
124127
case '\n':
125128
// terminate the msg and reset the msg ptr. then send
126129
// it to the handler for processing.
@@ -163,6 +166,9 @@ static void cmdMenu()
163166
printf(CFG_PRINTF_NEWLINE);
164167
printf(CFG_INTERFACE_PROMPT);
165168
#endif
169+
#if CFG_INTERFACE_CONFIRMREADY == 1
170+
printf("%s%s", CFG_INTERFACE_CONFIRMREADY_TEXT, CFG_PRINTF_NEWLINE);
171+
#endif
166172
}
167173

168174
/**************************************************************************/
@@ -201,14 +207,22 @@ void cmdParse(char *cmd)
201207
else if ((argc - 1) < cmd_tbl[i].minArgs)
202208
{
203209
// Too few arguments supplied
210+
#if CFG_INTERFACE_SHORTERRORS == 1
211+
printf ("%s%s", CFG_INTERFACE_SHORTERRORS_TOOFEWARGS, CFG_PRINTF_NEWLINE);
212+
#else
204213
printf ("Too few arguments (%d expected)%s", cmd_tbl[i].minArgs, CFG_PRINTF_NEWLINE);
205214
printf ("%sType '%s ?' for more information%s%s", CFG_PRINTF_NEWLINE, cmd_tbl[i].command, CFG_PRINTF_NEWLINE, CFG_PRINTF_NEWLINE);
215+
#endif
206216
}
207217
else if ((argc - 1) > cmd_tbl[i].maxArgs)
208218
{
209219
// Too many arguments supplied
220+
#if CFG_INTERFACE_SHORTERRORS == 1
221+
printf ("%s%s", CFG_INTERFACE_SHORTERRORS_TOOMANYARGS, CFG_PRINTF_NEWLINE);
222+
#else
210223
printf ("Too many arguments (%d maximum)%s", cmd_tbl[i].maxArgs, CFG_PRINTF_NEWLINE);
211224
printf ("%sType '%s ?' for more information%s%s", CFG_PRINTF_NEWLINE, cmd_tbl[i].command, CFG_PRINTF_NEWLINE, CFG_PRINTF_NEWLINE);
225+
#endif
212226
}
213227
else
214228
{
@@ -229,10 +243,15 @@ void cmdParse(char *cmd)
229243
return;
230244
}
231245
}
246+
// Command not recognized
247+
#if CFG_INTERFACE_SHORTERRORS == 1
248+
printf ("%s%s", CFG_INTERFACE_SHORTERRORS_UNKNOWNCOMMAND, CFG_PRINTF_NEWLINE);
249+
#else
232250
printf("Command not recognized: '%s'%s%s", cmd, CFG_PRINTF_NEWLINE, CFG_PRINTF_NEWLINE);
233251
#if CFG_INTERFACE_SILENTMODE == 0
234252
printf("Type '?' for a list of all available commands%s", CFG_PRINTF_NEWLINE);
235253
#endif
254+
#endif
236255

237256
cmdMenu();
238257
}

drivers/lcd/tft/drawing.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ uint16_t drawBGR2RGB(uint16_t color)
970970
r = (color>>11) & 0x1f;
971971

972972
return( (b<<11) + (g<<5) + (r<<0) );
973-
}
973+
}
974974

975975
/**************************************************************************/
976976
/*!
@@ -1131,7 +1131,6 @@ void drawButton(uint16_t x, uint16_t y, uint16_t width, uint16_t height, const F
11311131
void drawIcon16(uint16_t x, uint16_t y, uint16_t color, uint16_t icon[])
11321132
{
11331133
int i;
1134-
uint16_t row;
11351134
for (i = 0; i<16; i++)
11361135
{
11371136
if (icon[i] & (0X8000)) drawPixel(x, y+i, color);

main.c

Lines changed: 50 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
88
Software License Agreement (BSD License)
99
10-
Copyright (c) 2010, microBuilder SARL
10+
Copyright (c) 2011, microBuilder SARL
1111
All rights reserved.
1212
1313
Redistribution and use in source and binary forms, with or without
@@ -33,109 +33,78 @@
3333
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3434
*/
3535
/**************************************************************************/
36+
#include <stdlib.h>
3637
#include <stdio.h>
38+
#include <string.h>
3739

3840
#include "projectconfig.h"
3941
#include "sysinit.h"
4042

41-
#include "drivers/sensors/pn532/pn532.h"
42-
#include "drivers/sensors/pn532/pn532_drvr.h"
43+
#include "core/gpio/gpio.h"
44+
#include "core/systick/systick.h"
45+
46+
#ifdef CFG_INTERFACE
47+
#include "core/cmd/cmd.h"
48+
#endif
4349

4450
/**************************************************************************/
4551
/*!
46-
Main program entry point. After reset, normal code execution will
47-
begin here.
52+
Approximates a 1 millisecond delay using "nop". This is less
53+
accurate than a dedicated timer, but is useful in certain situations.
4854
49-
Note: CFG_INTERFACE is normally enabled by default. If you wish to
50-
enable the blinking LED code in main, you will need to open
51-
projectconfig.h, comment out "#define CFG_INTERFACE" and
52-
rebuild the project.
55+
The number of ticks to delay depends on the optimisation level set
56+
when compiling (-O). Depending on the compiler settings, one of the
57+
two defined values for 'delay' should be used.
5358
*/
5459
/**************************************************************************/
55-
int main (void)
60+
void delayms(uint32_t ms)
5661
{
57-
#ifdef CFG_INTERFACE
58-
//#error "CFG_INTERFACE must be disabled in projectconfig.h for this demo"
59-
#endif
60-
#if !defined CFG_PRINTF_USBCDC
61-
#error "CFG_PRINTF_USBCDC must be enabled in projectconfig.h for this demo"
62-
#endif
62+
uint32_t delay = ms * ((CFG_CPU_CCLK / 100) / 45); // Release Mode (-Os)
63+
// uint32_t delay = ms * ((CFG_CPU_CCLK / 100) / 120); // Debug Mode (No optimisations)
64+
65+
while (delay > 0)
66+
{
67+
__asm volatile ("nop");
68+
delay--;
69+
}
70+
}
6371

72+
/**************************************************************************/
73+
/*!
74+
Main program entry point. After reset, normal code execution will
75+
begin here.
76+
*/
77+
/**************************************************************************/
78+
int main(void)
79+
{
6480
// Configure cpu and mandatory peripherals
6581
systemInit();
66-
67-
// Wait 5 second for someone to open the USB connection for printf
68-
systickDelay(5000);
69-
70-
// Initialise the PN532
71-
pn532Init();
7282

73-
byte_t response[256];
74-
size_t responseLen;
75-
pn532_error_t error;
76-
77-
// Setup command to initialise a single ISO14443A target at 106kbps
78-
byte_t abtCommand[] = { PN532_COMMAND_INLISTPASSIVETARGET, 0x01, PN532_MODULATION_ISO14443A_106KBPS };
83+
uint32_t currentSecond, lastSecond;
84+
currentSecond = lastSecond = 0;
7985

8086
while (1)
8187
{
82-
printf("%s", CFG_PRINTF_NEWLINE);
83-
printf("Wait for an ISO14443A card (Mifare Classic, etc.)%s", CFG_PRINTF_NEWLINE);
84-
85-
// Send the command
86-
error = pn532Write(abtCommand, sizeof(abtCommand));
87-
88-
// Wait until we get a response or an unexpected error message
89-
do
90-
{
91-
error = pn532Read(response, &responseLen);
92-
systickDelay(25);
93-
}
94-
#ifdef PN532_UART
95-
while (error == PN532_ERROR_RESPONSEBUFFEREMPTY);
96-
#endif
97-
#ifdef PN532_SPI
98-
while ((error == PN532_ERROR_RESPONSEBUFFEREMPTY) || (error = PN532_ERROR_SPIREADYSTATUSTIMEOUT));
99-
#endif
100-
101-
// Print the card details if possible
102-
if (!error)
88+
// Toggle LED once per second ... rollover = 136 years :)
89+
currentSecond = systickGetSecondsActive();
90+
if (currentSecond != lastSecond)
10391
{
104-
/* Response for ISO14443A 106KBPS (Mifare Classic, etc.)
105-
See UM0701-02 section 7.3.5 for more information
106-
107-
byte Description
108-
------------- ------------------------------------------
109-
b7 Tags Found
110-
b8 Tag Number (only one used in this example)
111-
b9..10 SENS_RES
112-
b11 SEL_RES
113-
b12 NFCID Length
114-
b13..NFCIDLen NFCID
115-
116-
SENS_RES SEL_RES Manufacturer/Card Type NFCID Len
117-
-------- ------- ----------------------- ---------
118-
00 04 08 NXP Mifare Classic 1K 4 bytes */
119-
120-
printf("%s", CFG_PRINTF_NEWLINE);
121-
printf("%-12s: %d %s", "Tags Found", response[7], CFG_PRINTF_NEWLINE);
122-
printf("%-12s: %02X %02X %s", "SENS_RES", response[9], response[10], CFG_PRINTF_NEWLINE);
123-
printf("%-12s: %02X %s", "SEL_RES", response[11], CFG_PRINTF_NEWLINE);
124-
printf("%-12s: ", "NFCID");
125-
size_t pos;
126-
for (pos=0; pos < response[12]; pos++)
92+
lastSecond = currentSecond;
93+
if (gpioGetValue(CFG_LED_PORT, CFG_LED_PIN) == CFG_LED_OFF)
12794
{
128-
printf("%02x ", response[13 + pos]);
95+
gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_ON);
96+
}
97+
else
98+
{
99+
gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_OFF);
129100
}
130-
printf(CFG_PRINTF_NEWLINE);
131-
}
132-
else
133-
{
134-
// Oops .... something bad happened. Check 'error'
135-
printf("Ooops! Error %02X %s", error, CFG_PRINTF_NEWLINE);
136101
}
137102

138-
// Wait at least one second before trying again
139-
systickDelay(1000);
103+
// Poll for CLI input if CFG_INTERFACE is enabled in projectconfig.h
104+
#ifdef CFG_INTERFACE
105+
cmdPoll();
106+
#endif
140107
}
108+
109+
return 0;
141110
}

project/commands/drawing/cmd_pixel.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ void cmd_getpixel(uint8_t argc, char **argv)
8383
getNumber (argv[0], &x);
8484
getNumber (argv[1], &y);
8585

86-
uint16_t value = lcdGetPixel(x, y);
86+
// Get pixel and switch R and B
87+
uint16_t value = drawBGR2RGB(lcdGetPixel(x, y));
8788

8889
// Output the results
8990
printf("%d%s", value, CFG_PRINTF_NEWLINE);

0 commit comments

Comments
 (0)