Changeset 22 for webserver/example/freeRTOSexample/Source
- Timestamp:
- 08/14/09 11:24:55 (15 years ago)
- Files:
-
- webserver/example/freeRTOSexample/Source/EnergyMeters/Meters.c (modified) (6 diffs)
- webserver/example/freeRTOSexample/Source/EnergyMeters/MetersIncludes.h (added)
- webserver/example/freeRTOSexample/Source/EnergyMeters/Meters_ISRs.c (modified) (3 diffs)
- webserver/example/freeRTOSexample/Source/EnergyMeters/timeConversion.c (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
webserver/example/freeRTOSexample/Source/EnergyMeters/Meters.c
r19 r22 4 4 #include "task.h" 5 5 6 #define metersSTACK_SIZE configMINIMAL_STACK_SIZE 6 #define metersSTACK_SIZE configMINIMAL_STACK_SIZE+200 7 7 /* masks for RTC */ 8 8 #define MASKSEC 0x3F // Second 00..59 00000000:00000000:00xxxxxx … … 10 10 #define MASKHR 0x1F0000 // Hour 00..23 000xxxxx:00000000:00000000 11 11 12 #include "MetersIncludes.h" 13 14 extern xTickCount; /* tick counter (milliseconds) */ 12 15 13 16 portBASE_TYPE Init_P2_0(void); … … 21 24 22 25 portTickType xLastMeterTaskRunTime; /* keeps the last time the meter calculation ran */ 23 portTickType xMeterIdleRate = 1000; /* the rate (in ticks = ms) at which the calculation runs when no pulses triggered a calculation */24 26 25 27 … … 35 37 36 38 Init_P2_0(); /* init GPIO for meters */ 37 xLastMeterTaskRunTime = xTaskGetTickCount(); /* init last run time */38 39 39 40 40 for( ;; ) … … 73 73 { 74 74 75 initMeterItems(); 75 76 /* Spawn the task. */ 76 77 xTaskCreate( vMeters_Task, ( signed portCHAR * ) "Meters", metersSTACK_SIZE, NULL, uxPriority, ( xTaskHandle * ) NULL ); … … 106 107 107 108 } 109 110 void initMeterItems(void) 111 { 112 int i; 113 for (i = 0; i < NUMBER_OF_METERS; i++) 114 { 115 meterItems[i].meterEnabled = 0; // disable all meters 116 } 117 118 // Init Gas meter 119 meterItems[METER_INDEX_GAS].meterEnabled = 1; /* 0: item not used, 1: meter enabled */ 120 meterItems[METER_INDEX_GAS].timeLastTick = getEpochTimeWithMs(); /* when did the last tick occur? epoch (seconds) */ 121 meterItems[METER_INDEX_GAS].timeBeforeLastTick = getEpochTimeWithMs(); /* when did the tick before last tick occur? epoch (seconds) */ 122 meterItems[METER_INDEX_GAS].valueLastTick = 0; /* what value did we have at the last tick? */ 123 meterItems[METER_INDEX_GAS].valueBeforeLastTick = 1; /* what value did we have at the tick before the last tick? */ 124 125 } webserver/example/freeRTOSexample/Source/EnergyMeters/Meters_ISRs.c
r19 r22 2 2 #include "semphr.h" 3 3 #include "task.h" 4 #include "MetersIncludes.h" 4 5 5 extern basementGasReading;6 6 extern xMetersSemaphore; 7 extern xTickCount; /* millisecond tick counter */ 8 9 void handleGasMeterTick(void); 7 10 8 11 /* The interrupt entry point. */ … … 19 22 if ((IO2_INT_STAT_R & (1 << 10)) != 0) /* P2.10 interrupt triggered */ 20 23 { 21 basementGasReading++;24 handleGasMeterTick(); 22 25 } 23 26 // else if ((IO2_INT_STAT_R & (1 << n)) != 0) /* some other interrupt triggered */ … … 56 59 } 57 60 61 void handleGasMeterTick(void) 62 { 63 meterItems[METER_INDEX_GAS].timeBeforeLastTick = meterItems[METER_INDEX_GAS].timeLastTick; /* when did the tick before the last tick occur? */ 64 meterItems[METER_INDEX_GAS].timeLastTick = getEpochTimeWithMs(); /* when did the last tick occur? epoch (seconds) */ 65 meterItems[METER_INDEX_GAS].valueLastTick = 0; /* what value did we have at the last tick? */ 66 meterItems[METER_INDEX_GAS].valueBeforeLastTick = 1; /* what value did we have at the tick before the last tick? */ 67 } 58 68 59 60