command.c File Reference

#include "t89c51cc02.h"
#include "datatypes.h"
#include "command.h"
#include "eeprom.h"

Go to the source code of this file.

Functions

void Command_SetRead (BYTE marker)
 marks a sensor for reading after next measurement
void Command_EnableReport (BYTE timeframes)
 enables reporting of all sensors
BYTE Command_ReportDue ()
 signal if a report of the sensor values is due
void Command_EnableMonitor (BYTE marker, WORD boundary, bit direction)
 marks one sensor for monitoring so it will report a value above or beyond a specified boundary value
void Command_DisableMonitor (BYTE marker)
 disable monitoring for a given sensor
BYTE CheckMonitor (BYTE marker, WORD value)
 checks whether the monitoring condition for a given sensor is true
WORD Command_GetBoundary (BYTE marker)
 reports the current boundary value for a given sensor
void Command_SetBoundary (BYTE marker, WORD bound)
 set the boundary value for a given sensor
void Command_ReadDefaultConfiguration ()
 load monitoring data from EEPROM and activate it again
void Command_WriteDefaultConfiguration ()
 writes the current monitoring conditions into the EEPROM

Variables

LONG readenable
 stores a bit vector to mark which sensor values have to be sent after the current sampling cycle.
LONG monitor
LONG monitor_direction
volatile bit reporting
volatile bit timecheck
volatile bit read_eeprom_config
volatile bit write_eeprom_config
BYTE report
BYTE report_reload
WORD idata monitor_boundary [NR_SENSORS]
 boundary values for monitoring
const unsigned long code masks []


Detailed Description

Definition in file command.c.


Function Documentation

BYTE CheckMonitor BYTE  marker,
WORD  value
 

checks whether the monitoring condition for a given sensor is true

The sample value is compared to the boundary for the given sensor.
The direction bit of the monitoring condition is used to determine the needed relation.

Parameters:
marker number of monitored sensor
value current sensor reading
Returns:
a positive value if the monitoring condition is true

Definition at line 153 of file command.c.

References masks, monitor, monitor_boundary, monitor_direction, and NR_SENSORS.

Referenced by main().

void Command_DisableMonitor BYTE  marker  ) 
 

disable monitoring for a given sensor

Parameters:
marker number of sensor for which monitoring has to be disabled

Definition at line 137 of file command.c.

References masks, monitor, and NR_SENSORS.

Referenced by CAN_interrupt().

void Command_EnableMonitor BYTE  marker,
WORD  boundary,
bit  direction
 

marks one sensor for monitoring so it will report a value above or beyond a specified boundary value

Monitoring of a given sensor is enabled.
A set monitoring direction means that sensor values above the specified boundary are reported. If the direction bit is not set sensor values below the boundary are reported.

Parameters:
marker number of sensor to be monitored
boundary boundary value of reading
direction 1 if report on value larger than the boundary, 0 on lower value

Definition at line 119 of file command.c.

References masks, monitor, monitor_boundary, monitor_direction, and NR_SENSORS.

Referenced by CAN_interrupt().

void Command_EnableReport BYTE  timeframes  ) 
 

enables reporting of all sensors

The firmware will skip the given amount of timeframes between complete reports.
A timeframe value of 0 indicates that every sampling run has to be reported.

Parameters:
timeframes number of timeframes to be skipped before report is sent

Definition at line 70 of file command.c.

References report, report_reload, and reporting.

Referenced by CAN_interrupt().

WORD Command_GetBoundary BYTE  marker  ) 
 

reports the current boundary value for a given sensor

The boundary value is persistent, even if the monitoring condition has been disabled with a Command_EnableMonitor command for the given sensor.

Parameters:
marker number of sensor whose boundary has to be returned
Returns:
the boundary value of the specified sensor

Definition at line 184 of file command.c.

References monitor_boundary.

void Command_ReadDefaultConfiguration void   ) 
 

load monitoring data from EEPROM and activate it again

This function reads the EEPROM contents and checks its checksum. If the checksum is correct the values are used to set the monitoring conditions for up to all sensors.

Definition at line 206 of file command.c.

