See changelog
authorKevin Townsend <kevin@ktownsend.com>
Fri, 4 Nov 2011 21:27:22 +0000 (22:27 +0100)
committerKevin Townsend <kevin@ktownsend.com>
Fri, 4 Nov 2011 21:27:22 +0000 (22:27 +0100)
12 files changed:
ChangeLog.txt
Makefile
build/codelite/LPC1343 Workspace.tags [deleted file]
build/codelite/LPC1343 Workspace.workspace.session
build/codelite/LPC1343_CodeBase.project
build/crossworks/LPC1343_CodeBase.hzs
drivers/lcd/bitmap/sharpmem/sharpmem.c
drivers/spiflash/spiflash.h
drivers/spiflash/w25q16bv/w25q16bv.c
main.c
projectconfig.h
sysinit.c

index 73bb2e2..2eb8825 100644 (file)
@@ -6,6 +6,12 @@ v0.9.8 - Ongoing
   /tools/examples/spiflash/*
 - Added write function to SPI Flash driver
   /drivers/spiflash/*
+- Added CFG_BRD_LPC1343_REFDESIGN_MINIMAL as a board
+  option in projectconfig.h.  Tries to keep the flash
+  use as small as possible by initialising less
+  peripherals in systemInit().
+- Changed CodeLite project files to support real
+  debugging with a Segger J-Link and GDB Server.
 
 v0.9.5 - 3 August 2011
 ======================
index 3f71b77..78bfbf7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -15,6 +15,14 @@ SRAM_USB = 384
 VPATH = 
 OBJS = main.o
 
+##########################################################################
+# Debug settings
+##########################################################################
+
+# Set DEBUGBUILD to 'TRUE' for full debugging (larger, slower binaries), 
+# or to 'FALSE' for release builds (smallest, fastest binaries)
+DEBUGBUILD = FALSE
+
 ##########################################################################
 # Project-specific files 
 ##########################################################################
@@ -157,9 +165,14 @@ OBJS += $(TARGET)_handlers.o LPC1xxx_startup.o
 ##########################################################################
 # Compiler settings, parameters and flags
 ##########################################################################
+ifeq (TRUE,$(DEBUGBUILD))
+  CFLAGS  = -c -g -O0 $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -fno-builtin
+  ASFLAGS = -c -g -O0 $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -D__ASSEMBLY__ -x assembler-with-cpp
+else
+  CFLAGS  = -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -fno-builtin
+  ASFLAGS = -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -D__ASSEMBLY__ -x assembler-with-cpp
+endif
 
-CFLAGS  = -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -fno-builtin
-ASFLAGS = -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -D__ASSEMBLY__ -x assembler-with-cpp
 LDFLAGS = -nostartfiles -mthumb -mcpu=$(CPU_TYPE) -Wl,--gc-sections
 LDLIBS  = -lm
 OCFLAGS = --strip-unneeded
diff --git a/build/codelite/LPC1343 Workspace.tags b/build/codelite/LPC1343 Workspace.tags
deleted file mode 100644 (file)
index d64d744..0000000
Binary files a/build/codelite/LPC1343 Workspace.tags and /dev/null differ
index df01b19..3eb326e 100644 (file)
@@ -1,24 +1,18 @@
-<?xml version="1.0" encoding="utf-8"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <Session Name="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\build\codelite\LPC1343 Workspace.workspace">
-  <int Value="0" Name="m_selectedTab"/>
+  <int Value="1" 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\main.c" Name="FileName"/>
-      <int Value="0" Name="FirstVisibleLine"/>
-      <int Value="11" Name="CurrentLine"/>
-      <wxArrayString Name="Bookmarks"/>
-    </TabInfo>
     <TabInfo>
       <wxString Value="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\Makefile" Name="FileName"/>
-      <int Value="161" Name="FirstVisibleLine"/>
-      <int Value="167" Name="CurrentLine"/>
+      <int Value="0" Name="FirstVisibleLine"/>
+      <int Value="5" Name="CurrentLine"/>
       <wxArrayString Name="Bookmarks"/>
     </TabInfo>
     <TabInfo>
-      <wxString Value="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\projectconfig.h" Name="FileName"/>
-      <int Value="45" Name="FirstVisibleLine"/>
-      <int Value="10" Name="CurrentLine"/>
+      <wxString Value="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" Name="FileName"/>
+      <int Value="21" Name="FirstVisibleLine"/>
+      <int Value="62" Name="CurrentLine"/>
       <wxArrayString Name="Bookmarks"/>
     </TabInfo>
   </TabInfoArray>
index 96405f8..655a180 100644 (file)
       <ResourceCompiler Options=""/>
     </GlobalSettings>
     <Configuration Name="Debug" CompilerType="gnu gcc" DebuggerType="GNU gdb debugger" Type="Dynamic Library" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
-      <Compiler Options="-g" C_Options="-g" Required="yes" PreCompiledHeader="">
+      <Compiler Options="-g" C_Options="-g" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
         <IncludePath Value="."/>
       </Compiler>
       <Linker Options="" Required="yes"/>
       <ResourceCompiler Options="" Required="no"/>
-      <General OutputFile="" IntermediateDirectory="./Debug" Command="" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes"/>
-      <Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;"/>
+      <General OutputFile="" IntermediateDirectory="../../" Command="firmware.elf" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes"/>
+      <Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
+        <![CDATA[]]>
+      </Environment>
       <Debugger IsRemote="yes" RemoteHostName="localhost" RemoteHostPort="2331" DebuggerPath="arm-none-eabi-gdb.exe">
-        <PostConnectCommands># Make sure that we are using SWD
+        <PostConnectCommands/>
+        <StartupCommands># Make sure that we are using SWD
 monitor interface SWD
+
 # Set monitor to little endian
 monitor endian little
+
 # Set monitor speed
 monitor speed 1000
+
 # Reset device
 monitor reset
+
 # Set device ID to LPC1343
 monitor flash device = LPC1343
+
 # Enable flash download
 monitor flash download = 1
+
 # Transfer the firmware to the device
 load "../../firmware.elf"
+
 # Initializing PC and stack pointer
 monitor reg r13 = (0x00000000)
 monitor reg pc = (0x00000004)
-</PostConnectCommands>
-        <StartupCommands/>
+
+monitor reset</StartupCommands>
       </Debugger>
       <PreBuild/>
       <PostBuild/>
@@ -346,15 +356,22 @@ monitor reg pc = (0x00000004)
         <CustomPostBuild/>
         <CustomPreBuild/>
       </AdditionalRules>
+      <Completion>
+        <ClangCmpFlags/>
+        <ClangPP/>
+        <SearchPaths/>
+      </Completion>
     </Configuration>
     <Configuration Name="Release" CompilerType="gnu gcc" DebuggerType="GNU gdb debugger" Type="Dynamic Library" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
-      <Compiler Options="" C_Options="" Required="yes" PreCompiledHeader="">
+      <Compiler Options="" C_Options="" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
         <IncludePath Value="."/>
       </Compiler>
       <Linker Options="-O2" Required="yes"/>
       <ResourceCompiler Options="" Required="no"/>
       <General OutputFile="" IntermediateDirectory="./Release" Command="" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes"/>
-      <Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;"/>
+      <Environment EnvVarSetName="&lt;Use Defaults&gt;" DbgSetName="&lt;Use Defaults&gt;">
+        <![CDATA[]]>
+      </Environment>
       <Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="">
         <PostConnectCommands/>
         <StartupCommands/>
@@ -375,6 +392,11 @@ monitor reg pc = (0x00000004)
         <CustomPostBuild/>
         <CustomPreBuild/>
       </AdditionalRules>
+      <Completion>
+        <ClangCmpFlags/>
+        <ClangPP/>
+        <SearchPaths/>
+      </Completion>
     </Configuration>
   </Settings>
 </CodeLite_Project>
index f4373df..d377204 100644 (file)
   <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;core" name="unnamed" />
+  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;core;cpu" name="unnamed" />
+  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;core;i2c" name="unnamed" />
+  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;core;pmu" name="unnamed" />
+  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;core;timer32" name="unnamed" />
+  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;core;uart" name="unnamed" />
+  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;core;wdt" 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;bitmap" name="unnamed" />
+  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers;lcd;bitmap;sharpmem" name="unnamed" />
+  <ProjectSessionItem path="LPC1343_CodeBase;LPC1343_CodeBase;Source Files;drivers;lcd;tft" name="unnamed" />
  </Project>
  <Register1>
   <RegisterWindow openNodes="USB;USB/USBRxPLen;USB/USBTxPLen;USB/USBCtrl" binaryNodes="" hiddenNodes="" unsignedNodes="" visibleGroups="CPU;USB" decimalNodes="" octalNodes="" asciiNodes="" />
  </TraceWindow>
  <Watch1>
   <Watches active="1" update="Each Second" >
-   <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" />
+   <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" />
   </Watches>
  </Watch1>
  <Watch2>
@@ -68,7 +80,7 @@
   <Watches active="0" update="Never" />
  </Watch4>
  <Files>
-  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="18" debugPath="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" y="14" path="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" left="0" selected="1" name="unnamed" top="84" />
+  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="20" debugPath="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" y="5" path="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\main.c" left="0" selected="1" name="unnamed" top="0" />
  </Files>
  <ARMCrossStudioWindow activeProject="LPC1343_CodeBase" autoConnectTarget="Segger J-Link" debugSearchFileMap="" fileDialogInitialDirectory="C:\Dropbox\microBuilder\Code\LPC1343\LPC1343_CodeBase_GIT\drivers\lcd\tft\hw" fileDialogDefaultFilter="*.c" autoConnectCapabilities="388991" debugSearchPath="" buildConfiguration="THUMB Flash Release" />
 </session>
index dd829e2..545e643 100644 (file)
@@ -328,7 +328,7 @@ void sharpmemRefresh(void)
     {
       // Send end of line and address bytes
       sharpmemSendByte(0x00);
-      if (currentline < SHARPMEM_LCDHEIGHT)
+      if (currentline <= SHARPMEM_LCDHEIGHT)
       {
         sharpmemSendByte(sharpmemSwap(currentline));
       }
index 0f7e253..f970cdd 100644 (file)
@@ -277,4 +277,63 @@ spiflashError_e spiflashEraseChip (void);
 /**************************************************************************/
 spiflashError_e spiflashWritePage (uint32_t address, uint8_t *buffer, uint32_t len);
 
+/**************************************************************************/
+/*! 
+    @brief      Writes a continuous stream of data that will automatically
+                cross page boundaries.
+                
+    @note       Before writing data, make sure that the appropriate sectors
+                have been erased, otherwise the data will be meaningless.
+
+    @param[in]  address
+                The 24-bit address where the write will start.
+    @param[out] *buffer
+                Pointer to the buffer that will store the read results
+    @param[in]  len
+                Length of the buffer, within the limits of the starting
+                address and size of the flash device.
+
+    @section  EXAMPLE
+
+    @code
+    spiflashError_e error;
+    uint8_t buffer[256];
+
+    buffer[0] = 0x12;
+    buffer[1] = 0x34;
+    buffer[2] = 0x56;
+    buffer[3] = 0x78;
+    buffer[4] = 0xDE;
+    buffer[5] = 0xAD;
+    buffer[6] = 0xC0;
+    buffer[7] = 0xDE;
+
+    error = spiflashWrite (0, buffer, 8);
+    if (error)
+    {
+      // Check what went wrong
+      switch (error)
+      {
+        case SPIFLASH_ERROR_ADDROUTOFRANGE:
+          // Specified starting address is out of range
+          break;
+        case SPIFLASH_ERROR_DATAEXCEEDSPAGESIZE:
+          // Supplied data exceeds max page size
+          break;
+        case SPIFLASH_ERROR_PAGEWRITEOVERFLOW:
+          // The data length plus the start address offset exceeeds page limits
+          break;
+        case SPIFLASH_ERROR_TIMEOUT_READY:
+          // Timeout waiting for ready status (can be pre or post write)
+          break;
+        case SPIFLASH_ERROR_PROTECTIONERR:
+          // Unable to set write latch
+          break;
+      }
+    }
+    @endcode
+*/
+/**************************************************************************/
+spiflashError_e spiflashWrite (uint32_t address, uint8_t *buffer, uint32_t len);
+
 #endif
