modm API documentation
modm::Vl6180< I2cMaster > Class Template Reference

#include <modm/driver/position/vl6180.hpp>

Inheritance diagram for modm::Vl6180< I2cMaster >:
modm::I2cDevice< I2cMaster, 2 > modm::NestedResumable< 10+1 >

Classes

struct  Data
 

Public Typedefs

typedef modm::Flags8< InterruptConfigInterruptConfig_t
 
typedef modm::Configuration< InterruptConfig_t, InterruptSource, 0x7 > RangeInterruptSource_t
 
typedef modm::Configuration< InterruptConfig_t, InterruptSource, 0x7, 3 > ALS_InterruptSource_t
 
typedef modm::Configuration< RangeStatus_t, RangeErrorCode, 0xF0 > RangeErrorCode_t
 
typedef modm::Configuration< ALS_Status_t, ALS_ErrorCode, 0xF0 > ALS_ErrorCode_t
 
typedef modm::Flags8< InterruptStatusInterruptStatus_t
 
typedef modm::Configuration< InterruptStatus_t, InterruptSource, 0x7 > RangeInterruptStatus_t
 
typedef modm::Configuration< InterruptStatus_t, InterruptSource, 0x7, 3 > ALS_InterruptStatus_t
 
typedef modm::Configuration< InterruptStatus_t, InterruptError,(3<< 6)> InterruptError_t
 
using Control_t = modm::FlagsGroup< GpioMode_t, HistoryControl_t, InterruptConfig_t, InterruptClear_t, Start_t, RangeCheck_t, VhvRecalibrate_t, RangeStatus_t, ALS_Status_t, InterruptStatus_t >
 

Public Types

enum  Register : uint16_t
 The addresses of the Configuration and Data Registers.
 
enum  GpioMode : uint8_t
 SYSTEM_MODE_GPIO0 and SYSTEM_MODE_GPIO1.
 
enum  HistoryControl : uint8_t
 SYSTEM_HISTORY_CTRL.
 
enum  InterruptConfig
 SYSTEM_INTERRUPT_CONFIG_GPIO.
 
enum  InterruptSource : uint8_t
 
enum  InterruptClear : uint8_t
 SYSTEM_INTERRUPT_CLEAR.
 
enum  Start : uint8_t
 
enum  RangeCheck : uint8_t
 SYSRANGE_RANGE_CHECK_ENABLES.
 
enum  VhvRecalibrate : uint8_t
 SYSRANGE_VHV_RECALIBRATE.
 
enum  AnalogGain : uint8_t
 SYSALS_ANALOGUE_GAIN.
 
enum  RangeStatus : uint8_t
 RESULT_RANGE_STATUS.
 
enum  RangeErrorCode : uint8_t
 
enum  ALS_Status : uint8_t
 RESULT_ALS_STATUS.
 
enum  ALS_ErrorCode : uint8_t
 
enum  InterruptStatus
 RESULT_INTERRUPT_STATUS_GPIO.
 
enum  InterruptError : uint8_t
 

Public Member Functions

 MODM_FLAGS8 (GpioMode)
 
 MODM_FLAGS8 (HistoryControl)
 
 MODM_FLAGS8 (InterruptClear)
 
 MODM_FLAGS8 (Start)
 
 MODM_FLAGS8 (RangeCheck)
 
 MODM_FLAGS8 (VhvRecalibrate)
 
 MODM_FLAGS8 (RangeStatus)
 
 MODM_FLAGS8 (ALS_Status)
 
 Vl6180 (Data &data, uint8_t address=0x29)
 Constructor, requires an vl6180::Data object, sets address to default of 0x29.
 
modm::ResumableResult< bool > ping ()
 
modm::ResumableResult< bool > initialize ()
 
modm::ResumableResult< bool > setDeviceAddress (uint8_t address)
 
modm::ResumableResult< bool > setGain (AnalogGain gain)
 Sets a new analog gain for ALS.
 
modm::ResumableResult< bool > setIntegrationTime (uint16_t time)
 
modm::ResumableResult< bool > readDistance ()
 Reads the distance and buffer the results (can take 10-55ms).
 
modm::ResumableResult< bool > readAmbientLight ()
 
RangeErrorCode getRangeError ()
 
ALS_ErrorCode getALS_Error ()
 
