Changeset 60

Show
Ignore:
Timestamp:
04/04/10 10:49:44 (15 years ago)
Author:
phil
Message:

meter value calculation now not in ISR anymore, introduced METERS_INT_CHECK_INTERVAL_MS define
and meterIntStatus . Check of meterIntStatus and calculation now in vMeters_Task every METERS_INT_CHECK_INTERVAL_MS ms.

Files:

Legend:

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

    r59 r60  
    3030 
    3131 
     32 
     33portLONG meterIntStatus = 0; /* which meter interrupts were triggered? (bitwise 0 to 7) */ 
     34 
     35 
    3236  int rtcHOURS; 
    3337  int rtcMINUTES; 
     
    4852  { 
    4953 
    50     /* this runs every 1000 ms */ 
     54    /* this runs every METERS_INT_CHECK_INTERVAL_MS ms */ 
    5155 
    5256    basementGasCalculation(); 
     
    7175    rtcSECONDS = RTC_CTIME0 & MASKSEC;                                          // Read Second 
    7276 
    73     xSemaphoreTake( xMetersSemaphore, 1000 ); /* timeout 1 sec */ 
     77    xSemaphoreTake( xMetersSemaphore, METERS_INT_CHECK_INTERVAL_MS ); /* timeout METERS_INT_CHECK_INTERVAL_MS ms */ 
    7478 
    7579 
     
    145149{ 
    146150 
     151    if ( (meterIntStatus & (1<<10)) != 0) 
     152    { 
     153      handleMeterTick(METER_INDEX_TST); 
     154      meterIntStatus &= (~(1<<10)); 
     155    } 
     156 
     157    if ( (meterIntStatus & (1<<0)) != 0) 
     158    { 
     159      handleMeterTick(METER_INDEX_GAS); 
     160      meterIntStatus &= (~(1<<0)); 
     161    } 
     162 
     163    if ( (meterIntStatus & (1<<1)) != 0) 
     164    { 
     165      handleMeterTick(METER_INDEX_EL1); 
     166      meterIntStatus &= (~(1<<1)); 
     167    } 
     168 
     169    if ( (meterIntStatus & (1<<2)) != 0) 
     170    { 
     171      handleMeterTick(METER_INDEX_EL2); 
     172      meterIntStatus &= (~(1<<2)); 
     173    } 
     174 
     175    if ( (meterIntStatus & (1<<3)) != 0) 
     176    { 
     177      handleMeterTick(METER_INDEX_AU1); 
     178      meterIntStatus &= (~(1<<3)); 
     179    } 
     180 
     181 
    147182} 
    148183 
  • webserver/example/EnergyMeters/Source/EnergyMeters/MetersIncludes.h

    r56 r60  
    1111#define METER_INDEX_AU1  4 /* index of Auxiliary input 1 */ 
    1212#define METER_INDEX_AU2  5 /* index of Auxiliary input 1 */ 
     13 
     14 
     15#define METERS_INT_CHECK_INTERVAL_MS 100 /* how often (in ms) do we check if one of the I/O lines has triggered */ 
    1316 
    1417 
  • webserver/example/EnergyMeters/Source/EnergyMeters/Meters_ISRs.c

    r59 r60  
    1313extern xTickCount; /* millisecond tick counter */ 
    1414 
     15extern meterIntStatus; 
    1516 
    1617int globalValue = 0; 
     
    3334  if ((IO2_INT_STAT_R & (1 << 10)) != 0) /* P2.10 interrupt triggered - SPI Load Switch */ 
    3435  { 
    35     handleMeterTick(METER_INDEX_TST); 
     36    meterIntStatus |= (1<<10); 
     37    //handleMeterTick(METER_INDEX_TST); 
    3638    IO2_INT_CLR |= (1<<10); 
    3739  } 
    3840  if ((IO2_INT_STAT_R & (1 << 0)) != 0) /* P0.0 interrupt triggered - connector J4, Pin 0*/ 
    3941  { 
    40     handleMeterTick(METER_INDEX_GAS); 
     42    meterIntStatus |= (1<<0); 
     43    //handleMeterTick(METER_INDEX_GAS); 
    4144    IO2_INT_CLR |= (1<<0); 
    4245  } 
    4346  if ((IO2_INT_STAT_R & (1 << 1)) != 0) /* P0.1 interrupt triggered - connector J4, Pin 1*/ 
    4447  { 
    45     handleMeterTick(METER_INDEX_EL1); 
     48    meterIntStatus |= (1<<1); 
     49    //handleMeterTick(METER_INDEX_EL1); 
    4650    IO2_INT_CLR |= (1<<1); 
    4751  } 
    4852  if ((IO2_INT_STAT_R & (1 << 2)) != 0) /* P0.3 interrupt triggered - connector J4, Pin 3*/ 
    4953  { 
    50     handleMeterTick(METER_INDEX_EL2); 
     54    meterIntStatus |= (1<<2); 
     55    //handleMeterTick(METER_INDEX_EL2); 
    5156    IO2_INT_CLR |= (1<<2); 
    5257  } 
    5358  if ((IO2_INT_STAT_R & (1 << 3)) != 0) /* P0.4 interrupt triggered - connector J4, Pin 4*/ 
    5459  { 
    55     handleMeterTick(METER_INDEX_AU1); 
     60    meterIntStatus |= (1<<3); 
     61    //handleMeterTick(METER_INDEX_AU1); 
    5662    IO2_INT_CLR |= (1<<3); 
    5763  } 
     
    5965  //if ((IO2_INT_STAT_R & (1 << 4)) != 0) /* P0.2 interrupt triggered - connector J4, Pin 2*/ 
    6066  //{ 
     67  // meterIntStatus |= (1<<4); 
    6168  // handleMeterTick(METER_INDEX_AU2); 
    6269  //  IO2_INT_CLR |= (1<<4);