This program is for writing to PCA9532 on the LPCXpresso Base Board.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers PCA9532.h Source File

PCA9532.h

00001 /* MIDI class for mbed Microcontroller
00002  * Copyright (c) 2008, cstyles -- Modified by Lerche for PCA9532
00003  */ 
00004 #include "mbed.h"
00005 #ifndef MBED_PCA9532_H
00006 #define MBED_PCA9532_H
00007 #define INPUT0 0x00
00008 #define INPUT1 0x01
00009 #define PSC0   0x02
00010 #define PWM0   0x03
00011 #define PSC1   0x04
00012 #define PWM1   0x05
00013 #define LS0    0x06
00014 #define LS1    0x07
00015 #define LS2    0x08
00016 #define LS3    0x09
00017 
00018 /* Class: PCA9532
00019  *  Abstraction for the LED dimmer on LPCXpresso Base Board
00020  */ 
00021  
00022 namespace mbed {
00023 class PCA9532 {
00024   public:
00025      /* Constructor: PCA9532
00026       *  Create an instance of the PCA9532 connected to specfied I2C pins, with the specified address.
00027       *
00028       * Variables:
00029       *  sda - The I2C data pin (p28)
00030       *  scl - The I2C clock pin (p27)
00031       *  addr - The address of this instance (0xC0) 
00032       */   
00033     PCA9532 (PinName sda, PinName scl, int addr);
00034      /* Function: read
00035       *  Read the IO pin level
00036       *
00037       * Variables:
00038       *  none
00039       */ 
00040     int read (void);
00041      /* Function: write
00042       *  Write the IO pin levels / Turn on LEDs
00043       *
00044       * Variables:
00045       *  data - An in, though only the bottom 8 bits are used
00046       *  command - Where to put the data. 
00047       */ 
00048     void write (int command, int data);
00049    
00050   private :   
00051     I2C _i2c;
00052     int _addr;
00053   };
00054 }
00055 #endif