I2C driver for the NXP chip PCA9685 16xPWM LED controller A total of 4 RGBA LEDs can be controlled by 1 chip giving a RGBA value in the form of: rgba(0-255,0-255,0-255,0-100) then dimmed by 0-100%
pca9685_reg.h@0:62c7c3514d8f, 2012-06-15 (annotated)
- Committer:
- Bas
- Date:
- Fri Jun 15 23:30:43 2012 +0000
- Revision:
- 0:62c7c3514d8f
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Bas | 0:62c7c3514d8f | 1 | #ifndef __PCA9685_H |
Bas | 0:62c7c3514d8f | 2 | #define __PCA9685_H |
Bas | 0:62c7c3514d8f | 3 | |
Bas | 0:62c7c3514d8f | 4 | /* Devices */ |
Bas | 0:62c7c3514d8f | 5 | #define LEDDRV1 0xb8 |
Bas | 0:62c7c3514d8f | 6 | #define LEDDRV2 0xba |
Bas | 0:62c7c3514d8f | 7 | #define LEDDRV3 0xd8 |
Bas | 0:62c7c3514d8f | 8 | #define LEDDRV4 0xda |
Bas | 0:62c7c3514d8f | 9 | #define LEDDRV5 0xc8 |
Bas | 0:62c7c3514d8f | 10 | #define LEDDRV6 0xca |
Bas | 0:62c7c3514d8f | 11 | |
Bas | 0:62c7c3514d8f | 12 | /* RGBA LED's. Max 4 on 1 chip */ |
Bas | 0:62c7c3514d8f | 13 | #define RGBA_LED1 0 |
Bas | 0:62c7c3514d8f | 14 | #define RGBA_LED2 1 |
Bas | 0:62c7c3514d8f | 15 | #define RGBA_LED3 2 |
Bas | 0:62c7c3514d8f | 16 | #define RGBA_LED4 3 |
Bas | 0:62c7c3514d8f | 17 | |
Bas | 0:62c7c3514d8f | 18 | /* Registers */ |
Bas | 0:62c7c3514d8f | 19 | #define PCA9685_MODE1 0x00 |
Bas | 0:62c7c3514d8f | 20 | #define PCA9685_MODE2 0x01 |
Bas | 0:62c7c3514d8f | 21 | #define PCA9685_SUBADR1 0x02 |
Bas | 0:62c7c3514d8f | 22 | #define PCA9685_SUBADR2 0x03 |
Bas | 0:62c7c3514d8f | 23 | #define PCA9685_SUBADR3 0x04 |
Bas | 0:62c7c3514d8f | 24 | #define PCA9685_ALLCALLADR 0x05 |
Bas | 0:62c7c3514d8f | 25 | #define PCA9685_LED0_ON_L 0x06 |
Bas | 0:62c7c3514d8f | 26 | #define PCA9685_LED0_ON_H 0x07 |
Bas | 0:62c7c3514d8f | 27 | #define PCA9685_LED0_OFF_L 0x08 |
Bas | 0:62c7c3514d8f | 28 | #define PCA9685_LED0_OFF_H 0x09 |
Bas | 0:62c7c3514d8f | 29 | #define PCA9685_LED1_ON_L 0x0a |
Bas | 0:62c7c3514d8f | 30 | #define PCA9685_LED1_ON_H 0x0b |
Bas | 0:62c7c3514d8f | 31 | #define PCA9685_LED1_OFF_L 0x0c |
Bas | 0:62c7c3514d8f | 32 | #define PCA9685_LED1_OFF_H 0x0d |
Bas | 0:62c7c3514d8f | 33 | #define PCA9685_LED2_ON_L 0x0e |
Bas | 0:62c7c3514d8f | 34 | #define PCA9685_LED2_ON_H 0x0f |
Bas | 0:62c7c3514d8f | 35 | #define PCA9685_LED2_OFF_L 0x10 |
Bas | 0:62c7c3514d8f | 36 | #define PCA9685_LED2_OFF_H 0x11 |
Bas | 0:62c7c3514d8f | 37 | #define PCA9685_LED3_ON_L 0x12 |
Bas | 0:62c7c3514d8f | 38 | #define PCA9685_LED3_ON_H 0x13 |
Bas | 0:62c7c3514d8f | 39 | #define PCA9685_LED3_OFF_L 0x14 |
Bas | 0:62c7c3514d8f | 40 | #define PCA9685_LED3_OFF_H 0x15 |
Bas | 0:62c7c3514d8f | 41 | #define PCA9685_LED4_ON_L 0x16 |
Bas | 0:62c7c3514d8f | 42 | #define PCA9685_LED4_ON_H 0x17 |
Bas | 0:62c7c3514d8f | 43 | #define PCA9685_LED4_OFF_L 0x18 |
Bas | 0:62c7c3514d8f | 44 | #define PCA9685_LED4_OFF_H 0x19 |
Bas | 0:62c7c3514d8f | 45 | #define PCA9685_LED5_ON_L 0x1a |
Bas | 0:62c7c3514d8f | 46 | #define PCA9685_LED5_ON_H 0x1b |
Bas | 0:62c7c3514d8f | 47 | #define PCA9685_LED5_OFF_L 0x1c |
Bas | 0:62c7c3514d8f | 48 | #define PCA9685_LED5_OFF_H 0x1d |
Bas | 0:62c7c3514d8f | 49 | #define PCA9685_LED6_ON_L 0x1e |
Bas | 0:62c7c3514d8f | 50 | #define PCA9685_LED6_ON_H 0x1d |
Bas | 0:62c7c3514d8f | 51 | #define PCA9685_LED6_OFF_L 0x20 |
Bas | 0:62c7c3514d8f | 52 | #define PCA9685_LED6_OFF_H 0x21 |
Bas | 0:62c7c3514d8f | 53 | #define PCA9685_LED7_ON_L 0x22 |
Bas | 0:62c7c3514d8f | 54 | #define PCA9685_LED7_ON_H 0x23 |
Bas | 0:62c7c3514d8f | 55 | #define PCA9685_LED7_OFF_L 0x24 |
Bas | 0:62c7c3514d8f | 56 | #define PCA9685_LED7_OFF_H 0x25 |
Bas | 0:62c7c3514d8f | 57 | #define PCA9685_LED8_ON_L 0x26 |
Bas | 0:62c7c3514d8f | 58 | #define PCA9685_LED8_ON_H 0x27 |
Bas | 0:62c7c3514d8f | 59 | #define PCA9685_LED8_OFF_L 0x28 |
Bas | 0:62c7c3514d8f | 60 | #define PCA9685_LED8_OFF_H 0x29 |
Bas | 0:62c7c3514d8f | 61 | #define PCA9685_LED9_ON_L 0x2a |
Bas | 0:62c7c3514d8f | 62 | #define PCA9685_LED9_ON_H 0x2b |
Bas | 0:62c7c3514d8f | 63 | #define PCA9685_LED9_OFF_L 0x2c |
Bas | 0:62c7c3514d8f | 64 | #define PCA9685_LED9_OFF_H 0x2d |
Bas | 0:62c7c3514d8f | 65 | #define PCA9685_LED10_ON_L 0x2e |
Bas | 0:62c7c3514d8f | 66 | #define PCA9685_LED10_ON_H 0x2f |
Bas | 0:62c7c3514d8f | 67 | #define PCA9685_LED10_OFF_L 0x30 |
Bas | 0:62c7c3514d8f | 68 | #define PCA9685_LED10_OFF_H 0x31 |
Bas | 0:62c7c3514d8f | 69 | #define PCA9685_LED11_ON_L 0x32 |
Bas | 0:62c7c3514d8f | 70 | #define PCA9685_LED11_ON_H 0x33 |
Bas | 0:62c7c3514d8f | 71 | #define PCA9685_LED11_OFF_L 0x34 |
Bas | 0:62c7c3514d8f | 72 | #define PCA9685_LED11_OFF_H 0x35 |
Bas | 0:62c7c3514d8f | 73 | #define PCA9685_LED12_ON_L 0x36 |
Bas | 0:62c7c3514d8f | 74 | #define PCA9685_LED12_ON_H 0x37 |
Bas | 0:62c7c3514d8f | 75 | #define PCA9685_LED12_OFF_L 0x38 |
Bas | 0:62c7c3514d8f | 76 | #define PCA9685_LED12_OFF_H 0x39 |
Bas | 0:62c7c3514d8f | 77 | #define PCA9685_LED13_ON_L 0x3a |
Bas | 0:62c7c3514d8f | 78 | #define PCA9685_LED13_ON_H 0x3b |
Bas | 0:62c7c3514d8f | 79 | #define PCA9685_LED13_OFF_L 0x3c |
Bas | 0:62c7c3514d8f | 80 | #define PCA9685_LED13_OFF_H 0x3d |
Bas | 0:62c7c3514d8f | 81 | #define PCA9685_LED14_ON_L 0x3e |
Bas | 0:62c7c3514d8f | 82 | #define PCA9685_LED14_ON_H 0x3f |
Bas | 0:62c7c3514d8f | 83 | #define PCA9685_LED14_OFF_L 0x40 |
Bas | 0:62c7c3514d8f | 84 | #define PCA9685_LED14_OFF_H 0x41 |
Bas | 0:62c7c3514d8f | 85 | #define PCA9685_LED15_ON_L 0x42 |
Bas | 0:62c7c3514d8f | 86 | #define PCA9685_LED15_ON_H 0x43 |
Bas | 0:62c7c3514d8f | 87 | #define PCA9685_LED15_OFF_L 0x44 |
Bas | 0:62c7c3514d8f | 88 | #define PCA9685_LED15_OFF_H 0x45 |
Bas | 0:62c7c3514d8f | 89 | #define PCA9685_ALL_LED_ON_L 0xfa |
Bas | 0:62c7c3514d8f | 90 | #define PCA9685_ALL_LED_ON_H 0xfb |
Bas | 0:62c7c3514d8f | 91 | #define PCA9685_ALL_LED_OFF_L 0xfc |
Bas | 0:62c7c3514d8f | 92 | #define PCA9685_ALL_LED_OFF_H 0xfd |
Bas | 0:62c7c3514d8f | 93 | #define PCA9685_PRE_SCALE 0xfe |
Bas | 0:62c7c3514d8f | 94 | |
Bas | 0:62c7c3514d8f | 95 | /* MODE1 bits */ |
Bas | 0:62c7c3514d8f | 96 | #define PCA9685_RESTART 0x80 |
Bas | 0:62c7c3514d8f | 97 | #define PCA9685_EXTCLK 0x40 |
Bas | 0:62c7c3514d8f | 98 | #define PCA9685_AI 0x20 |
Bas | 0:62c7c3514d8f | 99 | #define PCA9685_SLEEP 0x10 |
Bas | 0:62c7c3514d8f | 100 | #define PCA9685_SUB1 0x08 |
Bas | 0:62c7c3514d8f | 101 | #define PCA9685_SUB2 0x04 |
Bas | 0:62c7c3514d8f | 102 | #define PCA9685_SUB3 0x02 |
Bas | 0:62c7c3514d8f | 103 | #define PCA9685_ALLCALL 0x01 |
Bas | 0:62c7c3514d8f | 104 | |
Bas | 0:62c7c3514d8f | 105 | /* MODE2 bits */ |
Bas | 0:62c7c3514d8f | 106 | #define PCA9685_INVRT 0x10 |
Bas | 0:62c7c3514d8f | 107 | #define PCA9685_OCH 0x08 |
Bas | 0:62c7c3514d8f | 108 | #define PCA9685_OUTDRV 0x04 |
Bas | 0:62c7c3514d8f | 109 | #define PCA9685_OUTNE1 0x02 |
Bas | 0:62c7c3514d8f | 110 | #define PCA9685_OUTNE0 0x01 |
Bas | 0:62c7c3514d8f | 111 | |
Bas | 0:62c7c3514d8f | 112 | /* LEDX_ON_H bits */ |
Bas | 0:62c7c3514d8f | 113 | #define PCA9685_LED_ON 0x10 |
Bas | 0:62c7c3514d8f | 114 | |
Bas | 0:62c7c3514d8f | 115 | /* LEDX_OFF_H bits */ |
Bas | 0:62c7c3514d8f | 116 | #define PCA9685_LED_OFF 0x10 |
Bas | 0:62c7c3514d8f | 117 | |
Bas | 0:62c7c3514d8f | 118 | #define PCA9685_LED_BUFSIZ 0x04 |
Bas | 0:62c7c3514d8f | 119 | #define PCA9685_BASE(led) ((led * 4) + 6) |
Bas | 0:62c7c3514d8f | 120 | #define PCA9685_BASE_RGBA(led) (led * 16 + 6) |
Bas | 0:62c7c3514d8f | 121 | #define PCA9685_LED_ON_L 0x00 |
Bas | 0:62c7c3514d8f | 122 | #define PCA9685_LED_ON_H 0x01 |
Bas | 0:62c7c3514d8f | 123 | #define PCA9685_LED_OFF_L 0x02 |
Bas | 0:62c7c3514d8f | 124 | #define PCA9685_LED_OFF_H 0x03 |
Bas | 0:62c7c3514d8f | 125 | #define PCA9685_ALL_LEDS -1 |
Bas | 0:62c7c3514d8f | 126 | |
Bas | 0:62c7c3514d8f | 127 | |
Bas | 0:62c7c3514d8f | 128 | #endif |