sharp.h File Reference

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

Go to the source code of this file.

Defines

#define SHARP_PWRCTL   P3_2
#define SHARP_PWRCTL_MASK   0x04
#define SHARP_ONLY   0x03
#define SHARP_TIMER_RELOAD_H   0x7d
#define SHARP_TIMER_RELOAD_L   0xcb
#define Sharp_PowerOn()   P3=(P3 & SHARP_ONLY)|SHARP_PWRCTL_MASK; Sharp_TimerInit();
#define Sharp_PowerOff()   SHARP_PWRCTL=0; TR1=0; ET1=0;

Functions

void Sharp_init (void)
 initializes GP2D120 subsystem
void Sharp_TimerInit (void)
 initializes an ISR to signal that the Sharp GP2D120 is ready to be read.
WORD Sharp_read (void)
 read Sharp GP2D120 sensor if it is active
void Sharp_Timer_interrupt (void) interrupt 3 using 2
 Timer ISR for delaying the Sharp GP2D120.


Detailed Description

Definition in file sharp.h.


Define Documentation

#define SHARP_ONLY   0x03
 

bit mask to clear all enable bits for optic sensors

Definition at line 11 of file sharp.h.

 
#define Sharp_PowerOff  )     SHARP_PWRCTL=0; TR1=0; ET1=0;
 

deactivates the Sharp GP2D120 and its Timer

Definition at line 21 of file sharp.h.

Referenced by main(), and Sharp_init().

 
#define Sharp_PowerOn  )     P3=(P3 & SHARP_ONLY)|SHARP_PWRCTL_MASK; Sharp_TimerInit();
 

deactivates all optic sensors except for the Sharp GP2D120 and starts the Sharp Timer ISR (see Sharp_Timer_interrupt )

Definition at line 19 of file sharp.h.

Referenced by main().

#define SHARP_PWRCTL   P3_2
 

Port pin that activates the powersupply for the Sharp GP2D120

Definition at line 6 of file sharp.h.

Referenced by Photosensor_read(), and Sharp_read().

#define SHARP_PWRCTL_MASK   0x04
 

bit mask for accessing the Shapr powercontrol flag

Definition at line 8 of file sharp.h.

#define SHARP_TIMER_RELOAD_H   0x7d
 

reload values to get approx. 25ms timing @ 16MHz: 0x10000 - 0x8235 = 0x7dcb - HIByte

Definition at line 14 of file sharp.h.

Referenced by Sharp_Timer_interrupt(), and Sharp_TimerInit().

#define SHARP_TIMER_RELOAD_L   0xcb
 

reload values to get approx. 25ms timing @ 16MHz: 0x10000 - 0x8235 = 0x7dcb - LOByte

Definition at line 16 of file sharp.h.

Referenced by Sharp_Timer_interrupt(), and Sharp_TimerInit().


Function Documentation

WORD Sharp_read void   ) 
 

read Sharp GP2D120 sensor if it is active

Returns:
0xffff if Sharp is not active, Sharp reading else

Definition at line 86 of file sharp.c.

References ADC(), SHARP_PWRCTL, and sharp_ready.

Referenced by main().

void Sharp_Timer_interrupt void   ) 
 

Timer ISR for delaying the Sharp GP2D120.

This Timer ISR delays the Sharp GP2D120 and signals its readiness after 50ms via the sharp_ready semaphore. The interrupt is triggered every 25ms. Therefor the routine uses a flag (wait_bit) to signal its second run. The sensor readiness is signalled in the second run of the ISR. The ISR deactivates itself after its second execution.

Definition at line 64 of file sharp.c.

References sharp_ready, SHARP_TIMER_RELOAD_H, SHARP_TIMER_RELOAD_L, and wait_bit.

void Sharp_TimerInit void   ) 
 

initializes an ISR to signal that the Sharp GP2D120 is ready to be read.

Initializes an ISR to signal that the Sharp GP2D120 is ready to output a valid distance reading. Activates Timer 1 which counts for 25ms twice and sets a readiness signal upon 2nd ISR invocation. (

See also:
sharp_ready)

Definition at line 39 of file sharp.c.

References sharp_ready, SHARP_TIMER_RELOAD_H, SHARP_TIMER_RELOAD_L, and wait_bit.


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