This software drives a PCA9675 device via an I2C bus. Included functions allow you to read the device ID, set the IO direction, and read and write from the device.

Dependencies:   mbed

Committer:
DavidGilesHitex
Date:
Tue Nov 23 10:59:14 2010 +0000
Revision:
0:3331b5950572

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
DavidGilesHitex 0:3331b5950572 1 #include "mbed.h"
DavidGilesHitex 0:3331b5950572 2
DavidGilesHitex 0:3331b5950572 3 #ifndef PCA9675__
DavidGilesHitex 0:3331b5950572 4 #define PCA9675__
DavidGilesHitex 0:3331b5950572 5 #endif
DavidGilesHitex 0:3331b5950572 6
DavidGilesHitex 0:3331b5950572 7 /* Define a class for PCA9675 */
DavidGilesHitex 0:3331b5950572 8 class PCA9675
DavidGilesHitex 0:3331b5950572 9 {
DavidGilesHitex 0:3331b5950572 10 /* Private members first */
DavidGilesHitex 0:3331b5950572 11 private:
DavidGilesHitex 0:3331b5950572 12 uint8_t My_Lcoal_Slave_Address;
DavidGilesHitex 0:3331b5950572 13 uint8_t My_Local_Port0_Direction;
DavidGilesHitex 0:3331b5950572 14 uint8_t My_Local_Port1_Direction;
DavidGilesHitex 0:3331b5950572 15 sint32_t reset(); /* Reset the device using a general call */
DavidGilesHitex 0:3331b5950572 16 I2C *My_Local_I2C; /* make use of the existing I2C class for i2C calls */
DavidGilesHitex 0:3331b5950572 17
DavidGilesHitex 0:3331b5950572 18 /* Public members next */
DavidGilesHitex 0:3331b5950572 19 public:
DavidGilesHitex 0:3331b5950572 20 PCA9675(I2C *Selected_I2C_Channel, uint8_t Slave_Address); /* Constructor - create with the slave address */
DavidGilesHitex 0:3331b5950572 21 ~PCA9675(); /* Destructor */
DavidGilesHitex 0:3331b5950572 22 sint32_t init(uint8_t port0_Direction, uint8_t port1_Direction); /* Reset the device and setup the IO direction */
DavidGilesHitex 0:3331b5950572 23 sint32_t write_data(uint8_t port0_payload, uint8_t port1_payload); /* Write two bytes of data to the device */
DavidGilesHitex 0:3331b5950572 24 sint32_t read_data(uint8_t *read_port0, uint8_t *read_port1); /* Read two bytes from the device */
DavidGilesHitex 0:3331b5950572 25 sint32_t read_device_ID(uint8_t *manufacturer, uint16_t *part_ident, uint8_t *die_revision);
DavidGilesHitex 0:3331b5950572 26 uint8_t read_slave_address(); /* Read the configured slave address */
DavidGilesHitex 0:3331b5950572 27
DavidGilesHitex 0:3331b5950572 28
DavidGilesHitex 0:3331b5950572 29 enum PCA9675_Defines
DavidGilesHitex 0:3331b5950572 30 {
DavidGilesHitex 0:3331b5950572 31 eI2C_ACK = 0,
DavidGilesHitex 0:3331b5950572 32 ePCA9675_RESET_COMMAND = 6,
DavidGilesHitex 0:3331b5950572 33 ePCA9675_RESET_ADDRESS = 0,
DavidGilesHitex 0:3331b5950572 34 ePCA9675_PORT0 = 0,
DavidGilesHitex 0:3331b5950572 35 ePCA9675_PORT1 = 1,
DavidGilesHitex 0:3331b5950572 36 eI2C_REPEATED_START = 1,
DavidGilesHitex 0:3331b5950572 37 eI2C_NO_REPEATED_START = 0
DavidGilesHitex 0:3331b5950572 38 };
DavidGilesHitex 0:3331b5950572 39
DavidGilesHitex 0:3331b5950572 40
DavidGilesHitex 0:3331b5950572 41 };
DavidGilesHitex 0:3331b5950572 42
DavidGilesHitex 0:3331b5950572 43
DavidGilesHitex 0:3331b5950572 44
DavidGilesHitex 0:3331b5950572 45
DavidGilesHitex 0:3331b5950572 46