modm API documentation
modm::lp503x< I2cMaster, Channels > Class Template Reference

#include <modm/driver/pwm/lp503x.hpp>

Inheritance diagram for modm::lp503x< I2cMaster, Channels >:
modm::I2cDevice< I2cMaster, 3 > modm::NestedResumable< 10+1 >

Public Typedefs

using RegisterValue_t = FlagsGroup< DeviceConfig0_t, DeviceConfig1_t, Reset_t >
 

Public Types

enum  Register : uint8_t {
  DeviceConfig0 = 0x00, DeviceConfig1 = 0x01, LedConfig0 = 0x02, LedConfig1 = 0x03,
  BankBrightness = 0x04, BankAColor = 0x05, BankBColor = 0x06, BankCColor = 0x07,
  Led0Brightness = 0x08, Out0Color = 0x14, Reset = 0x38
}
 
enum  DeviceConfig0 : uint8_t { ChipEnable = (1 << 6) }
 
enum  DeviceConfig1 : uint8_t {
  LedGlobalOff = (1 << 0), HighCurrent = (1 << 1), PwmDithering = (1 << 2), AutoIncrement = (1 << 3),
  PowerSave = (1 << 4), LogScale = (1 << 5)
}
 
enum  LedBankMode : uint16_t {
  Led0 = (1 << 0), Led1 = (1 << 1), Led2 = (1 << 2), Led3 = (1 << 3),
  Led4 = (1 << 4), Led5 = (1 << 5), Led6 = (1 << 6), Led7 = (1 << 7),
  Led8 = (1 << 8), Led9 = (1 << 9), Led10 = (1 << 10), Led11 = (1 << 11)
}
 
enum  Reset : uint8_t { ResetDevice = 0xff }
 

Public Member Functions

 MODM_FLAGS8 (DeviceConfig0)
 
 MODM_FLAGS8 (DeviceConfig1)
 
 MODM_FLAGS16 (LedBankMode)
 
 MODM_FLAGS8 (Reset)
 
 Lp503x (uint8_t i2cAddress)
 
modm::ResumableResult< bool > initialize ()
 Initialize device, call before using any other function.
 
modm::ResumableResult< bool > enable ()
 Enable device.
 
modm::ResumableResult< bool > disable ()
 Disable device.
 
modm::ResumableResult< bool > setConfiguration (DeviceConfig1_t configuration)
 
modm::ResumableResult< bool > setChannelBrightness (uint8_t channel, uint8_t value)
 
modm::ResumableResult< bool > setChannelBrightnessValues (uint8_t startChannel, const uint8_t *values, uint8_t numChannels)
 
modm::ResumableResult< bool > setLedGroupBrightness (uint8_t index, uint8_t value)
 
modm::ResumableResult< bool > setBankModeEnabled (LedBankMode_t bankMode)
 
modm::ResumableResult< bool > setBankBrightness (uint8_t value)
 
modm::ResumableResult< bool > setBankABrightness (uint8_t value)
 
modm::ResumableResult< bool > setBankBBrightness (uint8_t value)
 
modm::ResumableResult< bool > setBankCBrightness (uint8_t value)
 
void attachConfigurationHandler (I2c::ConfigurationHandler handler)
 
modm::ResumableResult< bool > ping ()
 
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.
 

Public Attributes

DeviceConfig1_t DefaultConfiguration
 

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, size_t Channels>
class modm::lp503x< I2cMaster, Channels >

LP5030/LP5036 30/36-channel, 12-bit PWM LED controller

Template Parameters
I2cMasterI2C interface
Author
Christopher Durand

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.
modm::ResumableResult<bool> modm::I2cDevice< I2cMaster, 10 , I2cWriteReadTransaction >::ping ( )
inheritedinline
Return Values
truedevice responds to address
falseno device with address found
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 , size_t Channels>
modm::ResumableResult<bool> modm::lp503x< I2cMaster, Channels >::setBankABrightness ( uint8_t  value)

Set brightness for all channels 3n configured in bank mode.

template<typename I2cMaster , size_t Channels>
modm::ResumableResult<bool> modm::lp503x< I2cMaster, Channels >::setBankBBrightness ( uint8_t  value)

Set brightness for all channels 3n+1 configured in bank mode.

template<typename I2cMaster , size_t Channels>
modm::ResumableResult<bool> modm::lp503x< I2cMaster, Channels >::setBankBrightness ( uint8_t  value)

Set bank brightness multiplicator. This controls all channels in bank mode.

template<typename I2cMaster , size_t Channels>
modm::ResumableResult<bool> modm::lp503x< I2cMaster, Channels >::setBankCBrightness ( uint8_t  value)

Set brightness for all channels 3n+2 configured in bank mode.

template<typename I2cMaster , size_t Channels>
modm::ResumableResult<bool> modm::lp503x< I2cMaster, Channels >::setBankModeEnabled ( LedBankMode_t  bankMode)

Enable bank mode for a led group. This allows to simultaniously dim multiple RGB leds by accessing the global bank registers.

If bank mode is enabled for a led group (3n, 3n+1, 3n+2) its brightnesses are controlled by the global BankAColor, BankBColor, BankCColor registers and the BankBrightness register. The inidividual channel settings are ignored then.

template<typename I2cMaster , size_t Channels>
modm::ResumableResult<bool> modm::lp503x< I2cMaster, Channels >::setChannelBrightness ( uint8_t  channel,
uint8_t  value 
)

Set brightness value for individual output channel.

This writes to the OutXColor registers.

If the LogScale flag is set these values are scaled logithmically to 12 bit pwm duty-cycles (default).

Parameters
channeloutput channel index
value8-bit brightness value
template<typename I2cMaster , size_t Channels>
modm::ResumableResult<bool> modm::lp503x< I2cMaster, Channels >::setChannelBrightnessValues ( uint8_t  startChannel,
const uint8_t *  values,
uint8_t  numChannels 
)

Set brightness values for multiple output channels in one transaction.

This writes the OutXColor registers.

Parameters
channeloutput channel start index
numChannelsnumber of values to write
value8-bit brightness value
template<typename I2cMaster , size_t Channels>
modm::ResumableResult<bool> modm::lp503x< I2cMaster, Channels >::setConfiguration ( DeviceConfig1_t  configuration)

Set device configuration AutoIncrement is always set

template<typename I2cMaster , size_t Channels>
modm::ResumableResult<bool> modm::lp503x< I2cMaster, Channels >::setLedGroupBrightness ( uint8_t  index,
uint8_t  value 
)

Set brightness multiplicator for output channel group (3n, 3n+1, 3n+2). Intended for dimming RGB Leds.

When this feature is not required, this function can be ignored. The default of 0xFF corresponds to full on. Then the resulting LED brightness only depends on the individual channel settings.

This setting has no effect when the LED group is configured in bank mode. Then the value from the BankBrightness register is used.

Default value is 0xFF.

Parameters
value8-bit brightness value
bool modm::I2cDevice< I2cMaster, 10 , I2cWriteReadTransaction >::wasTransactionSuccessful ( )
inheritedinlineprotected
Returns
true when transaction did not return an error.

Member Data Documentation

template<typename I2cMaster , size_t Channels>
DeviceConfig1_t modm::lp503x< I2cMaster, Channels >::DefaultConfiguration
Initial value:
DeviceConfig1::HighCurrent |
DeviceConfig1::PwmDithering |
DeviceConfig1::PowerSave |
DeviceConfig1::LogScale

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