µracoli Manual  Version foo
LEDPS - Using a LED as Photo Sensor

Data Structures

struct  ledps_ctx_t
 

Detailed Description

Implementation for using a LED as photo sensor. The LED is connected between two port pins, so that it can be reverse charged.

Functions

static uint8_t ledps_get_raw ( void *  pctx,
uint8_t *  pdata 
)
static

Retrieve raw value from LED-Photo-Sensor

Definition at line 173 of file ledps.h.

static uint8_t ledps_get_val ( void *  pctx,
uint8_t *  pdata 
)
static

Retrieve value from LED-Photo-Sensor

Definition at line 159 of file ledps.h.

static void ledps_sleep ( void *  pctx)
static

LED-Photo-Sensor does not support sleep.

Definition at line 189 of file ledps.h.

static void ledps_trigger ( void *  pctx,
bool  one_shot 
)
static

this function is empty

Definition at line 154 of file ledps.h.

static uint16_t sample_port ( char  portid,
uint8_t  anode_pin,
uint8_t  cathode_pin 
)
static
1 #define LEDPS_PORTx (1)
2 #define LEDPS_PORT ('x')
3 #define LEDPS_ANODE (y)
4 #define LEDPS_CATHODE (z)
5 x: name of PORT, upper case letter A...F
6 y: port pin for anode 0 ... 7
7 z: port pin for cathode 0 ... 7

Definition at line 105 of file ledps.h.

static uint8_t sensor_create_ledps ( void *  pdata,
bool  raw,
char  portid,
uint8_t  panode,
uint8_t  pcathode 
)
static

Create an instance of a ledps sensor and initialize the sensor.

Returns
sizeof(ledps_ctx_t)

Definition at line 199 of file ledps.h.


Data Structure Documentation

struct ledps_ctx_t

LED context

Definition at line 76 of file ledps.h.

Data Fields
sensor_driver_t g
uint8_t panode
uint8_t pcathode
char portid

driver structure

Defines

#define DO_LED_PS (   port,
  ddr,
  pin,
  anode,
  cathode,
  ledps_cnt 
)
Value:
do { \
ddr |= (_BV(anode) | _BV(cathode)); \
port &= ~_BV(anode); \
port |= _BV(cathode); \
_delay_us(5); \
cli(); \
ddr &= ~_BV(cathode); \
port &= ~_BV(cathode); \
ledps_cnt = 0x7fff; \
do { \
_delay_us(20); \
} while ((pin & _BV(cathode)) && --ledps_cnt);\
sei(); \
ddr |= (_BV(anode) | _BV(cathode));\
} while(0)

Sampling Macro

Definition at line 55 of file ledps.h.

#define LEDPS_DEBUG   (0)

Debgging driver with HIF

Definition at line 47 of file ledps.h.