Example code and library for the PCF9532 I2C LED driver on the Embedded Artists baseboard
Embed:
(wiki syntax)
Show/hide line numbers
PCA9532.h
00001 /* mbed PCF9532 LED Driver Library 00002 * 00003 * Copyright (c) 2010, cstyles (http://mbed.org) 00004 * 00005 * Permission is hereby granted, free of charge, to any person obtaining a copy 00006 * of this software and associated documentation files (the "Software"), to deal 00007 * in the Software without restriction, including without limitation the rights 00008 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00009 * copies of the Software, and to permit persons to whom the Software is 00010 * furnished to do so, subject to the following conditions: 00011 * 00012 * The above copyright notice and this permission notice shall be included in 00013 * all copies or substantial portions of the Software. 00014 * 00015 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00016 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00017 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00018 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00019 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00020 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00021 * THE SOFTWARE. 00022 */ 00023 00024 #ifndef PCA9532_H 00025 #define PCA9532_H 00026 00027 #include "mbed.h" 00028 00029 // register names 00030 #define PCA9532_REG_INPUT0 0 00031 #define PCA9532_REG_INPUT1 1 00032 #define PCA9532_REG_PSC0 2 00033 #define PCA9532_REG_PWM0 3 00034 #define PCA9532_REG_PSC1 4 00035 #define PCA9532_REG_PWM1 5 00036 #define PCA9532_REG_LS0 6 00037 #define PCA9532_REG_LS1 7 00038 #define PCA9532_REG_LS2 8 00039 #define PCA9532_REG_LS3 9 00040 00041 // LED modes 00042 #define MODE_OFF 0 00043 #define MODE_ON 1 00044 #define MODE_PWM0 2 00045 #define MODE_PWM1 3 00046 00047 class PCA9532 { 00048 00049 public: 00050 00051 PCA9532(PinName sda, PinName scl, int addr); 00052 00053 int SetLed (int led, int mode); 00054 int SetMode (int mask, int mode); 00055 int Duty (int channel, float duty); 00056 int Period (int channel, float period); 00057 00058 protected: 00059 00060 void _write(int reg, int data); 00061 int _read(int reg); 00062 int _addr; 00063 I2C _i2c; 00064 00065 }; 00066 00067 00068 #endif
Generated on Fri Aug 26 2022 16:47:10 by
1.7.2