mini board PCU9669 (and PCA9665) sample code
Dependencies: mbed PCU9669 utility PCA9665 I2C_slaves parallel_bus
Fork of mini_board_PCU9669_old by
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
Diff: mini_board_libs/PCU9669/transfer_manager.h
- Revision:
- 10:47974d9e6a5f
- Parent:
- 8:6120bbbe3636
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mini_board_libs/PCU9669/transfer_manager.h Fri Jul 06 08:30:10 2012 +0000 @@ -0,0 +1,132 @@ +/** A sample code for "mini board PCU9669/PCA9665" + * + * @author Akifumi (Tedd) OKANO, NXP Semiconductors + * @version 1.0 + * @date 26-Mar-2012 + * + * Released under the MIT License: http://mbed.org/license/mit + * + * An operation sample of PCU9669/PCA9665 I2C bus controller. + * The mbed accesses the bus controller's parallel port (8/2 bit address and 8 bit data) by bit-banging. + * The bit-banging is poerformed by PortInOut function of mbed library. + * + * To make the code porting easier, all codes are partitioned into layers to abstract other parts. + * The mbed specific parts are concentrated in lowest layer: "hardware_abs.*". + * This module may need to be modified for the porting. + * + * All other upper layers are writen in standard-C. + * + * base code is written from 05-Sep-2011 to 09-Sep-2011. + * And demo code has been build on 11-Sep-2011. + * Debug and code adjustment has been done on 08-Sep-2011. + * Small sanitization for main.cpp. All mbed related codes are moved in to "hardware_abs.*". 13-Oct-2011 + * hardware_abs are moved into parallel_bus library folder, 3 LED driver operation sample 13-Feb.-2012 + * PCU9669 and PCA9665 codes are packed in a project 14-Feb-2012. + * + * Before builidng the code, please edit the file mini_board_PCU9669/config.h + * Un-comment the target name what you want to target. + */ + +/** Data transfer is abstracted on this layer + * + * The transer can be managed by a struct and some functions + */ +#ifndef __TRANSFER_MANAGER__ +#define __TRANSFER_MANAGER__ + +#define TRIGGER_BY_RISING_EDGE 0 +#define TRIGGER_BY_FALLING_EDGE 1 + +/** @typedef transaction + * + * A transaction (single data read/write access to the slave) is managed by this structure + * An array of the transaction makes a transfer. + * The sample of the transfer management can be found in "main.cpp". + */ +typedef struct transaction_st { + char i2c_address __attribute__((packed)); + char *data __attribute__((packed)); + char length __attribute__((packed)); +} +transaction; + +/** Setup transfer + * + * A transfer (consists multiple transactions) will be set into the buffer. + * This function only sets the data. + * + * @param ch target of channel: CH_FM_PLUS | CH_UFM1 | CH_UFM2 + * @param *t a pointer to transaction array. This array represents a transfer. + * @param n_of_transaction number of transactions (how many transactions in this transfer) + * @see setup_transfer() + * @see buffer_overwrite() + * @see buffer_read() + * @see start() + */ +void setup_transfer( char ch, transaction *t, char n_of_transaction ); + +/** Set N of transaction + * + * To modify the N_OF_TRANSACTION + * This can be used to ignore transactions after specified transaction + * + * @param ch target of channel: CH_FM_PLUS | CH_UFM1 | CH_UFM2 + * @param n_of_transaction number of transactions (how many transactions in this transfer) + * @see setup_transfer() + * @see buffer_overwrite() + * @see buffer_read() + * @see start() + */ +void set_n_of_transaction( char ch, char n_of_transaction ); + +/** Buffer overwrite (in a transaction) + * + * Buffer contents in a transaction can be overwritten. + * + * @param ch target of channel: CH_FM_PLUS | CH_UFM1 | CH_UFM2 + * @param transaction_number points the target transaction by number. + * @param offset offset of overwriting start byte + * @param *data pointer to char array, this contents will be written + * @param length number of bytes to overwrite + * @see setup_transfer() + * @see buffer_overwrite() + * @see buffer_read() + * @see start() + */ +void buffer_overwrite( char ch, char transaction_number, char offset, char *data, char length ); + +/** Buffer read (in a transaction) + * + * Buffer read interface. + * + * @param ch target of channel: CH_FM_PLUS | CH_UFM1 | CH_UFM2 + * @param transaction_number points the target transaction by number. + * @param offset offset of reading start byte + * @param *data pointer to char array, the data will be written here + * @param length number of bytes to read + * @see setup_transfer() + * @see buffer_overwrite() + * @see buffer_read() + * @see start() + */ +void buffer_read( char ch, char transaction_number, char offset, char *data, char length ); + +/** Start transfer + * + * Starts the transfer of specified channel + * + * @param ch target of channel: CH_FM_PLUS | CH_UFM1 | CH_UFM2 + * @see setup_transfer() + * @see buffer_overwrite() + * @see buffer_read() + * @see start() + */ +void start( char ch ); +void start_by_trigger( char ch, char polarity ); +void stop( char ch ); + +// void single_transaction_buffer_fill( char ch, char *data, char length ); + + +#endif // __TRANSFER_MANAGER__ +