50#include <sys/bitops.h>
69#define LIGHT_RAW_BLACK 0xffc0
70#define LIGHT_RAW_WHITE 0x5080
77#define LIGHT(a) (147 - ds_scale(a)/7)
78#define LIGHT_MAX LIGHT(LIGHT_RAW_WHITE)
83#define LIGHT_1 LIGHT(SENSOR_1)
84#define LIGHT_2 LIGHT(SENSOR_2)
85#define LIGHT_3 LIGHT(SENSOR_3)
87#ifdef CONF_DSENSOR_ROTATION
91#define ROTATION_1 (ds_rotations[2])
92#define ROTATION_2 (ds_rotations[1])
93#define ROTATION_3 (ds_rotations[0])
96#ifdef CONF_DSENSOR_VELOCITY
100#define VELOCITY_1 (ds_velocities[2])
101#define VELOCITY_2 (ds_velocities[1])
102#define VELOCITY_3 (ds_velocities[0])
105#ifdef CONF_DSENSOR_MUX
106#define SENSOR_1A (ds_muxs[2][0])
107#define SENSOR_1B (ds_muxs[2][1])
108#define SENSOR_1C (ds_muxs[2][2])
109#define SENSOR_2A (ds_muxs[1][0])
110#define SENSOR_2B (ds_muxs[1][1])
111#define SENSOR_2C (ds_muxs[1][2])
112#define SENSOR_3A (ds_muxs[0][0])
113#define SENSOR_3B (ds_muxs[0][1])
114#define SENSOR_3C (ds_muxs[0][2])
118#define TOUCH(a) ((unsigned int)(a) < 0x8000)
122#define TOUCH_1 TOUCH(SENSOR_1)
123#define TOUCH_2 TOUCH(SENSOR_2)
124#define TOUCH_3 TOUCH(SENSOR_3)
127#define ds_scale(x) ((unsigned int)(x)>>6)
128#define ds_unscale(x) ((unsigned int)(x)<<6)
142#ifdef CONF_DSENSOR_ROTATION
148#ifdef CONF_DSENSOR_VELOCITY
149extern volatile int ds_velocities[3];
152#ifdef CONF_DSENSOR_MUX
153extern unsigned char ds_mux;
155extern volatile int ds_muxs[3][3];
184 bit_clear(&PORT6, 0);
187 bit_clear(&PORT6, 1);
190 bit_clear(&PORT6, 2);
194#ifdef CONF_DSENSOR_ROTATION
232#ifdef CONF_DSENSOR_MUX
234#define DS_MUX_POST_SWITCH 150
247extern void ds_mux_on(
volatile unsigned *sensor,
256extern inline void ds_mux_off(
volatile unsigned *sensor)
259 bit_clear(&ds_mux, 0);
261 bit_clear(&ds_mux, 1);
263 bit_clear(&ds_mux, 2);
#define SENSOR_2
Sensor on input pad 2.
void ds_passive(volatile unsigned *sensor)
set sensor mode to passive (light sensor detects ambient light)
void ds_rotation_set(volatile unsigned *sensor, int pos)
set rotation to an absolute value
void ds_active(volatile unsigned *sensor)
set sensor mode to active (light sensor emits light, rotation works)
void ds_rotation_off(volatile unsigned *sensor)
stop tracking rotation sensor
#define SENSOR_1
< the raw sensors
#define SENSOR_3
Sensor on input pad 3.
void ds_rotation_on(volatile unsigned *sensor)
start tracking rotation sensor
unsigned char ds_activation
activation bitmask
unsigned char ds_rotation
rotation bitmask
volatile int ds_rotations[3]
rotational position