Skip to content

Commit

Permalink
Fixed wrong WAIT_TIME RegisterAddress, Better RegisterAddress layout …
Browse files Browse the repository at this point in the history
…and description
  • Loading branch information
TomSaw committed Mar 13, 2021
1 parent bc86f40 commit 53d29fb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
30 changes: 16 additions & 14 deletions src/modm/driver/color/tcs3472.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,26 @@ struct tcs3472
enum class
RegisterAddress : uint8_t
{
ENABLE = 0x00, ///< Power up the device, Enable features
INTEGRATION_TIME = 0x01, ///< Integration time control @see Tcs3472::setIntegrationTime
WAIT_TIME = 0x02,
INTERRUPT_PERSISTENCE_FILTER = 0x0C,
// INTERRUPT = 0x02, ///< Interrupt settings
// INT_SOURCE = 0x03, ///< Interrupt source
ID = 0x12, ///< Part number
/// Set the WAITLONG Flag in CONFIGURATION. When asserted, the wait cycles
/// are increased by a factor 12× from that programmed in the WTIME register.
CONFIGURATION = 0x0D,
GAIN = 0x0F, ///< Sensitivity settings @see Tcs3414::setGain

// Interrupt threshold registers
ENABLE = 0x00, ///< Power up the device, Enable features
ID = 0x12, ///< Read part-ID

// Shutter configuration
INTEGRATION_TIME = 0x01, ///< Shutter integration time
GAIN = 0x0F, ///< Shutter gain control

// Waittime configuration
WAIT_TIME = 0x03, ///< Waittime between samples. Conceived for power savings
CONFIGURATION = 0x0D, ///< Setting WAITLONG multiplies WAIT_TIME by 12

// Interrupt configuration
LOW_THRESH_LOW_BYTE = 0x04, ///< Low byte of low interrupt threshold
LOW_THRESH_HIGH_BYTE = 0x05, ///< High byte of low interrupt threshold
HIGH_THRESH_LOW_BYTE = 0x06, ///< Low byte of high interrupt threshold
HIGH_THRESH_HIGH_BYTE = 0x07, ///< High byte of high interrupt threshold
INTERRUPT_PERSIST_FILTER = 0x0C,///< Set how much threshold-passing cycles are required, to trigger the interrupt
RELOAD_INTERRUPT = 0x66, ///< Reset Interrupt special command

// Data results
CDATALOW = 0x14, ///< Low byte of ADC clear channel
CDATAHIGH = 0x15, ///< High byte of ADC clear channel
RDATALOW = 0x16, ///< Low byte of ADC red channel
Expand Down Expand Up @@ -238,7 +240,7 @@ class Tcs3472 : public tcs3472, public modm::I2cDevice<I2cMaster, 2>
/// The gain can be used to adjust the sensitivity of all ADC output channels.
modm::ResumableResult<bool>
setInterruptPersistenceFilter(InterruptPersistence value)
{ return writeRegister(RegisterAddress::INTERRUPT_PERSISTENCE_FILTER, uint8_t(value)); }
{ return writeRegister(RegisterAddress::INTERRUPT_PERSIST_FILTER, uint8_t(value)); }

public:
/// Resets the interrupt output.
Expand Down
2 changes: 1 addition & 1 deletion src/modm/driver/color/tcs3472_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ modm::Tcs3472<I2cMaster>::setWaitTime(WaitTime wait_time, bool wait_long)
{
RF_BEGIN();

if (RF_CALL(writeRegister(RegisterAddress::CONFIGURATION, wait_long ? 0x02 : 0x00)))
if (RF_CALL(writeRegister(RegisterAddress::CONFIGURATION, wait_long ? 1 << 1 : 0)))
{
if (RF_CALL(writeRegister(RegisterAddress::WAIT_TIME, uint8_t(wait_time))))
{
Expand Down

0 comments on commit 53d29fb

Please sign in to comment.