PCA9629A component library

Dependents:   PCA9629A_Hello

Committer:
nxp_ip
Date:
Fri Sep 12 08:10:19 2014 +0000
Revision:
0:0c797805233b
PCA9629 "A". The "A" version component library. Version 1.1.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nxp_ip 0:0c797805233b 1 /** A sample code for PCA9629A
nxp_ip 0:0c797805233b 2 *
nxp_ip 0:0c797805233b 3 * @author Akifumi (Tedd) OKANO, NXP Semiconductors
nxp_ip 0:0c797805233b 4 * @version 1.1
nxp_ip 0:0c797805233b 5 * @date 12-Sep-2012
nxp_ip 0:0c797805233b 6 *
nxp_ip 0:0c797805233b 7 * revision history (PCA9629A)
nxp_ip 0:0c797805233b 8 * version 0.1 (05-Jun-2013) : PCA9629"A" initial version
nxp_ip 0:0c797805233b 9 * version 0.2 (05-Jun-2013) : register name fix, register description added
nxp_ip 0:0c797805233b 10 * version 1.0 (23-Apr-2014) : unnecessary parameter for constructor has been removed
nxp_ip 0:0c797805233b 11 * version 1.1 (12-Sep-2014) : constructor variation added. ramp parameter API added
nxp_ip 0:0c797805233b 12 *
nxp_ip 0:0c797805233b 13 * Released under the Apache 2 license License
nxp_ip 0:0c797805233b 14 *
nxp_ip 0:0c797805233b 15 * An operation sample of PCA9629A stepper motor controller.
nxp_ip 0:0c797805233b 16 * The mbed accesses the PCA9629A registers through I2C.
nxp_ip 0:0c797805233b 17 *
nxp_ip 0:0c797805233b 18 * About PCA9629A:
nxp_ip 0:0c797805233b 19 * http://www.nxp.com/products/interface_and_connectivity/i2c/i2c_bus_controller_and_bridge_ics/PCA9629APW.html
nxp_ip 0:0c797805233b 20 */
nxp_ip 0:0c797805233b 21
nxp_ip 0:0c797805233b 22 #ifndef MBED_PCA9629A
nxp_ip 0:0c797805233b 23 #define MBED_PCA9629A
nxp_ip 0:0c797805233b 24
nxp_ip 0:0c797805233b 25 #define DEFAULT_PCA9629A_ADDR 0x42
nxp_ip 0:0c797805233b 26 #define I2C_SCL_FREQUENCY (400 * 1000) // I2C SCL clock frequency (for when the cunstructor with pin names is used)
nxp_ip 0:0c797805233b 27 #define ALLCALL_ADDR 0xE0
nxp_ip 0:0c797805233b 28
nxp_ip 0:0c797805233b 29
nxp_ip 0:0c797805233b 30 /** PCA9629A class
nxp_ip 0:0c797805233b 31 *
nxp_ip 0:0c797805233b 32 * This is a driver code for the PCA9629A stepper motor controller.
nxp_ip 0:0c797805233b 33 * This class provides interface for PCA9629A operation and accessing its registers.
nxp_ip 0:0c797805233b 34 * Detail information is available on next URL.
nxp_ip 0:0c797805233b 35 * http://www.nxp.com/products/interface_and_connectivity/i2c/i2c_bus_controller_and_bridge_ics/PCA9629APW.html
nxp_ip 0:0c797805233b 36 *
nxp_ip 0:0c797805233b 37 * Example:
nxp_ip 0:0c797805233b 38 * @code
nxp_ip 0:0c797805233b 39 * #include "mbed.h"
nxp_ip 0:0c797805233b 40 * #include "PCA9629A.h"
nxp_ip 0:0c797805233b 41 *
nxp_ip 0:0c797805233b 42 * PCA9629A motor( p28, p27, 0x42 ); // SDA, SCL, I2C_address (option)
nxp_ip 0:0c797805233b 43 *
nxp_ip 0:0c797805233b 44 * int main() {
nxp_ip 0:0c797805233b 45 *
nxp_ip 0:0c797805233b 46 * // Speed setting 200pps for clockwise (CW) rotation
nxp_ip 0:0c797805233b 47 * motor.pps( PCA9629A::CW, 200 );
nxp_ip 0:0c797805233b 48 *
nxp_ip 0:0c797805233b 49 * // Set 24 steps for CW
nxp_ip 0:0c797805233b 50 * motor.steps( PCA9629A::CW, 24 );
nxp_ip 0:0c797805233b 51 *
nxp_ip 0:0c797805233b 52 * // Speed setting 100pps for counterclockwise (CCW) rotation
nxp_ip 0:0c797805233b 53 * motor.pps( PCA9629A::CCW, 100 );
nxp_ip 0:0c797805233b 54 *
nxp_ip 0:0c797805233b 55 * // Set 48 steps for CCW
nxp_ip 0:0c797805233b 56 * motor.steps( PCA9629A::CCW, 24 );
nxp_ip 0:0c797805233b 57 *
nxp_ip 0:0c797805233b 58 * while ( 1 ) {
nxp_ip 0:0c797805233b 59 * motor.start( PCA9629A::CW ); // Motor start for CW
nxp_ip 0:0c797805233b 60 * wait( 1.0 );
nxp_ip 0:0c797805233b 61 *
nxp_ip 0:0c797805233b 62 * motor.start( PCA9629A::CCW ); // Motor start for CCW
nxp_ip 0:0c797805233b 63 * wait( 1.0 );
nxp_ip 0:0c797805233b 64 * }
nxp_ip 0:0c797805233b 65 * }
nxp_ip 0:0c797805233b 66 * @endcode
nxp_ip 0:0c797805233b 67 */
nxp_ip 0:0c797805233b 68
nxp_ip 0:0c797805233b 69
nxp_ip 0:0c797805233b 70 class PCA9629A
nxp_ip 0:0c797805233b 71 {
nxp_ip 0:0c797805233b 72 public:
nxp_ip 0:0c797805233b 73 /** name of the PCA9629A registers */
nxp_ip 0:0c797805233b 74 typedef enum {
nxp_ip 0:0c797805233b 75 MODE, /**< 0x00 Mode register */
nxp_ip 0:0c797805233b 76 WDTOI, /**< 0x01 WatchDog Time-Out Interval register */
nxp_ip 0:0c797805233b 77 WDCNTL, /**< 0x02 WatchDog Control register */
nxp_ip 0:0c797805233b 78 IO_CFG, /**< 0x03 I/O Configuration register */
nxp_ip 0:0c797805233b 79 INTMODE, /**< 0x04 Interrupt Mode register */
nxp_ip 0:0c797805233b 80 MSK, /**< 0x05 Mask interrupt register */
nxp_ip 0:0c797805233b 81 INTSTAT, /**< 0x06 Interrupt Status register */
nxp_ip 0:0c797805233b 82 IP, /**< 0x07 Input Port register */
nxp_ip 0:0c797805233b 83 INT_MTR_ACT, /**< 0x08 Interrupt motor action control register */
nxp_ip 0:0c797805233b 84 EXTRASTEPS0, /**< 0x09 Extra steps count for INTP0 control register */
nxp_ip 0:0c797805233b 85 EXTRASTEPS1, /**< 0x0A Extra steps count for INTP1 control register */
nxp_ip 0:0c797805233b 86 OP_CFG_PHS, /**< 0x0B Output Port Configuration and Phase control register */
nxp_ip 0:0c797805233b 87 OP_STAT_TO, /**< 0x0C Output state and time-out control register */
nxp_ip 0:0c797805233b 88 RUCNTL, /**< 0x0D Ramp-up control register */
nxp_ip 0:0c797805233b 89 RDCNTL, /**< 0x0E Ramp-down control register */
nxp_ip 0:0c797805233b 90 PMA, /**< 0x0F Perform multiple of actions control register */
nxp_ip 0:0c797805233b 91 LOOPDLY_CW, /**< 0x10 Loop delay timer for CW to CCW control register */
nxp_ip 0:0c797805233b 92 LOOPDLY_CCW, /**< 0x11 Loop delay timer for CCW to CW control register */
nxp_ip 0:0c797805233b 93 CWSCOUNTL, /**< 0x12 Number of clockwise steps register (low byte) */
nxp_ip 0:0c797805233b 94 CWSCOUNTH, /**< 0x13 Number of clockwise steps register (high byte) */
nxp_ip 0:0c797805233b 95 CCWSCOUNTL, /**< 0x14 Number of counter-clockwise steps register (low byte) */
nxp_ip 0:0c797805233b 96 CCWSCOUNTH, /**< 0x15 Number of counter-clockwise steps register (high byte) */
nxp_ip 0:0c797805233b 97 CWPWL, /**< 0x16 Clockwise step pulse width register (low byte) */
nxp_ip 0:0c797805233b 98 CWPWH, /**< 0x17 Clockwise step pulse width register (high byte) */
nxp_ip 0:0c797805233b 99 CCWPWL, /**< 0x18 Counter-clockwise step pulse width register (low byte) */
nxp_ip 0:0c797805233b 100 CCWPWH, /**< 0x19 Counter-clockwise step pulse width register (high byte) */
nxp_ip 0:0c797805233b 101 MCNTL, /**< 0x1A Motor control register */
nxp_ip 0:0c797805233b 102 SUBADR1, /**< 0x1B I2C-bus subaddress 1 */
nxp_ip 0:0c797805233b 103 SUBADR2, /**< 0x1C I2C-bus subaddress 2 */
nxp_ip 0:0c797805233b 104 SUBADR3, /**< 0x1D I2C-bus subaddress 3 */
nxp_ip 0:0c797805233b 105 ALLCALLADR, /**< 0x1E All Call I2C-bus address */
nxp_ip 0:0c797805233b 106 STEPCOUNT0, /**< 0x1F Step counter registers: STEPCOUNT0 */
nxp_ip 0:0c797805233b 107 STEPCOUNT1, /**< 0x20 Step counter registers: STEPCOUNT1 */
nxp_ip 0:0c797805233b 108 STEPCOUNT2, /**< 0x21 Step counter registers: STEPCOUNT2 */
nxp_ip 0:0c797805233b 109 STEPCOUNT3 /**< 0x22 Step counter registers: STEPCOUNT3 */
nxp_ip 0:0c797805233b 110 } RegisterName;
nxp_ip 0:0c797805233b 111
nxp_ip 0:0c797805233b 112 private:
nxp_ip 0:0c797805233b 113 /* register names for 2 bytes accessing */
nxp_ip 0:0c797805233b 114 typedef enum {
nxp_ip 0:0c797805233b 115 CWPW_ = CWPWL | 0x80, /**< Step pulse width for CW rotation */
nxp_ip 0:0c797805233b 116 CCWPW_ = CCWPWL | 0x80, /**< Step pulse width for CCW rotation */
nxp_ip 0:0c797805233b 117 CWSCOUNT_ = CWSCOUNTL | 0x80, /**< Number of steps CW */
nxp_ip 0:0c797805233b 118 CCWSCOUNT_ = CCWSCOUNTL | 0x80, /**< Number of steps CCW */
nxp_ip 0:0c797805233b 119
nxp_ip 0:0c797805233b 120 } _RegisterNameFor16bitAccess;
nxp_ip 0:0c797805233b 121
nxp_ip 0:0c797805233b 122 public:
nxp_ip 0:0c797805233b 123 /** register names for 2 bytes accessing */
nxp_ip 0:0c797805233b 124 typedef enum {
nxp_ip 0:0c797805233b 125 CW__STEP_WIDTH = CWPW_,
nxp_ip 0:0c797805233b 126 CCW_STEP_WIDTH = CCWPW_,
nxp_ip 0:0c797805233b 127 CW__STEP_COUNT = CWSCOUNT_,
nxp_ip 0:0c797805233b 128 CCW_STEP_COUNT = CCWSCOUNT_,
nxp_ip 0:0c797805233b 129 } RegisterNameFor16bitAccess;
nxp_ip 0:0c797805233b 130
nxp_ip 0:0c797805233b 131 /** register names for 4 bytes accessing */
nxp_ip 0:0c797805233b 132 typedef enum {
nxp_ip 0:0c797805233b 133 STEPCOUNT = STEPCOUNT0,
nxp_ip 0:0c797805233b 134 } RegisterNameFor32bitAccess;
nxp_ip 0:0c797805233b 135
nxp_ip 0:0c797805233b 136 /** keyword to select direction of rotation */
nxp_ip 0:0c797805233b 137 typedef enum {
nxp_ip 0:0c797805233b 138 CW = 0, /**< Clockwise direction */
nxp_ip 0:0c797805233b 139 CCW /**< ConterClockwise direction */
nxp_ip 0:0c797805233b 140 } Direction;
nxp_ip 0:0c797805233b 141
nxp_ip 0:0c797805233b 142 /** Create a PCA9629A instance connected to specified I2C pins with specified address
nxp_ip 0:0c797805233b 143 *
nxp_ip 0:0c797805233b 144 * @param I2C_sda I2C-bus SDA pin
nxp_ip 0:0c797805233b 145 * @param I2C_scl I2C-bus SCL pin
nxp_ip 0:0c797805233b 146 * @param I2C_address I2C-bus address (default: 0x42)
nxp_ip 0:0c797805233b 147 */
nxp_ip 0:0c797805233b 148 PCA9629A(
nxp_ip 0:0c797805233b 149 PinName I2C_sda,
nxp_ip 0:0c797805233b 150 PinName I2C_scl,
nxp_ip 0:0c797805233b 151 char I2C_address = DEFAULT_PCA9629A_ADDR
nxp_ip 0:0c797805233b 152 );
nxp_ip 0:0c797805233b 153
nxp_ip 0:0c797805233b 154 /** Create a PCA9629A instance connected to specified I2C pins with specified address
nxp_ip 0:0c797805233b 155 *
nxp_ip 0:0c797805233b 156 * @param I2C object (instance)
nxp_ip 0:0c797805233b 157 * @param I2C_address I2C-bus address (default: 0x42)
nxp_ip 0:0c797805233b 158 */
nxp_ip 0:0c797805233b 159 PCA9629A(
nxp_ip 0:0c797805233b 160 I2C &i2c_,
nxp_ip 0:0c797805233b 161 char I2C_address = DEFAULT_PCA9629A_ADDR
nxp_ip 0:0c797805233b 162 );
nxp_ip 0:0c797805233b 163
nxp_ip 0:0c797805233b 164 /** Destractor
nxp_ip 0:0c797805233b 165 *
nxp_ip 0:0c797805233b 166 *
nxp_ip 0:0c797805233b 167 *
nxp_ip 0:0c797805233b 168 */
nxp_ip 0:0c797805233b 169 ~PCA9629A();
nxp_ip 0:0c797805233b 170
nxp_ip 0:0c797805233b 171 /** Software reset
nxp_ip 0:0c797805233b 172 *
nxp_ip 0:0c797805233b 173 * Performs software reset through I2C bus
nxp_ip 0:0c797805233b 174 */
nxp_ip 0:0c797805233b 175 void software_reset( void );
nxp_ip 0:0c797805233b 176
nxp_ip 0:0c797805233b 177 /** Initialize all registers
nxp_ip 0:0c797805233b 178 *
nxp_ip 0:0c797805233b 179 * The initializing values are defined in the function
nxp_ip 0:0c797805233b 180 */
nxp_ip 0:0c797805233b 181 void init_registers( void );
nxp_ip 0:0c797805233b 182
nxp_ip 0:0c797805233b 183 /** Initialize all registers
nxp_ip 0:0c797805233b 184 *
nxp_ip 0:0c797805233b 185 * The initializing values are defined in the function
nxp_ip 0:0c797805233b 186 */
nxp_ip 0:0c797805233b 187 void set_all_registers( char *a, char size );
nxp_ip 0:0c797805233b 188
nxp_ip 0:0c797805233b 189 /** Write 1 byte data into a register
nxp_ip 0:0c797805233b 190 *
nxp_ip 0:0c797805233b 191 * Setting 8 bits data into a register
nxp_ip 0:0c797805233b 192 *
nxp_ip 0:0c797805233b 193 * @param register_name the register name: data writing into
nxp_ip 0:0c797805233b 194 * @param value 8 bits writing data
nxp_ip 0:0c797805233b 195 */
nxp_ip 0:0c797805233b 196 void write( RegisterName register_name, char value );
nxp_ip 0:0c797805233b 197
nxp_ip 0:0c797805233b 198 /** Write 2 bytes data into a register
nxp_ip 0:0c797805233b 199 *
nxp_ip 0:0c797805233b 200 * Setting 16 bits data into registers
nxp_ip 0:0c797805233b 201 *
nxp_ip 0:0c797805233b 202 * @param register_name the register name: data writing into (it can be "SROTN_", "CWPW_", "CCWPW_", "CWRCOUNT_", "CCWSCOUNT_", "CWRCOUNT_" or "CCWRCOUNT_" )
nxp_ip 0:0c797805233b 203 * @param value 16 bits writing data
nxp_ip 0:0c797805233b 204 */
nxp_ip 0:0c797805233b 205 void write( RegisterNameFor16bitAccess register_name, short value );
nxp_ip 0:0c797805233b 206
nxp_ip 0:0c797805233b 207 /** Read 1 byte data from a register
nxp_ip 0:0c797805233b 208 *
nxp_ip 0:0c797805233b 209 * Setting data into a register
nxp_ip 0:0c797805233b 210 *
nxp_ip 0:0c797805233b 211 * @param register_name the register name: data reading from
nxp_ip 0:0c797805233b 212 * @return read 8 bits data from the register
nxp_ip 0:0c797805233b 213 */
nxp_ip 0:0c797805233b 214 char read( RegisterName register_name );
nxp_ip 0:0c797805233b 215
nxp_ip 0:0c797805233b 216 /** Read 2 byte data from registers
nxp_ip 0:0c797805233b 217 *
nxp_ip 0:0c797805233b 218 * Setting data into a register
nxp_ip 0:0c797805233b 219 *
nxp_ip 0:0c797805233b 220 * @param register_name the register name: data writing into (it can be "SROTN_", "CWPW_", "CCWPW_", "CWRCOUNT_", "CCWSCOUNT_", "CWRCOUNT_" or "CCWRCOUNT_" )
nxp_ip 0:0c797805233b 221 * @return read 16 bits data from the registers
nxp_ip 0:0c797805233b 222 */
nxp_ip 0:0c797805233b 223 short read( RegisterNameFor16bitAccess register_name );
nxp_ip 0:0c797805233b 224
nxp_ip 0:0c797805233b 225 /** Read 4 byte data from registers
nxp_ip 0:0c797805233b 226 *
nxp_ip 0:0c797805233b 227 * Setting data into a register
nxp_ip 0:0c797805233b 228 *
nxp_ip 0:0c797805233b 229 * @param register_name the register name: data writing into (it can be "STEPCOUNT")
nxp_ip 0:0c797805233b 230 * @return read 32 bits data from the registers
nxp_ip 0:0c797805233b 231 */
nxp_ip 0:0c797805233b 232 long read( RegisterNameFor32bitAccess register_name );
nxp_ip 0:0c797805233b 233
nxp_ip 0:0c797805233b 234 /** Motor start
nxp_ip 0:0c797805233b 235 *
nxp_ip 0:0c797805233b 236 * Start command
nxp_ip 0:0c797805233b 237 * This function starts motor operation with hard-stop flag and rotation+step enabled, no repeat will be performed
nxp_ip 0:0c797805233b 238 * If custom start is required, use "write( PCA9629A::MCNTL, 0xXX )" to control each bits.
nxp_ip 0:0c797805233b 239 *
nxp_ip 0:0c797805233b 240 * @param dir rotate direction ("CW" or "CCW")
nxp_ip 0:0c797805233b 241 */
nxp_ip 0:0c797805233b 242 void start( Direction dir );
nxp_ip 0:0c797805233b 243
nxp_ip 0:0c797805233b 244 /** Motor stop
nxp_ip 0:0c797805233b 245 *
nxp_ip 0:0c797805233b 246 * Stop command
nxp_ip 0:0c797805233b 247 *
nxp_ip 0:0c797805233b 248 */
nxp_ip 0:0c797805233b 249 void stop( void );
nxp_ip 0:0c797805233b 250
nxp_ip 0:0c797805233b 251 /** Set PPS
nxp_ip 0:0c797805233b 252 *
nxp_ip 0:0c797805233b 253 * Setting PulsePerSecond
nxp_ip 0:0c797805233b 254 * This interface can be used to set CWPWx or CCWPWx registers
nxp_ip 0:0c797805233b 255 *
nxp_ip 0:0c797805233b 256 * @param dir rotate direction ("CW" or "CCW")
nxp_ip 0:0c797805233b 257 * @param pulse_per_second pps defineds pulse width for the motor. The pulse width will be 1/pps
nxp_ip 0:0c797805233b 258 * @return 16 bit data that what set to the CWPWx or CCWPWx registers
nxp_ip 0:0c797805233b 259 */
nxp_ip 0:0c797805233b 260 short pps( Direction dir, float pulse_per_second );
nxp_ip 0:0c797805233b 261
nxp_ip 0:0c797805233b 262 /** Set steps count
nxp_ip 0:0c797805233b 263 *
nxp_ip 0:0c797805233b 264 * Setting step count
nxp_ip 0:0c797805233b 265 * This interfaces CWSCOUNTx and CCWSCOUNTx registers
nxp_ip 0:0c797805233b 266 *
nxp_ip 0:0c797805233b 267 * @param dir rotate direction ("CW" or "CCW")
nxp_ip 0:0c797805233b 268 * @param step_count sets number of steps with 16 bit value
nxp_ip 0:0c797805233b 269 */
nxp_ip 0:0c797805233b 270 void steps( Direction dir, int step_count );
nxp_ip 0:0c797805233b 271
nxp_ip 0:0c797805233b 272 /** Ramp-up rate
nxp_ip 0:0c797805233b 273 *
nxp_ip 0:0c797805233b 274 * Setting ramp-up rate
nxp_ip 0:0c797805233b 275 *
nxp_ip 0:0c797805233b 276 * @param rate set acceleration ratio. From 0 to 13. 0 for disable. Bigger valure accelerate faster.
nxp_ip 0:0c797805233b 277 */
nxp_ip 0:0c797805233b 278 void ramp_up( char rate );
nxp_ip 0:0c797805233b 279
nxp_ip 0:0c797805233b 280 /** Ramp-down rate
nxp_ip 0:0c797805233b 281 *
nxp_ip 0:0c797805233b 282 * Setting ramp-down rate
nxp_ip 0:0c797805233b 283 *
nxp_ip 0:0c797805233b 284 * @param rate set deceleration ratio. From 0 to 13. 0 for disable. Bigger valure decelerate faster.
nxp_ip 0:0c797805233b 285 */
nxp_ip 0:0c797805233b 286 void ramp_down( char rate );
nxp_ip 0:0c797805233b 287
nxp_ip 0:0c797805233b 288 /** Register dump
nxp_ip 0:0c797805233b 289 *
nxp_ip 0:0c797805233b 290 * Dumping all register data to serial console
nxp_ip 0:0c797805233b 291 *
nxp_ip 0:0c797805233b 292 */
nxp_ip 0:0c797805233b 293 void register_dump( void );
nxp_ip 0:0c797805233b 294
nxp_ip 0:0c797805233b 295 /** Register dump
nxp_ip 0:0c797805233b 296 *
nxp_ip 0:0c797805233b 297 * Dumping all register data to serial console
nxp_ip 0:0c797805233b 298 *
nxp_ip 0:0c797805233b 299 */
nxp_ip 0:0c797805233b 300 void speed_change( unsigned short pw );
nxp_ip 0:0c797805233b 301
nxp_ip 0:0c797805233b 302 /** Register dump
nxp_ip 0:0c797805233b 303 *
nxp_ip 0:0c797805233b 304 * Dumping all register data to serial console
nxp_ip 0:0c797805233b 305 *
nxp_ip 0:0c797805233b 306 */
nxp_ip 0:0c797805233b 307 void calibration( float coefficient );
nxp_ip 0:0c797805233b 308
nxp_ip 0:0c797805233b 309
nxp_ip 0:0c797805233b 310 private:
nxp_ip 0:0c797805233b 311 /* plescaler range setting */
nxp_ip 0:0c797805233b 312 typedef enum {
nxp_ip 0:0c797805233b 313 PRESCALER_FROM_40_TO_333333, /*< Prescaler range from 3us(333333pps) to 24.576ms(40 pps) */
nxp_ip 0:0c797805233b 314 PRESCALER_FROM_20_TO_166667, /*< Prescaler range from 6us(166667pps) to 49.152ms(20 pps) */
nxp_ip 0:0c797805233b 315 PRESCALER_FROM_10_TO_83333, /*< Prescaler range from 12us( 83333pps) to 98.304ms(10 pps) */
nxp_ip 0:0c797805233b 316 PRESCALER_FROM_5_TO_41667, /*< Prescaler range from 24us( 41667pps) to 196.608ms( 5 pps) */
nxp_ip 0:0c797805233b 317 PRESCALER_FROM_2_5_TO_20833, /*< Prescaler range from 48us( 20833pps) to 393.216ms( 2.5 pps) */
nxp_ip 0:0c797805233b 318 PRESCALER_FROM_1_27_TO_10416, /*< Prescaler range from 96us( 10416pps) to 786.432ms( 1.27pps) */
nxp_ip 0:0c797805233b 319 PRESCALER_FROM_0_64_TO_5208, /*< Prescaler range from 192us( 5208pps) to 1572.864ms( 0.64pps) */
nxp_ip 0:0c797805233b 320 PRESCALER_FROM_0_32_TO_2604, /*< Prescaler range from 384us( 2604pps) to 3145.728ms( 0.32pps) */
nxp_ip 0:0c797805233b 321 } PrescalerRange;
nxp_ip 0:0c797805233b 322
nxp_ip 0:0c797805233b 323 /* Set PPS
nxp_ip 0:0c797805233b 324 *
nxp_ip 0:0c797805233b 325 * Setting PulsePerSecond
nxp_ip 0:0c797805233b 326 * This interface can be used to set CWPWx or CCWPWx registers
nxp_ip 0:0c797805233b 327 *
nxp_ip 0:0c797805233b 328 * @param dir rotate direction ("CW" or "CCW")
nxp_ip 0:0c797805233b 329 * @param prescaler prescaler setting (for 3 bits setting range from 0 to 0x7. See datasheet)
nxp_ip 0:0c797805233b 330 * @param pulse_per_second pps defineds pulse width for the motor. The pulse width will be 1/pps
nxp_ip 0:0c797805233b 331 * @return 16 bit data that what set to the CWPWx or CCWPWx registers
nxp_ip 0:0c797805233b 332 */
nxp_ip 0:0c797805233b 333 short pps( Direction dir, PrescalerRange prescaler, int pulse_per_second );
nxp_ip 0:0c797805233b 334
nxp_ip 0:0c797805233b 335 I2C *i2c_p;
nxp_ip 0:0c797805233b 336 I2C &i2c;
nxp_ip 0:0c797805233b 337 char i2c_addr;
nxp_ip 0:0c797805233b 338 };
nxp_ip 0:0c797805233b 339
nxp_ip 0:0c797805233b 340 #endif // MBED_PCA9629A