mini board PCU9669 (and PCA9665) sample code

Dependencies:   mbed PCU9669 utility PCA9665 I2C_slaves parallel_bus

Fork of mini_board_PCU9669_old by InetrfaceProducts NXP

Sample code for PCU9669 (PCU9661, PCA9663, PCA9661 and PCA9665) evaluation board.

PCU9669 evaluation board: Mini board PCU9669
User manual is available -> http://www.nxp.com/documents/user_manual/UM10580.pdf

Committer:
nxp_ip
Date:
Wed Mar 28 04:32:50 2012 +0000
Revision:
8:6120bbbe3636
correction for comment on header part of each files (date: 26-Mar-2011 --> 26-Mar-2012)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nxp_ip 8:6120bbbe3636 1 /** A sample code for "mini board PCU9669/PCA9665"
nxp_ip 8:6120bbbe3636 2 *
nxp_ip 8:6120bbbe3636 3 * @author Akifumi (Tedd) OKANO, NXP Semiconductors
nxp_ip 8:6120bbbe3636 4 * @version 1.0
nxp_ip 8:6120bbbe3636 5 * @date 26-Mar-2012
nxp_ip 8:6120bbbe3636 6 *
nxp_ip 8:6120bbbe3636 7 * Released under the MIT License: http://mbed.org/license/mit
nxp_ip 8:6120bbbe3636 8 *
nxp_ip 8:6120bbbe3636 9 * An operation sample of PCU9669/PCA9665 I2C bus controller.
nxp_ip 8:6120bbbe3636 10 * The mbed accesses the bus controller's parallel port (8/2 bit address and 8 bit data) by bit-banging.
nxp_ip 8:6120bbbe3636 11 * The bit-banging is poerformed by PortInOut function of mbed library.
nxp_ip 8:6120bbbe3636 12 *
nxp_ip 8:6120bbbe3636 13 * To make the code porting easier, all codes are partitioned into layers to abstract other parts.
nxp_ip 8:6120bbbe3636 14 * The mbed specific parts are concentrated in lowest layer: "hardware_abs.*".
nxp_ip 8:6120bbbe3636 15 * This module may need to be modified for the porting.
nxp_ip 8:6120bbbe3636 16 *
nxp_ip 8:6120bbbe3636 17 * All other upper layers are writen in standard-C.
nxp_ip 8:6120bbbe3636 18 *
nxp_ip 8:6120bbbe3636 19 * base code is written from 05-Sep-2011 to 09-Sep-2011.
nxp_ip 8:6120bbbe3636 20 * And demo code has been build on 11-Sep-2011.
nxp_ip 8:6120bbbe3636 21 * Debug and code adjustment has been done on 08-Sep-2011.
nxp_ip 8:6120bbbe3636 22 * Small sanitization for main.cpp. All mbed related codes are moved in to "hardware_abs.*". 13-Oct-2011
nxp_ip 8:6120bbbe3636 23 * hardware_abs are moved into parallel_bus library folder, 3 LED driver operation sample 13-Feb.-2012
nxp_ip 8:6120bbbe3636 24 * PCU9669 and PCA9665 codes are packed in a project 14-Feb-2012.
nxp_ip 8:6120bbbe3636 25 *
nxp_ip 8:6120bbbe3636 26 * Before builidng the code, please edit the file mini_board_PCU9669/config.h
nxp_ip 8:6120bbbe3636 27 * Un-comment the target name what you want to target.
nxp_ip 8:6120bbbe3636 28 */
nxp_ip 8:6120bbbe3636 29
nxp_ip 8:6120bbbe3636 30 /** Data transfer is abstracted on this layer
nxp_ip 8:6120bbbe3636 31 *
nxp_ip 8:6120bbbe3636 32 * The transer can be managed by a struct and some functions
nxp_ip 8:6120bbbe3636 33 */
nxp_ip 8:6120bbbe3636 34 #ifndef __TRANSFER_MANAGER__
nxp_ip 8:6120bbbe3636 35 #define __TRANSFER_MANAGER__
nxp_ip 8:6120bbbe3636 36
nxp_ip 8:6120bbbe3636 37 #define TRIGGER_BY_RISING_EDGE 0
nxp_ip 8:6120bbbe3636 38 #define TRIGGER_BY_FALLING_EDGE 1
nxp_ip 8:6120bbbe3636 39
nxp_ip 8:6120bbbe3636 40 /** @typedef transaction
nxp_ip 8:6120bbbe3636 41 *
nxp_ip 8:6120bbbe3636 42 * A transaction (single data read/write access to the slave) is managed by this structure
nxp_ip 8:6120bbbe3636 43 * An array of the transaction makes a transfer.
nxp_ip 8:6120bbbe3636 44 * The sample of the transfer management can be found in "main.cpp".
nxp_ip 8:6120bbbe3636 45 */
nxp_ip 8:6120bbbe3636 46 typedef struct transaction_st {
nxp_ip 8:6120bbbe3636 47 char i2c_address __attribute__((packed));
nxp_ip 8:6120bbbe3636 48 char *data __attribute__((packed));
nxp_ip 8:6120bbbe3636 49 char length __attribute__((packed));
nxp_ip 8:6120bbbe3636 50 }
nxp_ip 8:6120bbbe3636 51 transaction;
nxp_ip 8:6120bbbe3636 52
nxp_ip 8:6120bbbe3636 53 /** Setup transfer
nxp_ip 8:6120bbbe3636 54 *
nxp_ip 8:6120bbbe3636 55 * A transfer (consists multiple transactions) will be set into the buffer.
nxp_ip 8:6120bbbe3636 56 * This function only sets the data.
nxp_ip 8:6120bbbe3636 57 *
nxp_ip 8:6120bbbe3636 58 * @param ch target of channel: CH_FM_PLUS | CH_UFM1 | CH_UFM2
nxp_ip 8:6120bbbe3636 59 * @param *t a pointer to transaction array. This array represents a transfer.
nxp_ip 8:6120bbbe3636 60 * @param n_of_transaction number of transactions (how many transactions in this transfer)
nxp_ip 8:6120bbbe3636 61 * @see setup_transfer()
nxp_ip 8:6120bbbe3636 62 * @see buffer_overwrite()
nxp_ip 8:6120bbbe3636 63 * @see buffer_read()
nxp_ip 8:6120bbbe3636 64 * @see start()
nxp_ip 8:6120bbbe3636 65 */
nxp_ip 8:6120bbbe3636 66 void setup_transfer( char ch, transaction *t, char n_of_transaction );
nxp_ip 8:6120bbbe3636 67
nxp_ip 8:6120bbbe3636 68 /** Set N of transaction
nxp_ip 8:6120bbbe3636 69 *
nxp_ip 8:6120bbbe3636 70 * To modify the N_OF_TRANSACTION
nxp_ip 8:6120bbbe3636 71 * This can be used to ignore transactions after specified transaction
nxp_ip 8:6120bbbe3636 72 *
nxp_ip 8:6120bbbe3636 73 * @param ch target of channel: CH_FM_PLUS | CH_UFM1 | CH_UFM2
nxp_ip 8:6120bbbe3636 74 * @param n_of_transaction number of transactions (how many transactions in this transfer)
nxp_ip 8:6120bbbe3636 75 * @see setup_transfer()
nxp_ip 8:6120bbbe3636 76 * @see buffer_overwrite()
nxp_ip 8:6120bbbe3636 77 * @see buffer_read()
nxp_ip 8:6120bbbe3636 78 * @see start()
nxp_ip 8:6120bbbe3636 79 */
nxp_ip 8:6120bbbe3636 80 void set_n_of_transaction( char ch, char n_of_transaction );
nxp_ip 8:6120bbbe3636 81
nxp_ip 8:6120bbbe3636 82 /** Buffer overwrite (in a transaction)
nxp_ip 8:6120bbbe3636 83 *
nxp_ip 8:6120bbbe3636 84 * Buffer contents in a transaction can be overwritten.
nxp_ip 8:6120bbbe3636 85 *
nxp_ip 8:6120bbbe3636 86 * @param ch target of channel: CH_FM_PLUS | CH_UFM1 | CH_UFM2
nxp_ip 8:6120bbbe3636 87 * @param transaction_number points the target transaction by number.
nxp_ip 8:6120bbbe3636 88 * @param offset offset of overwriting start byte
nxp_ip 8:6120bbbe3636 89 * @param *data pointer to char array, this contents will be written
nxp_ip 8:6120bbbe3636 90 * @param length number of bytes to overwrite
nxp_ip 8:6120bbbe3636 91 * @see setup_transfer()
nxp_ip 8:6120bbbe3636 92 * @see buffer_overwrite()
nxp_ip 8:6120bbbe3636 93 * @see buffer_read()
nxp_ip 8:6120bbbe3636 94 * @see start()
nxp_ip 8:6120bbbe3636 95 */
nxp_ip 8:6120bbbe3636 96 void buffer_overwrite( char ch, char transaction_number, char offset, char *data, char length );
nxp_ip 8:6120bbbe3636 97
nxp_ip 8:6120bbbe3636 98 /** Buffer read (in a transaction)
nxp_ip 8:6120bbbe3636 99 *
nxp_ip 8:6120bbbe3636 100 * Buffer read interface.
nxp_ip 8:6120bbbe3636 101 *
nxp_ip 8:6120bbbe3636 102 * @param ch target of channel: CH_FM_PLUS | CH_UFM1 | CH_UFM2
nxp_ip 8:6120bbbe3636 103 * @param transaction_number points the target transaction by number.
nxp_ip 8:6120bbbe3636 104 * @param offset offset of reading start byte
nxp_ip 8:6120bbbe3636 105 * @param *data pointer to char array, the data will be written here
nxp_ip 8:6120bbbe3636 106 * @param length number of bytes to read
nxp_ip 8:6120bbbe3636 107 * @see setup_transfer()
nxp_ip 8:6120bbbe3636 108 * @see buffer_overwrite()
nxp_ip 8:6120bbbe3636 109 * @see buffer_read()
nxp_ip 8:6120bbbe3636 110 * @see start()
nxp_ip 8:6120bbbe3636 111 */
nxp_ip 8:6120bbbe3636 112 void buffer_read( char ch, char transaction_number, char offset, char *data, char length );
nxp_ip 8:6120bbbe3636 113
nxp_ip 8:6120bbbe3636 114 /** Start transfer
nxp_ip 8:6120bbbe3636 115 *
nxp_ip 8:6120bbbe3636 116 * Starts the transfer of specified channel
nxp_ip 8:6120bbbe3636 117 *
nxp_ip 8:6120bbbe3636 118 * @param ch target of channel: CH_FM_PLUS | CH_UFM1 | CH_UFM2
nxp_ip 8:6120bbbe3636 119 * @see setup_transfer()
nxp_ip 8:6120bbbe3636 120 * @see buffer_overwrite()
nxp_ip 8:6120bbbe3636 121 * @see buffer_read()
nxp_ip 8:6120bbbe3636 122 * @see start()
nxp_ip 8:6120bbbe3636 123 */
nxp_ip 8:6120bbbe3636 124 void start( char ch );
nxp_ip 8:6120bbbe3636 125 void start_by_trigger( char ch, char polarity );
nxp_ip 8:6120bbbe3636 126 void stop( char ch );
nxp_ip 8:6120bbbe3636 127
nxp_ip 8:6120bbbe3636 128 // void single_transaction_buffer_fill( char ch, char *data, char length );
nxp_ip 8:6120bbbe3636 129
nxp_ip 8:6120bbbe3636 130
nxp_ip 8:6120bbbe3636 131 #endif // __TRANSFER_MANAGER__
nxp_ip 8:6120bbbe3636 132