Added backlight, reset, triangle and corner commands
authorKevin Townsend <kevin@ktownsend.com>
Wed, 13 Jul 2011 00:33:01 +0000 (02:33 +0200)
committerKevin Townsend <kevin@ktownsend.com>
Wed, 13 Jul 2011 00:33:01 +0000 (02:33 +0200)
38 files changed:
ChangeLog.txt
Makefile
build/codelite/LPC1343 Workspace.tags
build/codelite/LPC1343 Workspace.workspace.session
build/codelite/LPC1343_CodeBase.project
build/crossworks/LPC1343_CodeBase.hzp
build/crossworks/LPC1343_CodeBase.hzs
core/gpio/gpio.c
core/gpio/gpio.h
core/usbcdc/cdcuser.c
core/usbcdc/cdcuser.h
core/usbcdc/usbcfg.h
core/usbcdc/usbcore.c
core/usbcdc/usbcore.h
core/usbcdc/usbdesc.c
core/usbcdc/usbhw.c
core/usbcdc/usbuser.c
drivers/chibi/chb_drvr.c
drivers/eeprom/mcp24aa/mcp24aa.c
drivers/lcd/bitmap/ssd1306/ssd1306.c
drivers/lcd/bitmap/st7565/st7565.c
drivers/lcd/tft/drawing.c
drivers/lcd/tft/drawing.h
drivers/rtc/isl12022m/isl12022m.c
drivers/sensors/lm75b/lm75b.c
drivers/sensors/tcs3414/tcs3414.c
drivers/sensors/tsl2561/tsl2561.c
lpc134x.h
main.c
project/cmd_tbl.h
project/commands/cmd_reset.c [new file with mode: 0644]
project/commands/drawing/cmd_backlight.c [new file with mode: 0644]
project/commands/drawing/cmd_roundedcorner.c [new file with mode: 0644]
project/commands/drawing/cmd_triangle.c [new file with mode: 0644]
projectconfig.h
sysdefs.h
sysinit.c
tools/testfirmware/usbcli.bin [deleted file]

index 8338ec6..96d9ba5 100644 (file)
@@ -1,8 +1,11 @@
 v0.9.3 - Ongoing
 ================
 
+- Added drawCornerFilled() to drawing.c and LCD CLI
+- Fixed a nasty bug with 'gpioInterruptEvent' in the 
+  gpioSetInterrupt function (core/gpio/gpio.c)
 - Add drawTriangle() and drawTriangleFilled() to
-  drawing.c
+  drawing.c and LCD CLI
 - Added cpuReset() to reset the board via AIRCR
 - Removed text input dialogue from LCD CLI ('T') to
   save a few KB.  Command file still exists, just no
index a211627..ef0296a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -26,12 +26,13 @@ VPATH += project/commands
 OBJS += cmd_chibi_addr.o cmd_chibi_tx.o
 OBJS += cmd_i2ceeprom_read.o cmd_i2ceeprom_write.o cmd_lm75b_gettemp.o
 OBJS += cmd_reset.o cmd_sd_dir.o cmd_sysinfo.o cmd_uart.o 
+OBJS += cmd_roundedcorner.o
 
 VPATH += project/commands/drawing
 OBJS += cmd_backlight.o cmd_bmp.o cmd_button.o cmd_calibrate.o
 OBJS += cmd_circle.o cmd_clear.o cmd_line.o cmd_orientation.o
 OBJS += cmd_pixel.o cmd_progress.o cmd_rectangle.o cmd_text.o
-OBJS += cmd_textw.o cmd_tsthreshhold.o cmd_tswait.o
+OBJS += cmd_textw.o cmd_tsthreshhold.o cmd_tswait.o cmd_triangle.o
 
 ##########################################################################
 # Optional driver files 
index dfffc1d..0006aac 100644 (file)
Binary files a/build/codelite/LPC1343 Workspace.tags and b/build/codelite/LPC1343 Workspace.tags differ
index 0a04b08..6d56121 100644 (file)
@@ -1,18 +1,24 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Session Name="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\build\codelite\LPC1343 Workspace.workspace">
-  <int Value="1" Name="m_selectedTab"/>
+  <int Value="2" Name="m_selectedTab"/>
   <wxString Value="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\build\codelite\LPC1343 Workspace.workspace" Name="m_workspaceName"/>
   <TabInfoArray Name="TabInfoArray">
     <TabInfo>
-      <wxString Value="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\Makefile" Name="FileName"/>
-      <int Value="33" Name="FirstVisibleLine"/>
-      <int Value="53" Name="CurrentLine"/>
+      <wxString Value="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" Name="FileName"/>
+      <int Value="2" Name="FirstVisibleLine"/>
+      <int Value="19" Name="CurrentLine"/>
       <wxArrayString Name="Bookmarks"/>
     </TabInfo>
     <TabInfo>
-      <wxString Value="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\project\commands\drawing\cmd_text.c" Name="FileName"/>
-      <int Value="73" Name="FirstVisibleLine"/>
-      <int Value="86" Name="CurrentLine"/>
+      <wxString Value="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\core\usbcdc\usbcore.c" Name="FileName"/>
+      <int Value="159" Name="FirstVisibleLine"/>
+      <int Value="178" Name="CurrentLine"/>
+      <wxArrayString Name="Bookmarks"/>
+    </TabInfo>
+    <TabInfo>
+      <wxString Value="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\Makefile" Name="FileName"/>
+      <int Value="18" Name="FirstVisibleLine"/>
+      <int Value="29" Name="CurrentLine"/>
       <wxArrayString Name="Bookmarks"/>
     </TabInfo>
   </TabInfoArray>
index 582d2f6..b5f9df1 100644 (file)
         <File Name="../../project/commands/drawing/cmd_rectangle.c"/>
         <File Name="../../project/commands/drawing/cmd_tsthreshhold.c"/>
         <File Name="../../project/commands/drawing/cmd_backlight.c"/>
+        <File Name="../../project/commands/drawing/cmd_triangle.c"/>
+        <File Name="../../project/commands/drawing/cmd_roundedcorner.c"/>
       </VirtualDirectory>
       <File Name="../../project/commands/cmd_uart.c"/>
     </VirtualDirectory>
index c2466de..4085d03 100644 (file)
@@ -1,5 +1,5 @@
 <!DOCTYPE CrossStudio_Project_File>
-<solution Name="LPC1343_CodeBase" version="2">
+<solution Name="LPC1343_CodeBase" target="8" version="2">
   <project Name="LPC1343_CodeBase">
     <configuration Name="Common" Target="LPC1343" arm_architecture="v7M" arm_core_type="Cortex-M3" arm_linker_heap_size="512" arm_linker_process_stack_size="0" arm_linker_stack_size="1024" arm_simulator_memory_simulation_filename="$(TargetsDir)/LPC1000/LPC1000SimulatorMemory.dll" arm_simulator_memory_simulation_parameter="LPC13;0x8000;0x2000;0x0" arm_target_debug_interface_type="ADIv5" arm_target_loader_parameter="12000000" c_additional_options="" c_preprocessor_definitions="USE_PROCESS_STACK" c_user_include_directories="$(TargetsDir)/LPC1000/include;" link_include_standard_libraries="No" link_include_startup_code="No" linker_additional_files="$(TargetsDir)/LPC1000/lib/liblpc1000$(LibExt)$(LIB);$(TargetsDir)/LPC1000/lib/cmsis$(LibExt)$(LIB)" linker_memory_map_file="$(TargetsDir)/LPC1000/LPC1343_MemoryMap.xml" linker_output_format="bin" oscillator_frequency="12MHz" project_directory="" project_type="Executable" property_groups_file_path="$(TargetsDir)/LPC1000/propertyGroups13xx.xml"/>
     <configuration Name="Flash" Placement="Flash" arm_target_flash_loader_file_path="$(TargetsDir)/LPC1000/Release/Loader_lpc1300.elf" arm_target_flash_loader_type="LIBMEM RPC Loader" linker_patch_build_command="$(StudioDir)/bin/crossscript &quot;load(\&quot;$(TargetsDir)/LPC1000/LPC1000_LinkPatch.js\&quot;);patch(\&quot;$(TargetPath)\&quot;);&quot;" linker_section_placement_file="$(StudioDir)/targets/Cortex_M/flash_placement.xml" target_reset_script="FLASHReset()"/>
           </file>
           <file file_name="../../core/usbcdc/usbcore.c">
             <configuration Name="THUMB Flash Debug" build_exclude_from_build="No"/>
+            <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
           </file>
           <file file_name="../../core/usbcdc/usbdesc.c">
             <configuration Name="THUMB Flash Debug" build_exclude_from_build="No"/>
+            <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
           </file>
           <file file_name="../../core/usbcdc/usbhw.c">
             <configuration Name="THUMB Flash Debug" build_exclude_from_build="No"/>
+            <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
           </file>
           <file file_name="../../core/usbcdc/usbuser.c">
             <configuration Name="THUMB Flash Debug" build_exclude_from_build="No"/>
+            <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
+          </file>
+          <file file_name="../../core/usbcdc/cdc_buf.c">
+            <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
+            <configuration Name="THUMB Flash Debug" build_exclude_from_build="No"/>
           </file>
-          <file file_name="../../core/usbcdc/cdc_buf.c"/>
         </folder>
         <folder Name="pwm">
           <file file_name="../../core/pwm/pwm.c"/>
         <folder Name="libc">
           <file file_name="../../core/libc/stdio.c">
             <configuration Name="THUMB Flash Debug" build_exclude_from_build="No"/>
+            <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
           </file>
           <file file_name="../../core/libc/string.c">
             <configuration Name="THUMB Flash Debug" build_exclude_from_build="No"/>
+            <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
+          </file>
+          <file file_name="../../core/libc/ctype.c">
+            <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
           </file>
-          <file file_name="../../core/libc/ctype.c"/>
         </folder>
       </folder>
       <file file_name="../../lpc134x.h"/>
             <file file_name="../../project/commands/drawing/cmd_rectangle.c"/>
             <file file_name="../../project/commands/drawing/cmd_tsthreshhold.c"/>
             <file file_name="../../project/commands/drawing/cmd_backlight.c"/>
+            <file file_name="../../project/commands/drawing/cmd_triangle.c"/>
+            <file file_name="../../project/commands/drawing/cmd_roundedcorner.c"/>
           </folder>
           <file file_name="../../project/commands/cmd_uart.c"/>
           <file file_name="../../project/commands/cmd_reset.c"/>
         </folder>
         <file file_name="../../project/cmd_tbl.h"/>
       </folder>