index 7146938..c99e1dc 100644 (file)
@@ -589,3 +589,109 @@ spiflashError_e spiflashWritePage (uint32_t address, uint8_t *buffer, uint32_t l
   return SPIFLASH_ERROR_OK;
 }
 
+/**************************************************************************/
+/*! 
+    @brief      Writes a continuous stream of data that will automatically
+                cross page boundaries.
+                
+    @note       Before writing data, make sure that the appropriate sectors
+                have been erased, otherwise the data will be meaningless.
+
+    @param[in]  address
+                The 24-bit address where the write will start.
+    @param[out] *buffer
+                Pointer to the buffer that will store the read results
+    @param[in]  len
+                Length of the buffer, within the limits of the starting
+                address and size of the flash device.
+
+    @section  EXAMPLE
+
+    @code
+    spiflashError_e error;
+    uint8_t buffer[256];
+
+    buffer[0] = 0x12;
+    buffer[1] = 0x34;
+    buffer[2] = 0x56;
+    buffer[3] = 0x78;
+    buffer[4] = 0xDE;
+    buffer[5] = 0xAD;
+    buffer[6] = 0xC0;
+    buffer[7] = 0xDE;
+
+    error = spiflashWrite (0, buffer, 8);
+    if (error)
+    {
+      // Check what went wrong
+      switch (error)
+      {
+        case SPIFLASH_ERROR_ADDROUTOFRANGE:
+          // Specified starting address is out of range
+          break;
+        case SPIFLASH_ERROR_DATAEXCEEDSPAGESIZE:
+          // Supplied data exceeds max page size
+          break;
+        case SPIFLASH_ERROR_PAGEWRITEOVERFLOW:
+          // The data length plus the start address offset exceeeds page limits
+          break;
+        case SPIFLASH_ERROR_TIMEOUT_READY:
+          // Timeout waiting for ready status (can be pre or post write)
+          break;
+        case SPIFLASH_ERROR_PROTECTIONERR:
+          // Unable to set write latch
+          break;
+      }
+    }
+    @endcode
+*/
+/**************************************************************************/
+spiflashError_e spiflashWrite (uint32_t address, uint8_t *buffer, uint32_t len)
+{
+  uint32_t bytestowrite;
+  uint32_t bufferoffset;
+  spiflashError_e error;
+
+  // There's no point duplicating most error checks here since they will all be
+  // done in the underlying call to spiflashWritePage
+
+  // If the data is only on one page we can take a shortcut
+  if ((address % W25Q16BV_PAGESIZE) + len <= W25Q16BV_PAGESIZE)
+  {
+    // Only one page ... write and be done with it
+    return spiflashWritePage(address, buffer, len);
+  }
+
+  // Block spans multiple pages
+  bufferoffset = 0;
+  while(len)
+  {
+    // Figure out how many bytes need to be written to this page
+    bytestowrite = W25Q16BV_PAGESIZE - (address % W25Q16BV_PAGESIZE);
+    // Write the current page
+    error = spiflashWritePage(address, buffer+bufferoffset, bytestowrite);
+    // Abort if we returned an error
+    if (error) 
+      return error;
+    // Adjust address and len, and buffer offset
+    address += bytestowrite;
+    len -= bytestowrite;
+    bufferoffset+=bytestowrite;
+    // If the next page is the last one, write it and exit
+    // otherwise stay in the the loop and keep writing
+    if (len <= W25Q16BV_PAGESIZE)
+    {
+      // Write the last frame and then quit
+      error = spiflashWritePage(address, buffer+bufferoffset, len);
+      // Abort if we returned an error
+      if (error) 
+        return error;
+      // set len to zero to gracefully exit loop
+      len = 0;
+    }
+  }
+
+  return SPIFLASH_ERROR_OK;
+}
+
+
diff --git a/main.c b/main.c
index 8b75435..1ab3bf2 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
@@ -82,22 +60,15 @@ int main(void)
 
   uint32_t currentSecond, lastSecond;
   currentSecond = lastSecond = 0;