References CHECKSUM_FILLER, EEPROM_BOUNDARY, EEPROM_CHECKSUM, EEPROM_DIRECTION, EEPROM_MONITOR, EEPROM_read(), monitor, monitor_boundary, and monitor_direction.

Referenced by main().

BYTE Command_ReportDue void   ) 
 

signal if a report of the sensor values is due

The routine counts the elapsed timeframes for reports and signals when the report is due at the current time slot.

Returns:
a value <>0 indicates a report is due

Definition at line 84 of file command.c.

References report, report_reload, and reporting.

Referenced by main().

void Command_SetBoundary BYTE  marker,
WORD  bound
 

set the boundary value for a given sensor

Parameters:
marker number of sensor for which the boundary has to be set
bound new boundary value

Definition at line 195 of file command.c.

References monitor_boundary.

void Command_SetRead BYTE  marker  ) 
 

marks a sensor for reading after next measurement

The marker corresponds to a bit number in the readenable status word

Parameters:
marker 

Definition at line 56 of file command.c.

References masks, NR_SENSORS, and readenable.

Referenced by CAN_interrupt().

void Command_WriteDefaultConfiguration void   ) 
 

writes the current monitoring conditions into the EEPROM

The needed checksum is calculated before writing the configuration.
Interrupts are disabled during EEPROM access and are reenabled afterwards.
Writing to the EEPROM costs time. Writing the configuration may led to violation of the timing constraints of the sensor sampling.

Definition at line 251 of file command.c.

References CHECKSUM_FILLER, monitor, monitor_boundary, and monitor_direction.


Variable Documentation

const unsigned long code masks[]
 

Initial value:

 { 0x00001,0x00002,0x00004,0x00008,0x00010,0x00020,
                                  0x00040,0x00080,0x00100,0x00200,0x00400,0x00800,
                                  0x01000,0x02000,0x04000,0x08000,0x10000,0x20000}
bit masks to select individual bits of a LONG

Definition at line 46 of file command.c.

Referenced by CheckMonitor(), Command_DisableMonitor(), Command_EnableMonitor(), and Command_SetRead().

LONG monitor
 

stores a bit vector to mark which sensors are monitored

Definition at line 20 of file command.c.

Referenced by CAN_interrupt(), CheckMonitor(), Command_DisableMonitor(), Command_EnableMonitor(), Command_ReadDefaultConfiguration(), and Command_WriteDefaultConfiguration().

WORD idata monitor_boundary[NR_SENSORS]
 

boundary values for monitoring

The values are located in the indirect addressable IRAM of the T89C51CC02.

Definition at line 43 of file command.c.

Referenced by CheckMonitor(), Command_EnableMonitor(), Command_GetBoundary(), Command_ReadDefaultConfiguration(), Command_SetBoundary(), and Command_WriteDefaultConfiguration().

LONG monitor_direction
 

bit vector which indicates the direction of boundary monitoring

Definition at line 23 of file command.c.

Referenced by CheckMonitor(), Command_EnableMonitor(), Command_ReadDefaultConfiguration(), and Command_WriteDefaultConfiguration().

volatile bit read_eeprom_config
 

semaphore to schedule a reread of the EEPROM contents

Definition at line 31 of file command.c.

Referenced by CAN_interrupt(), and main().

LONG readenable
 

stores a bit vector to mark which sensor values have to be sent after the current sampling cycle.

The bit vector is automatically cleared when all scheduled readings have taken place.

Definition at line 17 of file command.c.

Referenced by Command_SetRead(), and main().

BYTE report
 

number of timeframes for reporting

Definition at line 36 of file command.c.

Referenced by Command_EnableReport(), and Command_ReportDue().

volatile bit reporting
 

a flag that indicates if all sensor values should be reported

Definition at line 26 of file command.c.

Referenced by Command_EnableReport(), Command_ReportDue(), and main().

volatile bit timecheck
 

a flag that indicates whether the main loop shall report violations of the timing restrictions

Definition at line 28 of file command.c.

volatile bit write_eeprom_config
 

semaphore to schedule writing of new EEPROM contents

Definition at line 33 of file command.c.

Referenced by CAN_interrupt().


Generated on Wed Oct 24 12:57:24 2007 for SensorControl by  doxygen 1.4.6