Christian Lerche
/
PCA9532
This program is for writing to PCA9532 on the LPCXpresso Base Board.
PCA9532.h@0:8dffae878f54, 2010-02-06 (annotated)
- Committer:
- Lerche
- Date:
- Sat Feb 06 06:32:14 2010 +0000
- Revision:
- 0:8dffae878f54
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Lerche | 0:8dffae878f54 | 1 | /* MIDI class for mbed Microcontroller |
Lerche | 0:8dffae878f54 | 2 | * Copyright (c) 2008, cstyles -- Modified by Lerche for PCA9532 |
Lerche | 0:8dffae878f54 | 3 | */ |
Lerche | 0:8dffae878f54 | 4 | #include "mbed.h" |
Lerche | 0:8dffae878f54 | 5 | #ifndef MBED_PCA9532_H |
Lerche | 0:8dffae878f54 | 6 | #define MBED_PCA9532_H |
Lerche | 0:8dffae878f54 | 7 | #define INPUT0 0x00 |
Lerche | 0:8dffae878f54 | 8 | #define INPUT1 0x01 |
Lerche | 0:8dffae878f54 | 9 | #define PSC0 0x02 |
Lerche | 0:8dffae878f54 | 10 | #define PWM0 0x03 |
Lerche | 0:8dffae878f54 | 11 | #define PSC1 0x04 |
Lerche | 0:8dffae878f54 | 12 | #define PWM1 0x05 |
Lerche | 0:8dffae878f54 | 13 | #define LS0 0x06 |
Lerche | 0:8dffae878f54 | 14 | #define LS1 0x07 |
Lerche | 0:8dffae878f54 | 15 | #define LS2 0x08 |
Lerche | 0:8dffae878f54 | 16 | #define LS3 0x09 |
Lerche | 0:8dffae878f54 | 17 | |
Lerche | 0:8dffae878f54 | 18 | /* Class: PCA9532 |
Lerche | 0:8dffae878f54 | 19 | * Abstraction for the LED dimmer on LPCXpresso Base Board |
Lerche | 0:8dffae878f54 | 20 | */ |
Lerche | 0:8dffae878f54 | 21 | |
Lerche | 0:8dffae878f54 | 22 | namespace mbed { |
Lerche | 0:8dffae878f54 | 23 | class PCA9532 { |
Lerche | 0:8dffae878f54 | 24 | public: |
Lerche | 0:8dffae878f54 | 25 | /* Constructor: PCA9532 |
Lerche | 0:8dffae878f54 | 26 | * Create an instance of the PCA9532 connected to specfied I2C pins, with the specified address. |
Lerche | 0:8dffae878f54 | 27 | * |
Lerche | 0:8dffae878f54 | 28 | * Variables: |
Lerche | 0:8dffae878f54 | 29 | * sda - The I2C data pin (p28) |
Lerche | 0:8dffae878f54 | 30 | * scl - The I2C clock pin (p27) |
Lerche | 0:8dffae878f54 | 31 | * addr - The address of this instance (0xC0) |
Lerche | 0:8dffae878f54 | 32 | */ |
Lerche | 0:8dffae878f54 | 33 | PCA9532 (PinName sda, PinName scl, int addr); |
Lerche | 0:8dffae878f54 | 34 | /* Function: read |
Lerche | 0:8dffae878f54 | 35 | * Read the IO pin level |
Lerche | 0:8dffae878f54 | 36 | * |
Lerche | 0:8dffae878f54 | 37 | * Variables: |
Lerche | 0:8dffae878f54 | 38 | * none |
Lerche | 0:8dffae878f54 | 39 | */ |
Lerche | 0:8dffae878f54 | 40 | int read (void); |
Lerche | 0:8dffae878f54 | 41 | /* Function: write |
Lerche | 0:8dffae878f54 | 42 | * Write the IO pin levels / Turn on LEDs |
Lerche | 0:8dffae878f54 | 43 | * |
Lerche | 0:8dffae878f54 | 44 | * Variables: |
Lerche | 0:8dffae878f54 | 45 | * data - An in, though only the bottom 8 bits are used |
Lerche | 0:8dffae878f54 | 46 | * command - Where to put the data. |
Lerche | 0:8dffae878f54 | 47 | */ |
Lerche | 0:8dffae878f54 | 48 | void write (int command, int data); |
Lerche | 0:8dffae878f54 | 49 | |
Lerche | 0:8dffae878f54 | 50 | private : |
Lerche | 0:8dffae878f54 | 51 | I2C _i2c; |
Lerche | 0:8dffae878f54 | 52 | int _addr; |
Lerche | 0:8dffae878f54 | 53 | }; |
Lerche | 0:8dffae878f54 | 54 | } |
Lerche | 0:8dffae878f54 | 55 | #endif |