command.h File Reference

#include "t89c51cc02.h"
#include "datatypes.h"

Go to the source code of this file.

Defines

#define NR_SENSORS   18
#define COMMAND_READ   0x00
#define COMMAND_MONITOR   0x10
#define COMMAND_STOPMONITOR   0x11
#define COMMAND_MONITORSTATUS   0x12
#define COMMAND_RECALLMONITOR   0x13
#define COMMAND_STOPALLMONITORS   0x14
#define COMMAND_REPORT   0x20
#define COMMAND_STOPREPORT   0x21
#define COMMAND_TIMECHECK_ENABLE   0xA0
#define COMMAND_TIMECHECK_DISABLE   0xA1
#define COMMAND_TIMECHECKSTATUS   0xA2
#define COMMAND_EEPROM_SAVEMONITOR   0xE0
#define COMMAND_EEPROM_CLEAR   0xE1
#define COMMAND_RESET   0xff
#define Command_ClearRead()   readenable=0
#define Command_DisableReport()   reporting=0
#define Command_ClearMonitor()   monitor=0
#define Command_CheckMonitor()   (monitor!=0)
#define Command_TimecheckEnable()   timecheck=1
#define Command_TimecheckDisable()   timecheck=0
#define Command_CheckTime()   (timecheck==1)
#define CHECKSUM_FILLER   0x3c2a

Functions

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


Detailed Description

Definition in file command.h.


Define Documentation

#define CHECKSUM_FILLER   0x3c2a
 

start value for checksum calculation

Definition at line 59 of file command.h.

Referenced by Command_ReadDefaultConfiguration(), and Command_WriteDefaultConfiguration().

 
#define Command_CheckMonitor  )     (monitor!=0)
 

checkes whether sensors are monitored

Definition at line 50 of file command.h.

 
#define Command_CheckTime  )     (timecheck==1)
 

checks whether monitoring of the timing constraints is active

Definition at line 56 of file command.h.

Referenced by CAN_interrupt().

 
#define Command_ClearMonitor  )     monitor=0
 

macro to disable all monitoring conditions

Definition at line 48 of file command.h.

Referenced by CAN_interrupt().

 
#define Command_ClearRead  )     readenable=0
 

macro to clear reading markers

Definition at line 44 of file command.h.

Referenced by CAN_interrupt().

 
#define Command_DisableReport  )     reporting=0
 

macro to disable whole sample reporting

Definition at line 46 of file command.h.

Referenced by CAN_interrupt().

#define COMMAND_EEPROM_CLEAR   0xE1
 

symbolic command name to clear the monitoring configuration inside of the EEPROM

Definition at line 39 of file command.h.

Referenced by CAN_interrupt().

#define COMMAND_EEPROM_SAVEMONITOR   0xE0
 

symbolic command name to save the active monitoring conditions to the EEPROM

Definition at line 37 of file command.h.

Referenced by CAN_interrupt().

#define COMMAND_MONITOR   0x10
 

symbolic command name to set a monitoring condition for a given sensor

Definition at line 17 of file command.h.

Referenced by CAN_interrupt().

#define COMMAND_MONITORSTATUS   0x12
 

symbolic command name to read the status of active monitoring conditions

Definition at line 21 of file command.h.

Referenced by CAN_interrupt().

#define COMMAND_READ   0x00
 

symbolic command name to schedule reading of a given sensor

Definition at line 15 of file command.h.

Referenced by CAN_interrupt().

#define COMMAND_RECALLMONITOR   0x13
 

symbolic command name to schedule a reinitialization of the monitoring conditions from EEPROM contents

Definition at line 23 of file command.h.

Referenced by CAN_interrupt().

#define COMMAND_REPORT   0x20
 

symbolic command name to schedule complete sample reports

Definition at line 27 of file command.h.

Referenced by CAN_interrupt().

#define COMMAND_RESET   0xff
 

symbolic command name to reset all monitoring and reporting conditions

Definition at line 41 of file command.h.

Referenced by CAN_interrupt().

#define COMMAND_STOPALLMONITORS   0x14
 

symbolic command name to remove all active monitoring conditions

Definition at line 25 of file command.h.

Referenced by CAN_interrupt().

#define COMMAND_STOPMONITOR   0x11
 

symbolic command name to disable a monitoring condition for a given sensor

Definition at line 19 of file command.h.

Referenced by CAN_interrupt().

#define COMMAND_STOPREPORT   0x21
 

symbolic command name to stop complete reporting

Definition at line 29 of file command.h.

Referenced by CAN_interrupt().

#define COMMAND_TIMECHECK_DISABLE   0xA1
 

symbolic command name to disable time constraint monitoring

Definition at line 33 of file command.h.

Referenced by CAN_interrupt().

#define COMMAND_TIMECHECK_ENABLE   0xA0
 

symbolic command name to enable monitoring of the time constraints

Definition at line 31 of file command.h.

Referenced by CAN_interrupt().

 
#define Command_TimecheckDisable  )     timecheck=0
 

macro to disable monitoring of the timing constraints

Definition at line 54 of file command.h.

Referenced by CAN_interrupt().

 
#define Command_TimecheckEnable  )     timecheck=1
 

macro to enable monitoring of the timing constraints

Definition at line 52 of file command.h.

Referenced by CAN_interrupt(), and main().

#define COMMAND_TIMECHECKSTATUS   0xA2
 

symbolic command name to read the status of time constraint monitoring

Definition at line 35 of file command.h.

Referenced by CAN_interrupt().

#define NR_SENSORS   18
 

number of sensors available in the system

Definition at line 12 of file command.h.

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


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

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().

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().

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