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])
115 #endif //CONF_DSENSOR_MUX
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
149 extern volatile int ds_velocities[3];
152 #ifdef CONF_DSENSOR_MUX
153 extern unsigned char ds_mux;
155 extern volatile int ds_muxs[3][3];
156 #endif //CONF_DSENSOR_MUX
194 #ifdef CONF_DSENSOR_ROTATION
229 #endif // CONF_DSENSOR_ROTATION
232 #ifdef CONF_DSENSOR_MUX
234 #define DS_MUX_POST_SWITCH 150
247 extern void ds_mux_on(
volatile unsigned *sensor,
256 extern inline void ds_mux_off(
volatile unsigned *sensor)
265 #endif // CONF_DSENSOR_MUX
271 #endif // CONF_DSENSOR
277 #endif // __dsensor_h__
#define bit_clear(byte, bit)
clear a single bit in memory
Internal Interface: H8/3297 processor registers.
volatile int ds_rotations[3]
rotational position
void ds_passive(volatile unsigned *sensor)
set sensor mode to passive (light sensor detects ambient light)
void ds_active(volatile unsigned *sensor)
set sensor mode to active (light sensor emits light, rotation works)
#define SENSOR_3
Sensor on input pad 3.
unsigned char ds_activation
activation bitmask
kernel configuration file
Internal Interface: H8/300 bit operations.
void ds_rotation_on(volatile unsigned *sensor)
start tracking rotation sensor
#define SENSOR_1
< the raw sensors
void ds_rotation_off(volatile unsigned *sensor)
stop tracking rotation sensor
void ds_rotation_set(volatile unsigned *sensor, int pos)
set rotation to an absolute value
volatile unsigned char PORT6
port 6 I/O register
#define SENSOR_2
Sensor on input pad 2.
unsigned char ds_rotation
rotation bitmask
#define bit_set(byte, bit)
set a single bit in memory