Show
Ignore:
Timestamp:
08/14/09 11:24:55 (15 years ago)
Author:
phil
Message:

deleted some test files,
gas meter values (unsigned long long) now updated.
added epoch time handling

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • webserver/example/freeRTOSexample/Source/EnergyMeters/Meters.c

    r19 r22  
    44#include "task.h" 
    55 
    6 #define metersSTACK_SIZE                configMINIMAL_STACK_SIZE 
     6#define metersSTACK_SIZE                configMINIMAL_STACK_SIZE+200 
    77/* masks for RTC */ 
    88#define MASKSEC 0x3F                                                                            // Second 00..59   00000000:00000000:00xxxxxx 
     
    1010#define MASKHR  0x1F0000                                                                        // Hour 00..23     000xxxxx:00000000:00000000 
    1111 
     12#include "MetersIncludes.h" 
     13 
     14extern xTickCount; /* tick counter (milliseconds) */ 
    1215 
    1316portBASE_TYPE Init_P2_0(void); 
     
    2124 
    2225portTickType 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 */ 
    2426 
    2527 
     
    3537         
    3638  Init_P2_0(); /* init GPIO for meters */ 
    37   xLastMeterTaskRunTime = xTaskGetTickCount(); /* init last run time */ 
    38  
    3939 
    4040  for( ;; ) 
     
    7373{ 
    7474 
     75  initMeterItems(); 
    7576  /* Spawn the task. */ 
    7677  xTaskCreate( vMeters_Task, ( signed portCHAR * ) "Meters", metersSTACK_SIZE, NULL, uxPriority, ( xTaskHandle * ) NULL ); 
     
    106107 
    107108} 
     109 
     110void 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  
    22#include "semphr.h" 
    33#include "task.h" 
     4#include "MetersIncludes.h" 
    45 
    5 extern basementGasReading; 
    66extern xMetersSemaphore; 
     7extern xTickCount; /* millisecond tick counter */ 
     8 
     9void handleGasMeterTick(void); 
    710 
    811/* The interrupt entry point. */ 
     
    1922  if ((IO2_INT_STAT_R & (1 << 10)) != 0) /* P2.10 interrupt triggered */ 
    2023  { 
    21     basementGasReading++
     24    handleGasMeterTick()
    2225  } 
    2326 // else if ((IO2_INT_STAT_R & (1 << n)) != 0) /* some other interrupt triggered */ 
     
    5659} 
    5760 
     61void 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} 
    5868 
    59  
    60