photosensor.h File Reference

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

Go to the source code of this file.

Defines

#define PHOTOSENSOR_OFF   0x03
#define Photosensor_PowerOff()   P3=(P3 & PHOTOSENSOR_OFF)
#define Photosensor_select(s)   psensor=s; P3=((P3 & PHOTOSENSOR_OFF)|psensor_select[psensor & 0x07])
#define PHOTOSENSORS_NR   5

Functions

void Photosensor_init (void)
 initialize photosensor subsystem
void Photosensor_toggle (void)
 toggles LED of selected photosensor
WORD Photosensor_read (BYTE)
 read the value of a single photosensor


Detailed Description

Definition in file photosensor.h.


Define Documentation

#define PHOTOSENSOR_OFF   0x03
 

bit mask used to turn off all photosensors

Definition at line 7 of file photosensor.h.

 
#define Photosensor_PowerOff  )     P3=(P3 & PHOTOSENSOR_OFF)
 

macro to turn off all photosensors

Definition at line 9 of file photosensor.h.

Referenced by main(), Photosensor_init(), Photosensor_read(), and Photosensor_toggle().

#define Photosensor_select  )     psensor=s; P3=((P3 & PHOTOSENSOR_OFF)|psensor_select[psensor & 0x07])
 

macro to activate a given photosensor

Definition at line 11 of file photosensor.h.

Referenced by Photosensor_read(), and Photosensor_toggle().

#define PHOTOSENSORS_NR   5
 

number of active photosensors

Definition at line 13 of file photosensor.h.


Function Documentation

void Photosensor_init void   ) 
 

initialize photosensor subsystem

The photosensors are turned off by default.

Definition at line 31 of file photosensor.c.

References Photosensor_PowerOff, and psensor.

Referenced by main().

WORD Photosensor_read BYTE  sensornr  ) 
 

read the value of a single photosensor

The given sensor is activated first and than sampled with a simple differential scheme.

Parameters:
sensornr number of photo sensor to read
Returns:
voltage value of given sensor

Definition at line 79 of file photosensor.c.

References ADC(), Photosensor_PowerOff, Photosensor_select, and SHARP_PWRCTL.

Referenced by main().

void Photosensor_toggle void   ) 
 

toggles LED of selected photosensor

The photosensor is selected with the Photosensor_select function.
Invalid sensor numbers will turn off all photosensors.

Definition at line 44 of file photosensor.c.

References Photosensor_PowerOff, Photosensor_select, and psensor.


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