RGB LED Driver demo
Dependents: NJU6063_HelloWorld
Diff: NJU6063.h
- Revision:
- 3:f83202c2ae59
- Parent:
- 2:137675ac48ab
--- a/NJU6063.h Sun Jan 10 11:49:59 2016 +0000 +++ b/NJU6063.h Mon Jan 18 05:07:27 2016 +0000 @@ -8,52 +8,59 @@ */ #ifndef MBED_NJU6063_H #define MBED_NJU6063_H - +# #include "mbed.h" #define NJU6063_SLAVE 0x40 -#define EN 0x01 -#define EXT 0x02 -#define FDX1 0x00 -#define FDX2 0x04 -#define FDX4 0x08 -#define FDX8 0x0C -#define FC1000KHZ 0x00 -#define FC1300KHZ 0x10 -#define FC800KHZ 0x20 -#define FC2200KHZ 0x30 -#define DMGP 0x80 -#define DO1 0x40 -#define ILED1OFF 0x00 -#define ILED1X1 0x03 -#define ILED1X05 0x02 -#define ILED1X025 0x01 -#define ILED2OFF 0x00 -#define ILED2X1 0x03 -#define ILED2X05 0x02 -#define ILED2X025 0x01 -#define ILED3OFF 0x00 -#define ILED3X1 0x03 -#define ILED3X05 0x02 -#define ILED3X025 0x01 -#define ALL 0xff +#define NJU6063_INIT 0x00 +#define NJU6063_ILED 0x01 +#define NJU6063_PWM1 0x02 +#define NJU6063_PWM2 0x03 +#define NJU6063_PWM3 0x04 +#define NJU6063_DIMM 0x05 +#define NJU6063_STON 0x06 +#define NJU6063_START 0x07 +#define NJU6063_DCHK 0x0b +#define NJU6063_MADRES 0x0d + -#define DEFAULTINIT FC800KHZ|FDX8|EN +#define NJU6063_EN 0x01 +#define NJU6063_EXT 0x02 +#define NJU6063_FDX1 0x00 +#define NJU6063_FDX2 0x04 +#define NJU6063_FDX4 0x08 +#define NJU6063_FDX8 0x0C +#define NJU6063_FC1000KHZ 0x00 +#define NJU6063_FC1300KHZ 0x10 +#define NJU6063_FC800KHZ 0x20 +#define NJU6063_FC2200KHZ 0x30 +#define NJU6063_DMGP 0x80 +#define NJU6063_DO1 0x40 +#define NJU6063_ILED1OFF 0x00 +#define NJU6063_ILED1X1 0x03 +#define NJU6063_ILED1X05 0x02 +#define NJU6063_ILED1X025 0x01 +#define NJU6063_ILED2OFF 0x00 +#define NJU6063_ILED2X1 0x03 +#define NJU6063_ILED2X05 0x02 +#define NJU6063_ILED2X025 0x01 +#define NJU6063_ILED3OFF 0x00 +#define NJU6063_ILED3X1 0x03 +#define NJU6063_ILED3X05 0x02 +#define NJU6063_ILED3X025 0x01 +#define NJU6063_ALL 0xff + +#define NJU6063_DEFAULTINIT NJU6063_FC800KHZ|NJU6063_FDX8|NJU6063_EN +#define NJU6063_WAIT wait_us(500*3) +#define NJU6063_WAIT_MS wait_ms(200) class NJU6063 { private: I2C _i2c; - I2C_TypeDef* _i2c_type; + //I2C_TypeDef* _myI2c; + //I2C_HandleTypeDef _myI2cH; DigitalOut _rst; int ack; - uint32_t* _i2c_cr1; - uint32_t* _i2c_cr2; - uint32_t* _i2c_dr; - uint32_t* _i2c_sr1; - uint32_t* _i2c_sr2; - void SetCR1(uint16_t data) { *_i2c_cr1 |= data;} - void SetCR2(uint16_t data) { *_i2c_cr2 |= data;} - void TxDR(uint8_t data) { *_i2c_dr = data; } public: /** * @param sda I2C-bus SDA pin @@ -70,7 +77,7 @@ /** NJU6063 device addres set * @param n Max number of device. 1 - 254 */ - uint8_t set_multi_device(uint8_t n); + uint8_t set_multi_device(uint8_t n=0xfe); /** NJU6063 Initial setting * @param chip_addr target chip address * @param d data