sharp.c File Reference

#include "t89c51cc02.h"
#include "datatypes.h"
#include "adc.h"
#include "sharp.h"

Go to the source code of this file.

Functions

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

Variables

volatile bit sharp_ready
volatile bit wait_bit


Detailed Description

Definition in file sharp.c.


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.


Variable Documentation

volatile bit sharp_ready
 

A semaphore that signals whether the GP2D120 is ready to be read

Definition at line 19 of file sharp.c.

Referenced by Sharp_read(), Sharp_Timer_interrupt(), and Sharp_TimerInit().

volatile bit wait_bit
 

A semaphore that signals the second run of the Sharp delaying Timer interrupt if 0

Definition at line 21 of file sharp.c.

Referenced by Sharp_Timer_interrupt(), and Sharp_TimerInit().


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