-
+  
   while (1)
   {
-    // Toggle LED once per second ... rollover = 136 years :)
+    // Toggle LED once per second
     currentSecond = systickGetSecondsActive();
     if (currentSecond != lastSecond)
     {
       lastSecond = currentSecond;
-      if (gpioGetValue(CFG_LED_PORT, CFG_LED_PIN) == CFG_LED_OFF)
-      {
-        gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_ON); 
-      }
-      else
-      {
-        gpioSetValue (CFG_LED_PORT, CFG_LED_PIN, CFG_LED_OFF); 
-      }
+         gpioSetValue(CFG_LED_PORT, CFG_LED_PIN, ~(gpioGetValue(CFG_LED_PORT, CFG_LED_PIN)));
     }
 
     // Poll for CLI input if CFG_INTERFACE is enabled in projectconfig.h
index 90259ae..e59629a 100644 (file)
     different pin configuration, you will need to specify which board you
     are using by enabling one of the following definitions. The code base
     will then try to configure itself accordingly for that board.
+
+    CFG_BRD_LPC1343_REFDESIGN   
+    =========================
+
+        microBuilder.eu LPC1343 Reference Design base board with
+        on-board peripherals initialised (EEPROM, USB or UART CLI, etc.)
+               
+               This is the recommended starting point for new development
+               since it makes it easy to send printf output to USB CDC, access
+               the on-board EEPROM, etc.
+
+    CFG_BRD_LPC1343_REFDESIGN_MINIMAL
+    =================================
+
+        microBuilder.eu LPC1343 Reference Design base board with 
+        only the most common peripherals initialised by default.  
+        
+        Results in smallest code since EEPROM, USB, etc., are not
+        initialised on startup.  By default, only the following
+        peripherals are initialised by systemInit():
+        
+              - CPU (Configures the PLL, etc.)
+              - GPIO
+              - SysTick Timer
+              - UART (with printf support) *
+    
+        * Can be removed to save 0.8kb in debug and 0.3 kb in
+        release. Comment out 'CFG_PRINTF_UART' to disable it.
+  
+        The code size can be further reduced by several KB by removing
+        any IRQ Handlers that are not used.  The I2C IRQHandler, for
+        example, uses ~1KB of flash in debug and ~400KB in release mode,
+        but because it is referenced in the startup code it is always
+        included even if I2C is never used in the project.
+
+        Other IRQ Handlers that you might be able to comment out
+        to save some space are:
+
+        IRQ Handler               Debug   Release
+        ------------------------- ------  -------
+        I2C_IRQHandler            1160 b    400 b
+        SSP_IRQHandler             160 b     76 b
+        UART_IRQHandler            246 b    116 b
+        WAKEUP_IRQHandler          160 b    100 b
+        WDT_IRQHandler              50 b     28 b
+
+    CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB
+    ====================================
+
+        microBuilder.eu/Adafruit Stand-Alone "Smart LCD" with USB enabled
+        for the CLI interface.
+
+    CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART
+    =====================================
+
+        microBuilder.eu/Adafruit Stand-Alone "Smart LCD" with UART enabled
+        for the CLI interface.
+
+    CFG_BRD_LPC1343_802154USBSTICK
+    ==============================
+
+        microBuilder.eu USB stick 802.15.4 868/915MHz RF transceiver
+
     -----------------------------------------------------------------------*/
     #define CFG_BRD_LPC1343_REFDESIGN
