LP55231 driver
Diff: LP55231.cpp
- Revision:
- 0:4ff4e0b7f25c
- Child:
- 1:4ab9f195e998
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/LP55231.cpp Wed Aug 22 06:32:51 2018 +0000 @@ -0,0 +1,33 @@ +#include "LP55231.h" + +LP55231::LP55231(PinName sda, PinName scl, uint8_t addr) : m_i2c(sda, scl), m_addr(addr) {} + +uint8_t LP55231::LP55231_Init(void){ + + SetRegister(REG_ENGINE_CNTRL1, 0x40); + SetRegister(REG_MISC, 0x53); + + return 0; +} + +LP55231::~LP55231(void) { +}; + + +void LP55231::LP55231_SetLed(uint8_t led, uint8_t brightness) +{ + SetRegister(REG_D7_PWM, brightness); /* RED1 */ + SetRegister(REG_D1_PWM, brightness); /* GREEN1 */ + SetRegister(REG_D2_PWM, brightness); /* BLUE1 */ +} + + +// --- Private Functions --- // + +void LP55231::SetRegister(uint8_t registerAddr, uint8_t data) +{ + char data_write[2]; + data_write[0] = registerAddr; + data_write[1] = data; + m_i2c.write(m_addr, data_write, 3); +} \ No newline at end of file