template<typename T >
modm::ResumableResult< bool > updateRegister (Register reg, T setMask, T clearMask=T (0xff))
 
modm::ResumableResult< bool > write (Register reg, uint8_t value)
 write a 8bit value a register
 
DatagetData ()
 the data object for this sensor.
 
modm::ResumableResult< bool > read (Register reg, uint8_t *buffer, uint8_t length)
 read multiple 8bit values from a start register
 
void attachConfigurationHandler (I2c::ConfigurationHandler handler)
 
modm::ResumableResult< bool > read (uint8_t *buffer, std::size_t size)
 Starts a write transaction and waits until finished.
 
void setAddress (uint8_t address)
 
modm::ResumableResult< bool > write (const uint8_t *buffer, std::size_t size)
 Starts a write transaction and waits until finished.
 
modm::ResumableResult< bool > writeRead (const uint8_t *writeBuffer, std::size_t writeSize, uint8_t *readBuffer, std::size_t readSize)
 Starts a write-read transaction and waits until finished.
 

Protected Member Functions

int8_t getResumableDepth () const
 
bool isResumableRunning () const
 
bool isTransactionRunning ()
 
modm::ResumableResult< bool > runTransaction ()
 Starts our own transaction and waits until finished.
 
bool startRead (uint8_t *buffer, std::size_t size)
 Configures the transaction with a read operation and starts it.
 
bool startTransaction ()
 Starts the transaction with our own transaction object.
 
bool startTransaction (modm::I2cTransaction *transaction)
 Starts the transaction with a separate transaction object.
 
bool startWrite (const uint8_t *buffer, std::size_t size)
 Configures the transaction with a write operation and starts it.
 
bool startWriteRead (const uint8_t *writeBuffer, std::size_t writeSize, uint8_t *readBuffer, std::size_t readSize)
 Configures the transaction with a write/read operation and starts it.
 
void stopResumable ()
 
bool wasTransactionSuccessful ()
 

Protected Attributes

I2cWriteReadTransaction transaction
 

Detailed Description

template<typename I2cMaster>
class modm::Vl6180< I2cMaster >

VL6180X: Proximity and ambient light sensing (ALS) module

This implementation loads the configuration as recommended by the application note AN2424. The class is build for single-shot measurements.

For custom settings use the updateRegister() function.

Author
Niklas Hauser

Member Enumeration Documentation

template<typename I2cMaster >
enum modm::Vl6180::Start : uint8_t
strong

SYSRANGE_START SYSALS_START

Member Function Documentation

void modm::I2cDevice< I2cMaster, 10 , I2cWriteReadTransaction >::attachConfigurationHandler ( I2c::ConfigurationHandler  handler)
inheritedinline

Attaches a configuration handler, which is called before a transaction, whenever the configuration has to be changed.

bool modm::I2cDevice< I2cMaster, 10 , I2cWriteReadTransaction >::isTransactionRunning ( )
inheritedinlineprotected
Returns
true when transaction is busy.
template<typename I2cMaster >
modm::ResumableResult<bool> modm::Vl6180< I2cMaster >::ping ( )

Ping the I2C device. This overwrites the build-in ping method of I2cDevice with a read of the model number.

template<typename I2cMaster >
modm::ResumableResult<bool> modm::Vl6180< I2cMaster >::readAmbientLight ( )
inline

Reads the ambient light and buffer the results. This takes as long as the chosen integration time (100ms default).

void modm::I2cDevice< I2cMaster, 10 , I2cWriteReadTransaction >::setAddress ( uint8_t  address)
inheritedinline

Sets a new address of the slave device.

Parameters
addressthe slave address not yet shifted left (address < 128).
template<typename I2cMaster >
modm::ResumableResult<bool> modm::Vl6180< I2cMaster >::setDeviceAddress ( uint8_t  address)

Set a new I2C address (< 128) for this device. The address is not permanent and must be set again after every device boot.

template<typename I2cMaster >
modm::ResumableResult<bool> modm::Vl6180< I2cMaster >::setIntegrationTime ( uint16_t  time)

Sets a new integration time for ALS.

Parameters
timeintegration time in ms, max ~500ms.
bool modm::I2cDevice< I2cMaster, 10 , I2cWriteReadTransaction >::wasTransactionSuccessful ( )
inheritedinlineprotected
Returns
true when transaction did not return an error.

The documentation for this class was generated from the following file: