Show
Ignore:
Timestamp:
01/31/10 12:44:23 (15 years ago)
Author:
phil
Message:

- SolarCount? data reading now working. Still hangs sometimes on Rx Data loss. Data not yet visible on web page.
- Deleted some unnecessary temp files from the compiler.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/EnergyMeters.hzp

    r34 r37  
    5454      </file> 
    5555      <file Name="heap_2.c" file_name="../../Source/portable/MemMang/heap_2.c"/> 
     56      <file file_name="../../Source/serial.c"/> 
    5657    </folder> 
    5758    <configuration Name="ARM Flash Debug" arm_target_flash_loader_type="LIBMEM RPC Loader" c_enforce_ansi_checking="No" c_preprocessor_definitions="" gcc_optimization_level="None" linker_keep_symbols="_vectors" linker_printf_fmt_level="int" linker_scanf_character_group_matching_enabled="No" linker_scanf_fmt_level="int"/> 
  • webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/EnergyMeters.hzs

    r35 r37  
    22<session> 
    33 <Bookmarks/> 
    4  <Breakpoints> 
    5   <BreakpointListItem line="335" action="" hardwareBreakpoint="" trigger="" useHWbreakpoint="false" group="Breakpoints" type="Breakpoint" state="2" counter="0" isFunctionBreakpoint="false" filename="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source\EnergyMeters\SolarCountUART.c" expression="" /> 
    6  </Breakpoints> 
     4 <Breakpoints/> 
    75 <ExecutionCountWindow/> 
    86 <Memory1> 
     
    1614 </Memory3> 
    1715 <Memory4> 
    18   <MemoryWindow autoEvaluate="0" addressText="0x40005749" numColumns="8" sizeText="1" dataSize="1" radix="16" addressSpace="" /> 
     16  <MemoryWindow autoEvaluate="0" addressText="" numColumns="16" sizeText="0" dataSize="1" radix="16" addressSpace="" /> 
    1917 </Memory4> 
    2018 <Project> 
     
    2220  <ProjectSessionItem path="EnergyMetersEmbedded;EnergyMetersEmbedded" name="unnamed" /> 
    2321  <ProjectSessionItem path="EnergyMetersEmbedded;EnergyMetersEmbedded;Demo Source" name="unnamed" /> 
    24   <ProjectSessionItem path="EnergyMetersEmbedded;EnergyMetersEmbedded;EnergyMeters" name="unnamed" /> 
    2522 </Project> 
    2623 <Register1> 
     
    4239 <Watch1> 
    4340  <Watches active="0" update="Three Seconds" > 
     41   <Watchpoint evalMode="2" linenumber="302" numelements="10" evalType="0" radix="16" name="rxUART3" expression="rxUART3" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
     42   <Watchpoint evalMode="2" linenumber="72" numelements="10" evalType="0" radix="16" name="meterItems" expression="meterItems" filename="d:/energymetersproject/source/energymeters/meters_isrs.c" /> 
    4443   <Watchpoint linenumber="64" radix="-1" name="currentTime" expression="currentTime" filename="d:/energymetersproject/source/energymeters/meters_isrs.c" /> 
    45    <Watchpoint linenumber="445" radix="16" name="PINSEL0" expression="PINSEL0" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
    46    <Watchpoint evalMode="2" linenumber="72" numelements="10" evalType="0" radix="16" name="meterItems" expression="meterItems" filename="d:/energymetersproject/source/energymeters/meters_isrs.c" /> 
    47    <Watchpoint evalMode="2" linenumber="229" numelements="10" evalType="0" radix="16" name="rxUART3" expression="rxUART3" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
     44   <Watchpoint linenumber="520" radix="16" name="PINSEL0" expression="PINSEL0" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
    4845  </Watches> 
    4946 </Watch1> 
     
    5754 </Watch3> 
    5855 <Watch4> 
    59   <Watches active="1" update="Five Seconds" > 
    60    <Watchpoint linenumber="227" radix="16" name="k" expression="k" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
    61    <Watchpoint evalMode="2" linenumber="389" numelements="6" evalType="0" radix="-1" name="chanVolt" expression="chanVolt" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
    62    <Watchpoint linenumber="224" radix="-1" name="lengthCompare" expression="lengthCompare" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
    63    <Watchpoint evalMode="2" linenumber="440" numelements="100" evalType="0" radix="-1" name="rxUART3" expression="rxUART3" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
    64    <Watchpoint evalMode="2" linenumber="389" numelements="6" evalType="0" radix="-1" name="chanWatt" expression="chanWatt" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
    65    <Watchpoint linenumber="224" radix="16" name="numRxBytes" expression="numRxBytes" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
    66    <Watchpoint linenumber="224" radix="16" name="numRxBytes" expression="numRxBytes" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
    67    <Watchpoint linenumber="210" radix="16" name="compareBuf" expression="compareBuf" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
    68    <Watchpoint linenumber="210" radix="16" name="compareBufMask" expression="compareBufMask" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
    69    <Watchpoint linenumber="87" radix="16" name="compareBuf" expression="compareBuf" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
     56  <Watches active="1" update="Twice a Second" > 
     57   <Watchpoint evalMode="2" linenumber="213" numelements="32" evalType="0" radix="1" name="cCountBuf" expression="cCountBuf" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/energymeters/arm7_lpc2368_rowley/webserver/httpd-cgi.c" /> 
     58   <Watchpoint evalMode="1" linenumber="225" evalType="1" radix="-1" name="uip_appdata" expression="uip_appdata" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/energymeters/arm7_lpc2368_rowley/webserver/httpd-cgi.c" /> 
     59   <Watchpoint linenumber="53" radix="16" name="currentChannel" expression="currentChannel" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
     60   <Watchpoint evalMode="2" linenumber="461" numelements="6" evalType="0" radix="-1" name="chanWatt" expression="chanWatt" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
     61   <Watchpoint evalMode="2" linenumber="461" numelements="6" evalType="0" radix="11" name="chanVolt" expression="chanVolt" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
     62   <Watchpoint evalMode="2" linenumber="512" numelements="100" evalType="0" radix="-1" name="rxUART3" expression="rxUART3" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
     63   <Watchpoint linenumber="55" radix="16" name="solarState" expression="solarState" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
     64   <Watchpoint linenumber="195" radix="-1" name="byteReceived" expression="byteReceived" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
     65   <Watchpoint linenumber="610" radix="-1" name="ch" expression="ch" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
     66   <Watchpoint linenumber="206" radix="16" name="RxBuf" expression="RxBuf" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
     67   <Watchpoint evalMode="1" linenumber="580" evalType="1" radix="-1" name="data" expression="data" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/source/energymeters/solarcountuart.c" /> 
     68   <Watchpoint evalMode="1" linenumber="238" evalType="1" radix="16" name="uip_appdata" expression="uip_appdata" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/energymeters/arm7_lpc2368_rowley/webserver/httpd-cgi.c" /> 
     69   <Watchpoint linenumber="235" radix="-1" name="cRxedChar" expression="cRxedChar" filename="c:/dokumente und einstellungen/phil/desktop/repo/webserver/example/energymeters/energymeters/common/full/comtest.c" /> 
    7070  </Watches> 
    7171 </Watch4> 
    7272 <Files> 
    73   <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source\portable\GCC\ARM7_LPC23xx\portISR.c" y="108" path="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source\portable\GCC\ARM7_LPC23xx\portISR.c" left="0" selected="0" name="unnamed" top="85" /> 
    74   <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source\EnergyMeters\SolarCountUART.c" y="35" path="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source\EnergyMeters\SolarCountUART.c" left="0" selected="1" name="unnamed" top="35" /> 
    75   <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\main.c" y="113" path="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\main.c" left="0" selected="0" name="unnamed" top="96" /> 
     73  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source\serial.c" y="192" path="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source\serial.c" left="0" selected="0" name="unnamed" top="177" /> 
     74  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source\EnergyMeters\SolarCountUART.c" y="103" path="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source\EnergyMeters\SolarCountUART.c" left="0" selected="0" name="unnamed" top="98" /> 
     75  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\dokumente und einstellungen\phil\desktop\repo\webserver\example\energymeters\energymeters\common\full\comtest.c" y="234" path="C:\dokumente und einstellungen\phil\desktop\repo\webserver\example\energymeters\energymeters\common\full\comtest.c" left="0" selected="0" name="unnamed" top="217" /> 
     76  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\main.c" y="113" path="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\main.c" left="0" selected="1" name="unnamed" top="113" /> 
     77  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\phil\Lokale Einstellungen\Anwendungsdaten\Rowley Associates Limited\CrossWorks for ARM\packages\targets\Philips_LPC210X\Philips_LPC230X_Startup.s" y="277" path="C:\Dokumente und Einstellungen\phil\Lokale Einstellungen\Anwendungsdaten\Rowley Associates Limited\CrossWorks for ARM\packages\targets\Philips_LPC210X\Philips_LPC230X_Startup.s" left="0" selected="0" name="unnamed" top="260" /> 
     78  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source\portable\GCC\ARM7_LPC23xx\portISR.c" y="209" path="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source\portable\GCC\ARM7_LPC23xx\portISR.c" left="0" selected="0" name="unnamed" top="203" /> 
     79  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source\tasks.c" y="558" path="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source\tasks.c" left="0" selected="0" name="unnamed" top="541" /> 
     80  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source\EnergyMeters\Meters_ISRs.c" y="0" path="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source\EnergyMeters\Meters_ISRs.c" left="0" selected="0" name="unnamed" top="67" /> 
     81  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source\queue.c" y="946" path="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source\queue.c" left="0" selected="0" name="unnamed" top="929" /> 
     82  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\webserver\httpd-cgi.c" y="246" path="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\webserver\httpd-cgi.c" left="0" selected="0" name="unnamed" top="210" /> 
     83  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\dokumente und einstellungen\phil\desktop\repo\webserver\example\energymeters\energymeters\common\ethernet\uip\uip-1.0\uip\uip.c" y="1643" path="C:\dokumente und einstellungen\phil\desktop\repo\webserver\example\energymeters\energymeters\common\ethernet\uip\uip-1.0\uip\uip.c" left="0" selected="0" name="unnamed" top="1626" /> 
     84  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\webserver\httpd.c" y="99" path="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\EnergyMeters\ARM7_LPC2368_Rowley\webserver\httpd.c" left="0" selected="0" name="unnamed" top="85" /> 
     85  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\EnergyMeters\Common\ethernet\uIP\uip-1.0\uip\uip_arp.c" y="420" path="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\EnergyMeters\Common\ethernet\uIP\uip-1.0\uip\uip_arp.c" left="0" selected="0" name="unnamed" top="403" /> 
     86  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\EnergyMeters\Common\ethernet\uIP\uip-1.0\uip\psock.c" y="227" path="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\EnergyMeters\Common\ethernet\uIP\uip-1.0\uip\psock.c" left="0" selected="0" name="unnamed" top="209" /> 
     87  <SessionOpenFile useTextEdit="1" useBinaryEdit="0" codecName="Latin1" x="0" debugPath="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\EnergyMeters\Common\Minimal\flash.c" y="134" path="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\EnergyMeters\Common\Minimal\flash.c" left="0" selected="0" name="unnamed" top="117" /> 
    7688 </Files> 
    77  <ARMCrossStudioWindow activeProject="EnergyMetersEmbedded" autoConnectTarget="Macraigor Wiggler (20 Pin)" debugSearchFileMap="" fileDialogInitialDirectory="C:\Dokumente und Einstellungen\phil\Desktop\repo\Examples_CP-JR_ARM7_LPC2368\ETT_LPC2368_Examples\PERIPHERAL_DEMO\LED_Blink" fileDialogDefaultFilter="*.c" autoConnectCapabilities="388479" debugSearchPath="" buildConfiguration="ARM Flash Debug" /> 
     89 <ARMCrossStudioWindow activeProject="EnergyMetersEmbedded" autoConnectTarget="Macraigor Wiggler (20 Pin)" debugSearchFileMap="" fileDialogInitialDirectory="C:\Dokumente und Einstellungen\phil\Desktop\repo\webserver\example\EnergyMeters\Source" fileDialogDefaultFilter="*.c" autoConnectCapabilities="388479" debugSearchPath="" buildConfiguration="ARM Flash Debug" /> 
    7890</session> 
  • webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/main.c

    r34 r37  
    118118  vParTestInitialise(); 
    119119 
    120   testUART3(); 
     120  //testUART3(); 
    121121 
    122122  /* Create the queue used by the LCD task.  Messages for display on the LCD 
    123123  are received via this queue. */ 
    124   xLCDQueue = xQueueCreate( mainQUEUE_SIZE, sizeof( xLCDMessage ) ); 
     124  //xLCDQueue = xQueueCreate( mainQUEUE_SIZE, sizeof( xLCDMessage ) ); 
    125125 
    126126  /* Create the lwIP task.  This uses the lwIP RTOS abstraction layer.*/ 
     
    128128 
    129129//  vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); 
    130   vStartMetersTask( mainFLASH_PRIORITY ); 
     130//*  vStartMetersTask( mainFLASH_PRIORITY ); 
     131 
     132  vStartSolarTask( mainFLASH_PRIORITY ); 
    131133        /* Start the standard demo tasks. */ 
    132134//  vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); 
     
    139141        /* Start the tasks defined within this file/specific to this demo. */ 
    140142 //   xTaskCreate( vCheckTask, ( signed portCHAR * ) "Check", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY, NULL ); 
    141     xTaskCreate( vLCDTask, ( signed portCHAR * ) "LCD", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL ); 
     143  
     144 
     145     
     146    // LCD task still interferes with UART3 (due to PINSEL3 and SCS setting in LCD_init */ 
     147  //  xTaskCreate( vLCDTask, ( signed portCHAR * ) "LCD", configMINIMAL_STACK_SIZE, NULL, mainCHECK_TASK_PRIORITY - 1, NULL ); 
    142148 
    143149        /* The suicide tasks must be created last as they need to know how many 
  • webserver/example/EnergyMeters/Source/EnergyMeters/Meters.c

    r30 r37  
    3636  vSemaphoreCreateBinary( xMetersSemaphore ); 
    3737         
    38   Init_P2_0(); /* init GPIO for meters */ 
     38  //Init_P2_0(); /* init GPIO for meters */ 
     39  // TODO: put this in again, right now it interferes with Solar UART3! 
     40 
    3941 
    4042  for( ;; ) 
    4143  { 
    4244 
     45    /* this runs every 1000 ms */ 
     46 
    4347    basementGasCalculation(); 
     48 
     49 
     50 
    4451 
    4552    portENTER_CRITICAL(); 
    4653            // example: do stuff 
     54 
     55 
    4756    portEXIT_CRITICAL(); 
    4857 
     
    7988 
    8089void vP2_0_ISR_Wrapper( void ); 
    81  
    82 // configure port-pins for use with LAN-controller, 
    83 // reset it and send the configuration-sequence 
    8490 
    8591portBASE_TYPE Init_P2_0(void) 
  • webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c

    r35 r37  
    22 
    33#include "LPC23xx.h" 
     4 
     5 
     6#include "FreeRTOS.h" 
     7#include "semphr.h"  
     8#include "task.h" 
     9#include "serial.h" 
     10 
     11#define solarSTACK_SIZE         configMINIMAL_STACK_SIZE+200 
     12 
     13#define SOLAR_READ_DELAY         500 
    414 
    515// Pin I/O LED Control Maskbit 
     
    1727#define SOL_CHAN     2 /* querying channel currentChannel */ 
    1828#define SOL_CHAN_WAIT_REPLY 3 /* waiting for reply on channel currentChannel = 0; */ 
    19 #define SOL_FINISHED 10 /* finished */ 
     29#define SOL_FINISHED 0xA /* finished */ 
    2030//#define SOL_ 
    2131//#define SOL_ 
    2232 
    2333 
     34// UART/FIFO Register Bit Masks 
     35 
     36#define UIIR_PEND         1U 
     37#define UIIR_RLS_INT      (3U << 1) 
     38#define UIIR_RDA_INT      (2U << 1) 
     39#define UIIR_CTI_INT      (6U << 1) 
     40#define UIIR_THRE_INT     (1U << 1) 
     41 
     42#define ULSR_RDR          1U 
     43 
     44 
     45/* Handle to the com port (UART3) */ 
     46  xComPortHandle xPort; 
     47 
     48unsigned int uart3TxRunning = 0; /* flag to tell if we are currently sending a datagram */ 
     49 
     50 
    2451unsigned int rxBuf3NextFreeRxPos = 0; 
    2552 
     
    2754 
    2855static int solarState = SOL_NO_INIT; /* state of the SolarCount communication state machine */ 
     56 
     57 
     58portTickType xReadRate, xLastReadTime; 
    2959 
    3060 
     
    97127void TXD_RS485(void)  
    98128{ 
    99   delay(500000); 
     129  //delay(500000); 
    100130  IOSET1 = DIR_RS485;           // RS485 Direction = 1 (Transmit) 
    101131} /* TXD_RS485 */ 
    102132 
    103133 
    104  
    105 void testUART3(void) 
    106 
    107   int k; 
    108   int RxBuf;            // one rx char 
    109   int uart_data;        // Character Receive Buffer 
    110   k = 0; 
    111  
    112  
     134void initSolarFSM(void) 
     135
     136  xLastReadTime = xTaskGetTickCount(); 
    113137  solarState = SOL_NO_INIT; 
    114   while (1) 
    115   { 
    116  
    117     solarFSM(); 
    118  
    119    if (solarState == SOL_FINISHED) 
    120    { 
    121       solarState = SOL_NO_INIT; 
    122    } /* if */ 
    123   } /* while */ 
    124  
    125 
     138  init_serial3(); 
     139} /* initSolarFSM */ 
     140 
     141 
    126142 
    127143/* Clear Uart3 RxBuf and pointer to next Rx element */ 
     
    140156void getUart3RxData(void) 
    141157{ 
    142  
     158  signed portBASE_TYPE byteReceived; /* did we receive a byte? */ 
     159 
     160  const portTickType xBlockTime = ( portTickType ) 0; /* ( portTickType ) 0xffff / portTICK_RATE_MS; */ 
    143161  unsigned char RxBuf; // one rx char, or 0x100 if no data 
    144   unsigned char rxTrue; // did we receive a byte? 
     162  //unsigned char rxTrue; // did we receive a byte? 
    145163 
    146164  while (rxBuf3NextFreeRxPos + 1 < RX_UART3_BUF_SIZE) 
    147165  { 
    148     /* while not overran */ 
    149  
    150     RxBuf = getchar3(&rxTrue); 
    151     if (rxTrue == 1) 
     166    /* while not overrun */ 
     167 
     168    //RxBuf = getchar3(&rxTrue); 
     169 
     170    byteReceived = xSerialGetChar( xPort, &RxBuf, xBlockTime ); 
     171 
     172 
     173    if ((rxBuf3NextFreeRxPos == 0) && (byteReceived == pdTRUE) && (RxBuf == 0x00)) 
     174    { 
     175      /* we are at position 0, and we have received a 0x00 byte. ignore this leading 0. */ 
     176     ; /* do nothing */ 
     177    } 
     178    else if (byteReceived == pdTRUE) 
    152179    { 
    153180       // if data available 
     
    168195  int i; 
    169196 
    170   if (n > RX_UART3_BUF_SIZE) 
    171   { 
    172     /* n too large */ 
    173     resetUart3RxBuf (); 
    174     return; 
    175   } 
     197  // for now, clear the whole buffer 
     198  resetUart3RxBuf(); 
     199 
     200 
     201  // begin quickfix (TODO) 
     202 
     203 
     204 
     205  //if (n > RX_UART3_BUF_SIZE) 
     206  //{ 
     207  //  /* n too large */ 
     208   
     209   
     210  //resetUart3RxBuf (); 
     211 
     212 
     213 
     214  //  return; 
     215  //} 
    176216  /* move end part of the buffer (after n) to front */ 
    177   for (i = 0; i < n; i++) 
    178  
    179     rxUART3[i] = rxUART3[i+n]; // move byte 
    180  
     217  //for (i = 0; i < n; i++) 
     218  //
     219  //  rxUART3[i] = rxUART3[i+n]; // move byte 
     220  //
    181221  /* write 0 to now unused elements */ 
    182   for (i = n; i < RX_UART3_BUF_SIZE; i++) 
    183   { 
    184     rxUART3[i] = 0; // clear byte 
    185   } 
     222  //for (i = n; i < RX_UART3_BUF_SIZE; i++) 
     223  //{ 
     224  //  rxUART3[i] = 0; // clear byte 
     225  //} 
     226 
     227  /* clear all elements */ 
     228 
     229  
     230 
     231 
    186232  /* adjust rxBuf3NextFreeRxPos */  
    187   if (n >= rxBuf3NextFreeRxPos) 
    188   { 
    189     /* remove more elements than are in the buffer */ 
    190     rxBuf3NextFreeRxPos = 0; // buffer empty 
    191   } 
    192   else 
    193   { 
    194     rxBuf3NextFreeRxPos -= n; 
    195   } 
    196 } /* chopUart3RxBuf */ 
     233  //if (n >= rxBuf3NextFreeRxPos) 
     234  //{ 
     235  //  /* remove more elements than are in the buffer */ 
     236  //  rxBuf3NextFreeRxPos = 0; // buffer empty 
     237  //} 
     238  //else 
     239  //{ 
     240  //  rxBuf3NextFreeRxPos -= n; 
     241  //} 
     242 // end quickfix (TODO) 
     243 
     244}/* chopUart3RxBuf */ 
    197245 
    198246 
     
    263311  int cmpResult; 
    264312 
     313 
    265314  /* always get Rx data */ 
    266315  getUart3RxData(); 
     
    269318  { 
    270319    case SOL_NO_INIT: 
    271       delay(500000); 
    272       init_serial3(); 
    273320      resetUart3RxBuf(); /* init */ 
    274321      currentChannel = 0; /* the channel we query first */ 
    275322 
    276       TXD_RS485(); 
    277       delay(500000); 
    278323       /* send init 1 */ 
    279324      send_uart3((unsigned char *)init1, sizeof(init1)); 
    280       RXD_RS485(); 
    281325      solarState = SOL_SENT_INIT; /* now wait for reply */ 
    282326    break; 
     
    310354    /* send query for channel number currentChannel */ 
    311355 
    312      TXD_RS485(); 
     356     vTaskDelayUntil( &xLastReadTime, SOLAR_READ_DELAY ); 
    313357     switch ( currentChannel ) 
    314358     { 
     
    338382        ; /* do nothing */ 
    339383     } /* switch */ 
    340      RXD_RS485(); 
    341384     if (solarState != SOL_FINISHED) 
    342385     { 
     
    395438 
    396439          /* finally, discard data from buffer */ 
    397           resetUart3RxBuf(); 
     440    
    398441   
    399442          /* switch to next channel */ 
     
    408451        } 
    409452 
     453        resetUart3RxBuf(); 
     454 
    410455      } 
    411456      else 
     
    425470 
    426471 
    427 /********************************/ 
    428 /* Initial UART3 = 115200,N,8,1 */ 
    429 /********************************/ 
     472 
    430473void init_serial3 (void)   
    431474{ 
     475 
    432476  unsigned int baud = 57600; 
    433477  unsigned int divisor = get_uart_clk(3, OSCILLATOR_CLOCK_FREQUENCY) / (16 * baud); 
    434478 
    435  
    436479  int i; 
    437480 
     
    441484  } 
    442485 
     486 /* init serial port */ 
     487 xPort = xSerialPortInitMinimal( baud /* baud rate */, 80 /* buffer length */ ); 
     488//vStartComTestTasks(); 
    443489 
    444490  // xxxx xxxx xxxx xxxx xxxx xxxx xxxx 1010 
     
    453499  PINSEL3 &= 0xFFFF3FFF;                                                                        // P1.19 = GPIO 
    454500  IODIR1 = DIR_RS485;                                                                           // Pin Control Direction RS485 = Output 
    455   RXD_RS485();                                                                                                // Default RS485 Direction 
     501  //RXD_RS485();                                                                                              // Default RS485 Direction 
    456502 
    457503   //PCLKSEL1 = 0;  /* UART3 frequency */ 
     
    474520 
    475521// Baud Rate Calculator: http://prototalk.net/forums/showthread.php?t=11 
    476  
    477 #if 0 
    478   U3LCR = 0x83;                                                  // 8 bits, no Parity, 1 Stop bit 
    479   U3DLL = 0x0C;                                                  // Baud 57600BPS for 12MHz PCLK Clock          
    480   U3FDR = 0xC1;                                                  // Fractional Divider (0x67 = 115200 , 0xCE = 57600 ????),       
    481   U3DLM = 0; 
    482  
    483   U3LCR = 0x03;                                                 // DLAB = 0 
    484 #endif 
    485  
    486522 
    487523 
     
    496532void send_uart3(char * data, int length) 
    497533{ 
    498   int i = 0;                                                                                            // Pointer Buffer 
    499  
    500   TXD_RS485();                                                                                          // Swap RS485 Direction = Transmit 
    501   delay(50000); 
    502  
    503  
    504   for (i = 0; i < length-1; i++)                                                                                                        // Get char & Print Until null 
    505   { 
     534 
     535 
     536  int i = 0;                            // Pointer Buffer 
     537 
     538  TXD_RS485();                                                                                           
     539  //delay(50000); 
     540 
     541  uart3TxRunning = 1; // sending in progress 
     542  for (i = 0; i < length-1; i++)        // Get char & Print Until null 
     543  { 
     544    
    506545    /* go only through length-1 because we do not send the terminating \x00 of the c-string in data */ 
    507     putchar3(data[i]);                                                                                         // Write char to UART                                                                                           // Next char 
     546    putchar3(data[i]); // Write char to UART 
    508547  } 
    509  
    510   delay(50000); 
    511   RXD_RS485();                                                                                          // Swap RS485 Direction = Receive 
     548  uart3TxRunning = 0; // done sending this datagram. The UART interrupt can switch to Rx as soon as FIFO is empty 
     549 
     550 
     551  // we send directly. unused. 
     552  // vSerialPutString( xPort, &(data[0]), length-1 ); 
     553 
    512554 
    513555  return; 
     
    555597} 
    556598 
     599 
     600 
     601static portTASK_FUNCTION( vSolar_Task, pvParameters ) 
     602{ 
     603 
     604 
     605  initSolarFSM(); 
     606 
     607  for( ;; ) 
     608  { 
     609 
     610 
     611 
     612    //portENTER_CRITICAL(); 
     613 
     614    solarFSM(); 
     615 
     616    //portEXIT_CRITICAL(); 
     617 
     618 
     619   if (solarState == SOL_FINISHED) 
     620   { 
     621      solarState = SOL_NO_INIT; 
     622   } /* if */ 
     623    
     624  } 
     625} 
     626 
     627 
     628 
     629void vStartSolarTask( unsigned portBASE_TYPE uxPriority ) 
     630{ 
     631 
     632  /* Spawn the task. */ 
     633  xTaskCreate( vSolar_Task, ( signed portCHAR * ) "Solar", solarSTACK_SIZE, NULL, uxPriority, ( xTaskHandle * ) NULL ); 
     634} 
     635