HWA
Bare metal programming with style
TCS3200: colour detector
Note
This implementation is old and needs to be updated

A class _tcs3200 object is colour light-to-frequency converter, also called 'colour detector'.

The measurement of the output signal frequency is left to the user.

The following declarations create a device called sensor0.

#define hw_sensor0 _tcs3200, 0, 0
#define hw_sensor0_s0 _ioa, porta, 1, 0
#define hw_sensor0_s1 _ioa, porta, 1, 1
#define hw_sensor0_s2 _ioa, porta, 1, 2
#define hw_sensor0_s3 _ioa, porta, 1, 3
#define hw_sensor0_oe _ioa, porta, 1, 4

Actions

configure

The user is responsible of the configuration of the I/O pins. The configure action, allows the selection of the maximum frequency of the output signal, the filter, and the enabling of the output signal.

hw[a]( configure, sensor0,
[ frequency, 0 // Requires both hw_sensor0_s1
| 12kHz // and hw_sensor0_s0 to be defined
| 120kHz // as real I/O pins.
| 600kHz, ] //
[ filter, red // Requires both _hw_rel_sensor_s3
| green // and hw_sensor0_s2 to be defined
| blue // as real I/O pins.
| clear ] //
[ output, on // Requires _hw_rel_sensor_oe
| off // to be defined as real I/O pin.
);
hw
#define hw(...)
hw( action, object [,...] ) executes an action immediately on an object.
Definition: hwa_macros.h:523