+    // #define CFG_BRD_LPC1343_REFDESIGN_MINIMAL
     // #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB
     // #define CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART
     // #define CFG_BRD_LPC1343_802154USBSTICK
       #define CFG_UART_BUFSIZE            (512)
     #endif
 
+    #ifdef CFG_BRD_LPC1343_REFDESIGN_MINIMAL
+      #define CFG_UART_BAUDRATE           (115200)
+      #define CFG_UART_BUFSIZE            (512)
+    #endif
+
     #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB
       #define CFG_UART_BAUDRATE           (115200)
       #define CFG_UART_BUFSIZE            (512)
       // #define CFG_SSP0_SCKPIN_0_6
     #endif
 
+    #ifdef CFG_BRD_LPC1343_REFDESIGN_MINIMAL
+      #define CFG_SSP0_SCKPIN_2_11
+      // #define CFG_SSP0_SCKPIN_0_6
+    #endif
+
     #if defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB || defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART
       #define CFG_SSP0_SCKPIN_2_11
       // #define CFG_SSP0_SCKPIN_0_6
       #define CFG_LED_OFF                 (1)
     #endif
 
+    #ifdef CFG_BRD_LPC1343_REFDESIGN_MINIMAL
+      #define CFG_LED_PORT                (2)
+      #define CFG_LED_PIN                 (10)
+      #define CFG_LED_ON                  (0)
+      #define CFG_LED_OFF                 (1)
+    #endif
+
     #if defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB || defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART
       #define CFG_LED_PORT                (2)
       #define CFG_LED_PIN                 (10)
       #define CFG_SDCARD_CDPIN            (0)
     #endif
 
