initial commit

Dependencies:   mbed

Fork of empc_pdu_v3 by gami

Committer:
rcflyair
Date:
Fri Apr 07 16:12:08 2017 +0000
Revision:
1:1686fedb8e0a
initial commit;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rcflyair 1:1686fedb8e0a 1 #ifndef TLC59116_H
rcflyair 1:1686fedb8e0a 2 #define TLC59116_H
rcflyair 1:1686fedb8e0a 3
rcflyair 1:1686fedb8e0a 4 #include <mbed.h>
rcflyair 1:1686fedb8e0a 5
rcflyair 1:1686fedb8e0a 6 #define TLC59116_ADDRESS (0x60 << 1)
rcflyair 1:1686fedb8e0a 7
rcflyair 1:1686fedb8e0a 8 //********** REGISTER MAP DEFINITION
rcflyair 1:1686fedb8e0a 9 #define MODE1 0x00;
rcflyair 1:1686fedb8e0a 10 #define MODE2 0x01;
rcflyair 1:1686fedb8e0a 11 #define PWM0 0x02;
rcflyair 1:1686fedb8e0a 12 #define PWM1 0x03;
rcflyair 1:1686fedb8e0a 13 #define PWM2 0x04;
rcflyair 1:1686fedb8e0a 14 #define PWM3 0x05;
rcflyair 1:1686fedb8e0a 15 #define PWM4 0x06;
rcflyair 1:1686fedb8e0a 16 #define PWM5 0x07;
rcflyair 1:1686fedb8e0a 17 #define PWM6 0x08;
rcflyair 1:1686fedb8e0a 18 #define PWM7 0x09;
rcflyair 1:1686fedb8e0a 19 #define PWM8 0x0A;
rcflyair 1:1686fedb8e0a 20 #define PWM9 0x0B;
rcflyair 1:1686fedb8e0a 21 #define PWM10 0x0C;
rcflyair 1:1686fedb8e0a 22 #define PWM11 0x0D;
rcflyair 1:1686fedb8e0a 23 #define PWM12 0x0E;
rcflyair 1:1686fedb8e0a 24 #define PWM13 0x0F;
rcflyair 1:1686fedb8e0a 25 #define PWM14 0x10;
rcflyair 1:1686fedb8e0a 26 #define PWM15 0x11;
rcflyair 1:1686fedb8e0a 27 #define GRPPWM 0x12;
rcflyair 1:1686fedb8e0a 28 #define GRPFREQ 0x13;
rcflyair 1:1686fedb8e0a 29 #define LEDOUT0 0x14;
rcflyair 1:1686fedb8e0a 30 #define LEDOUT1 0x15;
rcflyair 1:1686fedb8e0a 31 #define LEDOUT2 0x16;
rcflyair 1:1686fedb8e0a 32 #define LEDOUT3 0x17;
rcflyair 1:1686fedb8e0a 33 #define SUBADR1 0x18;
rcflyair 1:1686fedb8e0a 34 #define SUBADR2 0x19;
rcflyair 1:1686fedb8e0a 35 #define SUBADR3 0x1A;
rcflyair 1:1686fedb8e0a 36 #define ALLCALLADR 0x1B;
rcflyair 1:1686fedb8e0a 37 #define IREF 0x1C;
rcflyair 1:1686fedb8e0a 38 #define EFLAG1 0x1D;
rcflyair 1:1686fedb8e0a 39 #define EFLAG2 0x1E;
rcflyair 1:1686fedb8e0a 40
rcflyair 1:1686fedb8e0a 41
rcflyair 1:1686fedb8e0a 42 //********** CONTROL REGISTER MASK DEFINITION
rcflyair 1:1686fedb8e0a 43 // Auto Increment options
rcflyair 1:1686fedb8e0a 44 // The CONTROL REGISTER three most significant bits contain the auto incrementing flag
rcflyair 1:1686fedb8e0a 45 // and the five least significant the address the starting register address
rcflyair 1:1686fedb8e0a 46 // A12 A11 A10 D4 D3 D2 D1 D0
rcflyair 1:1686fedb8e0a 47 // The following #defines are masks setting the auto increment flag
rcflyair 1:1686fedb8e0a 48 //
rcflyair 1:1686fedb8e0a 49 // * No auto increment
rcflyair 1:1686fedb8e0a 50 // 000 is used when the same register must be accessed several times during a single I2C bus communication,
rcflyair 1:1686fedb8e0a 51 // for example, changing the brightness of a single LED. Data is overwritten each time the register
rcflyair 1:1686fedb8e0a 52 // is accessed during a write operation.
rcflyair 1:1686fedb8e0a 53 #define AUTO_INCREMENT_NONE 0x00; // mask = 000xxxxx
rcflyair 1:1686fedb8e0a 54 // * Auto increment all registers
rcflyair 1:1686fedb8e0a 55 // 100 is used when all the registers must be sequentially accessed, for example, power-up programming.
rcflyair 1:1686fedb8e0a 56 #define AUTO_INCREMENT_ALL 0x80; // mask = 100xxxxx
rcflyair 1:1686fedb8e0a 57 // * Auto increment brightness
rcflyair 1:1686fedb8e0a 58 // 101 is used when the four LED drivers must be individually programmed with different values during the
rcflyair 1:1686fedb8e0a 59 // same I2C bus communication, for example, changing a color setting to another color setting.
rcflyair 1:1686fedb8e0a 60 #define AUTO_INCREMENT_BRIGHTNESS 0xA0; // mask = 101xxxxx
rcflyair 1:1686fedb8e0a 61 // * Auto increment control
rcflyair 1:1686fedb8e0a 62 // 110 is used when the LED drivers must be globally programmed with different settings during the same
rcflyair 1:1686fedb8e0a 63 // I2C bus communication, for example, global brightness or blinking change.
rcflyair 1:1686fedb8e0a 64 #define AUTO_INCREMENT_GLOBAL_CONTROL 0xC0; // mask = 110xxxxx
rcflyair 1:1686fedb8e0a 65 // * Auto increment brightness and control
rcflyair 1:1686fedb8e0a 66 // 111 is used when individually and global changes must be performed during the same
rcflyair 1:1686fedb8e0a 67 // I2C bus communication, for example, changing color and global brightness at the same time.
rcflyair 1:1686fedb8e0a 68 #define AUTO_INCREMENT_BRIGHT_CONTROL 0xE0; // mask = 111xxxxx
rcflyair 1:1686fedb8e0a 69 //**********
rcflyair 1:1686fedb8e0a 70
rcflyair 1:1686fedb8e0a 71 // TLC59116 Registers
rcflyair 1:1686fedb8e0a 72 #define COMMAND 0x00;
rcflyair 1:1686fedb8e0a 73
rcflyair 1:1686fedb8e0a 74
rcflyair 1:1686fedb8e0a 75 class TLC59116
rcflyair 1:1686fedb8e0a 76 {
rcflyair 1:1686fedb8e0a 77 private:
rcflyair 1:1686fedb8e0a 78 I2C _i2c;
rcflyair 1:1686fedb8e0a 79 DigitalOut _cs;
rcflyair 1:1686fedb8e0a 80 char b[32];
rcflyair 1:1686fedb8e0a 81 public:
rcflyair 1:1686fedb8e0a 82 TLC59116(PinName sda, PinName scl, PinName cs);
rcflyair 1:1686fedb8e0a 83 void Enable(void);
rcflyair 1:1686fedb8e0a 84 void Disable(void);
rcflyair 1:1686fedb8e0a 85 int SWRST(void);
rcflyair 1:1686fedb8e0a 86 int init(void);
rcflyair 1:1686fedb8e0a 87 int SetBrightness(int x);
rcflyair 1:1686fedb8e0a 88 void SetAuto(bool v);
rcflyair 1:1686fedb8e0a 89 void SetManual(bool v);
rcflyair 1:1686fedb8e0a 90 void SetPower(bool v);
rcflyair 1:1686fedb8e0a 91 void SetFault(bool v);
rcflyair 1:1686fedb8e0a 92 void SetBarGraph(int x);
rcflyair 1:1686fedb8e0a 93 };
rcflyair 1:1686fedb8e0a 94
rcflyair 1:1686fedb8e0a 95 #endif