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
mini_board_libs/parallel_bus/hardware_abs.h@12:da04417f8739, 2012-07-11 (annotated)
- Committer:
- nxp_ip
- Date:
- Wed Jul 11 08:08:36 2012 +0000
- Revision:
- 12:da04417f8739
- Parent:
- 8:6120bbbe3636
new parallel port library (v2.0-alpha) test
Who changed what in which revision?
User | Revision | Line number | New 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 | /** Hardware abstraction layer module |
nxp_ip | 8:6120bbbe3636 | 31 | * |
nxp_ip | 8:6120bbbe3636 | 32 | * All MCU hardware related code are defined in this module |
nxp_ip | 8:6120bbbe3636 | 33 | * This module may need to be modified when the code is ported to other MCU. |
nxp_ip | 8:6120bbbe3636 | 34 | */ |
nxp_ip | 8:6120bbbe3636 | 35 | |
nxp_ip | 8:6120bbbe3636 | 36 | #ifndef MINIBOARD_HARDWARE_ABS__ |
nxp_ip | 8:6120bbbe3636 | 37 | #define MINIBOARD_HARDWARE_ABS__ |
nxp_ip | 8:6120bbbe3636 | 38 | |
nxp_ip | 8:6120bbbe3636 | 39 | /** @def BURST_DATA_ACCESS |
nxp_ip | 8:6120bbbe3636 | 40 | * |
nxp_ip | 8:6120bbbe3636 | 41 | * To accelerate multiple bus access on same addess, use BURST_DATA_ACCESS |
nxp_ip | 8:6120bbbe3636 | 42 | * On the mbed emvironment, this burst access enables 3 times faster read/write compare to single access. |
nxp_ip | 8:6120bbbe3636 | 43 | * For code porting, the BURST_DATA_ACCESS code part is not neccesary if the hardware is fast enough. |
nxp_ip | 8:6120bbbe3636 | 44 | */ |
nxp_ip | 8:6120bbbe3636 | 45 | #define BURST_DATA_ACCESS |
nxp_ip | 8:6120bbbe3636 | 46 | |
nxp_ip | 8:6120bbbe3636 | 47 | |
nxp_ip | 8:6120bbbe3636 | 48 | /** @def ASSERT / DEASSERT |
nxp_ip | 8:6120bbbe3636 | 49 | * |
nxp_ip | 8:6120bbbe3636 | 50 | * Reset signal logic difinition |
nxp_ip | 8:6120bbbe3636 | 51 | */ |
nxp_ip | 8:6120bbbe3636 | 52 | #define ASSERT 0 // for hardware reset |
nxp_ip | 8:6120bbbe3636 | 53 | #define DEASSERT 1 // for hardware reset |
nxp_ip | 8:6120bbbe3636 | 54 | |
nxp_ip | 8:6120bbbe3636 | 55 | |
nxp_ip | 8:6120bbbe3636 | 56 | /** Install an ISR |
nxp_ip | 8:6120bbbe3636 | 57 | * |
nxp_ip | 8:6120bbbe3636 | 58 | * Registering function as ISR. |
nxp_ip | 8:6120bbbe3636 | 59 | * The function will be called when the interrupt asserted. |
nxp_ip | 8:6120bbbe3636 | 60 | * |
nxp_ip | 8:6120bbbe3636 | 61 | * @param fptr a pointer to a function |
nxp_ip | 8:6120bbbe3636 | 62 | */ |
nxp_ip | 8:6120bbbe3636 | 63 | void install_ISR( void (*fptr)(void) ); |
nxp_ip | 8:6120bbbe3636 | 64 | |
nxp_ip | 8:6120bbbe3636 | 65 | /** Hardware initialization |
nxp_ip | 8:6120bbbe3636 | 66 | * |
nxp_ip | 8:6120bbbe3636 | 67 | * MCU side initialization should be done in this function. |
nxp_ip | 8:6120bbbe3636 | 68 | * For the mbed, it set the initial state of parallel bus control signal. |
nxp_ip | 8:6120bbbe3636 | 69 | */ |
nxp_ip | 8:6120bbbe3636 | 70 | void hardware_initialize( void ); |
nxp_ip | 8:6120bbbe3636 | 71 | |
nxp_ip | 8:6120bbbe3636 | 72 | /** Reset signal control |
nxp_ip | 8:6120bbbe3636 | 73 | * |
nxp_ip | 8:6120bbbe3636 | 74 | * This function drives the RESET signal line with given state. |
nxp_ip | 8:6120bbbe3636 | 75 | * |
nxp_ip | 8:6120bbbe3636 | 76 | * @param signal the state of RESET signal: ASSERT | DEASSERT |
nxp_ip | 8:6120bbbe3636 | 77 | */ |
nxp_ip | 8:6120bbbe3636 | 78 | void hardware_reset( char signal ); |
nxp_ip | 8:6120bbbe3636 | 79 | |
nxp_ip | 8:6120bbbe3636 | 80 | /** Hardware reset |
nxp_ip | 8:6120bbbe3636 | 81 | * |
nxp_ip | 8:6120bbbe3636 | 82 | * Asserts the RESET signal with required pulse width and waits its recovery time |
nxp_ip | 8:6120bbbe3636 | 83 | * |
nxp_ip | 8:6120bbbe3636 | 84 | * @param reset_pulse_width_us RESET pulse width in micro-seconds |
nxp_ip | 8:6120bbbe3636 | 85 | * @param reset_recovery_us RESET recovery time in micro-seconds (wait time after RESET de-assertion) |
nxp_ip | 8:6120bbbe3636 | 86 | */ |
nxp_ip | 8:6120bbbe3636 | 87 | void reset( int reset_pulse_width_us, int reset_recovery_us ); |
nxp_ip | 8:6120bbbe3636 | 88 | |
nxp_ip | 8:6120bbbe3636 | 89 | /** Triger signal control |
nxp_ip | 8:6120bbbe3636 | 90 | * |
nxp_ip | 8:6120bbbe3636 | 91 | * This function drives the TRIGGER signal line with given state. |
nxp_ip | 8:6120bbbe3636 | 92 | * |
nxp_ip | 8:6120bbbe3636 | 93 | * @param signal the state of TRIGGER signal: ASSERT | DEASSERT |
nxp_ip | 8:6120bbbe3636 | 94 | */ |
nxp_ip | 8:6120bbbe3636 | 95 | void hardware_trigger( char signal ); |
nxp_ip | 8:6120bbbe3636 | 96 | |
nxp_ip | 8:6120bbbe3636 | 97 | /** Write data |
nxp_ip | 8:6120bbbe3636 | 98 | * |
nxp_ip | 8:6120bbbe3636 | 99 | * Writes 1 byte |
nxp_ip | 8:6120bbbe3636 | 100 | * |
nxp_ip | 8:6120bbbe3636 | 101 | * @param addr 8 bit address where the data should be written to |
nxp_ip | 8:6120bbbe3636 | 102 | * @param data 8 bit data which will be written |
nxp_ip | 8:6120bbbe3636 | 103 | * @see read_data() |
nxp_ip | 8:6120bbbe3636 | 104 | */ |
nxp_ip | 8:6120bbbe3636 | 105 | void write_data( char addr, char data ); |
nxp_ip | 8:6120bbbe3636 | 106 | |
nxp_ip | 8:6120bbbe3636 | 107 | /** Read data |
nxp_ip | 8:6120bbbe3636 | 108 | * |
nxp_ip | 8:6120bbbe3636 | 109 | * Reads 1 byte |
nxp_ip | 8:6120bbbe3636 | 110 | * |
nxp_ip | 8:6120bbbe3636 | 111 | * @return 8 bit data which is read from bus |
nxp_ip | 8:6120bbbe3636 | 112 | * @param addr 8 bit address where the data should be read from |
nxp_ip | 8:6120bbbe3636 | 113 | * @see write_data() |
nxp_ip | 8:6120bbbe3636 | 114 | */ |
nxp_ip | 8:6120bbbe3636 | 115 | char read_data( char addr ); |
nxp_ip | 8:6120bbbe3636 | 116 | |
nxp_ip | 8:6120bbbe3636 | 117 | /** Wait micro-seconds |
nxp_ip | 8:6120bbbe3636 | 118 | * |
nxp_ip | 8:6120bbbe3636 | 119 | * Wait function waits given-micro-seconds |
nxp_ip | 8:6120bbbe3636 | 120 | * |
nxp_ip | 8:6120bbbe3636 | 121 | * @param micro-seconds the program should wait (32 bit integer value) |
nxp_ip | 8:6120bbbe3636 | 122 | * @see wait_sec() |
nxp_ip | 8:6120bbbe3636 | 123 | */ |
nxp_ip | 8:6120bbbe3636 | 124 | void hw_wait_us( int v ); |
nxp_ip | 8:6120bbbe3636 | 125 | |
nxp_ip | 8:6120bbbe3636 | 126 | /** Wait seconds |
nxp_ip | 8:6120bbbe3636 | 127 | * |
nxp_ip | 8:6120bbbe3636 | 128 | * Wait function waits given-seconds |
nxp_ip | 8:6120bbbe3636 | 129 | * |
nxp_ip | 8:6120bbbe3636 | 130 | * @param seconds the program should wait (float value) |
nxp_ip | 8:6120bbbe3636 | 131 | * @see hw_wait_us() |
nxp_ip | 8:6120bbbe3636 | 132 | */ |
nxp_ip | 8:6120bbbe3636 | 133 | void wait_sec( float ); |
nxp_ip | 8:6120bbbe3636 | 134 | |
nxp_ip | 8:6120bbbe3636 | 135 | |
nxp_ip | 8:6120bbbe3636 | 136 | /** BURST_DATA_ACCESS option code |
nxp_ip | 8:6120bbbe3636 | 137 | * |
nxp_ip | 8:6120bbbe3636 | 138 | * This code is option to accelerate the bus access |
nxp_ip | 8:6120bbbe3636 | 139 | */ |
nxp_ip | 8:6120bbbe3636 | 140 | #ifdef BURST_DATA_ACCESS |
nxp_ip | 8:6120bbbe3636 | 141 | |
nxp_ip | 8:6120bbbe3636 | 142 | /** Write data |
nxp_ip | 8:6120bbbe3636 | 143 | * |
nxp_ip | 8:6120bbbe3636 | 144 | * Writes multiple bytes to same address. |
nxp_ip | 8:6120bbbe3636 | 145 | * This function suitable to use for the registers like SLATABLE, TRANCONFIG and data buffers (through DATA register). |
nxp_ip | 8:6120bbbe3636 | 146 | * While this access is going, the interrupt will be tempolary disabled (ISR execution will be postponed) |
nxp_ip | 8:6120bbbe3636 | 147 | * |
nxp_ip | 8:6120bbbe3636 | 148 | * @param addr 8 bit address where the data should be written to |
nxp_ip | 8:6120bbbe3636 | 149 | * @param *data pointer to char array. The data in this array will be written |
nxp_ip | 8:6120bbbe3636 | 150 | * @param length length of the data (bytes) |
nxp_ip | 8:6120bbbe3636 | 151 | * @see read_data_burst() |
nxp_ip | 8:6120bbbe3636 | 152 | */ |
nxp_ip | 8:6120bbbe3636 | 153 | void write_data_burst( char addr, char *data, char length ); |
nxp_ip | 8:6120bbbe3636 | 154 | |
nxp_ip | 8:6120bbbe3636 | 155 | /** Read data |
nxp_ip | 8:6120bbbe3636 | 156 | * |
nxp_ip | 8:6120bbbe3636 | 157 | * Reads multiple bytes from same address. |
nxp_ip | 8:6120bbbe3636 | 158 | * This function suitable to use for the registers like SLATABLE, TRANCONFIG and data buffers (through DATA register). |
nxp_ip | 8:6120bbbe3636 | 159 | * While this access is going, the interrupt will be tempolary disabled (ISR execution will be postponed) |
nxp_ip | 8:6120bbbe3636 | 160 | * |
nxp_ip | 8:6120bbbe3636 | 161 | * @param addr 8 bit address where the data should be written to |
nxp_ip | 8:6120bbbe3636 | 162 | * @param *data pointer to char array. The read data will be written to this |
nxp_ip | 8:6120bbbe3636 | 163 | * @param length length of the data (bytes) |
nxp_ip | 8:6120bbbe3636 | 164 | * @see write_data_burst() |
nxp_ip | 8:6120bbbe3636 | 165 | */ |
nxp_ip | 8:6120bbbe3636 | 166 | void read_data_burst( char addr, char *data, char length ); |
nxp_ip | 8:6120bbbe3636 | 167 | #endif |
nxp_ip | 8:6120bbbe3636 | 168 | |
nxp_ip | 8:6120bbbe3636 | 169 | #endif // MINIBOARD_HARDWARE_ABS__ |
nxp_ip | 8:6120bbbe3636 | 170 |