A feature complete driver for the PCA9952/55 LED driver from NXP.
Dependents: PCA9955_HelloWorld
PCA9955.h@3:84571acc16a1, 2013-11-08 (annotated)
- Committer:
- neilt6
- Date:
- Fri Nov 08 16:19:36 2013 +0000
- Revision:
- 3:84571acc16a1
- Parent:
- 2:9d866639b32b
- Child:
- 4:6ca7ab31c5fb
Added the default LED All Call address, and 16-channel subaddress to the Address enum
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
neilt6 | 0:7b3cbb5a53b8 | 1 | /* PCA9952/55 Driver Library |
neilt6 | 0:7b3cbb5a53b8 | 2 | * Copyright (c) 2013 Neil Thiessen |
neilt6 | 0:7b3cbb5a53b8 | 3 | * |
neilt6 | 0:7b3cbb5a53b8 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
neilt6 | 0:7b3cbb5a53b8 | 5 | * you may not use this file except in compliance with the License. |
neilt6 | 0:7b3cbb5a53b8 | 6 | * You may obtain a copy of the License at |
neilt6 | 0:7b3cbb5a53b8 | 7 | * |
neilt6 | 0:7b3cbb5a53b8 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
neilt6 | 0:7b3cbb5a53b8 | 9 | * |
neilt6 | 0:7b3cbb5a53b8 | 10 | * Unless required by applicable law or agreed to in writing, software |
neilt6 | 0:7b3cbb5a53b8 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
neilt6 | 0:7b3cbb5a53b8 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
neilt6 | 0:7b3cbb5a53b8 | 13 | * See the License for the specific language governing permissions and |
neilt6 | 0:7b3cbb5a53b8 | 14 | * limitations under the License. |
neilt6 | 0:7b3cbb5a53b8 | 15 | */ |
neilt6 | 0:7b3cbb5a53b8 | 16 | |
neilt6 | 0:7b3cbb5a53b8 | 17 | #ifndef PCA9955_H |
neilt6 | 0:7b3cbb5a53b8 | 18 | #define PCA9955_H |
neilt6 | 0:7b3cbb5a53b8 | 19 | |
neilt6 | 0:7b3cbb5a53b8 | 20 | #include "mbed.h" |
neilt6 | 0:7b3cbb5a53b8 | 21 | |
neilt6 | 0:7b3cbb5a53b8 | 22 | /** PCA9952/55 class. |
neilt6 | 0:7b3cbb5a53b8 | 23 | * Used for controlling a PCA9952/55 constant current LED driver connected via I2C. |
neilt6 | 0:7b3cbb5a53b8 | 24 | * |
neilt6 | 0:7b3cbb5a53b8 | 25 | * Example: |
neilt6 | 0:7b3cbb5a53b8 | 26 | * @code |
neilt6 | 0:7b3cbb5a53b8 | 27 | * #include "mbed.h" |
neilt6 | 0:7b3cbb5a53b8 | 28 | * #include "PCA9955.h" |
neilt6 | 0:7b3cbb5a53b8 | 29 | * |
neilt6 | 0:7b3cbb5a53b8 | 30 | * //Create an PCA9955 object at the default address (ADDRESS_0) |
neilt6 | 0:7b3cbb5a53b8 | 31 | * PCA9955 driver(p28, p27); |
neilt6 | 0:7b3cbb5a53b8 | 32 | * |
neilt6 | 0:7b3cbb5a53b8 | 33 | * int main() |
neilt6 | 0:7b3cbb5a53b8 | 34 | * { |
neilt6 | 0:7b3cbb5a53b8 | 35 | * //Try to open the PCA9955 |
neilt6 | 0:7b3cbb5a53b8 | 36 | * if (driver.open()) { |
neilt6 | 0:7b3cbb5a53b8 | 37 | * printf("Device detected!\n"); |
neilt6 | 0:7b3cbb5a53b8 | 38 | * |
neilt6 | 0:7b3cbb5a53b8 | 39 | * //Reset the device |
neilt6 | 0:7b3cbb5a53b8 | 40 | * //NOTE: This might reset other I2C devices as well! |
neilt6 | 0:7b3cbb5a53b8 | 41 | * driver.reset(); |
neilt6 | 0:7b3cbb5a53b8 | 42 | * |
neilt6 | 0:7b3cbb5a53b8 | 43 | * //Set all the output states to PWM mode |
neilt6 | 0:7b3cbb5a53b8 | 44 | * driver.allOutputStates(PCA9955::OUTPUT_PWM); |
neilt6 | 0:7b3cbb5a53b8 | 45 | * |
neilt6 | 0:7b3cbb5a53b8 | 46 | * //Set the all of the output currents to maximum |
neilt6 | 0:7b3cbb5a53b8 | 47 | * driver.allOutputCurrents(1.0); |
neilt6 | 0:7b3cbb5a53b8 | 48 | * |
neilt6 | 0:7b3cbb5a53b8 | 49 | * while (1) { |
neilt6 | 0:7b3cbb5a53b8 | 50 | * //Generate a breathing effect on all of the outputs |
neilt6 | 0:7b3cbb5a53b8 | 51 | * for (float i = 0.0f; i < 360.0f; i += 0.1f) { |
neilt6 | 2:9d866639b32b | 52 | * driver = 0.5 * (sinf(i * 3.14159265f / 180.0f) + 1); |
neilt6 | 0:7b3cbb5a53b8 | 53 | * } |
neilt6 | 0:7b3cbb5a53b8 | 54 | * } |
neilt6 | 0:7b3cbb5a53b8 | 55 | * } else { |
neilt6 | 0:7b3cbb5a53b8 | 56 | * error("Device not detected!\n"); |
neilt6 | 0:7b3cbb5a53b8 | 57 | * } |
neilt6 | 0:7b3cbb5a53b8 | 58 | * } |
neilt6 | 0:7b3cbb5a53b8 | 59 | * @endcode |
neilt6 | 0:7b3cbb5a53b8 | 60 | */ |
neilt6 | 0:7b3cbb5a53b8 | 61 | class PCA9955 |
neilt6 | 0:7b3cbb5a53b8 | 62 | { |
neilt6 | 0:7b3cbb5a53b8 | 63 | public: |
neilt6 | 0:7b3cbb5a53b8 | 64 | /** Represents the different I2C address possibilities for the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 65 | */ |
neilt6 | 0:7b3cbb5a53b8 | 66 | enum Address { |
neilt6 | 0:7b3cbb5a53b8 | 67 | ADDRESS_0 = (0x60 << 1), /**< A[3:0] pins = 0000 */ |
neilt6 | 0:7b3cbb5a53b8 | 68 | ADDRESS_1 = (0x61 << 1), /**< A[3:0] pins = 0001 */ |
neilt6 | 0:7b3cbb5a53b8 | 69 | ADDRESS_2 = (0x62 << 1), /**< A[3:0] pins = 0010 */ |
neilt6 | 0:7b3cbb5a53b8 | 70 | ADDRESS_3 = (0x63 << 1), /**< A[3:0] pins = 0011 */ |
neilt6 | 0:7b3cbb5a53b8 | 71 | ADDRESS_4 = (0x64 << 1), /**< A[3:0] pins = 0100 */ |
neilt6 | 0:7b3cbb5a53b8 | 72 | ADDRESS_5 = (0x65 << 1), /**< A[3:0] pins = 0101 */ |
neilt6 | 0:7b3cbb5a53b8 | 73 | ADDRESS_6 = (0x66 << 1), /**< A[3:0] pins = 0110 */ |
neilt6 | 0:7b3cbb5a53b8 | 74 | ADDRESS_7 = (0x67 << 1), /**< A[3:0] pins = 0111 */ |
neilt6 | 0:7b3cbb5a53b8 | 75 | ADDRESS_8 = (0x68 << 1), /**< A[3:0] pins = 1000 (not available on PCA9952) */ |
neilt6 | 0:7b3cbb5a53b8 | 76 | ADDRESS_9 = (0x69 << 1), /**< A[3:0] pins = 1001 (not available on PCA9952) */ |
neilt6 | 0:7b3cbb5a53b8 | 77 | ADDRESS_10 = (0x6A << 1), /**< A[3:0] pins = 1010 (not available on PCA9952) */ |
neilt6 | 0:7b3cbb5a53b8 | 78 | ADDRESS_11 = (0x6B << 1), /**< A[3:0] pins = 1011 (not available on PCA9952) */ |
neilt6 | 0:7b3cbb5a53b8 | 79 | ADDRESS_12 = (0x6C << 1), /**< A[3:0] pins = 1100 (not available on PCA9952) */ |
neilt6 | 0:7b3cbb5a53b8 | 80 | ADDRESS_13 = (0x6D << 1), /**< A[3:0] pins = 1101 (not available on PCA9952) */ |
neilt6 | 0:7b3cbb5a53b8 | 81 | ADDRESS_14 = (0x6E << 1), /**< A[3:0] pins = 1110 (not available on PCA9952) */ |
neilt6 | 3:84571acc16a1 | 82 | ADDRESS_15 = (0x6F << 1), /**< A[3:0] pins = 1111 (not available on PCA9952) */ |
neilt6 | 3:84571acc16a1 | 83 | ADDRESS_ALL = (0x70 << 1), /**< The default LED All Call address */ |
neilt6 | 3:84571acc16a1 | 84 | ADDRESS_SUB = (0x76 << 1) /**< The default subaddress for 16-channel LED drivers */ |
neilt6 | 0:7b3cbb5a53b8 | 85 | }; |
neilt6 | 0:7b3cbb5a53b8 | 86 | |
neilt6 | 0:7b3cbb5a53b8 | 87 | /** Represents the different outputs of the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 88 | */ |
neilt6 | 0:7b3cbb5a53b8 | 89 | enum Output { |
neilt6 | 0:7b3cbb5a53b8 | 90 | OUTPUT_0 = 0, /**< LED output 0 */ |
neilt6 | 0:7b3cbb5a53b8 | 91 | OUTPUT_1 = 1, /**< LED output 1 */ |
neilt6 | 0:7b3cbb5a53b8 | 92 | OUTPUT_2 = 2, /**< LED output 2 */ |
neilt6 | 0:7b3cbb5a53b8 | 93 | OUTPUT_3 = 3, /**< LED output 3 */ |
neilt6 | 0:7b3cbb5a53b8 | 94 | OUTPUT_4 = 4, /**< LED output 4 */ |
neilt6 | 0:7b3cbb5a53b8 | 95 | OUTPUT_5 = 5, /**< LED output 5 */ |
neilt6 | 0:7b3cbb5a53b8 | 96 | OUTPUT_6 = 6, /**< LED output 6 */ |
neilt6 | 0:7b3cbb5a53b8 | 97 | OUTPUT_7 = 7, /**< LED output 7 */ |
neilt6 | 0:7b3cbb5a53b8 | 98 | OUTPUT_8 = 8, /**< LED output 8 */ |
neilt6 | 0:7b3cbb5a53b8 | 99 | OUTPUT_9 = 9, /**< LED output 9 */ |
neilt6 | 0:7b3cbb5a53b8 | 100 | OUTPUT_10 = 10, /**< LED output 10 */ |
neilt6 | 0:7b3cbb5a53b8 | 101 | OUTPUT_11 = 11, /**< LED output 11 */ |
neilt6 | 0:7b3cbb5a53b8 | 102 | OUTPUT_12 = 12, /**< LED output 12 */ |
neilt6 | 0:7b3cbb5a53b8 | 103 | OUTPUT_13 = 13, /**< LED output 13 */ |
neilt6 | 0:7b3cbb5a53b8 | 104 | OUTPUT_14 = 14, /**< LED output 14 */ |
neilt6 | 0:7b3cbb5a53b8 | 105 | OUTPUT_15 = 15 /**< LED output 15 */ |
neilt6 | 0:7b3cbb5a53b8 | 106 | }; |
neilt6 | 0:7b3cbb5a53b8 | 107 | |
neilt6 | 0:7b3cbb5a53b8 | 108 | /** Represents the power mode of the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 109 | */ |
neilt6 | 0:7b3cbb5a53b8 | 110 | enum PowerMode { |
neilt6 | 0:7b3cbb5a53b8 | 111 | POWER_NORMAL, /**< Oscillator is enabled */ |
neilt6 | 0:7b3cbb5a53b8 | 112 | POWER_SHUTDOWN /**< Oscillator is disabled */ |
neilt6 | 0:7b3cbb5a53b8 | 113 | }; |
neilt6 | 0:7b3cbb5a53b8 | 114 | |
neilt6 | 0:7b3cbb5a53b8 | 115 | /** Represents the output change mode of the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 116 | */ |
neilt6 | 0:7b3cbb5a53b8 | 117 | enum OutputChangeMode { |
neilt6 | 0:7b3cbb5a53b8 | 118 | OUTPUT_CHANGE_ON_STOP, /**< Outputs change on STOP command */ |
neilt6 | 0:7b3cbb5a53b8 | 119 | OUTPUT_CHANGE_ON_ACK /**< Outputs change on ACK */ |
neilt6 | 0:7b3cbb5a53b8 | 120 | }; |
neilt6 | 0:7b3cbb5a53b8 | 121 | |
neilt6 | 0:7b3cbb5a53b8 | 122 | /** Represents the group control mode of the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 123 | */ |
neilt6 | 0:7b3cbb5a53b8 | 124 | enum GroupMode { |
neilt6 | 0:7b3cbb5a53b8 | 125 | GROUP_DIMMING, /**< Group control = dimming */ |
neilt6 | 0:7b3cbb5a53b8 | 126 | GROUP_BLINKING /**< group control = blinking */ |
neilt6 | 0:7b3cbb5a53b8 | 127 | }; |
neilt6 | 0:7b3cbb5a53b8 | 128 | |
neilt6 | 0:7b3cbb5a53b8 | 129 | /** Represents the individual driver output states of the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 130 | */ |
neilt6 | 0:7b3cbb5a53b8 | 131 | enum OutputState { |
neilt6 | 0:7b3cbb5a53b8 | 132 | OUTPUT_OFF, /**< LED driver x is off (default power-up state) */ |
neilt6 | 0:7b3cbb5a53b8 | 133 | OUTPUT_ON, /**< LED driver x is fully on (individual brightness and group dimming/blinking not controlled) */ |
neilt6 | 0:7b3cbb5a53b8 | 134 | OUTPUT_PWM, /**< LED driver x individual brightness can be controlled through its PWMx register */ |
neilt6 | 0:7b3cbb5a53b8 | 135 | OUTPUT_PWM_GRPPWM /**< LED driver x individual brightness and group dimming/blinking can be controlled through its PWMx register and the GRPPWM registers */ |
neilt6 | 0:7b3cbb5a53b8 | 136 | }; |
neilt6 | 0:7b3cbb5a53b8 | 137 | |
neilt6 | 0:7b3cbb5a53b8 | 138 | /** Represents the fault test flags for the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 139 | */ |
neilt6 | 0:7b3cbb5a53b8 | 140 | enum FaultFlags { |
neilt6 | 0:7b3cbb5a53b8 | 141 | FAULT_OUTPUT_0 = (1 << 0), /**< LED output 0 is either open or shorted */ |
neilt6 | 0:7b3cbb5a53b8 | 142 | FAULT_OUTPUT_1 = (1 << 1), /**< LED output 1 is either open or shorted */ |
neilt6 | 0:7b3cbb5a53b8 | 143 | FAULT_OUTPUT_2 = (1 << 2), /**< LED output 2 is either open or shorted */ |
neilt6 | 0:7b3cbb5a53b8 | 144 | FAULT_OUTPUT_3 = (1 << 3), /**< LED output 3 is either open or shorted */ |
neilt6 | 0:7b3cbb5a53b8 | 145 | FAULT_OUTPUT_4 = (1 << 4), /**< LED output 4 is either open or shorted */ |
neilt6 | 0:7b3cbb5a53b8 | 146 | FAULT_OUTPUT_5 = (1 << 5), /**< LED output 5 is either open or shorted */ |
neilt6 | 0:7b3cbb5a53b8 | 147 | FAULT_OUTPUT_6 = (1 << 6), /**< LED output 6 is either open or shorted */ |
neilt6 | 0:7b3cbb5a53b8 | 148 | FAULT_OUTPUT_7 = (1 << 7), /**< LED output 7 is either open or shorted */ |
neilt6 | 0:7b3cbb5a53b8 | 149 | FAULT_OUTPUT_8 = (1 << 8), /**< LED output 8 is either open or shorted */ |
neilt6 | 0:7b3cbb5a53b8 | 150 | FAULT_OUTPUT_9 = (1 << 9), /**< LED output 9 is either open or shorted */ |
neilt6 | 0:7b3cbb5a53b8 | 151 | FAULT_OUTPUT_10 = (1 << 10), /**< LED output 10 is either open or shorted */ |
neilt6 | 0:7b3cbb5a53b8 | 152 | FAULT_OUTPUT_11 = (1 << 11), /**< LED output 11 is either open or shorted */ |
neilt6 | 0:7b3cbb5a53b8 | 153 | FAULT_OUTPUT_12 = (1 << 12), /**< LED output 12 is either open or shorted */ |
neilt6 | 0:7b3cbb5a53b8 | 154 | FAULT_OUTPUT_13 = (1 << 13), /**< LED output 13 is either open or shorted */ |
neilt6 | 0:7b3cbb5a53b8 | 155 | FAULT_OUTPUT_14 = (1 << 14), /**< LED output 14 is either open or shorted */ |
neilt6 | 0:7b3cbb5a53b8 | 156 | FAULT_OUTPUT_15 = (1 << 15) /**< LED output 15 is either open or shorted */ |
neilt6 | 0:7b3cbb5a53b8 | 157 | }; |
neilt6 | 0:7b3cbb5a53b8 | 158 | |
neilt6 | 0:7b3cbb5a53b8 | 159 | /** Create a PCA9952/55 object connected to the specified I2C pins with the specified I2C slave address |
neilt6 | 0:7b3cbb5a53b8 | 160 | * |
neilt6 | 0:7b3cbb5a53b8 | 161 | * @param sda The I2C data pin. |
neilt6 | 0:7b3cbb5a53b8 | 162 | * @param scl The I2C clock pin. |
neilt6 | 0:7b3cbb5a53b8 | 163 | * @param addr The I2C slave address (defaults to ADDRESS_0). |
neilt6 | 0:7b3cbb5a53b8 | 164 | */ |
neilt6 | 0:7b3cbb5a53b8 | 165 | PCA9955(PinName sda, PinName scl, Address addr = ADDRESS_0); |
neilt6 | 0:7b3cbb5a53b8 | 166 | |
neilt6 | 1:016f916c5579 | 167 | /** Probe for the PCA9952/55 and configure Auto-Increment if present |
neilt6 | 0:7b3cbb5a53b8 | 168 | * |
neilt6 | 0:7b3cbb5a53b8 | 169 | * @returns |
neilt6 | 0:7b3cbb5a53b8 | 170 | * 'true' if the device exists on the bus, |
neilt6 | 0:7b3cbb5a53b8 | 171 | * 'false' if the device doesn't exist on the bus. |
neilt6 | 0:7b3cbb5a53b8 | 172 | */ |
neilt6 | 1:016f916c5579 | 173 | bool open(); |
neilt6 | 0:7b3cbb5a53b8 | 174 | |
neilt6 | 0:7b3cbb5a53b8 | 175 | /** Issue an SWRST call to reset the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 176 | * @warning This might reset other I2C devices as well! |
neilt6 | 0:7b3cbb5a53b8 | 177 | */ |
neilt6 | 1:016f916c5579 | 178 | void reset(); |
neilt6 | 0:7b3cbb5a53b8 | 179 | |
neilt6 | 0:7b3cbb5a53b8 | 180 | /** Determine whether the LED All Call address is enabled on the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 181 | * |
neilt6 | 0:7b3cbb5a53b8 | 182 | * @returns Whether or not the LED All Call address is enabled. |
neilt6 | 0:7b3cbb5a53b8 | 183 | */ |
neilt6 | 1:016f916c5579 | 184 | bool allCallEnabled(); |
neilt6 | 0:7b3cbb5a53b8 | 185 | |
neilt6 | 0:7b3cbb5a53b8 | 186 | /** Set whether the LED All Call address is enabled on the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 187 | * |
neilt6 | 0:7b3cbb5a53b8 | 188 | * @param enabled Whether or not the LED All Call address is enabled. |
neilt6 | 0:7b3cbb5a53b8 | 189 | */ |
neilt6 | 0:7b3cbb5a53b8 | 190 | void allCallEnabled(bool enabled); |
neilt6 | 0:7b3cbb5a53b8 | 191 | |
neilt6 | 0:7b3cbb5a53b8 | 192 | /** Determine whether subaddress 3 is enabled on the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 193 | * |
neilt6 | 0:7b3cbb5a53b8 | 194 | * @returns Whether or not subaddress 3 is enabled. |
neilt6 | 0:7b3cbb5a53b8 | 195 | */ |
neilt6 | 1:016f916c5579 | 196 | bool subCall3Enabled(); |
neilt6 | 0:7b3cbb5a53b8 | 197 | |
neilt6 | 0:7b3cbb5a53b8 | 198 | /** Set whether subaddress 3 is enabled on the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 199 | * |
neilt6 | 0:7b3cbb5a53b8 | 200 | * @param enabled Whether or not subaddress 3 is enabled. |
neilt6 | 0:7b3cbb5a53b8 | 201 | */ |
neilt6 | 0:7b3cbb5a53b8 | 202 | void subCall3Enabled(bool enabled); |
neilt6 | 0:7b3cbb5a53b8 | 203 | |
neilt6 | 0:7b3cbb5a53b8 | 204 | /** Determine whether subaddress 2 is enabled on the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 205 | * |
neilt6 | 0:7b3cbb5a53b8 | 206 | * @returns Whether or not subaddress 2 is enabled. |
neilt6 | 0:7b3cbb5a53b8 | 207 | */ |
neilt6 | 1:016f916c5579 | 208 | bool subCall2Enabled(); |
neilt6 | 0:7b3cbb5a53b8 | 209 | |
neilt6 | 0:7b3cbb5a53b8 | 210 | /** Set whether subaddress 2 is enabled on the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 211 | * |
neilt6 | 0:7b3cbb5a53b8 | 212 | * @param enabled Whether or not subaddress 2 is enabled. |
neilt6 | 0:7b3cbb5a53b8 | 213 | */ |
neilt6 | 0:7b3cbb5a53b8 | 214 | void subCall2Enabled(bool enabled); |
neilt6 | 0:7b3cbb5a53b8 | 215 | |
neilt6 | 0:7b3cbb5a53b8 | 216 | /** Determine whether subaddress 1 is enabled on the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 217 | * |
neilt6 | 0:7b3cbb5a53b8 | 218 | * @returns Whether or not subaddress 1 is enabled. |
neilt6 | 0:7b3cbb5a53b8 | 219 | */ |
neilt6 | 1:016f916c5579 | 220 | bool subCall1Enabled(); |
neilt6 | 0:7b3cbb5a53b8 | 221 | |
neilt6 | 0:7b3cbb5a53b8 | 222 | /** Set whether subaddress 1 is enabled on the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 223 | * |
neilt6 | 0:7b3cbb5a53b8 | 224 | * @param enabled Whether or not subaddress 1 is enabled. |
neilt6 | 0:7b3cbb5a53b8 | 225 | */ |
neilt6 | 0:7b3cbb5a53b8 | 226 | void subCall1Enabled(bool enabled); |
neilt6 | 0:7b3cbb5a53b8 | 227 | |
neilt6 | 0:7b3cbb5a53b8 | 228 | /** Get the current power mode of the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 229 | * |
neilt6 | 0:7b3cbb5a53b8 | 230 | * @returns The current power mode as a PowerMode enum. |
neilt6 | 0:7b3cbb5a53b8 | 231 | */ |
neilt6 | 1:016f916c5579 | 232 | PCA9955::PowerMode powerMode(); |
neilt6 | 0:7b3cbb5a53b8 | 233 | |
neilt6 | 0:7b3cbb5a53b8 | 234 | /** Set the power mode of the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 235 | * |
neilt6 | 0:7b3cbb5a53b8 | 236 | * @param mode The new power mode as a PowerMode enum. |
neilt6 | 0:7b3cbb5a53b8 | 237 | */ |
neilt6 | 0:7b3cbb5a53b8 | 238 | void powerMode(PowerMode mode); |
neilt6 | 0:7b3cbb5a53b8 | 239 | |
neilt6 | 0:7b3cbb5a53b8 | 240 | /** Get the current output change mode of the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 241 | * |
neilt6 | 0:7b3cbb5a53b8 | 242 | * @returns The current output change mode as an OutputChangeMode enum. |
neilt6 | 0:7b3cbb5a53b8 | 243 | */ |
neilt6 | 1:016f916c5579 | 244 | PCA9955::OutputChangeMode outputChangeMode(); |
neilt6 | 0:7b3cbb5a53b8 | 245 | |
neilt6 | 0:7b3cbb5a53b8 | 246 | /** Set the output change mode of the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 247 | * |
neilt6 | 0:7b3cbb5a53b8 | 248 | * @param mode The new output change mode as an OutputChangeMode enum. |
neilt6 | 0:7b3cbb5a53b8 | 249 | */ |
neilt6 | 0:7b3cbb5a53b8 | 250 | void outputChangeMode(OutputChangeMode mode); |
neilt6 | 0:7b3cbb5a53b8 | 251 | |
neilt6 | 0:7b3cbb5a53b8 | 252 | /** Get the current group control mode of the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 253 | * |
neilt6 | 0:7b3cbb5a53b8 | 254 | * @returns The current group control mode as a GroupMode enum. |
neilt6 | 0:7b3cbb5a53b8 | 255 | */ |
neilt6 | 1:016f916c5579 | 256 | PCA9955::GroupMode groupMode(); |
neilt6 | 0:7b3cbb5a53b8 | 257 | |
neilt6 | 0:7b3cbb5a53b8 | 258 | /** Set the group control mode of the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 259 | * |
neilt6 | 0:7b3cbb5a53b8 | 260 | * @param mode The new group control mode as a GroupMode enum. |
neilt6 | 0:7b3cbb5a53b8 | 261 | */ |
neilt6 | 0:7b3cbb5a53b8 | 262 | void groupMode(GroupMode mode); |
neilt6 | 0:7b3cbb5a53b8 | 263 | |
neilt6 | 0:7b3cbb5a53b8 | 264 | /** Determine whether or not the PCA9952/55 is overheating |
neilt6 | 0:7b3cbb5a53b8 | 265 | * |
neilt6 | 0:7b3cbb5a53b8 | 266 | * @returns |
neilt6 | 0:7b3cbb5a53b8 | 267 | * 'true' if the device is currently disabled due to overheating, |
neilt6 | 0:7b3cbb5a53b8 | 268 | * 'false' if the device is functioning normally. |
neilt6 | 0:7b3cbb5a53b8 | 269 | */ |
neilt6 | 1:016f916c5579 | 270 | bool overTemp(); |
neilt6 | 0:7b3cbb5a53b8 | 271 | |
neilt6 | 0:7b3cbb5a53b8 | 272 | /** Get the specified output's state |
neilt6 | 0:7b3cbb5a53b8 | 273 | * |
neilt6 | 0:7b3cbb5a53b8 | 274 | * @param output The output to check. |
neilt6 | 0:7b3cbb5a53b8 | 275 | * |
neilt6 | 0:7b3cbb5a53b8 | 276 | * @returns The output's current state as an OutputState enum. |
neilt6 | 0:7b3cbb5a53b8 | 277 | */ |
neilt6 | 0:7b3cbb5a53b8 | 278 | PCA9955::OutputState outputState(Output output); |
neilt6 | 0:7b3cbb5a53b8 | 279 | |
neilt6 | 0:7b3cbb5a53b8 | 280 | /** Set the specified output's state |
neilt6 | 0:7b3cbb5a53b8 | 281 | * |
neilt6 | 0:7b3cbb5a53b8 | 282 | * @param output The output to change. |
neilt6 | 0:7b3cbb5a53b8 | 283 | * @param state The new output state as an OutputState enum. |
neilt6 | 0:7b3cbb5a53b8 | 284 | */ |
neilt6 | 0:7b3cbb5a53b8 | 285 | void outputState(Output output, OutputState state); |
neilt6 | 0:7b3cbb5a53b8 | 286 | |
neilt6 | 0:7b3cbb5a53b8 | 287 | /** Get the current group control duty cycle of the PCA9952/55 in percent |
neilt6 | 0:7b3cbb5a53b8 | 288 | * |
neilt6 | 0:7b3cbb5a53b8 | 289 | * @returns The current group control duty cycle as a float (0.0 to 1.0). |
neilt6 | 0:7b3cbb5a53b8 | 290 | */ |
neilt6 | 1:016f916c5579 | 291 | float groupDuty(); |
neilt6 | 0:7b3cbb5a53b8 | 292 | |
neilt6 | 0:7b3cbb5a53b8 | 293 | /** Set the group control duty cycle of the PCA9952/55 in percent |
neilt6 | 0:7b3cbb5a53b8 | 294 | * |
neilt6 | 0:7b3cbb5a53b8 | 295 | * @param duty The new group control duty cycle as a float (0.0 to 1.0). |
neilt6 | 0:7b3cbb5a53b8 | 296 | */ |
neilt6 | 0:7b3cbb5a53b8 | 297 | void groupDuty(float duty); |
neilt6 | 0:7b3cbb5a53b8 | 298 | |
neilt6 | 0:7b3cbb5a53b8 | 299 | /** Get the current group control duty cycle of the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 300 | * |
neilt6 | 0:7b3cbb5a53b8 | 301 | * @returns The current group control duty cycle as an unsigned char (0 to 255). |
neilt6 | 0:7b3cbb5a53b8 | 302 | */ |
neilt6 | 1:016f916c5579 | 303 | char groupDuty_char(); |
neilt6 | 0:7b3cbb5a53b8 | 304 | |
neilt6 | 0:7b3cbb5a53b8 | 305 | /** Set the group control duty cycle of the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 306 | * |
neilt6 | 0:7b3cbb5a53b8 | 307 | * @param duty The new group control duty cycle as an unsigned char (0 to 255). |
neilt6 | 0:7b3cbb5a53b8 | 308 | */ |
neilt6 | 0:7b3cbb5a53b8 | 309 | void groupDuty_char(char duty); |
neilt6 | 0:7b3cbb5a53b8 | 310 | |
neilt6 | 0:7b3cbb5a53b8 | 311 | /** Get the current group control blink period of the PCA9952/55 in seconds |
neilt6 | 0:7b3cbb5a53b8 | 312 | * |
neilt6 | 0:7b3cbb5a53b8 | 313 | * @returns The current group control blink period in seconds (0.067 to 16.8). |
neilt6 | 0:7b3cbb5a53b8 | 314 | */ |
neilt6 | 1:016f916c5579 | 315 | float groupBlinkPeriod(); |
neilt6 | 0:7b3cbb5a53b8 | 316 | |
neilt6 | 0:7b3cbb5a53b8 | 317 | /** Set the current group control blink period of the PCA9952/55 in seconds |
neilt6 | 0:7b3cbb5a53b8 | 318 | * |
neilt6 | 0:7b3cbb5a53b8 | 319 | * @param period The new group control blink period in seconds (0.067 to 16.8). |
neilt6 | 0:7b3cbb5a53b8 | 320 | */ |
neilt6 | 0:7b3cbb5a53b8 | 321 | void groupBlinkPeriod(float period); |
neilt6 | 0:7b3cbb5a53b8 | 322 | |
neilt6 | 0:7b3cbb5a53b8 | 323 | /** Get the current group control blink period of the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 324 | * |
neilt6 | 0:7b3cbb5a53b8 | 325 | * @returns The current group control blink period as an unsigned char (0 to 255). |
neilt6 | 0:7b3cbb5a53b8 | 326 | */ |
neilt6 | 1:016f916c5579 | 327 | char groupBlinkPeriod_char(); |
neilt6 | 0:7b3cbb5a53b8 | 328 | |
neilt6 | 0:7b3cbb5a53b8 | 329 | /** Set the current group control blink period of the PCA9952/55 |
neilt6 | 0:7b3cbb5a53b8 | 330 | * |
neilt6 | 0:7b3cbb5a53b8 | 331 | * @param period The new group control blink period as an unsigned char (0 to 255). |
neilt6 | 0:7b3cbb5a53b8 | 332 | */ |
neilt6 | 0:7b3cbb5a53b8 | 333 | void groupBlinkPeriod_char(char period); |
neilt6 | 0:7b3cbb5a53b8 | 334 | |
neilt6 | 0:7b3cbb5a53b8 | 335 | /** Get the specified output's duty cycle in percent |
neilt6 | 0:7b3cbb5a53b8 | 336 | * |
neilt6 | 0:7b3cbb5a53b8 | 337 | * @param output The output to check. |
neilt6 | 0:7b3cbb5a53b8 | 338 | * |
neilt6 | 0:7b3cbb5a53b8 | 339 | * @returns The output's current duty cycle as a float (0.0 to 1.0). |
neilt6 | 0:7b3cbb5a53b8 | 340 | */ |
neilt6 | 0:7b3cbb5a53b8 | 341 | float outputDuty(Output output); |
neilt6 | 0:7b3cbb5a53b8 | 342 | |
neilt6 | 0:7b3cbb5a53b8 | 343 | /** Set the specified output's duty cycle in percent |
neilt6 | 0:7b3cbb5a53b8 | 344 | * |
neilt6 | 0:7b3cbb5a53b8 | 345 | * @param output The output to change. |
neilt6 | 0:7b3cbb5a53b8 | 346 | * @param duty The new output duty cycle as a float (0.0 to 1.0). |
neilt6 | 0:7b3cbb5a53b8 | 347 | */ |
neilt6 | 0:7b3cbb5a53b8 | 348 | void outputDuty(Output output, float duty); |
neilt6 | 0:7b3cbb5a53b8 | 349 | |
neilt6 | 0:7b3cbb5a53b8 | 350 | /** Get the specified output's duty cycle |
neilt6 | 0:7b3cbb5a53b8 | 351 | * |
neilt6 | 0:7b3cbb5a53b8 | 352 | * @param output The output to check. |
neilt6 | 0:7b3cbb5a53b8 | 353 | * |
neilt6 | 0:7b3cbb5a53b8 | 354 | * @returns The output's current duty cycle as an unsigned char (0 to 255). |
neilt6 | 0:7b3cbb5a53b8 | 355 | */ |
neilt6 | 0:7b3cbb5a53b8 | 356 | char outputDuty_char(Output output); |
neilt6 | 0:7b3cbb5a53b8 | 357 | |
neilt6 | 0:7b3cbb5a53b8 | 358 | /** Set the specified output's duty cycle |
neilt6 | 0:7b3cbb5a53b8 | 359 | * |
neilt6 | 0:7b3cbb5a53b8 | 360 | * @param output The output to change. |
neilt6 | 0:7b3cbb5a53b8 | 361 | * @param duty The new output duty cycle as an unsigned char (0 to 255). |
neilt6 | 0:7b3cbb5a53b8 | 362 | */ |
neilt6 | 0:7b3cbb5a53b8 | 363 | void outputDuty_char(Output output, char duty); |
neilt6 | 0:7b3cbb5a53b8 | 364 | |
neilt6 | 0:7b3cbb5a53b8 | 365 | /** Get the specified output's current reference in percent |
neilt6 | 0:7b3cbb5a53b8 | 366 | * |
neilt6 | 0:7b3cbb5a53b8 | 367 | * @param output The output to check. |
neilt6 | 0:7b3cbb5a53b8 | 368 | * |
neilt6 | 0:7b3cbb5a53b8 | 369 | * @returns The output's current reference as a float (0.0 to 1.0). |
neilt6 | 0:7b3cbb5a53b8 | 370 | */ |
neilt6 | 0:7b3cbb5a53b8 | 371 | float outputCurrent(Output output); |
neilt6 | 0:7b3cbb5a53b8 | 372 | |
neilt6 | 0:7b3cbb5a53b8 | 373 | /** Set the specified output's current reference in percent |
neilt6 | 0:7b3cbb5a53b8 | 374 | * |
neilt6 | 0:7b3cbb5a53b8 | 375 | * @param output The output to change. |
neilt6 | 0:7b3cbb5a53b8 | 376 | * @param iref The new output current reference as a float (0.0 to 1.0). |
neilt6 | 0:7b3cbb5a53b8 | 377 | */ |
neilt6 | 0:7b3cbb5a53b8 | 378 | void outputCurrent(Output output, float iref); |
neilt6 | 0:7b3cbb5a53b8 | 379 | |
neilt6 | 0:7b3cbb5a53b8 | 380 | /** Get the specified output's current reference |
neilt6 | 0:7b3cbb5a53b8 | 381 | * |
neilt6 | 0:7b3cbb5a53b8 | 382 | * @param output The output to check. |
neilt6 | 0:7b3cbb5a53b8 | 383 | * |
neilt6 | 0:7b3cbb5a53b8 | 384 | * @returns The output's current reference as an unsigned char (0 to 255). |
neilt6 | 0:7b3cbb5a53b8 | 385 | */ |
neilt6 | 0:7b3cbb5a53b8 | 386 | char outputCurrent_char(Output output); |
neilt6 | 0:7b3cbb5a53b8 | 387 | |
neilt6 | 0:7b3cbb5a53b8 | 388 | /** Set the specified output's current reference |
neilt6 | 0:7b3cbb5a53b8 | 389 | * |
neilt6 | 0:7b3cbb5a53b8 | 390 | * @param output The output to change. |
neilt6 | 0:7b3cbb5a53b8 | 391 | * @param iref The new output current reference as an unsigned char (0 to 255). |
neilt6 | 0:7b3cbb5a53b8 | 392 | */ |
neilt6 | 0:7b3cbb5a53b8 | 393 | void outputCurrent_char(Output output, char iref); |
neilt6 | 0:7b3cbb5a53b8 | 394 | |
neilt6 | 0:7b3cbb5a53b8 | 395 | /** Get the turn-on delay between LEDn outputs |
neilt6 | 0:7b3cbb5a53b8 | 396 | * |
neilt6 | 0:7b3cbb5a53b8 | 397 | * @returns The turn-on delay between LEDn outputs in clocks (0 to 15 - 125ns per clock). |
neilt6 | 0:7b3cbb5a53b8 | 398 | */ |
neilt6 | 1:016f916c5579 | 399 | char outputDelay(); |
neilt6 | 0:7b3cbb5a53b8 | 400 | |
neilt6 | 0:7b3cbb5a53b8 | 401 | /** Set the specified output's current reference |
neilt6 | 0:7b3cbb5a53b8 | 402 | * |
neilt6 | 0:7b3cbb5a53b8 | 403 | * @param clocks The turn-on delay between LEDn outputs in clocks (0 to 15 - 125ns per clock). |
neilt6 | 0:7b3cbb5a53b8 | 404 | */ |
neilt6 | 0:7b3cbb5a53b8 | 405 | void outputDelay(char clocks); |
neilt6 | 0:7b3cbb5a53b8 | 406 | |
neilt6 | 0:7b3cbb5a53b8 | 407 | /** Get subaddress 1 |
neilt6 | 0:7b3cbb5a53b8 | 408 | * |
neilt6 | 0:7b3cbb5a53b8 | 409 | * @returns The current I2C subaddress 1. |
neilt6 | 0:7b3cbb5a53b8 | 410 | */ |
neilt6 | 1:016f916c5579 | 411 | char subCall1Addr(); |
neilt6 | 0:7b3cbb5a53b8 | 412 | |
neilt6 | 0:7b3cbb5a53b8 | 413 | /** Set subaddress 1 |
neilt6 | 0:7b3cbb5a53b8 | 414 | * |
neilt6 | 0:7b3cbb5a53b8 | 415 | * @param addr The new I2C subaddress 1. |
neilt6 | 0:7b3cbb5a53b8 | 416 | */ |
neilt6 | 0:7b3cbb5a53b8 | 417 | void subCall1Addr(char addr); |
neilt6 | 0:7b3cbb5a53b8 | 418 | |
neilt6 | 0:7b3cbb5a53b8 | 419 | /** Get subaddress 2 |
neilt6 | 0:7b3cbb5a53b8 | 420 | * |
neilt6 | 0:7b3cbb5a53b8 | 421 | * @returns The current I2C subaddress 2. |
neilt6 | 0:7b3cbb5a53b8 | 422 | */ |
neilt6 | 1:016f916c5579 | 423 | char subCall2Addr(); |
neilt6 | 0:7b3cbb5a53b8 | 424 | |
neilt6 | 0:7b3cbb5a53b8 | 425 | /** Set subaddress 2 |
neilt6 | 0:7b3cbb5a53b8 | 426 | * |
neilt6 | 0:7b3cbb5a53b8 | 427 | * @param addr The new I2C subaddress 2. |
neilt6 | 0:7b3cbb5a53b8 | 428 | */ |
neilt6 | 0:7b3cbb5a53b8 | 429 | void subCall2Addr(char addr); |
neilt6 | 0:7b3cbb5a53b8 | 430 | |
neilt6 | 0:7b3cbb5a53b8 | 431 | /** Get subaddress 3 |
neilt6 | 0:7b3cbb5a53b8 | 432 | * |
neilt6 | 0:7b3cbb5a53b8 | 433 | * @returns The current I2C subaddress 3. |
neilt6 | 0:7b3cbb5a53b8 | 434 | */ |
neilt6 | 1:016f916c5579 | 435 | char subCall3Addr(); |
neilt6 | 0:7b3cbb5a53b8 | 436 | |
neilt6 | 0:7b3cbb5a53b8 | 437 | /** Set subaddress 3 |
neilt6 | 0:7b3cbb5a53b8 | 438 | * |
neilt6 | 0:7b3cbb5a53b8 | 439 | * @param addr The new I2C subaddress 3. |
neilt6 | 0:7b3cbb5a53b8 | 440 | */ |
neilt6 | 0:7b3cbb5a53b8 | 441 | void subCall3Addr(char addr); |
neilt6 | 0:7b3cbb5a53b8 | 442 | |
neilt6 | 0:7b3cbb5a53b8 | 443 | /** Get the LED All Call address |
neilt6 | 0:7b3cbb5a53b8 | 444 | * |
neilt6 | 0:7b3cbb5a53b8 | 445 | * @returns The current LED All Call address. |
neilt6 | 0:7b3cbb5a53b8 | 446 | */ |
neilt6 | 1:016f916c5579 | 447 | char allCallAddr(); |
neilt6 | 0:7b3cbb5a53b8 | 448 | |
neilt6 | 0:7b3cbb5a53b8 | 449 | /** Set the LED All Call address |
neilt6 | 0:7b3cbb5a53b8 | 450 | * |
neilt6 | 0:7b3cbb5a53b8 | 451 | * @param addr The new LED All Call address. |
neilt6 | 0:7b3cbb5a53b8 | 452 | */ |
neilt6 | 0:7b3cbb5a53b8 | 453 | void allCallAddr(char addr); |
neilt6 | 0:7b3cbb5a53b8 | 454 | |
neilt6 | 1:016f916c5579 | 455 | /** Set all of the output states to the same state |
neilt6 | 0:7b3cbb5a53b8 | 456 | * |
neilt6 | 0:7b3cbb5a53b8 | 457 | * @param state The new output state for all outputs. |
neilt6 | 0:7b3cbb5a53b8 | 458 | */ |
neilt6 | 0:7b3cbb5a53b8 | 459 | void allOutputStates(OutputState state); |
neilt6 | 0:7b3cbb5a53b8 | 460 | |
neilt6 | 1:016f916c5579 | 461 | /** Read all of the output duty cycles into an array as percents |
neilt6 | 1:016f916c5579 | 462 | * |
neilt6 | 1:016f916c5579 | 463 | * @param duties Pointer to any array for 16 duty cycles as floats (0.0 to 1.0). |
neilt6 | 1:016f916c5579 | 464 | */ |
neilt6 | 1:016f916c5579 | 465 | void getOutputDuties(float* duties); |
neilt6 | 1:016f916c5579 | 466 | |
neilt6 | 1:016f916c5579 | 467 | /** Set all of the output duty cycles to the same value in percent |
neilt6 | 0:7b3cbb5a53b8 | 468 | * |
neilt6 | 0:7b3cbb5a53b8 | 469 | * @param duty The new duty cycle for all outputs as a float (0.0 to 1.0). |
neilt6 | 0:7b3cbb5a53b8 | 470 | */ |
neilt6 | 0:7b3cbb5a53b8 | 471 | void allOutputDuties(float duty); |
neilt6 | 0:7b3cbb5a53b8 | 472 | |
neilt6 | 1:016f916c5579 | 473 | /** Set all of the output duty cycles from an array of percents |
neilt6 | 1:016f916c5579 | 474 | * |
neilt6 | 1:016f916c5579 | 475 | * @param duties Pointer to any array of 16 duty cycles as floats (0.0 to 1.0). |
neilt6 | 1:016f916c5579 | 476 | */ |
neilt6 | 1:016f916c5579 | 477 | void allOutputDuties(float* duties); |
neilt6 | 1:016f916c5579 | 478 | |
neilt6 | 1:016f916c5579 | 479 | /** Read all of the output duty cycles into an array |
neilt6 | 1:016f916c5579 | 480 | * |
neilt6 | 1:016f916c5579 | 481 | * @param duties Pointer to any array for 16 duty cycles as unsigned chars (0 to 255). |
neilt6 | 1:016f916c5579 | 482 | */ |
neilt6 | 1:016f916c5579 | 483 | void getOutputDuties_char(char* duties); |
neilt6 | 1:016f916c5579 | 484 | |
neilt6 | 1:016f916c5579 | 485 | /** Set all of the output duty cycles to the same value |
neilt6 | 0:7b3cbb5a53b8 | 486 | * |
neilt6 | 0:7b3cbb5a53b8 | 487 | * @param duty The new duty cycle for all outputs as an unsigned char (0 to 255). |
neilt6 | 0:7b3cbb5a53b8 | 488 | */ |
neilt6 | 0:7b3cbb5a53b8 | 489 | void allOutputDuties_char(char duty); |
neilt6 | 0:7b3cbb5a53b8 | 490 | |
neilt6 | 1:016f916c5579 | 491 | /** Set all of the output duty cycles from an array |
neilt6 | 1:016f916c5579 | 492 | * |
neilt6 | 1:016f916c5579 | 493 | * @param duties Pointer to any array of 16 duty cycles as unsigned chars (0 to 255). |
neilt6 | 1:016f916c5579 | 494 | */ |
neilt6 | 1:016f916c5579 | 495 | void allOutputDuties_char(char* duties); |
neilt6 | 1:016f916c5579 | 496 | |
neilt6 | 1:016f916c5579 | 497 | /** Read all of the output current references into an array as percents |
neilt6 | 1:016f916c5579 | 498 | * |
neilt6 | 1:016f916c5579 | 499 | * @param irefs Pointer to any array for 16 current references as floats (0.0 to 1.0). |
neilt6 | 1:016f916c5579 | 500 | */ |
neilt6 | 1:016f916c5579 | 501 | void getOutputCurrents(float* irefs); |
neilt6 | 1:016f916c5579 | 502 | |
neilt6 | 1:016f916c5579 | 503 | /** Set all of the output current references to the same value in percent |
neilt6 | 0:7b3cbb5a53b8 | 504 | * |
neilt6 | 0:7b3cbb5a53b8 | 505 | * @param iref The new current reference for all outputs as a float (0.0 to 1.0). |
neilt6 | 0:7b3cbb5a53b8 | 506 | */ |
neilt6 | 0:7b3cbb5a53b8 | 507 | void allOutputCurrents(float iref); |
neilt6 | 0:7b3cbb5a53b8 | 508 | |
neilt6 | 1:016f916c5579 | 509 | /** Set all of the output current references from an array of percents |
neilt6 | 1:016f916c5579 | 510 | * |
neilt6 | 1:016f916c5579 | 511 | * @param irefs Pointer to any array of 16 current references as floats (0.0 to 1.0). |
neilt6 | 1:016f916c5579 | 512 | */ |
neilt6 | 1:016f916c5579 | 513 | void allOutputCurrents(float* irefs); |
neilt6 | 1:016f916c5579 | 514 | |
neilt6 | 1:016f916c5579 | 515 | /** Read all of the output current references into an array |
neilt6 | 1:016f916c5579 | 516 | * |
neilt6 | 1:016f916c5579 | 517 | * @param irefs Pointer to any array for 16 current references as unsigned chars (0 to 255). |
neilt6 | 1:016f916c5579 | 518 | */ |
neilt6 | 1:016f916c5579 | 519 | void getOutputCurrents_char(char* irefs); |
neilt6 | 1:016f916c5579 | 520 | |
neilt6 | 1:016f916c5579 | 521 | /** Set all of the output current references to the same value |
neilt6 | 0:7b3cbb5a53b8 | 522 | * |
neilt6 | 0:7b3cbb5a53b8 | 523 | * @param iref The new current reference for all outputs as an unsigned char (0 to 255). |
neilt6 | 0:7b3cbb5a53b8 | 524 | */ |
neilt6 | 0:7b3cbb5a53b8 | 525 | void allOutputCurrents_char(char iref); |
neilt6 | 0:7b3cbb5a53b8 | 526 | |
neilt6 | 1:016f916c5579 | 527 | /** Set all of the output current references from an array |
neilt6 | 1:016f916c5579 | 528 | * |
neilt6 | 1:016f916c5579 | 529 | * @param irefs Pointer to any array of 16 current references as unsigned chars (0 to 255). |
neilt6 | 1:016f916c5579 | 530 | */ |
neilt6 | 1:016f916c5579 | 531 | void allOutputCurrents_char(char* irefs); |
neilt6 | 1:016f916c5579 | 532 | |
neilt6 | 0:7b3cbb5a53b8 | 533 | /** Perform a fault test on all enabled outputs |
neilt6 | 0:7b3cbb5a53b8 | 534 | * |
neilt6 | 0:7b3cbb5a53b8 | 535 | * @returns The fault test flags as FaultFlags enum values OR'd together. |
neilt6 | 0:7b3cbb5a53b8 | 536 | */ |
neilt6 | 1:016f916c5579 | 537 | unsigned short faultTest(); |
neilt6 | 1:016f916c5579 | 538 | |
neilt6 | 1:016f916c5579 | 539 | #ifdef MBED_OPERATORS |
neilt6 | 1:016f916c5579 | 540 | /** A shorthand for allOutputDuties() |
neilt6 | 1:016f916c5579 | 541 | * |
neilt6 | 1:016f916c5579 | 542 | * @param value The new duty cycle for all outputs as a float (0.0 to 1.0). |
neilt6 | 1:016f916c5579 | 543 | */ |
neilt6 | 1:016f916c5579 | 544 | PCA9955& operator=(float value); |
neilt6 | 1:016f916c5579 | 545 | #endif |
neilt6 | 0:7b3cbb5a53b8 | 546 | |
neilt6 | 0:7b3cbb5a53b8 | 547 | private: |
neilt6 | 0:7b3cbb5a53b8 | 548 | //I2C register addresses |
neilt6 | 0:7b3cbb5a53b8 | 549 | enum Register { |
neilt6 | 0:7b3cbb5a53b8 | 550 | REG_MODE1 = 0x00, |
neilt6 | 0:7b3cbb5a53b8 | 551 | REG_MODE2 = 0x01, |
neilt6 | 0:7b3cbb5a53b8 | 552 | REG_LEDOUT0 = 0x02, |
neilt6 | 0:7b3cbb5a53b8 | 553 | REG_LEDOUT1 = 0x03, |
neilt6 | 0:7b3cbb5a53b8 | 554 | REG_LEDOUT2 = 0x04, |
neilt6 | 0:7b3cbb5a53b8 | 555 | REG_LEDOUT3 = 0x05, |
neilt6 | 0:7b3cbb5a53b8 | 556 | REG_GRPPWM = 0x08, |
neilt6 | 0:7b3cbb5a53b8 | 557 | REG_GRPFREQ = 0x09, |
neilt6 | 0:7b3cbb5a53b8 | 558 | REG_PWM0 = 0x0A, |
neilt6 | 0:7b3cbb5a53b8 | 559 | REG_PWM1 = 0x0B, |
neilt6 | 0:7b3cbb5a53b8 | 560 | REG_PWM2 = 0x0C, |
neilt6 | 0:7b3cbb5a53b8 | 561 | REG_PWM3 = 0x0D, |
neilt6 | 0:7b3cbb5a53b8 | 562 | REG_PWM4 = 0x0E, |
neilt6 | 0:7b3cbb5a53b8 | 563 | REG_PWM5 = 0x0F, |
neilt6 | 0:7b3cbb5a53b8 | 564 | REG_PWM6 = 0x10, |
neilt6 | 0:7b3cbb5a53b8 | 565 | REG_PWM7 = 0x11, |
neilt6 | 0:7b3cbb5a53b8 | 566 | REG_PWM8 = 0x12, |
neilt6 | 0:7b3cbb5a53b8 | 567 | REG_PWM9 = 0x13, |
neilt6 | 0:7b3cbb5a53b8 | 568 | REG_PWM10 = 0x14, |
neilt6 | 0:7b3cbb5a53b8 | 569 | REG_PWM11 = 0x15, |
neilt6 | 0:7b3cbb5a53b8 | 570 | REG_PWM12 = 0x16, |
neilt6 | 0:7b3cbb5a53b8 | 571 | REG_PWM13 = 0x17, |
neilt6 | 0:7b3cbb5a53b8 | 572 | REG_PWM14 = 0x18, |
neilt6 | 0:7b3cbb5a53b8 | 573 | REG_PWM15 = 0x19, |
neilt6 | 0:7b3cbb5a53b8 | 574 | REG_IREF0 = 0x22, |
neilt6 | 0:7b3cbb5a53b8 | 575 | REG_IREF1 = 0x23, |
neilt6 | 0:7b3cbb5a53b8 | 576 | REG_IREF2 = 0x24, |
neilt6 | 0:7b3cbb5a53b8 | 577 | REG_IREF3 = 0x25, |
neilt6 | 0:7b3cbb5a53b8 | 578 | REG_IREF4 = 0x26, |
neilt6 | 0:7b3cbb5a53b8 | 579 | REG_IREF5 = 0x27, |
neilt6 | 0:7b3cbb5a53b8 | 580 | REG_IREF6 = 0x28, |
neilt6 | 0:7b3cbb5a53b8 | 581 | REG_IREF7 = 0x29, |
neilt6 | 0:7b3cbb5a53b8 | 582 | REG_IREF8 = 0x2A, |
neilt6 | 0:7b3cbb5a53b8 | 583 | REG_IREF9 = 0x2B, |
neilt6 | 0:7b3cbb5a53b8 | 584 | REG_IREF10 = 0x2C, |
neilt6 | 0:7b3cbb5a53b8 | 585 | REG_IREF11 = 0x2D, |
neilt6 | 0:7b3cbb5a53b8 | 586 | REG_IREF12 = 0x2E, |
neilt6 | 0:7b3cbb5a53b8 | 587 | REG_IREF13 = 0x2F, |
neilt6 | 0:7b3cbb5a53b8 | 588 | REG_IREF14 = 0x30, |
neilt6 | 0:7b3cbb5a53b8 | 589 | REG_IREF15 = 0x31, |
neilt6 | 0:7b3cbb5a53b8 | 590 | REG_OFFSET = 0x3A, |
neilt6 | 0:7b3cbb5a53b8 | 591 | REG_SUBADR1 = 0x3B, |
neilt6 | 0:7b3cbb5a53b8 | 592 | REG_SUBADR2 = 0x3C, |
neilt6 | 0:7b3cbb5a53b8 | 593 | REG_SUBADR3 = 0x3D, |
neilt6 | 0:7b3cbb5a53b8 | 594 | REG_ALLCALLADR = 0x3E, |
neilt6 | 0:7b3cbb5a53b8 | 595 | REG_RESERVED1 = 0x3F, |
neilt6 | 0:7b3cbb5a53b8 | 596 | REG_RESERVED2 = 0x40, |
neilt6 | 0:7b3cbb5a53b8 | 597 | REG_RESERVED3 = 0x41, |
neilt6 | 0:7b3cbb5a53b8 | 598 | REG_PWMALL = 0x42, |
neilt6 | 0:7b3cbb5a53b8 | 599 | REG_IREFALL = 0x43, |
neilt6 | 0:7b3cbb5a53b8 | 600 | REG_EFLAG0 = 0x44, |
neilt6 | 0:7b3cbb5a53b8 | 601 | REG_EFLAG1 = 0x45, |
neilt6 | 0:7b3cbb5a53b8 | 602 | REG_AUTO_INC = 0x80 |
neilt6 | 0:7b3cbb5a53b8 | 603 | }; |
neilt6 | 0:7b3cbb5a53b8 | 604 | |
neilt6 | 0:7b3cbb5a53b8 | 605 | //Member variables |
neilt6 | 0:7b3cbb5a53b8 | 606 | I2C m_I2C; |
neilt6 | 1:016f916c5579 | 607 | const int m_ADDR; |
neilt6 | 0:7b3cbb5a53b8 | 608 | |
neilt6 | 0:7b3cbb5a53b8 | 609 | //Internal functions |
neilt6 | 0:7b3cbb5a53b8 | 610 | char read(char reg); |
neilt6 | 1:016f916c5579 | 611 | void write(char reg, char data); |
neilt6 | 0:7b3cbb5a53b8 | 612 | void readMulti(char startReg, char* data, int length); |
neilt6 | 0:7b3cbb5a53b8 | 613 | void writeMulti(char* data, int length); |
neilt6 | 0:7b3cbb5a53b8 | 614 | }; |
neilt6 | 0:7b3cbb5a53b8 | 615 | |
neilt6 | 0:7b3cbb5a53b8 | 616 | #endif |