+    #ifdef CFG_BRD_LPC1343_REFDESIGN_MINIMAL
+      // #define CFG_SDCARD
+      #define CFG_SDCARD_READONLY         (1)   // Must be 0 or 1
+      #define CFG_SDCARD_CDPORT           (3)
+      #define CFG_SDCARD_CDPIN            (0)
+    #endif
+
     #if defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB || defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART
       #define CFG_SDCARD
       #define CFG_SDCARD_READONLY         (1)   // Must be 0 or 1
       #define CFG_USBCDC_BUFFERSIZE       (256)
     #endif
 
+    #ifdef CFG_BRD_LPC1343_REFDESIGN_MINIMAL
+      // #define CFG_USBHID
+      // #define CFG_USBCDC
+      #define CFG_USBCDC_BAUDRATE         (115200)
+      #define CFG_USBCDC_INITTIMEOUT      (5000)
+      #define CFG_USBCDC_BUFFERSIZE       (256)
+    #endif
+
     #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB
       // #define CFG_USBHID
       #define CFG_USBCDC
       #define CFG_PRINTF_NEWLINE          "\r\n"
     #endif
 
+    #ifdef CFG_BRD_LPC1343_REFDESIGN_MINIMAL
+      #define CFG_PRINTF_UART
+      // #define CFG_PRINTF_USBCDC
+      #define CFG_PRINTF_NEWLINE          "\r\n"
+    #endif
+
     #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB
       // #define CFG_PRINTF_UART
       #define CFG_PRINTF_USBCDC
       #define CFG_INTERFACE_CONFIRMREADY  (0)
     #endif
 
+    #ifdef CFG_BRD_LPC1343_REFDESIGN_MINIMAL
+      // #define CFG_INTERFACE
+      #define CFG_INTERFACE_MAXMSGSIZE    (256)
+      #define CFG_INTERFACE_PROMPT        "LPC1343 >> "
+      #define CFG_INTERFACE_SILENTMODE    (0)
+      #define CFG_INTERFACE_DROPCR        (0)
+      #define CFG_INTERFACE_ENABLEIRQ     (0)
+      #define CFG_INTERFACE_IRQPORT       (0)
+      #define CFG_INTERFACE_IRQPIN        (7)
+      #define CFG_INTERFACE_SHORTERRORS   (0)
+      #define CFG_INTERFACE_CONFIRMREADY  (0)
+    #endif
+
     #ifdef CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB
       #define CFG_INTERFACE
       #define CFG_INTERFACE_MAXMSGSIZE    (256)
       #define CFG_I2CEEPROM_SIZE          (3072)
     #endif
 
+    #ifdef CFG_BRD_LPC1343_REFDESIGN_MINIMAL
+      // #define CFG_I2CEEPROM
+      #define CFG_I2CEEPROM_SIZE          (3072)
+    #endif
+
     #if defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB || defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART
       #define CFG_I2CEEPROM
       #define CFG_I2CEEPROM_SIZE          (3072)
       #define CFG_CHIBI_BUFFERSIZE        (128)
     #endif
 
