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/PCU9669_access.h
- Revision:
- 6:1fc6a640d320
- Parent:
- 5:57c345099873
- Child:
- 7:87fd13f1faa6
--- a/mini_board_libs/PCU9669/PCU9669_access.h Mon Mar 26 06:17:23 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,192 +0,0 @@ -/** A sample code for "mini board PCU9669/PCA9665" - * - * @author Tedd OKANO, NXP Semiconductors - * @version 0.9 - * @date 14-Feb-2011 - * - * 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 - * Uncomment the target name what you want to target. - */ - -/** PCU9669 abstraction layer module - * - * Common access method is abstracted in this module. - * Each channel's registers, global registers and buffer access can be through these interface. - * This module works on top of hardware abstraction layer. - */ - -#ifndef __PCU9669_ACCESS__ -#define __PCU9669_ACCESS__ - -#include "hardware_abs.h" - -/** @def PCU9669_ID / PCA9663_ID / TARGET_BUS_CONTROLLER - * - * Device IDs which can be read from DEVICE_ID register. - * This value may need to be checked before the operation start. - */ -#define PCU9669_ID 0xE9 -#define PCA9663_ID 0x63 -//#define TARGET_BUS_CONTROLLER PCA9663_ID - -/** @def CH_FM_PLUS / CH_UFM1 / CH_UFM2 - * - * Channel number abstracted by its characters. - */ -#define CH_FM_PLUS 0 -#define CH_UFM1 1 -#define CH_UFM2 2 - -#define CH_0 0 -#define CH_1 1 -#define CH_2 2 - -/** @var Register names - * - * PCU9669/9663 internal register name and addesses - */ -typedef enum { - - // channel registers - - CONTROL = 0x00, // These are register offsets. offset base CH0=0xC0, CH1=0xD0, CH2=0xE0 - CHSTATUS, - INTMSK, - SLATABLE, - TRANCONFIG, - DATA, - TRANSEL, - TRANOFS, - BYTECOUNT, - FRAMECNT, - REFRATE, - SCLL, - SCLH, - MODE, - TIMEOUT, - PRESET, - - SCLPER = 0x0B, - SDADLY = 0x0C, - RESERVED = 0x0E, - - // global registers - - CTRLSTATUS = 0xF0, - CTRLINTMSK, - DEVICE_ID = 0xF6, - CTRLPRESET, - CTRLRDY = 0xFF, - - OFFSET_CH0 = 0xC0, - OFFSET_CH1 = 0xD0, - OFFSET_CH2 = 0xE0, - -} RegisterName; - - -/** @var Devide ID code - * - * Keeps the value which is read from DEVICE_ID register - */ -extern char device_id_code; - - -/** Write channel register - * - * Writing 8 bit data into register in specified channel. - * Register address offset of each channels is added in this function. - * - * @param ch target of channel: CH_FM_PLUS | CH_UFM1 | CH_UFM2 - * @param reg target channel register: RegisterName - * @param val target of channel: 8 bit value - * @see read_ch_register() - */ -void write_ch_register( char ch, char reg, char val ); - -/** Read channel register - * - * Read 8 bit data from register in specified channel. - * Register address offset of each channels is added in this function. - * - * @return 8 bit value from the register - * @param ch target of channel: CH_FM_PLUS | CH_UFM1 | CH_UFM2 - * @param reg target channel register: RegisterName - * @see write_ch_register() - */ -char read_ch_register( char ch, char reg ); - -/** Starting the bus controller (i.e. PCU9669) - * - * Checks the bus controller get ready, and ChipID is correct - * Then neccesary register initializations are done. - * In this reference code, no register initialization done. - * But if user need to do some, edit a module-private function "registers_initialize()" in "PCU9669_access.cpp" - * - * @return ZERO for no error, 1 for PCU9669 couldn't get ready after reset, 2 for ChipID was not match. - */ -int start_bus_controller( char target_id ); - - -/** BURST_DATA_ACCESS option code - * - * Following code is enabled only when BURST_DATA_ACCESS is defined in "hardware_abs.h" - */ -#ifdef BURST_DATA_ACCESS - -/** @def PCU9669_BURST_DATA_ACCESS - * - * PCU9669_BURST_DATA_ACCESS is defied to let upper layer know the burst access is available. - * This happens onlny BURST_DATA_ACCESS is defined in "hardware_abs.h" - */ -#define PCU9669_BURST_DATA_ACCESS - -/** Write channel register - * - * Write multiple bytes into a register in specified channel. - * Register address offset of each channels is added in this function. - * - * @param ch target of channel: CH_FM_PLUS | CH_UFM1 | CH_UFM2 - * @param reg target channel register: RegisterName - * @param *vp a pointer to char array. The data in the array will be written. - * @param length length of the data (bytes) - * @see read_ch_register_burst() - */ -void write_ch_register_burst( char ch, char reg, char *vp, char length ); - -/** Read channel register - * - * Read multiple bytes from a register in specified channel. - * Register address offset of each channels is added in this function. - * - * @param ch target of channel: CH_FM_PLUS | CH_UFM1 | CH_UFM2 - * @param reg target channel register: RegisterName - * @param *vp a pointer to char array. The data will be read into this. - * @param length length of the data (bytes) - * @see write_ch_register_burst() - */ -void read_ch_register_burst( char ch, char reg, char *vp, char length ); - -#endif // BURST_DATA_ACCESS - -#endif // __PCU9669_ACCESS__ -