Mini board PCU9669 evaluation kit library

Dependents:   mini_board_PCU9669

Committer:
nxp_ip
Date:
Wed Jan 14 04:30:37 2015 +0000
Revision:
4:b69135913a8f
Parent:
3:930ef1a6bc99
PCA9665 error handling improved

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nxp_ip 0:0737f5596e3d 1 /** A sample code for "mini board PCU9669/PCA9665"
nxp_ip 0:0737f5596e3d 2 *
nxp_ip 1:d7f7e0790f60 3 * @author Akifumi (Tedd) OKANO, NXP Semiconductors
nxp_ip 4:b69135913a8f 4 * @version 1.2
nxp_ip 4:b69135913a8f 5 * @date 13-Jan-2015
nxp_ip 0:0737f5596e3d 6 *
nxp_ip 0:0737f5596e3d 7 * Released under the MIT License: http://mbed.org/license/mit
nxp_ip 0:0737f5596e3d 8 *
nxp_ip 0:0737f5596e3d 9 * An operation sample of PCU9669/PCA9665 I2C bus controller.
nxp_ip 0:0737f5596e3d 10 * The mbed accesses the bus controller's parallel port (8/2 bit address and 8 bit data) by bit-banging.
nxp_ip 0:0737f5596e3d 11 * The bit-banging is poerformed by PortInOut function of mbed library.
nxp_ip 0:0737f5596e3d 12 *
nxp_ip 0:0737f5596e3d 13 * To make the code porting easier, all codes are partitioned into layers to abstract other parts.
nxp_ip 0:0737f5596e3d 14 * The mbed specific parts are concentrated in lowest layer: "hardware_abs.*".
nxp_ip 0:0737f5596e3d 15 * This module may need to be modified for the porting.
nxp_ip 0:0737f5596e3d 16 *
nxp_ip 0:0737f5596e3d 17 * All other upper layers are writen in standard-C.
nxp_ip 0:0737f5596e3d 18 *
nxp_ip 0:0737f5596e3d 19 * base code is written from 05-Sep-2011 to 09-Sep-2011.
nxp_ip 0:0737f5596e3d 20 * And demo code has been build on 11-Sep-2011.
nxp_ip 0:0737f5596e3d 21 * Debug and code adjustment has been done on 08-Sep-2011.
nxp_ip 0:0737f5596e3d 22 * Small sanitization for main.cpp. All mbed related codes are moved in to "hardware_abs.*". 13-Oct-2011
nxp_ip 0:0737f5596e3d 23 * hardware_abs are moved into parallel_bus library folder, 3 LED driver operation sample 13-Feb.-2012
nxp_ip 4:b69135913a8f 24 * PCU9669 and PCA9665 codes are packed in a project 14-Feb-2012.
nxp_ip 4:b69135913a8f 25 *
nxp_ip 0:0737f5596e3d 26 * Before builidng the code, please edit the file mini_board_PCU9669/config.h
nxp_ip 4:b69135913a8f 27 * Un-comment the target name what you want to target.
nxp_ip 0:0737f5596e3d 28 */
nxp_ip 0:0737f5596e3d 29
nxp_ip 0:0737f5596e3d 30 #ifndef MINIBOARD_PCA9665_ACCESS__
nxp_ip 0:0737f5596e3d 31 #define MINIBOARD_PCA9665_ACCESS__
nxp_ip 0:0737f5596e3d 32
nxp_ip 0:0737f5596e3d 33
nxp_ip 0:0737f5596e3d 34 #define OP_MODE_BOTH 0
nxp_ip 0:0737f5596e3d 35 #define OP_MODE_MASTER_ONLY 1
nxp_ip 0:0737f5596e3d 36 #define OP_MODE_SLAVE_ONLY 2
nxp_ip 0:0737f5596e3d 37
nxp_ip 0:0737f5596e3d 38 #define RESTART_DISABLE 0
nxp_ip 0:0737f5596e3d 39 #define STOP RESTART_DISABLE
nxp_ip 0:0737f5596e3d 40 #define RESTART_ENABLE 1
nxp_ip 0:0737f5596e3d 41 #define NEXT_RESTART RESTART_ENABLE
nxp_ip 0:0737f5596e3d 42
nxp_ip 0:0737f5596e3d 43 #define PCA9665_BURST_DATA_ACCESS
nxp_ip 0:0737f5596e3d 44
nxp_ip 0:0737f5596e3d 45
nxp_ip 0:0737f5596e3d 46 typedef enum {
nxp_ip 0:0737f5596e3d 47 SPEED_STD_MODE = 0,
nxp_ip 0:0737f5596e3d 48 SPEED_FAST_MODE = 1,
nxp_ip 0:0737f5596e3d 49 SPEED_FAST_MODE_PLUS = 2
nxp_ip 0:0737f5596e3d 50 }
nxp_ip 0:0737f5596e3d 51 speed_mode_val;
nxp_ip 0:0737f5596e3d 52
nxp_ip 0:0737f5596e3d 53 typedef enum {
nxp_ip 0:0737f5596e3d 54 DISABLE = 0,
nxp_ip 0:0737f5596e3d 55 ENABLE = 1
nxp_ip 0:0737f5596e3d 56 }
nxp_ip 0:0737f5596e3d 57 buffer_mode_flag;
nxp_ip 0:0737f5596e3d 58
nxp_ip 0:0737f5596e3d 59 void set_speed_mode( int mode );
nxp_ip 0:0737f5596e3d 60 void set_buffer_mode( int mode );
nxp_ip 0:0737f5596e3d 61
nxp_ip 0:0737f5596e3d 62 int i2c_write( char addr, char *dp, char length, char restart_flag );
nxp_ip 0:0737f5596e3d 63 int i2c_read( char addr, char *dp, char length, char restart_flag );
nxp_ip 0:0737f5596e3d 64
nxp_ip 0:0737f5596e3d 65 int i2c_write_buffer_mode( char addr, char *dp, char length, char restart_flag );
nxp_ip 0:0737f5596e3d 66 int i2c_read_buffer_mode( char addr, char *dp, char length, char restart_flag );
nxp_ip 0:0737f5596e3d 67
nxp_ip 0:0737f5596e3d 68 int i2c_write_byte_mode( char addr, char *dp, char length, char restart_flag );
nxp_ip 0:0737f5596e3d 69 int i2c_read_byte_mode( char addr, char *dp, char length, char restart_flag );
nxp_ip 0:0737f5596e3d 70
nxp_ip 0:0737f5596e3d 71 void PCA9665_init( void );
nxp_ip 0:0737f5596e3d 72
nxp_ip 0:0737f5596e3d 73 void indirect_write( char idaddr, char data );
nxp_ip 0:0737f5596e3d 74 char indirect_read( char idaddr );
nxp_ip 0:0737f5596e3d 75
nxp_ip 0:0737f5596e3d 76 #endif // MINIBOARD_PCA9665_ACCESS__
nxp_ip 0:0737f5596e3d 77