-      <file file_name="../../main.c"/>
+      <file file_name="../../main.c">
+        <configuration Name="THUMB Flash Release" build_exclude_from_build="No"/>
+        <configuration Name="THUMB Flash Debug" build_exclude_from_build="No"/>
+      </file>
     </folder>
     <folder Name="System Files">
       <file file_name="$(TargetsDir)/LPC1000/include/CMSIS/system_LPC13xx.c"/>
index 493c96b..e88fa52 100644 (file)
@@ -1,7 +1,16 @@
 <!DOCTYPE CrossStudio_for_ARM_Session_File>
 <session>
  <Bookmarks/>
- <Breakpoints/>
+ <Breakpoints>
+  <BreakpointListItem group="CM Exceptions" type="Exception" state="2" counter="0" expression="BusFault" />
+  <BreakpointListItem group="CM Exceptions" type="Exception" state="2" counter="0" expression="ExceptionEntryReturnFault" />
+  <BreakpointListItem group="CM Exceptions" type="Exception" state="2" counter="0" expression="HardFault" />
+  <BreakpointListItem group="CM Exceptions" type="Exception" state="2" counter="0" expression="MemManage" />
+  <BreakpointListItem group="CM Exceptions" type="Exception" state="3" counter="0" expression="Reset" />
+  <BreakpointListItem group="CM Exceptions" type="Exception" state="2" counter="0" expression="UsageFault_CheckingError" />
+  <BreakpointListItem group="CM Exceptions" type="Exception" state="2" counter="0" expression="UsageFault_Coprocessor" />
+  <BreakpointListItem group="CM Exceptions" type="Exception" state="2" counter="0" expression="UsageFault_StateError" />
+ </Breakpoints>
  <ExecutionCountWindow/>
  <Memory1>
   <MemoryWindow autoEvaluate="0" addressText="&amp;header" numColumns="8" sizeText="sizeof(header)" dataSize="1" radix="16" addressSpace="" />
   <ProjectSessionItem path="LPC1343_CodeBase" name="unnamed" />
   <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase" name="unnamed" />
   <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files" name="unnamed" />
-  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers" name="unnamed" />
-  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers;lcd" name="unnamed" />
-  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers;lcd;tft" name="unnamed" />
  </Project>
  <Register1>
-  <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="" />
+  <RegisterWindow openNodes="USB;USB/USBDevIntSt;USB/USBDevIntEn;USB/USBRxPLen;USB/USBTxPLen;USB/USBCtrl" binaryNodes="" hiddenNodes="" unsignedNodes="" visibleGroups="CPU;USB" decimalNodes="" octalNodes="" asciiNodes="" />
  </Register1>
  <Register2>
   <RegisterWindow openNodes="" binaryNodes="" hiddenNodes="" unsignedNodes="" visibleGroups="" decimalNodes="" octalNodes="" asciiNodes="" />
  </TraceWindow>
  <Watch1>
   <Watches active="1" update="Each Second" >
-   <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" />
-   <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" />
-   <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" />
    <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" />
+   <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" />
+   <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" />
+   <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" />
   </Watches>
  </Watch1>
  <Watch2>
@@ -56,6 +62,9 @@
  <Watch4>
   <Watches active="0" update="Never" />
  </Watch4>
- <Files/>
- <ARMCrossStudioWindow activeProject="LPC1343_CodeBase" autoConnectTarget="Segger J-Link" debugSearchFileMap="" fileDialogInitialDirectory="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\project\commands" fileDialogDefaultFilter="*.c" autoConnectCapabilities="388991" debugSearchPath="" buildConfiguration="THUMB Flash Release" />
+ <Files>
+  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" y="18" path="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" left="0" selected="1" name="unnamed" top="0" />
+  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\projectconfig.h" y="50" path="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\projectconfig.h" left="0" selected="0" name="unnamed" top="21" />
+ </Files>
+ <ARMCrossStudioWindow activeProject="LPC1343_CodeBase" autoConnectTarget="Segger J-Link" debugSearchFileMap="" fileDialogInitialDirectory="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\project\commands\drawing" fileDialogDefaultFilter="*.c" autoConnectCapabilities="388991" debugSearchPath="" buildConfiguration="THUMB Flash Release" />
 </session>
index 3809a5e..9c84655 100644 (file)
 volatile uint32_t chibi_counter  = 0;
 #endif
 
+#ifdef CFG_ALTRESET
+#include "core/cpu/cpu.h"
+#endif
+
 static bool _gpioInitialised = false;
 
 /**************************************************************************/
