Changeset 37 for webserver/example/EnergyMeters
- Timestamp:
- 01/31/10 12:44:23 (15 years ago)
- Files:
-
- webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/EnergyMeters.hzp (modified) (1 diff)
- webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/EnergyMeters.hzs (modified) (5 diffs)
- webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/main.c (modified) (3 diffs)
- webserver/example/EnergyMeters/Source/EnergyMeters/Meters.c (modified) (2 diffs)
- webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c (modified) (18 diffs)
- webserver/example/EnergyMeters/Source/serial.c (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/EnergyMeters.hzp
r34 r37 54 54 </file> 55 55 <file Name="heap_2.c" file_name="../../Source/portable/MemMang/heap_2.c"/> 56 <file file_name="../../Source/serial.c"/> 56 57 </folder> 57 58 <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 2 2 <session> 3 3 <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/> 7 5 <ExecutionCountWindow/> 8 6 <Memory1> … … 16 14 </Memory3> 17 15 <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="" /> 19 17 </Memory4> 20 18 <Project> … … 22 20 <ProjectSessionItem path="EnergyMetersEmbedded;EnergyMetersEmbedded" name="unnamed" /> 23 21 <ProjectSessionItem path="EnergyMetersEmbedded;EnergyMetersEmbedded;Demo Source" name="unnamed" /> 24 <ProjectSessionItem path="EnergyMetersEmbedded;EnergyMetersEmbedded;EnergyMeters" name="unnamed" />25 22 </Project> 26 23 <Register1> … … 42 39 <Watch1> 43 40 <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" /> 44 43 <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" /> 48 45 </Watches> 49 46 </Watch1> … … 57 54 </Watch3> 58 55 <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" /> 70 70 </Watches> 71 71 </Watch4> 72 72 <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" /> 76 88 </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" /> 78 90 </session> webserver/example/EnergyMeters/EnergyMeters/ARM7_LPC2368_Rowley/main.c
r34 r37 118 118 vParTestInitialise(); 119 119 120 testUART3();120 //testUART3(); 121 121 122 122 /* Create the queue used by the LCD task. Messages for display on the LCD 123 123 are received via this queue. */ 124 xLCDQueue = xQueueCreate( mainQUEUE_SIZE, sizeof( xLCDMessage ) );124 //xLCDQueue = xQueueCreate( mainQUEUE_SIZE, sizeof( xLCDMessage ) ); 125 125 126 126 /* Create the lwIP task. This uses the lwIP RTOS abstraction layer.*/ … … 128 128 129 129 // vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); 130 vStartMetersTask( mainFLASH_PRIORITY ); 130 //* vStartMetersTask( mainFLASH_PRIORITY ); 131 132 vStartSolarTask( mainFLASH_PRIORITY ); 131 133 /* Start the standard demo tasks. */ 132 134 // vStartBlockingQueueTasks( mainBLOCK_Q_PRIORITY ); … … 139 141 /* Start the tasks defined within this file/specific to this demo. */ 140 142 // 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 ); 142 148 143 149 /* The suicide tasks must be created last as they need to know how many webserver/example/EnergyMeters/Source/EnergyMeters/Meters.c
r30 r37 36 36 vSemaphoreCreateBinary( xMetersSemaphore ); 37 37 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 39 41 40 42 for( ;; ) 41 43 { 42 44 45 /* this runs every 1000 ms */ 46 43 47 basementGasCalculation(); 48 49 50 44 51 45 52 portENTER_CRITICAL(); 46 53 // example: do stuff 54 55 47 56 portEXIT_CRITICAL(); 48 57 … … 79 88 80 89 void vP2_0_ISR_Wrapper( void ); 81 82 // configure port-pins for use with LAN-controller,83 // reset it and send the configuration-sequence84 90 85 91 portBASE_TYPE Init_P2_0(void) webserver/example/EnergyMeters/Source/EnergyMeters/SolarCountUART.c
r35 r37 2 2 3 3 #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 4 14 5 15 // Pin I/O LED Control Maskbit … … 17 27 #define SOL_CHAN 2 /* querying channel currentChannel */ 18 28 #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 */ 20 30 //#define SOL_ 21 31 //#define SOL_ 22 32 23 33 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 48 unsigned int uart3TxRunning = 0; /* flag to tell if we are currently sending a datagram */ 49 50 24 51 unsigned int rxBuf3NextFreeRxPos = 0; 25 52 … … 27 54 28 55 static int solarState = SOL_NO_INIT; /* state of the SolarCount communication state machine */ 56 57 58 portTickType xReadRate, xLastReadTime; 29 59 30 60 … … 97 127 void TXD_RS485(void) 98 128 { 99 delay(500000);129 //delay(500000); 100 130 IOSET1 = DIR_RS485; // RS485 Direction = 1 (Transmit) 101 131 } /* TXD_RS485 */ 102 132 103 133 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 134 void initSolarFSM(void) 135 { 136 xLastReadTime = xTaskGetTickCount(); 113 137 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 126 142 127 143 /* Clear Uart3 RxBuf and pointer to next Rx element */ … … 140 156 void getUart3RxData(void) 141 157 { 142 158 signed portBASE_TYPE byteReceived; /* did we receive a byte? */ 159 160 const portTickType xBlockTime = ( portTickType ) 0; /* ( portTickType ) 0xffff / portTICK_RATE_MS; */ 143 161 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? 145 163 146 164 while (rxBuf3NextFreeRxPos + 1 < RX_UART3_BUF_SIZE) 147 165 { 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) 152 179 { 153 180 // if data available … … 168 195 int i; 169 196 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 //} 176 216 /* 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 byte180 }217 //for (i = 0; i < n; i++) 218 //{ 219 // rxUART3[i] = rxUART3[i+n]; // move byte 220 //} 181 221 /* 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 186 232 /* 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 */ 197 245 198 246 … … 263 311 int cmpResult; 264 312 313 265 314 /* always get Rx data */ 266 315 getUart3RxData(); … … 269 318 { 270 319 case SOL_NO_INIT: 271 delay(500000);272 init_serial3();273 320 resetUart3RxBuf(); /* init */ 274 321 currentChannel = 0; /* the channel we query first */ 275 322 276 TXD_RS485();277 delay(500000);278 323 /* send init 1 */ 279 324 send_uart3((unsigned char *)init1, sizeof(init1)); 280 RXD_RS485();281 325 solarState = SOL_SENT_INIT; /* now wait for reply */ 282 326 break; … … 310 354 /* send query for channel number currentChannel */ 311 355 312 TXD_RS485();356 vTaskDelayUntil( &xLastReadTime, SOLAR_READ_DELAY ); 313 357 switch ( currentChannel ) 314 358 { … … 338 382 ; /* do nothing */ 339 383 } /* switch */ 340 RXD_RS485();341 384 if (solarState != SOL_FINISHED) 342 385 { … … 395 438 396 439 /* finally, discard data from buffer */ 397 resetUart3RxBuf();440 398 441 399 442 /* switch to next channel */ … … 408 451 } 409 452 453 resetUart3RxBuf(); 454 410 455 } 411 456 else … … 425 470 426 471 427 /********************************/ 428 /* Initial UART3 = 115200,N,8,1 */ 429 /********************************/ 472 430 473 void init_serial3 (void) 431 474 { 475 432 476 unsigned int baud = 57600; 433 477 unsigned int divisor = get_uart_clk(3, OSCILLATOR_CLOCK_FREQUENCY) / (16 * baud); 434 478 435 436 479 int i; 437 480 … … 441 484 } 442 485 486 /* init serial port */ 487 xPort = xSerialPortInitMinimal( baud /* baud rate */, 80 /* buffer length */ ); 488 //vStartComTestTasks(); 443 489 444 490 // xxxx xxxx xxxx xxxx xxxx xxxx xxxx 1010 … … 453 499 PINSEL3 &= 0xFFFF3FFF; // P1.19 = GPIO 454 500 IODIR1 = DIR_RS485; // Pin Control Direction RS485 = Output 455 RXD_RS485(); // Default RS485 Direction501 //RXD_RS485(); // Default RS485 Direction 456 502 457 503 //PCLKSEL1 = 0; /* UART3 frequency */ … … 474 520 475 521 // Baud Rate Calculator: http://prototalk.net/forums/showthread.php?t=11 476 477 #if 0478 U3LCR = 0x83; // 8 bits, no Parity, 1 Stop bit479 U3DLL = 0x0C; // Baud 57600BPS for 12MHz PCLK Clock480 U3FDR = 0xC1; // Fractional Divider (0x67 = 115200 , 0xCE = 57600 ????),481 U3DLM = 0;482 483 U3LCR = 0x03; // DLAB = 0484 #endif485 486 522 487 523 … … 496 532 void send_uart3(char * data, int length) 497 533 { 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 506 545 /* 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 char546 putchar3(data[i]); // Write char to UART 508 547 } 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 512 554 513 555 return; … … 555 597 } 556 598 599 600 601 static 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 629 void 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