LP55231 driver

Committer:
duchonic
Date:
Wed Aug 22 06:32:51 2018 +0000
Revision:
0:4ff4e0b7f25c
Child:
1:4ab9f195e998
LP55231 library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
duchonic 0:4ff4e0b7f25c 1 #include "LP55231.h"
duchonic 0:4ff4e0b7f25c 2
duchonic 0:4ff4e0b7f25c 3 LP55231::LP55231(PinName sda, PinName scl, uint8_t addr) : m_i2c(sda, scl), m_addr(addr) {}
duchonic 0:4ff4e0b7f25c 4
duchonic 0:4ff4e0b7f25c 5 uint8_t LP55231::LP55231_Init(void){
duchonic 0:4ff4e0b7f25c 6
duchonic 0:4ff4e0b7f25c 7 SetRegister(REG_ENGINE_CNTRL1, 0x40);
duchonic 0:4ff4e0b7f25c 8 SetRegister(REG_MISC, 0x53);
duchonic 0:4ff4e0b7f25c 9
duchonic 0:4ff4e0b7f25c 10 return 0;
duchonic 0:4ff4e0b7f25c 11 }
duchonic 0:4ff4e0b7f25c 12
duchonic 0:4ff4e0b7f25c 13 LP55231::~LP55231(void) {
duchonic 0:4ff4e0b7f25c 14 };
duchonic 0:4ff4e0b7f25c 15
duchonic 0:4ff4e0b7f25c 16
duchonic 0:4ff4e0b7f25c 17 void LP55231::LP55231_SetLed(uint8_t led, uint8_t brightness)
duchonic 0:4ff4e0b7f25c 18 {
duchonic 0:4ff4e0b7f25c 19 SetRegister(REG_D7_PWM, brightness); /* RED1 */
duchonic 0:4ff4e0b7f25c 20 SetRegister(REG_D1_PWM, brightness); /* GREEN1 */
duchonic 0:4ff4e0b7f25c 21 SetRegister(REG_D2_PWM, brightness); /* BLUE1 */
duchonic 0:4ff4e0b7f25c 22 }
duchonic 0:4ff4e0b7f25c 23
duchonic 0:4ff4e0b7f25c 24
duchonic 0:4ff4e0b7f25c 25 // --- Private Functions --- //
duchonic 0:4ff4e0b7f25c 26
duchonic 0:4ff4e0b7f25c 27 void LP55231::SetRegister(uint8_t registerAddr, uint8_t data)
duchonic 0:4ff4e0b7f25c 28 {
duchonic 0:4ff4e0b7f25c 29 char data_write[2];
duchonic 0:4ff4e0b7f25c 30 data_write[0] = registerAddr;
duchonic 0:4ff4e0b7f25c 31 data_write[1] = data;
duchonic 0:4ff4e0b7f25c 32 m_i2c.write(m_addr, data_write, 3);
duchonic 0:4ff4e0b7f25c 33 }