@@ -75,6 +79,15 @@ void PIOINT1_IRQHandler(void)
 {
   uint32_t regVal;
 
+#if defined CFG_ALTRESET && CFG_ALTRESET_PORT == 1
+  regVal = gpioIntStatus(CFG_ALTRESET_PORT, CFG_ALTRESET_PIN);
+  if (regVal)
+  {
+    // Cause a reset and wait
+    cpuReset();
+  }
+#endif
+
 #ifdef CFG_CHIBI
   // Check for interrupt on 1.8
   regVal = gpioIntStatus(1, 8);
@@ -312,9 +325,9 @@ void gpioSetInterrupt (uint32_t portNum, uint32_t bitPos, gpioInterruptSense_t s
   if (!_gpioInitialised) gpioInit();
 
   // Get the appropriate register (handled this way to optimise code size)
-  REG32 *gpiois  = &GPIO_GPIO0IS;
-  REG32 *gpioibe = &GPIO_GPIO0IBE;
-  REG32 *gpioiev = &GPIO_GPIO0IEV;
+  REG32 *gpiois  = &GPIO_GPIO0IS;   // Interrupt sense (edge or level sensitive)
+  REG32 *gpioibe = &GPIO_GPIO0IBE;  // Interrupt both edges (0 = int controlled by GPIOIEV, 1 = both edges trigger interrupt)
+  REG32 *gpioiev = &GPIO_GPIO0IEV;  // 0 = falling edge or low, 1 = rising edge or high (depending on GPIOIS)
   switch (portNum)
   {
     case 0:
@@ -339,18 +352,18 @@ void gpioSetInterrupt (uint32_t portNum, uint32_t bitPos, gpioInterruptSense_t s
       break;
   }
 
-  if (gpioInterruptSense_Edge)
+
+  if (sense == gpioInterruptSense_Edge)
   {
     *gpiois &= ~(0x1<<bitPos);
-    /* single or double only applies when sense is 0(edge trigger). */
-    gpioInterruptEdge_Single ? (*gpioibe &= ~(0x1<<bitPos)) : (*gpioibe |= (0x1<<bitPos));
+    edge == gpioInterruptEdge_Single ? (*gpioibe &= ~(0x1<<bitPos)) : (*gpioibe |= (0x1<<bitPos));
   }
   else
   {
     *gpiois |= (0x1<<bitPos);
   }
 
-  gpioInterruptEvent_ActiveHigh ? (*gpioiev &= ~(0x1<<bitPos)) : (*gpioiev |= (0x1<<bitPos));
+  event == gpioInterruptEvent_ActiveHigh ? (*gpioiev &= ~(0x1<<bitPos)) : (*gpioiev |= (0x1<<bitPos));
 
   return;
 }
index 4d8fdf9..29476b6 100644 (file)
@@ -69,8 +69,7 @@ gpioInterruptEdge_t;
 
 /**************************************************************************/
 /*! 
-    Indicates whether the interrupt should be triggered in the rising
-    or falling edge.  ActiveHigh means that a HIGH level on the pin will
+    ActiveHigh means that a HIGH level on the pin will
     trigger an interrupt, ActiveLow means that a LOW level on the pin
     will trigger an interrupt.
 */
index d553f47..4b54ead 100644 (file)
@@ -26,7 +26,7 @@
 #include "cdcuser.h"
 #include "cdc_buf.h"
 
-// unsigned char BulkBufIn  [64];            // Buffer to store USB IN  packet
+unsigned char BulkBufIn  [64];            // Buffer to store USB IN  packet
 unsigned char BulkBufOut [64];            // Buffer to store USB OUT packet
 unsigned char NotificationBuf [10];
 
@@ -35,11 +35,11 @@ unsigned short  CDC_SerialState = 0x0000;
 unsigned short  CDC_DepInEmpty  = 1;                   // Data IN EP is empty
 
 /*----------------------------------------------------------------------------
-  We need a buffer for incoming data on USB port because USB receives
+  We need a buffer for incomming data on USB port because USB receives
   much faster than  UART transmits
  *---------------------------------------------------------------------------*/
 /* Buffer masks */
-#define CDC_BUF_SIZE               (64)   // Output buffer in bytes (power 2)
+#define CDC_BUF_SIZE               (64)               // Output buffer in bytes (power 2)
                                                        // large enough for file transfer
 #define CDC_BUF_MASK               (CDC_BUF_SIZE-1ul)
 
@@ -53,8 +53,7 @@ unsigned short  CDC_DepInEmpty  = 1;                   // Data IN EP is empty
 
 
 // CDC output buffer
-typedef struct __CDC_BUF_T 
-{
+typedef struct __CDC_BUF_T {
   unsigned char data[CDC_BUF_SIZE];
   volatile unsigned int wrIdx;
   volatile unsigned int rdIdx;
@@ -65,8 +64,7 @@ CDC_BUF_T  CDC_OutBuf;                                 // buffer for all CDC Out
 /*----------------------------------------------------------------------------
   read data from CDC_OutBuf
  *---------------------------------------------------------------------------*/
-int CDC_RdOutBuf (char *buffer, const int *length) 
-{
+int CDC_RdOutBuf (char *buffer, const int *length) {
   int bytesToRead, bytesRead;
   
   /* Read *length bytes, block if *bytes are not avaialable    */
@@ -86,8 +84,7 @@ int CDC_RdOutBuf (char *buffer, const int *length)
 /*----------------------------------------------------------------------------
   write data to CDC_OutBuf
  *---------------------------------------------------------------------------*/
-int CDC_WrOutBuf (const char *buffer, int *length) 
-{
+int CDC_WrOutBuf (const char *buffer, int *length) {
   int bytesToWrite, bytesWritten;
 
   // Write *length bytes
@@ -108,8 +105,8 @@ int CDC_WrOutBuf (const char *buffer, int *length)
 /*----------------------------------------------------------------------------
   check if character(s) are available at CDC_OutBuf
  *---------------------------------------------------------------------------*/
-int CDC_OutBufAvailChar (int *availChar) 
-{
+int CDC_OutBufAvailChar (int *availChar) {
+
   *availChar = CDC_BUF_COUNT(CDC_OutBuf);
 
   return (0);
@@ -123,8 +120,14 @@ int CDC_OutBufAvailChar (int *availChar)
   Parameters:   None 
   Return Value: None
  *---------------------------------------------------------------------------*/
-void CDC_Init (void) 
-{
+void CDC_Init (void) {
+
+//  ser_OpenPort ();
+//  ser_InitPort (CDC_LineCoding.dwDTERate,
+//                CDC_LineCoding.bDataBits, 
+//                CDC_LineCoding.bParityType,
+//                CDC_LineCoding.bCharFormat);
+
   CDC_DepInEmpty  = 1;
   CDC_SerialState = CDC_GetSerialState();
 
@@ -144,8 +147,8 @@ void CDC_Init (void)
   Parameters:   None                          (global SetupPacket and EP0Buf)
   Return Value: TRUE - Success, FALSE - Error
  *---------------------------------------------------------------------------*/
-uint32_t CDC_SendEncapsulatedCommand (void) 
-{
+uint32_t CDC_SendEncapsulatedCommand (void) {
+
   return (TRUE);
 }
 
@@ -156,8 +159,8 @@ uint32_t CDC_SendEncapsulatedCommand (void)
   Parameters:   None                          (global SetupPacket and EP0Buf)
   Return Value: TRUE - Success, FALSE - Error
  *---------------------------------------------------------------------------*/
-uint32_t CDC_GetEncapsulatedResponse (void) 
-{
+uint32_t CDC_GetEncapsulatedResponse (void) {
+
   /* ... add code to handle request */
   return (TRUE);
 }
@@ -169,8 +172,8 @@ uint32_t CDC_GetEncapsulatedResponse (void)
   Parameters:   FeatureSelector
   Return Value: TRUE - Success, FALSE - Error
  *---------------------------------------------------------------------------*/
-uint32_t CDC_SetCommFeature (unsigned short wFeatureSelector) 
-{
+uint32_t CDC_SetCommFeature (unsigned short wFeatureSelector) {
+
   /* ... add code to handle request */
   return (TRUE);
 }
@@ -182,8 +185,8 @@ uint32_t CDC_SetCommFeature (unsigned short wFeatureSelector)
   Parameters:   FeatureSelector
   Return Value: TRUE - Success, FALSE - Error
  *---------------------------------------------------------------------------*/
-uint32_t CDC_GetCommFeature (unsigned short wFeatureSelector) 
-{
+uint32_t CDC_GetCommFeature (unsigned short wFeatureSelector) {
+
   /* ... add code to handle request */
   return (TRUE);
 }
@@ -195,8 +198,8 @@ uint32_t CDC_GetCommFeature (unsigned short wFeatureSelector)
   Parameters:   FeatureSelector
   Return Value: TRUE - Success, FALSE - Error
  *---------------------------------------------------------------------------*/
-uint32_t CDC_ClearCommFeature (unsigned short wFeatureSelector) 
-{
+uint32_t CDC_ClearCommFeature (unsigned short wFeatureSelector) {
+
   /* ... add code to handle request */
   return (TRUE);
 }
@@ -208,8 +211,8 @@ uint32_t CDC_ClearCommFeature (unsigned short wFeatureSelector)
   Parameters:   none                    (global SetupPacket and EP0Buf)
   Return Value: TRUE - Success, FALSE - Error
  *---------------------------------------------------------------------------*/
-uint32_t CDC_SetLineCoding (void) 
-{
+uint32_t CDC_SetLineCoding (void) {
+
   CDC_LineCoding.dwDTERate   =   (EP0Buf[0] <<  0)
                                | (EP0Buf[1] <<  8)
                                | (EP0Buf[2] << 16)
@@ -218,6 +221,12 @@ uint32_t CDC_SetLineCoding (void)
   CDC_LineCoding.bParityType =  EP0Buf[5];
   CDC_LineCoding.bDataBits   =  EP0Buf[6];
 
+//  ser_ClosePort();
+//  ser_OpenPort ();
+//  ser_InitPort (CDC_LineCoding.dwDTERate,
+//                CDC_LineCoding.bDataBits, 
+//                CDC_LineCoding.bParityType,
+//                CDC_LineCoding.bCharFormat);    
   return (TRUE);
 }
 
@@ -228,8 +237,8 @@ uint32_t CDC_SetLineCoding (void)
   Parameters:   None                         (global SetupPacket and EP0Buf)
   Return Value: TRUE - Success, FALSE - Error
  *---------------------------------------------------------------------------*/
-uint32_t CDC_GetLineCoding (void) 
-{
+uint32_t CDC_GetLineCoding (void) {
+
   EP0Buf[0] = (CDC_LineCoding.dwDTERate >>  0) & 0xFF;
   EP0Buf[1] = (CDC_LineCoding.dwDTERate >>  8) & 0xFF;
   EP0Buf[2] = (CDC_LineCoding.dwDTERate >> 16) & 0xFF;
@@ -275,12 +284,22 @@ uint32_t CDC_SendBreak (unsigned short wDurationOfBreak) {
   Parameters:   none
   Return Value: none
  *---------------------------------------------------------------------------*/
-void CDC_BulkIn(void) 
-{
-//  int numBytesRead, numBytesAvail;
-//
-//  // ToDo: Modify BulkIn to send incoming data to USB
-//        
+void CDC_BulkIn(void) {
+  //int numBytesRead, numBytesAvail;
+
+//  uint8_t frame[64];
+//  uint32_t bytesRead = 0;
+//  if (cdcBufferDataPending())
+//  {
+//    // Read up to 64 bytes
+//    bytesRead = cdcBufferReadLen(frame, 64);
+//    if (bytesRead > 0)
+//    {
+//      USB_WriteEP (CDC_DEP_IN, frame, bytesRead);
+//    }
+//  }
+
+
 //  ser_AvailChar (&numBytesAvail);
 //
 //  // ... add code to check for overwrite
@@ -294,8 +313,6 @@ void CDC_BulkIn(void)
 //  else {
 //    CDC_DepInEmpty = 1;
 //  }
-//
-//
 } 
 
 
@@ -304,8 +321,7 @@ void CDC_BulkIn(void)
   Parameters:   none
   Return Value: none
  *---------------------------------------------------------------------------*/
-void CDC_BulkOut(void) 
-{
+void CDC_BulkOut(void) {
   int numBytesRead;
 
   // get data from USB into intermediate buffer
@@ -315,6 +331,7 @@ void CDC_BulkOut(void)
 
   // store data in a buffer to transmit it over serial interface
   CDC_WrOutBuf ((char *)&BulkBufOut[0], &numBytesRead);
+
 }
 
 
@@ -323,9 +340,19 @@ void CDC_BulkOut(void)
   Parameters:   none
   Return Value: SerialState as defined in usbcdc11.pdf
  *---------------------------------------------------------------------------*/
-unsigned short CDC_GetSerialState (void) 
-{
+unsigned short CDC_GetSerialState (void) {
+//  unsigned short temp;
+
   CDC_SerialState = 0;
+//  ser_LineState (&temp);
+//
+//  if (temp & 0x8000)  CDC_SerialState |= CDC_SERIAL_STATE_RX_CARRIER;
+//  if (temp & 0x2000)  CDC_SerialState |= CDC_SERIAL_STATE_TX_CARRIER;
+//  if (temp & 0x0010)  CDC_SerialState |= CDC_SERIAL_STATE_BREAK;
+//  if (temp & 0x4000)  CDC_SerialState |= CDC_SERIAL_STATE_RING;
+//  if (temp & 0x0008)  CDC_SerialState |= CDC_SERIAL_STATE_FRAMING;
+//  if (temp & 0x0004)  CDC_SerialState |= CDC_SERIAL_STATE_PARITY;
+//  if (temp & 0x0002)  CDC_SerialState |= CDC_SERIAL_STATE_OVERRUN;
 
   return (CDC_SerialState);
 }
@@ -334,8 +361,8 @@ unsigned short CDC_GetSerialState (void)
 /*----------------------------------------------------------------------------
   Send the SERIAL_STATE notification as defined in usbcdc11.pdf, 6.3.5.
  *---------------------------------------------------------------------------*/
-void CDC_NotificationIn (void) 
-{
+void CDC_NotificationIn (void) {
+
   NotificationBuf[0] = 0xA1;                           // bmRequestType
   NotificationBuf[1] = CDC_NOTIFICATION_SERIAL_STATE;  // bNotification (SERIAL_STATE)
   NotificationBuf[2] = 0x00;                           // wValue
index 55cd910..7512157 100644 (file)
@@ -50,7 +50,7 @@ extern void CDC_BulkOut                  (void);
 /* CDC Notification Callback Function */
 extern void CDC_NotificationIn           (void);
 
-/* CDC Initialization Function */
+/* CDC Initializtion Function */
 extern void CDC_Init (void);
 
 /* CDC prepare the SERAIAL_STATE */
index cad6c43..aa7ffde 100644 (file)
 #define USB_SUSPEND_EVENT   1
 #define USB_RESUME_EVENT    1
 #define USB_WAKEUP_EVENT    0
-#define USB_SOF_EVENT       1
+#define USB_SOF_EVENT       0
 #define USB_ERROR_EVENT     0
 #define USB_EP_EVENT        0x000B
 #define USB_CONFIGURE_EVENT 1
 #define USB_ADC_CIF_NUM     0
 #define USB_ADC_SIF1_NUM    1
 #define USB_ADC_SIF2_NUM    2
-#define USB_CDC             1
+#define USB_CDC                1
 #define USB_CDC_CIF_NUM     0
 #define USB_CDC_DIF_NUM     1
 #define USB_CDC_BUFSIZE     CFG_USBCDC_BUFSIZE
index fe09bbd..fe33aba 100644 (file)
@@ -169,7 +169,6 @@ void USB_StatusOutStage (void) {
 
 static inline uint32_t USB_ReqGetStatus (void) {
   uint32_t n, m;
-  uint16_t* ep0 = (uint16_t __attribute__((packed)) *)EP0Buf;
 
   switch (SetupPacket.bmRequestType.BM.Recipient) {
     case REQUEST_TO_DEVICE:
@@ -177,7 +176,7 @@ static inline uint32_t USB_ReqGetStatus (void) {
       break;
     case REQUEST_TO_INTERFACE:
       if ((USB_Configuration != 0) && (SetupPacket.wIndex.WB.L < USB_NumInterfaces)) {
-        *ep0 = 0;
+        *((uint16_t __attribute__((packed)) *)EP0Buf) = 0;
         EP0Data.pData = EP0Buf;
       } else {
         return (FALSE);
@@ -187,7 +186,7 @@ static inline uint32_t USB_ReqGetStatus (void) {
       n = SetupPacket.wIndex.WB.L & 0x8F;
       m = (n & 0x80) ? ((1 << 16) << (n & 0x0F)) : (1 << n);
       if (((USB_Configuration != 0) || ((n & 0x0F) == 0)) && (USB_EndPointMask & m)) {
-        *ep0 = (USB_EndPointHalt & m) ? 1 : 0;
+        *((uint16_t __attribute__((packed)) *)EP0Buf) = (USB_EndPointHalt & m) ? 1 : 0;
         EP0Data.pData = EP0Buf;
       } else {
         return (FALSE);
@@ -364,6 +363,7 @@ static inline uint32_t USB_ReqGetDescriptor (void) {
   return (TRUE);
 }
 
+
 /*
  *  Get Configuration USB Request
  *    Parameters:      None (global SetupPacket)
@@ -376,6 +376,7 @@ static inline uint32_t USB_ReqGetConfiguration (void) {
     case REQUEST_TO_DEVICE:
       // Added cast to avoid warnings due to USB_Configuration being volatile (KTownsend)
       EP0Data.pData = (uint8_t *)&USB_Configuration;
+      //EP0Data.pData = &USB_Configuration;
       break;
     default:
       return (FALSE);
@@ -562,6 +563,7 @@ static inline uint32_t USB_ReqSetInterface (void) {
   return (set);
 }
 
+
 /*
  *  USB Endpoint 0 Event Callback
  *    Parameters:      event
index 5098be0..f9d9778 100644 (file)
@@ -36,7 +36,6 @@ extern uint32_t USB_EndPointHalt;
 extern uint32_t USB_EndPointStall;
 extern uint8_t  USB_AltSetting[USB_IF_NUM];
 
-
 /* USB Endpoint 0 Buffer */
 extern uint8_t  EP0Buf[USB_MAX_PACKET0];
 
@@ -80,9 +79,4 @@ static inline void UsbAddPtr(void **vpptr, uint32_t n)
 }
 
 
-
-
-
-
-
 #endif  /* __USBCORE_H__ */
index 6642e60..d523e89 100644 (file)
@@ -20,6 +20,7 @@
  *          V1.00 Initial Version
  *---------------------------------------------------------------------------*/
 #include "projectconfig.h"
+
 #include "usb.h"
 #include "cdc.h"
 #include "usbcfg.h"
@@ -144,39 +145,39 @@ const uint8_t USB_StringDescriptor[] = {
 /* Index 0x01: Manufacturer */
   (13*2 + 2),                        /* bLength (13 Char + Type + lenght) */
   USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  'N',0,
+  'X',0,
+  'P',0,
+  ' ',0,
+  'S',0,
+  'E',0,
   'M',0,
   'I',0,
   'C',0,
-  'R',0,
   'O',0,
-  'B',0,
-  'U',0,
-  'I',0,
-  'L',0,
+  'N',0,
   'D',0,
-  'E',0,
-  'R',0,
   ' ',0,
 /* Index 0x02: Product */
   (17*2 + 2),                        /* bLength ( 17 Char + Type + lenght) */
   USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
+  'N',0,
+  'X',0,
+  'P',0,
+  ' ',0,
   'L',0,
   'P',0,
   'C',0,
   '1',0,
   '3',0,
-  '4',0,
-  '3',0,
+  'x',0,
+  'x',0,
   ' ',0,
+  'V',0,
   'C',0,
   'O',0,
   'M',0,
   ' ',0,
-  'P',0,
-  'O',0,
-  'R',0,
-  'T',0,
-  ' ',0,
 /* Index 0x03: Serial Number */
   (12*2 + 2),                        /* bLength (12 Char + Type + lenght) */
   USB_STRING_DESCRIPTOR_TYPE,        /* bDescriptorType */
index fdc88f1..88add23 100644 (file)
@@ -19,7 +19,7 @@
  *          V1.20 Added USB_ClearEPBuf
  *          V1.00 Initial Version
  *----------------------------------------------------------------------------*/
-#include "projectconfig.h"                        /* LPC13xx definitions */
+#include "projectconfig.h"
 #include "usb.h"
 #include "usbcfg.h"
 #include "usbreg.h"
@@ -79,13 +79,12 @@ void USBIOClkConfig( void )
  *    Return Value:    None
  */
 
-void delay (uint32_t length ) 
-{
+void delay (uint32_t length ) {
   uint32_t i;
 
   for ( i = 0; i < length; i++ )
   {
-    __asm("nop");
+    __asm volatile("nop");
   }
   return;
 }
@@ -98,8 +97,7 @@ void delay (uint32_t length )
  *    Return Value:    Endpoint Physical Address
  */
 
-uint32_t EPAdr (uint32_t EPNum) 
-{
+uint32_t EPAdr (uint32_t EPNum) {
   uint32_t val;
 
   val = (EPNum & 0x0F) << 1;
@@ -116,8 +114,8 @@ uint32_t EPAdr (uint32_t EPNum)
  *    Return Value:    None
  */
 
-void WrCmd (uint32_t cmd) 
-{
+void WrCmd (uint32_t cmd) {
+
   USB_DEVINTCLR = CCEMTY_INT;
   USB_CMDCODE = cmd;
   while ((USB_DEVINTST & (CCEMTY_INT | DEV_STAT_INT)) == 0);
@@ -131,8 +129,8 @@ void WrCmd (uint32_t cmd)
  *    Return Value:    None
  */
 
-void WrCmdDat (uint32_t cmd, uint32_t val) 
-{
+void WrCmdDat (uint32_t cmd, uint32_t val) {
+
   WrCmd(cmd);
   WrCmd(val);
 }
@@ -145,8 +143,8 @@ void WrCmdDat (uint32_t cmd, uint32_t val)
  *    Return Value:    None
  */
 
-void WrCmdEP (uint32_t EPNum, uint32_t cmd)
-{
+void WrCmdEP (uint32_t EPNum, uint32_t cmd){
+
   WrCmd(CMD_SEL_EP(EPAdr(EPNum)));
   WrCmd(cmd);
 }
@@ -158,8 +156,8 @@ void WrCmdEP (uint32_t EPNum, uint32_t cmd)
  *    Return Value:    Data Value
  */
 
-uint32_t RdCmdDat (uint32_t cmd) 
-{
+uint32_t RdCmdDat (uint32_t cmd) {
+
   USB_DEVINTCLR = CCEMTY_INT | CDFULL_INT;
   USB_CMDCODE = cmd;
   while ((USB_DEVINTST & (CDFULL_INT | DEV_STAT_INT)) == 0);
@@ -173,8 +171,8 @@ uint32_t RdCmdDat (uint32_t cmd)
  *    Return Value:    None
  */
 
-void USB_Init (void) 
-{
+void USB_Init (void) {
+
   // Setup USB clock and pins
   USBIOClkConfig();  
 
@@ -203,8 +201,7 @@ void USB_Init (void)
  *    Return Value:    None
  */
 
-void USB_Connect (uint32_t con) 
-{
+void USB_Connect (uint32_t con) {
   WrCmdDat(CMD_SET_DEV_STAT, DAT_WR_BYTE(con ? DEV_CON : 0));
 }
 
@@ -215,8 +212,8 @@ void USB_Connect (uint32_t con)
  *    Return Value:    None
  */
 
-void USB_Reset (void) 
-{
+void USB_Reset (void) {
+
   USB_DEVINTCLR = 0x000FFFFF;
   /* Enable all eight(8) EPs, note: EP won't be ready until it's
   configured/enabled when device sending SetEPStatus command 
@@ -233,8 +230,7 @@ void USB_Reset (void)
  *    Return Value:    None
  */
 
-void USB_Suspend (void) 
-{
+void USB_Suspend (void) {
   /* Performed by Hardware */
 }
 
@@ -245,8 +241,7 @@ void USB_Suspend (void)
  *    Return Value:    None
  */
 
-void USB_Resume (void) 
-{
+void USB_Resume (void) {
   /* Performed by Hardware */
 }
 
@@ -257,10 +252,9 @@ void USB_Resume (void)
  *    Return Value:    None
  */
 
-void USB_WakeUp (void) 
-{
-  if (USB_DeviceStatus & USB_GETSTATUS_REMOTE_WAKEUP) 
-  {
+void USB_WakeUp (void) {
+
+  if (USB_DeviceStatus & USB_GETSTATUS_REMOTE_WAKEUP) {
     WrCmdDat(CMD_SET_DEV_STAT, DAT_WR_BYTE(DEV_CON));
   }
 }
@@ -272,8 +266,7 @@ void USB_WakeUp (void)
  *    Return Value:    None
  */
 
-void USB_WakeUpCfg (uint32_t cfg) 
-{
+void USB_WakeUpCfg (uint32_t cfg) {
   cfg = cfg;  /* Not needed */
 }
 
@@ -284,8 +277,7 @@ void USB_WakeUpCfg (uint32_t cfg)
  *    Return Value:    None
  */
 
-void USB_SetAddress (uint32_t adr) 
-{
+void USB_SetAddress (uint32_t adr) {
   WrCmdDat(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | adr)); /* Don't wait for next */
   WrCmdDat(CMD_SET_ADDR, DAT_WR_BYTE(DEV_EN | adr)); /*  Setup Status Phase */
 }
@@ -297,8 +289,8 @@ void USB_SetAddress (uint32_t adr)
  *    Return Value:    None
  */
 
-void USB_Configure (uint32_t cfg) 
-{
+void USB_Configure (uint32_t cfg) {
+
   WrCmdDat(CMD_CFG_DEV, DAT_WR_BYTE(cfg ? CONF_DVICE : 0));
   return;
 }
@@ -310,8 +302,7 @@ void USB_Configure (uint32_t cfg)
  *    Return Value:    None
  */
 
-void USB_ConfigEP (USB_ENDPOINT_DESCRIPTOR *pEPD) 
-{
+void USB_ConfigEP (USB_ENDPOINT_DESCRIPTOR *pEPD) {
   return;
 }
 
@@ -322,8 +313,7 @@ void USB_ConfigEP (USB_ENDPOINT_DESCRIPTOR *pEPD)
  *    Return Value:    None
  */
 
-void USB_DirCtrlEP (uint32_t dir) 
-{
+void USB_DirCtrlEP (uint32_t dir) {
   dir = dir;  /* Not needed */
 }
 
@@ -336,8 +326,7 @@ void USB_DirCtrlEP (uint32_t dir)
  *    Return Value:    None
  */
 
-void USB_EnableEP (uint32_t EPNum) 
-{
+void USB_EnableEP (uint32_t EPNum) {
   WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0));
 }
 
@@ -350,8 +339,7 @@ void USB_EnableEP (uint32_t EPNum)
  *    Return Value:    None
  */
 
-void USB_DisableEP (uint32_t EPNum) 
-{
+void USB_DisableEP (uint32_t EPNum) {
   WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(EP_STAT_DA));
 }
 
@@ -364,8 +352,7 @@ void USB_DisableEP (uint32_t EPNum)
  *    Return Value:    None
  */
 
-void USB_ResetEP (uint32_t EPNum) 
-{
+void USB_ResetEP (uint32_t EPNum) {
   WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0));
 }
 
@@ -378,8 +365,7 @@ void USB_ResetEP (uint32_t EPNum)
  *    Return Value:    None
  */
 
-void USB_SetStallEP (uint32_t EPNum) 
-{
+void USB_SetStallEP (uint32_t EPNum) {
   WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(EP_STAT_ST));
 }
 
@@ -392,8 +378,7 @@ void USB_SetStallEP (uint32_t EPNum)
  *    Return Value:    None
  */
 
-void USB_ClrStallEP (uint32_t EPNum) 
-{
+void USB_ClrStallEP (uint32_t EPNum) {
   WrCmdDat(CMD_SET_EP_STAT(EPAdr(EPNum)), DAT_WR_BYTE(0));
 }
 
@@ -406,8 +391,7 @@ void USB_ClrStallEP (uint32_t EPNum)
  *    Return Value:    None
  */
 
-void USB_ClearEPBuf (uint32_t EPNum) 
-{
+void USB_ClearEPBuf (uint32_t EPNum) {
   WrCmdEP(EPNum, CMD_CLR_BUF);
 }
 
@@ -421,30 +405,26 @@ void USB_ClearEPBuf (uint32_t EPNum)
  *    Return Value:    Number of bytes read
  */
 
-uint32_t USB_ReadEP (uint32_t EPNum, uint8_t *pData) 
-{
+uint32_t USB_ReadEP (uint32_t EPNum, uint8_t *pData) {
   uint32_t cnt, n;
 
   USB_CTRL = ((EPNum & 0x0F) << 2) | CTRL_RD_EN;
   /* 3 clock cycles to fetch the packet length from RAM. */ 
   delay( 5 );
 
-  do 
-  {
+  do {
     cnt = USB_RXPLEN;
   } while ((cnt & PKT_DV) == 0);
   cnt &= PKT_LNGTH_MASK;
 
-  for (n = 0; n < (cnt + 3) / 4; n++) 
-  {
+  for (n = 0; n < (cnt + 3) / 4; n++) {
     *((uint32_t __attribute__((packed)) *)pData) = USB_RXDATA;
     pData += 4;
   }
 
   USB_CTRL = 0;
 
-  if ((EPNum & 0x80) != 0x04) 
-  {   /* Non-Isochronous Endpoint */
+  if ((EPNum & 0x80) != 0x04) {   /* Non-Isochronous Endpoint */
     WrCmdEP(EPNum, CMD_CLR_BUF);
   }
 
@@ -462,8 +442,7 @@ uint32_t USB_ReadEP (uint32_t EPNum, uint8_t *pData)
  *    Return Value:    Number of bytes written
  */
 
-uint32_t USB_WriteEP (uint32_t EPNum, uint8_t *pData, uint32_t cnt) 
-{
+uint32_t USB_WriteEP (uint32_t EPNum, uint8_t *pData, uint32_t cnt) {
   uint32_t n;
 
   USB_CTRL = ((EPNum & 0x0F) << 2) | CTRL_WR_EN;
@@ -471,8 +450,7 @@ uint32_t USB_WriteEP (uint32_t EPNum, uint8_t *pData, uint32_t cnt)
   delay( 5 );
   USB_TXPLEN = cnt;
 
-  for (n = 0; n < (cnt + 3) / 4; n++) 
-  {
+  for (n = 0; n < (cnt + 3) / 4; n++) {
     USB_TXDATA = *((uint32_t __attribute__((packed)) *)pData);
     pData += 4;
   }
@@ -490,8 +468,7 @@ uint32_t USB_WriteEP (uint32_t EPNum, uint8_t *pData, uint32_t cnt)
  *    Return Value:    Frame Number
  */
 
-uint32_t USB_GetFrame (void) 
-{
+uint32_t USB_GetFrame (void) {
   uint32_t val;
 
   WrCmd(CMD_RD_FRAME);
@@ -515,8 +492,7 @@ void USB_IRQHandler (void)
   USB_DEVINTCLR = disr;
 
   /* Device Status Interrupt (Reset, Connect change, Suspend/Resume) */
-  if (disr & DEV_STAT_INT) 
-  {
+  if (disr & DEV_STAT_INT) {
     WrCmd(CMD_GET_DEV_STAT);
     val = RdCmdDat(DAT_GET_DEV_STAT);       /* Device Status */
     if (val & DEV_RST) {                    /* Reset */
@@ -548,11 +524,10 @@ void USB_IRQHandler (void)
 
 #if USB_SOF_EVENT
   /* Start of Frame Interrupt */
-  if (disr & FRAME_INT) 
-  {
+  if (disr & FRAME_INT) {
     USB_DEVINTCLR = FRAME_INT;
     USB_SOF_Event();
-    // SOFIRQCount++;
+    SOFIRQCount++;
   }
 #endif
 
@@ -560,8 +535,7 @@ void USB_IRQHandler (void)
   /* NO error interrupt anymore, below code can be used
   as example to get error status from command engine. */
   /* Error Interrupt */
-  if (disr & ERR_INT) 
-  {
+  if (disr & ERR_INT) {
     WrCmd(CMD_RD_ERR_STAT);
     val = RdCmdDat(DAT_RD_ERR_STAT);
     USB_Error_Event(val);
@@ -602,5 +576,4 @@ void USB_IRQHandler (void)
 isr_end:
   return;
 }
-
 #endif
index 54f7b9e..6d1c660 100644 (file)
@@ -182,8 +182,7 @@ void USB_EndPoint1 (uint32_t event) {
  *    Parameter:       event
  */
 
-void USB_EndPoint2 (uint32_t event) 
-{
+void USB_EndPoint2 (uint32_t event) {
   event = event;
 }
 
index 4147725..fb78918 100644 (file)
@@ -766,7 +766,7 @@ static void chb_radio_init()
                       CHB_EINTPIN,
                       gpioInterruptSense_Edge,        // Edge-sensitive
                       gpioInterruptEdge_Single,       // Single edge
-                      gpioInterruptEvent_ActiveHigh); // High triggers interrupt
+                      gpioInterruptEvent_ActiveLow);  // High triggers interrupt
 
     // enable interrupt
     gpioIntEnable (CHB_EINTPORT,
index f7f981d..24d8975 100644 (file)
@@ -108,8 +108,6 @@ extern volatile uint8_t   I2CMasterBuffer[I2C_BUFSIZE];
 extern volatile uint8_t   I2CSlaveBuffer[I2C_BUFSIZE];
 extern volatile uint32_t  I2CReadLength, I2CWriteLength;
 
-uint32_t i, timeout;
-
 static bool _mcp24aaInitialised = false;
 
 /**************************************************************************/
@@ -164,6 +162,7 @@ mcp24aaError_e mcp24aaReadBuffer (uint16_t address, uint8_t *buffer, uint32_t bu
   // ToDo: Check if I2C is ready
 
   // Clear buffers
+  uint32_t i;
   for ( i = 0; i < I2C_BUFSIZE; i++ )
   {
     I2CMasterBuffer[i] = 0x00;
@@ -227,6 +226,7 @@ mcp24aaError_e mcp24aaWriteBuffer (uint16_t address, uint8_t *buffer, uint32_t b
   // ToDo: Check if I2C is ready
 
   // Clear write buffer
+  uint32_t i;
   for ( i = 0; i < I2C_BUFSIZE; i++ )
   {
     I2CMasterBuffer[i] = 0x00;
index 40d5a04..fce409b 100644 (file)
@@ -64,7 +64,7 @@ void ssd1306SendByte(uint8_t byte);
                          } while (0);
 #define DELAY(mS)     do { systickDelay( mS / CFG_SYSTICK_DELAY_IN_MS ); } while(0);
 
-uint8_t buffer[SSD1306_LCDWIDTH * SSD1306_LCDHEIGHT / 8];
+uint8_t _ssd1306buffer[SSD1306_LCDWIDTH * SSD1306_LCDHEIGHT / 8];
 
 /**************************************************************************/
 /* Private Methods                                                        */
@@ -223,7 +223,7 @@ void ssd1306DrawPixel(uint8_t x, uint8_t y)
   if ((x >= SSD1306_LCDWIDTH) || (y >= SSD1306_LCDHEIGHT))
     return;
 
-  buffer[x+ (y/8)*SSD1306_LCDWIDTH] |= (1 << y%8);
+  _ssd1306buffer[x+ (y/8)*SSD1306_LCDWIDTH] |= (1 << y%8);
 }
 
 /**************************************************************************/
@@ -241,7 +241,7 @@ void ssd1306ClearPixel(uint8_t x, uint8_t y)
   if ((x >= SSD1306_LCDWIDTH) || (y >= SSD1306_LCDHEIGHT))
     return;
 
-  buffer[x+ (y/8)*SSD1306_LCDWIDTH] &= ~(1 << y%8); 
+  _ssd1306buffer[x+ (y/8)*SSD1306_LCDWIDTH] &= ~(1 << y%8); 
 }
 
 /**************************************************************************/
@@ -259,7 +259,7 @@ void ssd1306ClearPixel(uint8_t x, uint8_t y)
 uint8_t ssd1306GetPixel(uint8_t x, uint8_t y)
 {
   if ((x >= SSD1306_LCDWIDTH) || (y >=SSD1306_LCDHEIGHT)) return 0;
-  return buffer[x+ (y/8)*SSD1306_LCDWIDTH] & (1 << y%8) ? 1 : 0;
+  return _ssd1306buffer[x+ (y/8)*SSD1306_LCDWIDTH] & (1 << y%8) ? 1 : 0;
 }
 
 /**************************************************************************/
@@ -269,7 +269,7 @@ uint8_t ssd1306GetPixel(uint8_t x, uint8_t y)
 /**************************************************************************/
 void ssd1306ClearScreen() 
 {
-  memset(buffer, 0, 1024);
+  memset(_ssd1306buffer, 0, 1024);
 }
 
 /**************************************************************************/
@@ -286,7 +286,7 @@ void ssd1306Refresh(void)
   uint16_t i;
   for (i=0; i<1024; i++) 
   {
-    DATA(buffer[i]);
+    DATA(_ssd1306buffer[i]);
   }
 }
 
index b0995ac..36707cb 100644 (file)
@@ -54,7 +54,7 @@ void sendByte(uint8_t byte);
 #define DATA(d)       do { gpioSetValue( ST7565_A0_PORT, ST7565_A0_PIN, 1 ); sendByte( d ); } while (0);
 #define DELAY(mS)     do { systickDelay( mS / CFG_SYSTICK_DELAY_IN_MS ); } while(0);
 
-uint8_t buffer[128*64/8];
+uint8_t _st7565buffer[128*64/8];
 
 /**************************************************************************/
 /* Private Methods                                                        */
@@ -257,7 +257,7 @@ void st7565SetBrightness(uint8_t val)
 /**************************************************************************/
 void st7565ClearScreen(void) 
 {
-  memset(&buffer, 0x00, 128*64/8);
+  memset(&_st7565buffer, 0x00, 128*64/8);
 }
 
 /**************************************************************************/
@@ -267,7 +267,7 @@ void st7565ClearScreen(void)
 /**************************************************************************/
 void st7565Refresh(void)
 {
-  writeBuffer(buffer);
+  writeBuffer(_st7565buffer);
 }
 
 /**************************************************************************/
@@ -286,7 +286,7 @@ void st7565DrawPixel(uint8_t x, uint8_t y)
     return;
 
   // x is which column
-  buffer[x+ (y/8)*128] |= (1 << (7-(y%8)));
+  _st7565buffer[x+ (y/8)*128] |= (1 << (7-(y%8)));
 }
 
 /**************************************************************************/
@@ -305,7 +305,7 @@ void st7565ClearPixel(uint8_t x, uint8_t y)
     return;
 
   // x is which column
-  buffer[x+ (y/8)*128] &= ~(1 << (7-(y%8)));
+  _st7565buffer[x+ (y/8)*128] &= ~(1 << (7-(y%8)));
 }
 
 /**************************************************************************/
@@ -323,7 +323,7 @@ void st7565ClearPixel(uint8_t x, uint8_t y)
 uint8_t st7565GetPixel(uint8_t x, uint8_t y)
 {
   if ((x >= 128) || (y >= 64)) return 0;
-  return buffer[x+ (y/8)*128] & (1 << (7-(y%8)));
+  return _st7565buffer[x+ (y/8)*128] & (1 << (7-(y%8)));
 }
 
 /**************************************************************************/
index 201df6c..61a0135 100644 (file)
@@ -649,6 +649,86 @@ void drawCircleFilled (uint16_t xCenter, uint16_t yCenter, uint16_t radius, uint
   }
 }
 
+/**************************************************************************/
+/*!
+    @brief  Draws a filled rounded corner
+
+    @param[in]  xCenter
+                The horizontal center of the circle
+    @param[in]  yCenter
+                The vertical center of the circle
+    @param[in]  radius
+                The circle's radius in pixels
+    @param[in]  position
+                The position of the corner, which affects how it will
+                be rendered
+    @param[in]  color
+                Color used when drawing
+*/
+/**************************************************************************/
+void drawCornerFilled (uint16_t xCenter, uint16_t yCenter, uint16_t radius, drawCornerPosition_t position, uint16_t color)
+{
+  int16_t f = 1 - radius;
+  int16_t ddF_x = 1;
+  int16_t ddF_y = -2 * radius;
+  int16_t x = 0;
+  int16_t y = radius;
+  int16_t xc_px, yc_my, xc_mx, xc_py, yc_mx, xc_my;
+  int16_t lcdWidth = lcdGetWidth();
+
+  switch (position)
+  {
+    case DRAW_CORNERPOSITION_TOPRIGHT:
+    case DRAW_CORNERPOSITION_TOPLEFT:
+      if (xCenter < lcdWidth) drawLine(xCenter, yCenter-radius < 0 ? 0 : yCenter-radius, xCenter, yCenter, color);
+      break;
+    case DRAW_CORNERPOSITION_BOTTOMRIGHT:
+    case DRAW_CORNERPOSITION_BOTTOMLEFT:
+      if (xCenter < lcdWidth) drawLine(xCenter, yCenter-radius < 0 ? 0 : yCenter, xCenter, (yCenter-radius) + (2*radius), color);
+      break;
+  }
+  
+  while (x<y) 
+  {
+    if (f >= 0) 
+    {
+      y--;
+      ddF_y += 2;
+      f += ddF_y;
+    }
+    x++;
+    ddF_x += 2;
+    f += ddF_x;
+
+    xc_px = xCenter+x;
+    xc_mx = xCenter-x;
+    xc_py = xCenter+y;
+    xc_my = xCenter-y;
+    yc_mx = yCenter-x;
+    yc_my = yCenter-y;
+
+    switch (position)
+    {
+      case DRAW_CORNERPOSITION_TOPRIGHT:
+        if ((xc_px < lcdWidth) && (xc_px >= 0)) drawLine(xc_px, yc_my, xc_px, yCenter, color);
+        if ((xc_py < lcdWidth) && (xc_py >= 0)) drawLine(xc_py, yc_mx, xc_py, yCenter, color);
+        break;
+      case DRAW_CORNERPOSITION_BOTTOMRIGHT:
+        if ((xc_px < lcdWidth) && (xc_px >= 0)) drawLine(xc_px, yCenter, xc_px, yc_my + 2*y, color);
+        if ((xc_py < lcdWidth) && (xc_py >= 0)) drawLine(xc_py, yCenter, xc_py, yc_mx + 2*x, color);
+        break;
+      case DRAW_CORNERPOSITION_TOPLEFT:
+        if ((xc_mx < lcdWidth) && (xc_mx >= 0)) drawLine(xc_mx, yc_my, xc_mx, yCenter, color);
+        if ((xc_my < lcdWidth) && (xc_my >= 0)) drawLine(xc_my, yc_mx, xc_my, yCenter, color);
+        break;
+      case DRAW_CORNERPOSITION_BOTTOMLEFT:
+        if ((xc_mx < lcdWidth) && (xc_mx >= 0)) drawLine(xc_mx, yCenter, xc_mx, yc_my + 2*y, color);
+        if ((xc_my < lcdWidth) && (xc_my >= 0)) drawLine(xc_my, yCenter, xc_my, yc_mx + 2*x, color);
+        break;
+    }
+  }
+}
+
 /**************************************************************************/
 /*!
     @brief  Draws a simple arrow of the specified width
index 7632392..d443bfd 100644 (file)
@@ -68,6 +68,14 @@ typedef enum
   DRAW_ROUNDEDCORNERS_RIGHT   = 5
 } drawRoundedCorners_t;
 
+typedef enum
+{
+  DRAW_CORNERPOSITION_TOPLEFT     = 0,
+  DRAW_CORNERPOSITION_TOPRIGHT    = 1,
+  DRAW_CORNERPOSITION_BOTTOMLEFT  = 2,
+  DRAW_CORNERPOSITION_BOTTOMRIGHT = 3
+} drawCornerPosition_t;
+
 typedef enum
 {
   DRAW_DIRECTION_LEFT,
@@ -83,6 +91,7 @@ void      drawLine             ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t
 void      drawLineDotted       ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t space, uint16_t solid, uint16_t color );
 void      drawCircle           ( uint16_t xCenter, uint16_t yCenter, uint16_t radius, uint16_t color );
 void      drawCircleFilled     ( uint16_t xCenter, uint16_t yCenter, uint16_t radius, uint16_t color );
+void      drawCornerFilled     (uint16_t xCenter, uint16_t yCenter, uint16_t radius, drawCornerPosition_t position, uint16_t color);
 void      drawArrow            ( uint16_t x, uint16_t y, uint16_t size, drawDirection_t, uint16_t color );
 void      drawRectangle        ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color );
 void      drawRectangleFilled  ( uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1, uint16_t color );
index b8ad0fa..ed2d0f8 100644 (file)
@@ -46,7 +46,6 @@ extern volatile uint8_t   I2CMasterBuffer[I2C_BUFSIZE];
 extern volatile uint8_t   I2CSlaveBuffer[I2C_BUFSIZE];
 extern volatile uint32_t  I2CReadLength, I2CWriteLength;
 
-uint32_t i;
 uint8_t monthday[12]={31,28,31,30,31,30,31,31,30,31,30,31};
 
 static bool _isl12022mInitialised = false;
@@ -79,6 +78,7 @@ uint8_t isl12022mBCDToDec(uint8_t val)
 isl12022mError_t isl12022mWrite8 (uint8_t address, uint8_t reg, uint32_t value)
 {
   // Clear write buffers
+  uint32_t i;
   for ( i = 0; i < I2C_BUFSIZE; i++ )
   {
     I2CMasterBuffer[i] = 0x00;
@@ -104,6 +104,7 @@ isl12022mError_t isl12022mReadBuffer(uint8_t address, uint8_t reg, uint8_t *buff
     return ISL12022M_ERROR_I2C_BUFFEROVERFLOW;
 
   // Clear write buffers
+  uint32_t i;
   for ( i = 0; i < I2C_BUFSIZE; i++ )
   {
     I2CMasterBuffer[i] = 0x00;
index d5633d9..ca4d742 100644 (file)
@@ -87,8 +87,6 @@ extern volatile uint8_t   I2CMasterBuffer[I2C_BUFSIZE];
 extern volatile uint8_t   I2CSlaveBuffer[I2C_BUFSIZE];
 extern volatile uint32_t  I2CReadLength, I2CWriteLength;
 
-uint32_t i;
-
 static bool _lm75bInitialised = false;
 
 /**************************************************************************/
@@ -99,6 +97,7 @@ static bool _lm75bInitialised = false;
 lm75bError_e lm75bWrite8 (uint8_t reg, uint32_t value)
 {
   // Clear write buffers
+  uint32_t i;
   for ( i = 0; i < I2C_BUFSIZE; i++ )
   {
     I2CMasterBuffer[i] = 0x00;
@@ -121,6 +120,7 @@ lm75bError_e lm75bWrite8 (uint8_t reg, uint32_t value)
 lm75bError_e lm75bRead16(uint8_t reg, int32_t *value)
 {
   // Clear write buffers
+  uint32_t i;
   for ( i = 0; i < I2C_BUFSIZE; i++ )
   {
     I2CMasterBuffer[i] = 0x00;
index 2a81c71..42a5719 100644 (file)
@@ -53,8 +53,6 @@ extern volatile uint8_t   I2CMasterBuffer[I2C_BUFSIZE];
 extern volatile uint8_t   I2CSlaveBuffer[I2C_BUFSIZE];
 extern volatile uint32_t  I2CReadLength, I2CWriteLength;
 
-uint32_t i;
-
 static bool _tcs3414Initialised = false;
 
 /**************************************************************************/
@@ -65,6 +63,7 @@ static bool _tcs3414Initialised = false;
 tcs3414Error_e tcs3414WriteCmd (uint8_t cmd)
 {
   // Clear write buffers
+  uint32_t i;
   for ( i = 0; i < I2C_BUFSIZE; i++ )
   {
     I2CMasterBuffer[i] = 0x00;
@@ -86,6 +85,7 @@ tcs3414Error_e tcs3414WriteCmd (uint8_t cmd)
 tcs3414Error_e tcs3414Write8 (uint8_t reg, uint32_t value)
 {
   // Clear write buffers
+  uint32_t i;
   for ( i = 0; i < I2C_BUFSIZE; i++ )
   {
     I2CMasterBuffer[i] = 0x00;
@@ -108,6 +108,7 @@ tcs3414Error_e tcs3414Write8 (uint8_t reg, uint32_t value)
 tcs3414Error_e tcs3414Read16(uint8_t reg, uint16_t *value)
 {
   // Clear write buffers
+  uint32_t i;
   for ( i = 0; i < I2C_BUFSIZE; i++ )
   {
     I2CMasterBuffer[i] = 0x00;
index 79027b5..db82dbe 100644 (file)
@@ -71,8 +71,6 @@ extern volatile uint8_t   I2CMasterBuffer[I2C_BUFSIZE];
 extern volatile uint8_t   I2CSlaveBuffer[I2C_BUFSIZE];
 extern volatile uint32_t  I2CReadLength, I2CWriteLength;
 
-uint32_t i;
-
 static bool _tsl2561Initialised = false;
 static tsl2561IntegrationTime_t _tsl2561IntegrationTime = TSL2561_INTEGRATIONTIME_402MS;
 static tsl2561Gain_t _tsl2561Gain = TSL2561_GAIN_0X;
@@ -85,6 +83,7 @@ static tsl2561Gain_t _tsl2561Gain = TSL2561_GAIN_0X;
 tsl2561Error_t tsl2561WriteCmd (uint8_t cmd)
 {
   // Clear write buffers
+  uint32_t i;
   for ( i = 0; i < I2C_BUFSIZE; i++ )
   {
     I2CMasterBuffer[i] = 0x00;
@@ -106,6 +105,7 @@ tsl2561Error_t tsl2561WriteCmd (uint8_t cmd)
 tsl2561Error_t tsl2561Write8 (uint8_t reg, uint32_t value)
 {
   // Clear write buffers
+  uint32_t i;
   for ( i = 0; i < I2C_BUFSIZE; i++ )
   {
     I2CMasterBuffer[i] = 0x00;
@@ -128,6 +128,7 @@ tsl2561Error_t tsl2561Write8 (uint8_t reg, uint32_t value)
 tsl2561Error_t tsl2561Read16(uint8_t reg, uint16_t *value)
 {
   // Clear write buffers
+  uint32_t i;
   for ( i = 0; i < I2C_BUFSIZE; i++ )
   {
     I2CMasterBuffer[i] = 0x00;
index e69af30..9da8fcb 100644 (file)
--- a/lpc134x.h
+++ b/lpc134x.h
@@ -2109,8 +2109,8 @@ static inline void NVIC_DisableIRQ(IRQn_t IRQn)
 #define USB_DEVINTST_EP6                          ((unsigned int) 0x00000080) // USB core interrupt for EP6
 #define USB_DEVINTST_EP7_MASK                     ((unsigned int) 0x00000100)
 #define USB_DEVINTST_EP7                          ((unsigned int) 0x00000100) // USB core interrupt for EP7
-#define USB_DEVINTST_DEV_START_MASK               ((unsigned int) 0x00000200)
-#define USB_DEVINTST_DEV_START                    ((unsigned int) 0x00000200)
+#define USB_DEVINTST_DEV_STAT_MASK                ((unsigned int) 0x00000200)
+#define USB_DEVINTST_DEV_STA                    ((unsigned int) 0x00000200)
 #define USB_DEVINTST_CC_EMPTY_MASK                ((unsigned int) 0x00000400)
 #define USB_DEVINTST_CC_EMPTY                     ((unsigned int) 0x00000400)
 #define USB_DEVINTST_CD_FULL_MASK                 ((unsigned int) 0x00000800)
@@ -2140,8 +2140,8 @@ static inline void NVIC_DisableIRQ(IRQn_t IRQn)
 #define USB_DEVINTEN_EP6                          ((unsigned int) 0x00000080)
 #define USB_DEVINTEN_EP7_MASK                     ((unsigned int) 0x00000100)
 #define USB_DEVINTEN_EP7                          ((unsigned int) 0x00000100)
-#define USB_DEVINTEN_DEV_START_MASK               ((unsigned int) 0x00000200)
-#define USB_DEVINTEN_DEV_START                    ((unsigned int) 0x00000200)
+#define USB_DEVINTEN_DEV_STAT_MASK                ((unsigned int) 0x00000200)
+#define USB_DEVINTEN_DEV_STA                    ((unsigned int) 0x00000200)
 #define USB_DEVINTEN_CC_EMPTY_MASK                ((unsigned int) 0x00000400)
 #define USB_DEVINTEN_CC_EMPTY                     ((unsigned int) 0x00000400)
 #define USB_DEVINTEN_CD_FULL_MASK                 ((unsigned int) 0x00000800)
@@ -2171,8 +2171,8 @@ static inline void NVIC_DisableIRQ(IRQn_t IRQn)
 #define USB_DEVINTCLR_EP6                         ((unsigned int) 0x00000080)
 #define USB_DEVINTCLR_EP7_MASK                    ((unsigned int) 0x00000100)
 #define USB_DEVINTCLR_EP7                         ((unsigned int) 0x00000100)
-#define USB_DEVINTCLR_DEV_START_MASK              ((unsigned int) 0x00000200)
-#define USB_DEVINTCLR_DEV_START                   ((unsigned int) 0x00000200)
+#define USB_DEVINTCLR_DEV_STAT_MASK               ((unsigned int) 0x00000200)
+#define USB_DEVINTCLR_DEV_STA                   ((unsigned int) 0x00000200)
 #define USB_DEVINTCLR_CC_EMPTY_MASK               ((unsigned int) 0x00000400)
 #define USB_DEVINTCLR_CC_EMPTY                    ((unsigned int) 0x00000400)
 #define USB_DEVINTCLR_CD_FULL_MASK                ((unsigned int) 0x00000800)
@@ -2202,8 +2202,8 @@ static inline void NVIC_DisableIRQ(IRQn_t IRQn)
 #define USB_DEVINTSET_EP6                         ((unsigned int) 0x00000080)
 #define USB_DEVINTSET_EP7_MASK                    ((unsigned int) 0x00000100)
 #define USB_DEVINTSET_EP7                         ((unsigned int) 0x00000100)
-#define USB_DEVINTSET_DEV_START_MASK              ((unsigned int) 0x00000200)
-#define USB_DEVINTSET_DEV_START                   ((unsigned int) 0x00000200)
+#define USB_DEVINTSET_DEV_STAT_MASK               ((unsigned int) 0x00000200)
+#define USB_DEVINTSET_DEV_STA                   ((unsigned int) 0x00000200)
 #define USB_DEVINTSET_CC_EMPTY_MASK               ((unsigned int) 0x00000400)
 #define USB_DEVINTSET_CC_EMPTY                    ((unsigned int) 0x00000400)
 #define USB_DEVINTSET_CD_FULL_MASK                ((unsigned int) 0x00000800)
diff --git a/main.c b/main.c
index 8b75435..d0dd354 100644 (file)
--- a/main.c
+++ b/main.c
   #include "core/cmd/cmd.h"
 #endif
 
-/**************************************************************************/
-/*! 
-    Approximates a 1 millisecond delay using "nop".  This is less
-    accurate than a dedicated timer, but is useful in certain situations.
-
-    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.
-*/
-/**************************************************************************/
-void delayms(uint32_t ms)
-{
-  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
index 7376c5a..a775021 100644 (file)
@@ -63,8 +63,10 @@ void cmd_progress(uint8_t argc, char **argv);
 void cmd_getpixel(uint8_t argc, char **argv);
 void cmd_calibrate(uint8_t argc, char **argv);
 void cmd_orientation(uint8_t argc, char **argv);
+void cmd_roundedcorner(uint8_t argc, char **argv);
 void cmd_text(uint8_t argc, char **argv);
 void cmd_textw(uint8_t argc, char **argv);
+void cmd_triangle(uint8_t argc, char **argv);
 void cmd_tsthreshhold(uint8_t argc, char **argv);
 void cmd_tswait(uint8_t argc, char **argv);
 #ifdef CFG_SDCARD
@@ -126,6 +128,7 @@ cmd_t cmd_tbl[] =
   { "g",    2,  2,  0, cmd_getpixel          , "Get Pixel"                      , "'g <x> <y>'" },
   { "l",    5,  7,  0, cmd_line              , "Line"                           , "'l <x1> <y1> <x2> <y2> <color> [<empty> <solid>]'" },
   { "L",    1,  1,  0, cmd_backlight         , "Backlight"                      , "'L <0|1>'" },
+  { "n",    5,  5,  0, cmd_roundedcorner     , "Rounded Corner"                 , "'n <x> <y> <radius> <corner> <color>'" },
   { "o",    0,  1,  0, cmd_orientation       , "LCD Orientation"                , "'o [<0|1>]'" },
   { "p",    3,  3,  0, cmd_pixel             , "Draw Pixel"                     , "'p <x> <y> <color>'" },
   { "P",    9,  9,  0, cmd_progress          , "Progress Bar"                   , "'P <x> <y> <w> <h> <%> <bclr> <bfillclr> <pbrdclr> <pfillclr>'" },
@@ -133,6 +136,7 @@ cmd_t cmd_tbl[] =
   { "R",    7,  7,  0, cmd_rectangleround    , "Rounded Rectangle"              , "'R <x1> <y1> <x2> <y2> <color> <radius> <corners>'" },
   { "s",    2, 99,  0, cmd_textw             , "Text Width"                     , "'s <font#> <msg>'" },
   { "t",    5, 99,  0, cmd_text              , "Text"                           , "'t <x> <y> <color> <font#> <msg>'" },
+  { "v",    7,  8,  0, cmd_triangle          , "Triangle"                       , "'v <x1> <y1> <x2> <y2> <x3> <y3> <color> [<filled[0|1]>]'" },
   { "W",    0,  1,  0, cmd_tswait            , "Wait for Touch"                 , "'W [<ms>]'" },
   { "x",    0,  1,  0, cmd_tsthreshhold      , "Touch Threshold"                , "'x [<0..254>]'" },
   #endif
diff --git a/project/commands/cmd_reset.c b/project/commands/cmd_reset.c
new file mode 100644 (file)
index 0000000..aa665f0
--- /dev/null
@@ -0,0 +1,60 @@
+/**************************************************************************/
+/*! 
+    @file     cmd_reset.c
+    @author   K. Townsend (microBuilder.eu)
+
+    @brief    Code to execute for cmd_reset in the 'core/cmd'
+              command-line interpretter.
+
+    @section LICENSE
+
+    Software License Agreement (BSD License)
+
+    Copyright (c) 2010, microBuilder SARL
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+    3. Neither the name of the copyright holders nor the
+    names of its contributors may be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/**************************************************************************/
+#include <stdio.h>
+
+#include "projectconfig.h"
+#include "core/cmd/cmd.h"
+#include "core/cpu/cpu.h"
+#include "project/commands.h"       // Generic helper functions
+
+#ifdef CFG_I2CEEPROM
+  #include "drivers/eeprom/eeprom.h"
+  #include "core/uart/uart.h"
+
+/**************************************************************************/
+/*! 
+    Resets the board using the AIRCR register
+*/
+/**************************************************************************/
+void cmd_reset(uint8_t argc, char **argv)
+{
+  cpuReset();
+}
+
+#endif
diff --git a/project/commands/drawing/cmd_backlight.c b/project/commands/drawing/cmd_backlight.c
new file mode 100644 (file)
index 0000000..2c3c359
--- /dev/null
@@ -0,0 +1,65 @@
+/**************************************************************************/
+/*! 
+    @file     cmd_backlight.c
+    @author   K. Townsend (microBuilder.eu)
+
+    @brief    Code to execute for cmd_backlight in the 'core/cmd'
+              command-line interpretter.
+
+    @section LICENSE
+
+    Software License Agreement (BSD License)
+
+    Copyright (c) 2010, microBuilder SARL
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+    3. Neither the name of the copyright holders nor the
+    names of its contributors may be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/**************************************************************************/
+#include <stdio.h>
+
+#include "projectconfig.h"
+#include "core/cmd/cmd.h"
+#include "project/commands.h"       // Generic helper functions
+
+#ifdef CFG_TFTLCD    
+  #include "drivers/lcd/tft/lcd.h"    
+  #include "drivers/lcd/tft/drawing.h"  
+
+/**************************************************************************/
+/*! 
+    Sets the LCD backlight state
+*/
+/**************************************************************************/
+void cmd_backlight(uint8_t argc, char **argv)
+{
+  int32_t input;
+  bool state;
+  getNumber (argv[0], &input);
+  // Set backlight
+  state = input < 1 ? false : true;
+  lcdBacklight(state);
+}
+
+#endif  
diff --git a/project/commands/drawing/cmd_roundedcorner.c b/project/commands/drawing/cmd_roundedcorner.c
new file mode 100644 (file)
index 0000000..fe69969
--- /dev/null
@@ -0,0 +1,85 @@
+/**************************************************************************/
+/*! 
+    @file     cmd_roundedcorner.c
+    @author   K. Townsend (microBuilder.eu)
+
+    @brief    Code to execute for cmd_roundedcorner in the 'core/cmd'
+              command-line interpretter.
+
+    @section LICENSE
+
+    Software License Agreement (BSD License)
+
+    Copyright (c) 2010, microBuilder SARL
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+    3. Neither the name of the copyright holders nor the
+    names of its contributors may be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/**************************************************************************/
+#include <stdio.h>
+
+#include "projectconfig.h"
+#include "core/cmd/cmd.h"
+#include "project/commands.h"       // Generic helper functions
+
+#ifdef CFG_TFTLCD    
+  #include "drivers/lcd/tft/lcd.h"    
+  #include "drivers/lcd/tft/drawing.h"  
+
+/**************************************************************************/
+/*! 
+    Displays a rounded corner on the LCD.
+*/
+/**************************************************************************/
+void cmd_roundedcorner(uint8_t argc, char **argv)
+{
+  int32_t x, y, r, corner, color;
+  
+  // Convert supplied parameters
+  getNumber (argv[0], &x);
+  getNumber (argv[1], &y);
+  getNumber (argv[2], &r);
+  getNumber (argv[3], &corner);
+  getNumber (argv[4], &color);
+
+  // Validate data
+  if (corner < 0 || corner > 3)
+  {
+    printf("Invalid Corner%s", CFG_PRINTF_NEWLINE);
+    return;
+  }
+  if (color < 0 || color > 0xFFFF)
+  {
+    printf("Invalid Color%s", CFG_PRINTF_NEWLINE);
+    return;
+  }
+  if (r < 1)
+  {
+    printf("Invalid Radius%s", CFG_PRINTF_NEWLINE);
+    return;
+  }
+
+  drawCornerFilled (x, y, r, corner, color);
+}
+
+#endif  
diff --git a/project/commands/drawing/cmd_triangle.c b/project/commands/drawing/cmd_triangle.c
new file mode 100644 (file)
index 0000000..ac82dfb
--- /dev/null
@@ -0,0 +1,85 @@
+/**************************************************************************/
+/*! 
+    @file     cmd_triangle.c
+    @author   K. Townsend (microBuilder.eu)
+
+    @brief    Code to execute for cmd_triangle in the 'core/cmd'
+              command-line interpretter.
+
+    @section LICENSE
+
+    Software License Agreement (BSD License)
+
+    Copyright (c) 2010, microBuilder SARL
+    All rights reserved.
+
+    Redistribution and use in source and binary forms, with or without
+    modification, are permitted provided that the following conditions are met:
+    1. Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+    2. Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in the
+    documentation and/or other materials provided with the distribution.
+    3. Neither the name of the copyright holders nor the
+    names of its contributors may be used to endorse or promote products
+    derived from this software without specific prior written permission.
+
+    THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
+    EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+    WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+    DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
+    DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+    (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+    LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+    ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+    (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+    SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
+/**************************************************************************/
+#include <stdio.h>
+
+#include "projectconfig.h"
+#include "core/cmd/cmd.h"
+#include "project/commands.h"       // Generic helper functions
+
+#ifdef CFG_TFTLCD    
+  #include "drivers/lcd/tft/lcd.h"    
+  #include "drivers/lcd/tft/drawing.h"  
+
+/**************************************************************************/
+/*! 
+    Displays a triangle on the LCD.
+*/
+/**************************************************************************/
+void cmd_triangle(uint8_t argc, char **argv)
+{
+  int32_t x1, y1, x2, y2, x3, y3, c, filled;
+  filled = 0;
+
+  // Convert supplied parameters
+  getNumber (argv[0], &x1);
+  getNumber (argv[1], &y1);
+  getNumber (argv[2], &x2);
+  getNumber (argv[3], &y2);
+  getNumber (argv[4], &x3);
+  getNumber (argv[5], &y3);
+  getNumber (argv[6], &c);
+  if (argc == 8)
+  {
+    getNumber (argv[7], &filled);
+  }
+
+  // ToDo: Validate data!
+  if (c < 0 || c > 0xFFFF)
+  {
+    printf("Invalid Color%s", CFG_PRINTF_NEWLINE);
+    return;
+  }
+
+  if (filled)
+    drawTriangleFilled(x1, y1, x2, y2, x3, y3, (uint16_t)c);
+  else
+    drawTriangle(x1, y1, x2, y2, x3, y3, (uint16_t)c);
+}
+
+#endif  
index c90a88a..1252ef0 100644 (file)
@@ -48,8 +48,8 @@
     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_USB
+    #define CFG_BRD_LPC1343_REFDESIGN
+    // #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB
     // #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART
     // #define CFG_BRD_LPC1343_802154USBSTICK
 /*=========================================================================*/
 /*=========================================================================*/
 
 
+/*=========================================================================
+    ALTERNATE RESET PIN
+    -----------------------------------------------------------------------
+
+    CFG_ALTRESET        If defined, indicates that a GPIO pin should be
+                        configured as an alternate reset pin in addition
+                        to the dedicated reset pin.
+    CFG_ALTRESET_PORT   The GPIO port where the alt reset pin is located
+    CFG_ALTRESET_PIN    The GPIO pin where the alt reset pin is located
+
+    -----------------------------------------------------------------------*/
+    #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART
+      #define CFG_ALTRESET
+      #define CFG_ALTRESET_PORT         (1)
+      #define CFG_ALTRESET_PIN          (5)   // P1.5 = RTS
+    #endif
+/*=========================================================================*/
+
+
 /*=========================================================================
     UART
     -----------------------------------------------------------------------
     #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB
       #define CFG_INTERFACE
       #define CFG_INTERFACE_MAXMSGSIZE    (256)
-      #define CFG_INTERFACE_PROMPT        "LCD >> "
+      #define CFG_INTERFACE_PROMPT        "CMD >> "
       #define CFG_INTERFACE_SILENTMODE    (0)
       #define CFG_INTERFACE_DROPCR        (0)
       #define CFG_INTERFACE_ENABLEIRQ     (0)
     #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART
       #define CFG_INTERFACE
       #define CFG_INTERFACE_MAXMSGSIZE    (256)
-      #define CFG_INTERFACE_PROMPT        "LCD >> "
+      #define CFG_INTERFACE_PROMPT        ">>"
       #define CFG_INTERFACE_SILENTMODE    (1)
       #define CFG_INTERFACE_DROPCR        (1)
       #define CFG_INTERFACE_ENABLEIRQ     (1)
index bf79c8e..9b786b4 100644 (file)
--- a/sysdefs.h
+++ b/sysdefs.h
 
 // Stay compatible with ugly "windows" style
 #define BOOL bool
+
+#ifndef TRUE
 #define TRUE true
+#endif
+#ifndef FALSE
 #define FALSE false
+#endif
 
 typedef volatile uint8_t REG8;
 typedef volatile uint16_t REG16;
index 60b4d3b..80d2f5c 100644 (file)
--- a/sysinit.c
+++ b/sysinit.c
@@ -130,6 +130,13 @@ void systemInit()
   gpioSetDir(CFG_LED_PORT, CFG_LED_PIN, 1);
   gpioSetValue(CFG_LED_PORT, CFG_LED_PIN, CFG_LED_OFF);
 
+  // Config alt reset pin if requested (really only relevant to LPC1343 LCD Board)
+  #ifdef CFG_ALTRESET
+    gpioSetDir (CFG_ALTRESET_PORT, CFG_ALTRESET_PIN, gpioDirection_Input);
+    gpioSetInterrupt (CFG_ALTRESET_PORT, CFG_ALTRESET_PIN, gpioInterruptSense_Level, gpioInterruptEdge_Single, gpioInterruptEvent_ActiveHigh);
+    gpioIntEnable (CFG_ALTRESET_PORT, CFG_ALTRESET_PIN); 
+  #endif
+
   // Initialise EEPROM
   #ifdef CFG_I2CEEPROM
     mcp24aaInit();
diff --git a/tools/testfirmware/usbcli.bin b/tools/testfirmware/usbcli.bin
deleted file mode 100644 (file)
index 652047c..0000000
Binary files a/tools/testfirmware/usbcli.bin and /dev/null differ
This page took 0.116124 seconds and 4 git commands to generate.