PCA9629 a stepper motor controller class library

Dependents:   PCA9629_Hello

Class library for PCA9629.

A sample program available on http://mbed.org/users/nxp_ip/code/PCA9629_Hello/

Committer:
nxp_ip
Date:
Mon Jul 23 04:57:38 2012 +0000
Revision:
7:199f109eb0c6
Parent:
6:138665018069
version 1.1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nxp_ip 7:199f109eb0c6 1 /** PCA9629 library
nxp_ip 4:9a80b6d63005 2 *
nxp_ip 5:aff87a1c8bd6 3 * @author Akifumi (Tedd) OKANO, NXP Semiconductors
nxp_ip 7:199f109eb0c6 4 * @version 1.1
nxp_ip 7:199f109eb0c6 5 * @date 23-Jul-2012
nxp_ip 7:199f109eb0c6 6 *
nxp_ip 7:199f109eb0c6 7 * revision history
nxp_ip 7:199f109eb0c6 8 * version 1.0 (24-Apr-2011) : Initial version
nxp_ip 7:199f109eb0c6 9 * version 1.1 (23-Jul-2012) : API modification
nxp_ip 7:199f109eb0c6 10 * Correction for comments
nxp_ip 4:9a80b6d63005 11 *
nxp_ip 4:9a80b6d63005 12 * Released under the MIT License: http://mbed.org/license/mit
nxp_ip 4:9a80b6d63005 13 *
nxp_ip 4:9a80b6d63005 14 * An operation sample of PCU9629 stepper motor controller.
nxp_ip 4:9a80b6d63005 15 * The mbed accesses the PCU9629 registers through I2C.
nxp_ip 7:199f109eb0c6 16 *
nxp_ip 7:199f109eb0c6 17 * About PCA9629:
nxp_ip 7:199f109eb0c6 18 * http://www.nxp.com/products/interface_and_connectivity/i2c/i2c_bus_controller_and_bridge_ics/PCA9629PW.html
nxp_ip 4:9a80b6d63005 19 */
nxp_ip 4:9a80b6d63005 20
nxp_ip 4:9a80b6d63005 21 #ifndef MBED_PCA9629
nxp_ip 4:9a80b6d63005 22 #define MBED_PCA9629
nxp_ip 4:9a80b6d63005 23
nxp_ip 4:9a80b6d63005 24 #define INTELIGENT_WRITE
nxp_ip 4:9a80b6d63005 25
nxp_ip 7:199f109eb0c6 26 #define DEFAULT_STEPS_PER_ROTATION 48
nxp_ip 7:199f109eb0c6 27 #define DEFAULT_PCA9629_ADDR 0x42
nxp_ip 4:9a80b6d63005 28
nxp_ip 4:9a80b6d63005 29 /** PCA9629 class
nxp_ip 4:9a80b6d63005 30 *
nxp_ip 7:199f109eb0c6 31 * This is a driver code for the PCA9629 stepper motor controller.
nxp_ip 7:199f109eb0c6 32 * This class provides interface for PCA9629 operation and accessing its registers.
nxp_ip 7:199f109eb0c6 33 * Detail information is available on next URL.
nxp_ip 7:199f109eb0c6 34 * http://www.nxp.com/products/interface_and_connectivity/i2c/i2c_bus_controller_and_bridge_ics/PCA9629PW.html
nxp_ip 7:199f109eb0c6 35 *
nxp_ip 7:199f109eb0c6 36 * Example:
nxp_ip 7:199f109eb0c6 37 * @code
nxp_ip 7:199f109eb0c6 38 * #include "mbed.h"
nxp_ip 7:199f109eb0c6 39 * #include "PCA9629.h"
nxp_ip 7:199f109eb0c6 40 *
nxp_ip 7:199f109eb0c6 41 * PCA9629 motor( p28, p27, 48 ); // SDA, SCL, Steps/rotation, I2C_address (option)
nxp_ip 7:199f109eb0c6 42 *
nxp_ip 7:199f109eb0c6 43 * int main() {
nxp_ip 7:199f109eb0c6 44 *
nxp_ip 7:199f109eb0c6 45 * // Speed setting 200pps for clockwise (CW) rotation
nxp_ip 7:199f109eb0c6 46 * motor.pps( PCA9629::CW, 200 );
nxp_ip 7:199f109eb0c6 47 *
nxp_ip 7:199f109eb0c6 48 * // Set 2 rotations and 24 steps for CW
nxp_ip 7:199f109eb0c6 49 * motor.rotations_and_steps( PCA9629::CW, 2, 24 );
nxp_ip 7:199f109eb0c6 50 *
nxp_ip 7:199f109eb0c6 51 * // Speed setting 100pps for counterclockwise (CCW) rotation
nxp_ip 7:199f109eb0c6 52 * motor.pps( PCA9629::CCW, 100 );
nxp_ip 7:199f109eb0c6 53 *
nxp_ip 7:199f109eb0c6 54 * // Set 1 rotation and 24 steps for CCW
nxp_ip 7:199f109eb0c6 55 * motor.rotations_and_steps( PCA9629::CCW, 1, 24 );
nxp_ip 7:199f109eb0c6 56 *
nxp_ip 7:199f109eb0c6 57 * while ( 1 ) {
nxp_ip 7:199f109eb0c6 58 * motor.start( PCA9629::CW ); // Motor start for CW
nxp_ip 7:199f109eb0c6 59 * wait( 1.0 );
nxp_ip 7:199f109eb0c6 60 *
nxp_ip 7:199f109eb0c6 61 * motor.start( PCA9629::CCW ); // Motor start for CCW
nxp_ip 7:199f109eb0c6 62 * wait( 1.0 );
nxp_ip 7:199f109eb0c6 63 * }
nxp_ip 7:199f109eb0c6 64 * }
nxp_ip 7:199f109eb0c6 65 * @endcode
nxp_ip 4:9a80b6d63005 66 */
nxp_ip 6:138665018069 67
nxp_ip 7:199f109eb0c6 68
nxp_ip 4:9a80b6d63005 69 class PCA9629 {
nxp_ip 4:9a80b6d63005 70 public:
nxp_ip 7:199f109eb0c6 71 /** name of the PCA9629 registers */
nxp_ip 4:9a80b6d63005 72 typedef enum {
nxp_ip 4:9a80b6d63005 73 MODE, /**< Mode rgister */
nxp_ip 4:9a80b6d63005 74 SUBADR1, /**< I2C-bus subaddress 1 */
nxp_ip 4:9a80b6d63005 75 SUBADR2, /**< I2C-bus subaddress 2 */
nxp_ip 4:9a80b6d63005 76 SUBADR3, /**< I2C-bus subaddress 3 */
nxp_ip 4:9a80b6d63005 77 ALLCALLADR, /**< All call I2C-bus address */
nxp_ip 4:9a80b6d63005 78 WDTOI, /**< Watchdog time-out interval register */
nxp_ip 4:9a80b6d63005 79 WDTCNTL, /**< Watchdog control register */
nxp_ip 4:9a80b6d63005 80 IP, /**< Input port register */
nxp_ip 4:9a80b6d63005 81 INTSTAT, /**< Interrupt status register */
nxp_ip 4:9a80b6d63005 82 OP, /**< Output port register */
nxp_ip 4:9a80b6d63005 83 IOC, /**< I/O configuration register */
nxp_ip 4:9a80b6d63005 84 MSK, /**< Mask interrupt register */
nxp_ip 4:9a80b6d63005 85 CLRINT, /**< Clear Interrupts */
nxp_ip 4:9a80b6d63005 86 INTMODE, /**< Interrupt mode register */
nxp_ip 4:9a80b6d63005 87 INT_ACT_SETUP, /**< Interrupt action setup control register */
nxp_ip 4:9a80b6d63005 88 INT_MTR_SETUP, /**< Interrupt motor setup control register */
nxp_ip 4:9a80b6d63005 89 INT_ES_SETUP, /**< Interrupt extra steps setup control register */
nxp_ip 4:9a80b6d63005 90 INT_AUTO_CLR, /**< Interrupt auto clear control register */
nxp_ip 4:9a80b6d63005 91 SETMODE, /**< Output state on STOP */
nxp_ip 4:9a80b6d63005 92 PHCNTL, /**< Phase control register */
nxp_ip 4:9a80b6d63005 93 SROTNL, /**< Steps per rotation low byte */
nxp_ip 4:9a80b6d63005 94 SROTNH, /**< Steps per rotation high byte */
nxp_ip 4:9a80b6d63005 95 CWPWL, /**< Step pulse width for CW rotation low byte */
nxp_ip 4:9a80b6d63005 96 CWPWH, /**< Step pulse width for CW rotation high byte */
nxp_ip 4:9a80b6d63005 97 CCWPWL, /**< Step pulse width for CCW rotation low byte */
nxp_ip 4:9a80b6d63005 98 CCWPWH, /**< Step pulse width for CCW rotation high byte */
nxp_ip 4:9a80b6d63005 99 CWSCOUNTL, /**< Number of steps CW low byte */
nxp_ip 4:9a80b6d63005 100 CWSCOUNTH, /**< Number of steps CW high byte */
nxp_ip 4:9a80b6d63005 101 CCWSCOUNTL, /**< Number of steps CCW low byte */
nxp_ip 4:9a80b6d63005 102 CCWSCOUNTH, /**< Number of steps CCW high byte */
nxp_ip 4:9a80b6d63005 103 CWRCOUNTL, /**< Number of rotatations CW low byte */
nxp_ip 4:9a80b6d63005 104 CWRCOUNTH, /**< Number of rotatations CW high byte */
nxp_ip 4:9a80b6d63005 105 CCWRCOUNTL, /**< Number of rotatations CCW low byte */
nxp_ip 4:9a80b6d63005 106 CCWRCOUNTH, /**< Number of rotatations CCW high byte */
nxp_ip 4:9a80b6d63005 107 EXTRASTEPS0, /**< Count value for extra steps or rotations for INTP0 */
nxp_ip 4:9a80b6d63005 108 EXTRASTEPS1, /**< Count value for extra steps or rotations for INTP1 */
nxp_ip 4:9a80b6d63005 109 RAMPCNTL, /**< Ramp control register */
nxp_ip 4:9a80b6d63005 110 LOOPDLY, /**< Loopdelay time register */
nxp_ip 4:9a80b6d63005 111 MCNTL, /**< Control start/stop motor */
nxp_ip 4:9a80b6d63005 112 } RegisterName;
nxp_ip 7:199f109eb0c6 113
nxp_ip 7:199f109eb0c6 114 private:
nxp_ip 7:199f109eb0c6 115 /* register names for 2 bytes accessing */
nxp_ip 4:9a80b6d63005 116 typedef enum {
nxp_ip 4:9a80b6d63005 117 SROTN_ = SROTNL | 0x80, /**< Steps per rotation */
nxp_ip 4:9a80b6d63005 118 CWPW_ = CWPWL | 0x80, /**< Step pulse width for CW rotation */
nxp_ip 4:9a80b6d63005 119 CCWPW_ = CCWPWL | 0x80, /**< Step pulse width for CCW rotation */
nxp_ip 4:9a80b6d63005 120 CWSCOUNT_ = CWSCOUNTL | 0x80, /**< Number of steps CW */
nxp_ip 4:9a80b6d63005 121 CCWSCOUNT_ = CCWSCOUNTL | 0x80, /**< Number of steps CCW */
nxp_ip 4:9a80b6d63005 122 CWRCOUNT_ = CWRCOUNTL | 0x80, /**< Number of rotatations CW */
nxp_ip 4:9a80b6d63005 123 CCWRCOUNT_ = CCWRCOUNTL | 0x80, /**< Number of rotatations CCW */
nxp_ip 7:199f109eb0c6 124 } _RegisterNameFor16bitAccess;
nxp_ip 7:199f109eb0c6 125
nxp_ip 7:199f109eb0c6 126 public:
nxp_ip 7:199f109eb0c6 127 /** register names for 2 bytes accessing */
nxp_ip 7:199f109eb0c6 128 typedef enum {
nxp_ip 4:9a80b6d63005 129 STEPS_PER_ROATION = SROTN_,
nxp_ip 4:9a80b6d63005 130 CW__STEP_WIDTH = CWPW_,
nxp_ip 4:9a80b6d63005 131 CCW_STEP_WIDTH = CCWPW_,
nxp_ip 4:9a80b6d63005 132 CW__STEP_COUNT = CWSCOUNT_,
nxp_ip 4:9a80b6d63005 133 CCW_STEP_COUNT = CCWSCOUNT_,
nxp_ip 4:9a80b6d63005 134 CW__ROTATION_COUNT = CWRCOUNT_,
nxp_ip 4:9a80b6d63005 135 CCW_ROTATION_COUNT = CCWRCOUNT_
nxp_ip 7:199f109eb0c6 136 } RegisterNameFor16bitAccess;
nxp_ip 4:9a80b6d63005 137
nxp_ip 4:9a80b6d63005 138 /** keyword to select direction of rotation */
nxp_ip 4:9a80b6d63005 139 typedef enum {
nxp_ip 4:9a80b6d63005 140 CW = 0, /**< Clockwise direction */
nxp_ip 4:9a80b6d63005 141 CCW /**< ConterClockwise direction */
nxp_ip 4:9a80b6d63005 142 } Direction;
nxp_ip 4:9a80b6d63005 143
nxp_ip 4:9a80b6d63005 144 /** Create a PCA9629 instance connected to specified I2C pins with specified address
nxp_ip 4:9a80b6d63005 145 *
nxp_ip 4:9a80b6d63005 146 * @param I2C_sda I2C-bus SDA pin
nxp_ip 4:9a80b6d63005 147 * @param I2C_scl I2C-bus SCL pin
nxp_ip 7:199f109eb0c6 148 * @param steps_per_rotation motor specific setting. This determines how many steps are needed to execute one full turn of motor shaft (360°).
nxp_ip 4:9a80b6d63005 149 * @param I2C_address I2C-bus address (default: 0x42)
nxp_ip 4:9a80b6d63005 150 */
nxp_ip 4:9a80b6d63005 151 PCA9629(
nxp_ip 4:9a80b6d63005 152 PinName I2C_sda,
nxp_ip 4:9a80b6d63005 153 PinName I2C_scl,
nxp_ip 7:199f109eb0c6 154 short steps_per_rotation,
nxp_ip 7:199f109eb0c6 155 char I2C_address = DEFAULT_PCA9629_ADDR
nxp_ip 4:9a80b6d63005 156 );
nxp_ip 4:9a80b6d63005 157
nxp_ip 7:199f109eb0c6 158 /** Software reset
nxp_ip 7:199f109eb0c6 159 *
nxp_ip 7:199f109eb0c6 160 * Performs software reset through I2C bus
nxp_ip 7:199f109eb0c6 161 */
nxp_ip 7:199f109eb0c6 162 void software_reset( void );
nxp_ip 7:199f109eb0c6 163
nxp_ip 4:9a80b6d63005 164 /** Initialize all registers
nxp_ip 4:9a80b6d63005 165 *
nxp_ip 4:9a80b6d63005 166 * The initializing values are defined in the function
nxp_ip 4:9a80b6d63005 167 */
nxp_ip 4:9a80b6d63005 168 void init_registers( void );
nxp_ip 4:9a80b6d63005 169
nxp_ip 4:9a80b6d63005 170 /** Initialize all registers
nxp_ip 4:9a80b6d63005 171 *
nxp_ip 4:9a80b6d63005 172 * The initializing values are defined in the function
nxp_ip 4:9a80b6d63005 173 */
nxp_ip 4:9a80b6d63005 174 void set_all_registers( char *a, char size );
nxp_ip 6:138665018069 175
nxp_ip 4:9a80b6d63005 176 /** Write 1 byte data into a register
nxp_ip 4:9a80b6d63005 177 *
nxp_ip 4:9a80b6d63005 178 * Setting 8 bits data into a register
nxp_ip 4:9a80b6d63005 179 *
nxp_ip 4:9a80b6d63005 180 * @param register_name the register name: data writing into
nxp_ip 4:9a80b6d63005 181 * @param value 8 bits writing data
nxp_ip 4:9a80b6d63005 182 */
nxp_ip 4:9a80b6d63005 183 void write( RegisterName register_name, char value );
nxp_ip 4:9a80b6d63005 184
nxp_ip 4:9a80b6d63005 185 /** Write 2 bytes data into a register
nxp_ip 4:9a80b6d63005 186 *
nxp_ip 4:9a80b6d63005 187 * Setting 16 bits data into registers
nxp_ip 4:9a80b6d63005 188 *
nxp_ip 4:9a80b6d63005 189 * @param register_name the register name: data writing into (it can be "SROTN_", "CWPW_", "CCWPW_", "CWRCOUNT_", "CCWSCOUNT_", "CWRCOUNT_" or "CCWRCOUNT_" )
nxp_ip 4:9a80b6d63005 190 * @param value 16 bits writing data
nxp_ip 4:9a80b6d63005 191 */
nxp_ip 7:199f109eb0c6 192 void write( RegisterNameFor16bitAccess register_name, short value );
nxp_ip 4:9a80b6d63005 193
nxp_ip 4:9a80b6d63005 194 /** Read 1 byte data from a register
nxp_ip 4:9a80b6d63005 195 *
nxp_ip 4:9a80b6d63005 196 * Setting data into a register
nxp_ip 4:9a80b6d63005 197 *
nxp_ip 4:9a80b6d63005 198 * @param register_name the register name: data reading from
nxp_ip 4:9a80b6d63005 199 * @return read 8 bits data from the register
nxp_ip 4:9a80b6d63005 200 */
nxp_ip 4:9a80b6d63005 201 char read( RegisterName register_name );
nxp_ip 4:9a80b6d63005 202
nxp_ip 4:9a80b6d63005 203 /** Read 2 byte data from registers
nxp_ip 4:9a80b6d63005 204 *
nxp_ip 4:9a80b6d63005 205 * Setting data into a register
nxp_ip 4:9a80b6d63005 206 *
nxp_ip 4:9a80b6d63005 207 * @param register_name the register name: data writing into (it can be "SROTN_", "CWPW_", "CCWPW_", "CWRCOUNT_", "CCWSCOUNT_", "CWRCOUNT_" or "CCWRCOUNT_" )
nxp_ip 4:9a80b6d63005 208 * @return read 16 bits data from the registers
nxp_ip 4:9a80b6d63005 209 */
nxp_ip 7:199f109eb0c6 210 short read( RegisterNameFor16bitAccess register_name );
nxp_ip 4:9a80b6d63005 211
nxp_ip 4:9a80b6d63005 212 /** Motor start
nxp_ip 4:9a80b6d63005 213 *
nxp_ip 4:9a80b6d63005 214 * Start command
nxp_ip 4:9a80b6d63005 215 * This function starts motor operation with hard-stop flag and rotation+step enabled, no repeat will be performed
nxp_ip 6:138665018069 216 * If custom start is required, use "write( PCA9629::MCNTL, 0xXX )" to control each bits.
nxp_ip 4:9a80b6d63005 217 *
nxp_ip 4:9a80b6d63005 218 * @param dir rotate direction ("CW" or "CCW")
nxp_ip 4:9a80b6d63005 219 */
nxp_ip 4:9a80b6d63005 220 void start( Direction dir );
nxp_ip 6:138665018069 221
nxp_ip 4:9a80b6d63005 222 /** Motor stop
nxp_ip 4:9a80b6d63005 223 *
nxp_ip 4:9a80b6d63005 224 * Stop command
nxp_ip 4:9a80b6d63005 225 *
nxp_ip 4:9a80b6d63005 226 */
nxp_ip 4:9a80b6d63005 227 void stop( void );
nxp_ip 4:9a80b6d63005 228
nxp_ip 4:9a80b6d63005 229 /** Set PPS
nxp_ip 4:9a80b6d63005 230 *
nxp_ip 4:9a80b6d63005 231 * Setting PulsePerSecond
nxp_ip 4:9a80b6d63005 232 * This interface can be used to set CWPWx or CCWPWx registers
nxp_ip 4:9a80b6d63005 233 *
nxp_ip 4:9a80b6d63005 234 * @param dir rotate direction ("CW" or "CCW")
nxp_ip 6:138665018069 235 * @param pulse_per_second pps defineds pulse width for the motor. The pulse width will be 1/pps
nxp_ip 4:9a80b6d63005 236 * @return 16 bit data that what set to the CWPWx or CCWPWx registers
nxp_ip 4:9a80b6d63005 237 */
nxp_ip 6:138665018069 238 short pps( Direction dir, float pulse_per_second );
nxp_ip 4:9a80b6d63005 239
nxp_ip 7:199f109eb0c6 240 /** Set rotations count
nxp_ip 4:9a80b6d63005 241 *
nxp_ip 4:9a80b6d63005 242 * Setting rotation count
nxp_ip 7:199f109eb0c6 243 * This interfaces CWRCOUNTx and CCWRCOUNTx registers
nxp_ip 4:9a80b6d63005 244 *
nxp_ip 4:9a80b6d63005 245 * @param dir rotate direction ("CW" or "CCW")
nxp_ip 7:199f109eb0c6 246 * @param rotation_count sets number of rotations with 16 bit value
nxp_ip 4:9a80b6d63005 247 */
nxp_ip 7:199f109eb0c6 248 void rotations( Direction dir, int rotation_count );
nxp_ip 4:9a80b6d63005 249
nxp_ip 7:199f109eb0c6 250 /** Set steps count
nxp_ip 4:9a80b6d63005 251 *
nxp_ip 4:9a80b6d63005 252 * Setting step count
nxp_ip 7:199f109eb0c6 253 * This interfaces CWSCOUNTx and CCWSCOUNTx registers
nxp_ip 4:9a80b6d63005 254 *
nxp_ip 4:9a80b6d63005 255 * @param dir rotate direction ("CW" or "CCW")
nxp_ip 7:199f109eb0c6 256 * @param step_count sets number of steps with 16 bit value
nxp_ip 4:9a80b6d63005 257 */
nxp_ip 7:199f109eb0c6 258 void steps( Direction dir, int step_count );
nxp_ip 4:9a80b6d63005 259
nxp_ip 7:199f109eb0c6 260 /** Set rotations and steps counts
nxp_ip 7:199f109eb0c6 261 *
nxp_ip 7:199f109eb0c6 262 * Setting rotation and step count
nxp_ip 7:199f109eb0c6 263 * This interfaces CWRCOUNTx, CCWRCOUNTx, CWSCOUNTx and CCWSCOUNTx registers
nxp_ip 7:199f109eb0c6 264 *
nxp_ip 7:199f109eb0c6 265 * @param dir rotate direction ("CW" or "CCW")
nxp_ip 7:199f109eb0c6 266 * @param rotation_count sets number of rotations with 16 bit value
nxp_ip 7:199f109eb0c6 267 * @param step_count sets number of steps with 16 bit value
nxp_ip 7:199f109eb0c6 268 */
nxp_ip 7:199f109eb0c6 269 void rotations_and_steps( Direction dir, int rotation_count, int step_count );
nxp_ip 4:9a80b6d63005 270
nxp_ip 4:9a80b6d63005 271 /** Register dump
nxp_ip 4:9a80b6d63005 272 *
nxp_ip 4:9a80b6d63005 273 * Dumping all register data to serial console
nxp_ip 4:9a80b6d63005 274 *
nxp_ip 4:9a80b6d63005 275 */
nxp_ip 4:9a80b6d63005 276 void register_dump( void );
nxp_ip 4:9a80b6d63005 277
nxp_ip 4:9a80b6d63005 278 /** Register dump
nxp_ip 4:9a80b6d63005 279 *
nxp_ip 4:9a80b6d63005 280 * Dumping all register data to serial console
nxp_ip 4:9a80b6d63005 281 *
nxp_ip 4:9a80b6d63005 282 */
nxp_ip 4:9a80b6d63005 283 void speed_change( unsigned short pw );
nxp_ip 4:9a80b6d63005 284
nxp_ip 4:9a80b6d63005 285 private:
nxp_ip 7:199f109eb0c6 286 /* plescaler range setting */
nxp_ip 7:199f109eb0c6 287 typedef enum {
nxp_ip 7:199f109eb0c6 288 PRESCALER_FROM_40_TO_333333, /*< Prescaler range from 3us(333333pps) to 24.576ms(40 pps) */
nxp_ip 7:199f109eb0c6 289 PRESCALER_FROM_20_TO_166667, /*< Prescaler range from 6us(166667pps) to 49.152ms(20 pps) */
nxp_ip 7:199f109eb0c6 290 PRESCALER_FROM_10_TO_83333, /*< Prescaler range from 12us( 83333pps) to 98.304ms(10 pps) */
nxp_ip 7:199f109eb0c6 291 PRESCALER_FROM_5_TO_41667, /*< Prescaler range from 24us( 41667pps) to 196.608ms( 5 pps) */
nxp_ip 7:199f109eb0c6 292 PRESCALER_FROM_2_5_TO_20833, /*< Prescaler range from 48us( 20833pps) to 393.216ms( 2.5 pps) */
nxp_ip 7:199f109eb0c6 293 PRESCALER_FROM_1_27_TO_10416, /*< Prescaler range from 96us( 10416pps) to 786.432ms( 1.27pps) */
nxp_ip 7:199f109eb0c6 294 PRESCALER_FROM_0_64_TO_5208, /*< Prescaler range from 192us( 5208pps) to 1572.864ms( 0.64pps) */
nxp_ip 7:199f109eb0c6 295 PRESCALER_FROM_0_32_TO_2604, /*< Prescaler range from 384us( 2604pps) to 3145.728ms( 0.32pps) */
nxp_ip 7:199f109eb0c6 296 } PrescalerRange;
nxp_ip 7:199f109eb0c6 297
nxp_ip 7:199f109eb0c6 298 /* Set PPS
nxp_ip 7:199f109eb0c6 299 *
nxp_ip 7:199f109eb0c6 300 * Setting PulsePerSecond
nxp_ip 7:199f109eb0c6 301 * This interface can be used to set CWPWx or CCWPWx registers
nxp_ip 7:199f109eb0c6 302 *
nxp_ip 7:199f109eb0c6 303 * @param dir rotate direction ("CW" or "CCW")
nxp_ip 7:199f109eb0c6 304 * @param prescaler prescaler setting (for 3 bits setting range from 0 to 0x7. See datasheet)
nxp_ip 7:199f109eb0c6 305 * @param pulse_per_second pps defineds pulse width for the motor. The pulse width will be 1/pps
nxp_ip 7:199f109eb0c6 306 * @return 16 bit data that what set to the CWPWx or CCWPWx registers
nxp_ip 7:199f109eb0c6 307 */
nxp_ip 7:199f109eb0c6 308 short pps( Direction dir, PrescalerRange prescaler, int pulse_per_second );
nxp_ip 6:138665018069 309
nxp_ip 4:9a80b6d63005 310 I2C i2c;
nxp_ip 4:9a80b6d63005 311 char i2c_addr;
nxp_ip 4:9a80b6d63005 312 };
nxp_ip 4:9a80b6d63005 313
nxp_ip 4:9a80b6d63005 314 #endif // MBED_PCA9629
nxp_ip 4:9a80b6d63005 315