LP55231 driver
LP55231.h@1:4ab9f195e998, 2018-08-22 (annotated)
- Committer:
- duchonic
- Date:
- Wed Aug 22 08:59:37 2018 +0000
- Revision:
- 1:4ab9f195e998
- Parent:
- 0:4ff4e0b7f25c
- Child:
- 2:79b94bf1cf59
colors, all 3 leds
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
duchonic | 0:4ff4e0b7f25c | 1 | #include "mbed.h" |
duchonic | 0:4ff4e0b7f25c | 2 | |
duchonic | 0:4ff4e0b7f25c | 3 | #ifndef LP55231_h |
duchonic | 0:4ff4e0b7f25c | 4 | #define LP55231_h |
duchonic | 0:4ff4e0b7f25c | 5 | |
duchonic | 0:4ff4e0b7f25c | 6 | #define REG_ENGINE_CNTRL1 (0x00) |
duchonic | 0:4ff4e0b7f25c | 7 | #define REG_MISC (0x36) |
duchonic | 1:4ab9f195e998 | 8 | |
duchonic | 0:4ff4e0b7f25c | 9 | #define REG_D1_PWM (0x16) /* GREEN1 */ |
duchonic | 0:4ff4e0b7f25c | 10 | #define REG_D2_PWM (0x17) /* BLUE1 */ |
duchonic | 1:4ab9f195e998 | 11 | #define REG_D3_PWM (0x18) /* GREEN2 */ |
duchonic | 1:4ab9f195e998 | 12 | #define REG_D4_PWM (0x19) /* BLUE2 */ |
duchonic | 1:4ab9f195e998 | 13 | #define REG_D5_PWM (0x1A) /* GREEN3 */ |
duchonic | 1:4ab9f195e998 | 14 | #define REG_D6_PWM (0x1B) /* BLUE3 */ |
duchonic | 0:4ff4e0b7f25c | 15 | #define REG_D7_PWM (0x1C) /* RED1 */ |
duchonic | 1:4ab9f195e998 | 16 | #define REG_D8_PWM (0x1D) /* RED2 */ |
duchonic | 1:4ab9f195e998 | 17 | #define REG_D9_PWM (0x1E) /* RED3 */ |
duchonic | 1:4ab9f195e998 | 18 | |
duchonic | 1:4ab9f195e998 | 19 | enum LP55231_leds |
duchonic | 1:4ab9f195e998 | 20 | { |
duchonic | 1:4ab9f195e998 | 21 | LP55231_LED1 = 0, |
duchonic | 1:4ab9f195e998 | 22 | LP55231_LED2, |
duchonic | 1:4ab9f195e998 | 23 | LP55231_LED3 |
duchonic | 1:4ab9f195e998 | 24 | }; |
duchonic | 1:4ab9f195e998 | 25 | |
duchonic | 1:4ab9f195e998 | 26 | struct LP55231_colors |
duchonic | 1:4ab9f195e998 | 27 | { |
duchonic | 1:4ab9f195e998 | 28 | uint8_t red; |
duchonic | 1:4ab9f195e998 | 29 | uint8_t green; |
duchonic | 1:4ab9f195e998 | 30 | uint8_t blue; |
duchonic | 1:4ab9f195e998 | 31 | }; |
duchonic | 1:4ab9f195e998 | 32 | |
duchonic | 0:4ff4e0b7f25c | 33 | |
duchonic | 0:4ff4e0b7f25c | 34 | class LP55231 |
duchonic | 0:4ff4e0b7f25c | 35 | { |
duchonic | 0:4ff4e0b7f25c | 36 | public: |
duchonic | 0:4ff4e0b7f25c | 37 | |
duchonic | 0:4ff4e0b7f25c | 38 | /** |
duchonic | 0:4ff4e0b7f25c | 39 | * @brief LP55231 constructor |
duchonic | 0:4ff4e0b7f25c | 40 | */ |
duchonic | 0:4ff4e0b7f25c | 41 | LP55231(PinName sda, PinName scl, uint8_t addr); |
duchonic | 0:4ff4e0b7f25c | 42 | |
duchonic | 0:4ff4e0b7f25c | 43 | /** |
duchonic | 0:4ff4e0b7f25c | 44 | * @brief LP55231 destructor |
duchonic | 0:4ff4e0b7f25c | 45 | */ |
duchonic | 0:4ff4e0b7f25c | 46 | ~LP55231(); |
duchonic | 0:4ff4e0b7f25c | 47 | |
duchonic | 0:4ff4e0b7f25c | 48 | /** |
duchonic | 0:4ff4e0b7f25c | 49 | * |
duchonic | 0:4ff4e0b7f25c | 50 | */ |
duchonic | 0:4ff4e0b7f25c | 51 | uint8_t LP55231_Init(void); |
duchonic | 0:4ff4e0b7f25c | 52 | |
duchonic | 0:4ff4e0b7f25c | 53 | /** |
duchonic | 0:4ff4e0b7f25c | 54 | * |
duchonic | 0:4ff4e0b7f25c | 55 | */ |
duchonic | 1:4ab9f195e998 | 56 | void LP55231_SetLed(LP55231_leds led, LP55231_colors color); |
duchonic | 0:4ff4e0b7f25c | 57 | |
duchonic | 0:4ff4e0b7f25c | 58 | private: |
duchonic | 0:4ff4e0b7f25c | 59 | I2C m_i2c; |
duchonic | 0:4ff4e0b7f25c | 60 | int m_addr; |
duchonic | 0:4ff4e0b7f25c | 61 | /** |
duchonic | 0:4ff4e0b7f25c | 62 | * |
duchonic | 0:4ff4e0b7f25c | 63 | */ |
duchonic | 0:4ff4e0b7f25c | 64 | void SetRegister(uint8_t registerAddr, uint8_t data); |
duchonic | 0:4ff4e0b7f25c | 65 | |
duchonic | 0:4ff4e0b7f25c | 66 | }; |
duchonic | 0:4ff4e0b7f25c | 67 | |
duchonic | 0:4ff4e0b7f25c | 68 | |
duchonic | 0:4ff4e0b7f25c | 69 | #endif |