Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mDotEVBM2X MTDOT-EVB-LinkCheck-AL MTDOT-EVBDemo-DRH MTDOT_BOX_EVB_Blinky ... more
NCP5623B.h
00001 /** 00002 * @file NCP5623B.h 00003 * @brief Device driver - NCP5623B Triple LED Driver IC w/RTOS support 00004 * @author Tim Barr 00005 * @version 1.0 00006 * @see http://www.onsemi.com/pub/Collateral/NCP5623B-D.PDF 00007 * 00008 * Copyright (c) 2015 00009 * 00010 * Licensed under the Apache License, Version 2.0 (the "License"); 00011 * you may not use this file except in compliance with the License. 00012 * You may obtain a copy of the License at 00013 * 00014 * http://www.apache.org/licenses/LICENSE-2.0 00015 * 00016 * Unless required by applicable law or agreed to in writing, software 00017 * distributed under the License is distributed on an "AS IS" BASIS, 00018 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00019 * See the License for the specific language governing permissions and 00020 * limitations under the License. 00021 * 00022 */ 00023 00024 #ifndef NCP5623B_H 00025 #define NCP5623B_H 00026 00027 #include "mbed.h" 00028 00029 /** Using the Multitech MTDOT-EVB 00030 * 00031 * Example: 00032 * @code 00033 * #include "mbed.h" 00034 * #include "NCP5623B.h" 00035 * 00036 00037 * 00038 * int main() 00039 * { 00040 00041 * } 00042 * @endcode 00043 */ 00044 00045 /** 00046 * @class NCP5623B 00047 * @brief API abstraction for the NCP5623B Triple LED Driver IC 00048 * initial version will be polling only. Interrupt service and rtos support will 00049 * be added at a later point 00050 */ 00051 class NCP5623B 00052 { 00053 public: 00054 00055 /** 00056 * @static DATAMASK 00057 * @brief Data mask 00058 */ 00059 uint8_t static const DATAMASK = 0x1F; 00060 00061 /** 00062 * @enum LEDNUM 00063 * @brief LED number for indexing 00064 */ 00065 enum LEDNUM 00066 { 00067 LED_1 = 0x00, /* LED 1 device pin 5 */ 00068 LED_2, /* LED 2 device pin 4 */ 00069 LED_3 /* LED 3 device pin 3 */ 00070 }; 00071 00072 /** 00073 * @enum DIMDIRECTIO 00074 * @brief Setting Dim direction for Dimming function 00075 */ 00076 enum DIMDIRECTION 00077 { 00078 DIMDWN = 0x00, /* Set dimmer direction to down */ 00079 DIMUP /* Set dimmer direction to up*/ 00080 }; 00081 00082 /** 00083 * @enum REGISTER 00084 * @brief The device register map using upper 3 bits 00085 */ 00086 enum REGISTER 00087 { 00088 SHUTDWN = 0x00, 00089 LEDCURR = 0x20, 00090 PWMLED1 = 0x40, 00091 PWMLED2 = 0x60, 00092 PWMLED3 = 0x80, 00093 DIMUPSET = 0xA0, 00094 DIMDWNSET = 0xC0, 00095 DIMTIME = 0xE0 00096 }; 00097 00098 /** Create the NCP5623B object 00099 * @param i2c - A defined I2C object 00100 */ 00101 NCP5623B(I2C &i2c); 00102 00103 /** Shutdown LEDS 00104 * @return status of command 00105 */ 00106 uint8_t shutdown(void) const; 00107 00108 /** Set static LED Current 00109 * @data - value of current draw for all LEDs range 0-31 00110 * @return status of command 00111 */ 00112 uint8_t setLEDCurrent(uint8_t data) const; 00113 00114 /** Set PWM mode for specific LED 00115 * @lednum - selects LED 00116 * @data - PWM value to set range 0-31 0-100% Pulse width 00117 * @return status of command 00118 */ 00119 uint8_t setPWM(LEDNUM lednum, int8_t data ) const; 00120 00121 /** Set Dimming mode for all LEDs 00122 * @dimdir - direction of dimming 00123 * @endstep - ending step of ramp up or ramp down range 0-31 00124 * @steptime - time per step range 0-31 in 8 msec multiples 00125 * @return status of command 00126 */ 00127 uint8_t setDimming(DIMDIRECTION dimdir, uint8_t endstep, uint8_t time) const; 00128 00129 private: 00130 I2C* _i2c; 00131 uint8_t static const _i2c_addr = (0x38 << 1); 00132 00133 uint8_t init(void); 00134 00135 /** Write to a register (exposed for debugging reasons) 00136 * @param reg - The register to be written 00137 * @param data - The data to be written 00138 */ 00139 uint8_t writeRegister(REGISTER const reg, uint8_t const data) const; 00140 }; 00141 00142 #endif
Generated on Tue Jul 19 2022 23:49:09 by