+    #ifdef CFG_BRD_LPC1343_REFDESIGN_MINIMAL
+      // #define CFG_CHIBI
+      #define CFG_CHIBI_MODE              (0)                 // OQPSK_868MHZ
+      #define CFG_CHIBI_POWER             (0xE9)              // CHB_PWR_EU2_3DBM
+      #define CFG_CHIBI_CHANNEL           (0)                 // 868-868.6 MHz
+      #define CFG_CHIBI_PANID             (0x1234)
+      #define CFG_CHIBI_PROMISCUOUS       (0)
+      #define CFG_CHIBI_BUFFERSIZE        (128)
+    #endif
+
     #if defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB || defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART
       // #define CFG_CHIBI
       #define CFG_CHIBI_MODE              (0)                 // OQPSK_868MHZ
       #define CFG_TFTLCD_TS_KEYPADDELAY      (100)
     #endif
 
+    #ifdef CFG_BRD_LPC1343_REFDESIGN_MINIMAL
+      // #define CFG_TFTLCD
+      #define CFG_TFTLCD_INCLUDESMALLFONTS   (0)
+      #define CFG_TFTLCD_TS_DEFAULTTHRESHOLD (50)
+      #define CFG_TFTLCD_TS_KEYPADDELAY      (100)
+    #endif
+
     #if defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB || defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART
       #define CFG_TFTLCD
       #define CFG_TFTLCD_INCLUDESMALLFONTS   (0)
 
   =========================================================================*/
 
-#if !defined CFG_BRD_LPC1343_REFDESIGN && !defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB && !defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART && !defined CFG_BRD_LPC1343_802154USBSTICK
-  #error "You must defined a target board (CFG_BRD_LPC1343_REFDESIGN or CFG_BRD_LPC1343_TFTLCDSTANDALONE or CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART or CFG_BRD_LPC1343_802154USBSTICK)"
+#if !defined CFG_BRD_LPC1343_REFDESIGN && !defined CFG_BRD_LPC1343_REFDESIGN_MINIMAL && !defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_USB && !defined CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART && !defined CFG_BRD_LPC1343_802154USBSTICK
+  #error "You must defined a target board (CFG_BRD_LPC1343_REFDESIGN or CFG_BRD_LPC1343_REFDESIGN_MINIMAL or CFG_BRD_LPC1343_TFTLCDSTANDALONE or CFG_BRD_LPC1343_TFTLCDSTANDALONE_UART or CFG_BRD_LPC1343_802154USBSTICK)"
 #endif
 
 #if defined CFG_PRINTF_USBCDC && defined CFG_PRINTF_UART
index 80d2f5c..4ce74dd 100644 (file)
--- a/sysinit.c
+++ b/sysinit.c
@@ -124,7 +124,6 @@ void systemInit()
   systickInit(CFG_SYSTICK_DELAY_IN_MS);     // Start systick timer
   gpioInit();                               // Enable GPIO
   pmuInit();                                // Configure power management
-  adcInit();                                // Config adc pins to save power
 
   // Set LED pin as output and turn LED off
   gpioSetDir(CFG_LED_PORT, CFG_LED_PIN, 1);
@@ -144,15 +143,19 @@ void systemInit()
 
   // Initialise UART with the default baud rate
   #ifdef CFG_PRINTF_UART
-    uint32_t uart = eepromReadU32(CFG_EEPROM_UART_SPEED);
-    if ((uart == 0xFFFFFFFF) || (uart > 115200))
-    {
-      uartInit(CFG_UART_BAUDRATE);  // Use default baud rate
-    }
-    else
-    {
-      uartInit(uart);               // Use baud rate from EEPROM
-    }
+    #ifdef CFG_I2CEEPROM
+      uint32_t uart = eepromReadU32(CFG_EEPROM_UART_SPEED);
+      if ((uart == 0xFFFFFFFF) || (uart > 115200))
+      {
+        uartInit(CFG_UART_BAUDRATE);  // Use default baud rate
+      }
+      else
+      {
+        uartInit(uart);               // Use baud rate from EEPROM
+      }
+    #else
+      uartInit(CFG_UART_BAUDRATE);
+    #endif
   #endif
 
   // Initialise PWM (requires 16-bit Timer 1 and P1.9)
This page took 0.059681 seconds and 4 git commands to generate.