jacobrosenthal commented on issue #757: HW driver: drv2605l URL: https://github.com/apache/mynewt-core/pull/757#issuecomment-361089441 Merged that branch here. Also just put everything in sensor creator so theres an obvious example, we can just rebase that out if people dont like it For anyone here who might have a drv2605 and an LRA lying around, heres a starting point and something that can be a tutorial soon: My syscfg. This is the hardest part as need to read the drv2605l datasheet or get a bunch of numbers from your motor manufacturer so you can override your motors voltage and other settings. ``` I2C_0: 1 #drv2605 DRV2605_OFB: 1 DRV2605_EN_PIN: 30 DRV2605_CLI: 1 DRV2605_LOG: 1 DRV2605_STATS: 1 #jinlong LVM061930 2.0v 2.35max 180hz DRV2605_RATED_VOLTAGE: 0x53 # See 8.5.2.1 Rated Voltage Programming DRV2605_OD_CLAMP: 0x69 # '8.5.2.2 Overdrive Voltage-Clamp Programming, Note: LRA and ERM (8) and (9) equations are swapped in the "SLOS854C REVISED SEPTEMBER 2014" datasheet, confirmed https://e2e.ti.com/support/other_analog/haptics/f/927/t/655886' DRV2605_DRIVE_TIME: 23 #8.6.21 LRA DRIVE_TIME = (0.5 ? (1/fLRA * 1000) - 0.5 ms) / 0.1 ms ``` Ill use the sensors_test app, my target.yml: ``` ### Target: targets/sensors-thingy target.app: "@apache-mynewt-core/apps/sensors_test" target.bsp: "@apache-mynewt-core/hw/bsp/nrf52-thingy" target.build_profile: "optimized" ``` Add the driver in your target's pkg.yml, though note this is already done for the sensor_test example ``` pkg.deps: "@apache-mynewt-core/hw/drivers/drv2605" ``` Run the app with perhaps `newt run sensors-thingy 0` Connect to your shell. I recommend first things first see if you can talk to device with ``` 053273 compat> drv2605 chip_id drv2605 chip_id 118613 0x07 ``` next see if your motor numbers work (make sure your motor is secured to something, this will fail otherwise) ``` 118613 compat> drv2605 op_mode diag drv2605 op_mode diag 120858 op_mode succeeded ``` If that didnt work or you didnt have good values overriden from before youll need to generate them if you need to autocal your device you can do that from here too with autocal and no params to get the default best guess ``` 001407 compat> drv2605 op_mode cal drv2605 op_mode cal 001931 op_mode succeeded drv2605 dump_cal DRV2605_CALIBRATED_COMP: 0x09 DRV2605_CALIBRATED_BEMF: 0x79 DRV2605_CALIBRATED_BEMF_GAIN: 1 ``` now youd want to save these as overrides in your target's syscfg.yml and restart Now you're ready to (sigh) rumble Enable the rom mode to use the stored patterns: ``` 021773 compat> drv2605 op_mode rom drv2605 op_mode rom 037245 op_mode succeeded ``` Load some of the internal roms, 4 hard clicks (1) with max delays in between (255) ``` 120858 compat> drv2605 load 1 255 1 255 1 255 1 255 drv2605 load 1 255 1 255 1 255 1 255 122555 Load succeeded ``` The motor is in standby by default so enable it ``` 002111 compat> drv2605 power_mode active drv2605 power_mode active 003263 power_mode succeeded ``` now you can trigger those forms, as many times as you want, or load new forms and trigger again. ``` 122555 compat> drv2605 trigger drv2605 trigger 128806 Trigger succeeded ``` Its handy to dump the register contents as you're poking around to see if what you think you did worked ``` 001931 compat> drv2605 dump_all drv2605 dump_all 069774 reg 0x:00 = 0xE0 069774 reg 0x:01 = 0x40 069774 reg 0x:02 = 0x00 069774 reg 0x:03 = 0x06 069774 reg 0x:04 = 0x01 069774 reg 0x:05 = 0xFF 069774 reg 0x:06 = 0x01 069774 reg 0x:07 = 0xFF 069775 reg 0x:08 = 0x01 069775 reg 0x:09 = 0xFF 069775 reg 0x:0A = 0x01 069775 reg 0x:0B = 0xFF 069775 reg 0x:0C = 0x00 069775 reg 0x:0D = 0x00 069775 reg 0x:0E = 0x00 069775 reg 0x:0F = 0x00 069775 reg 0x:10 = 0x00 069775 reg 0x:11 = 0x05 069775 reg 0x:12 = 0x19 069775 reg 0x:13 = 0xFF 069775 reg 0x:14 = 0x19 069775 reg 0x:15 = 0xFF 069775 reg 0x:16 = 0x3E 069775 reg 0x:17 = 0x89 069775 reg 0x:18 = 0x2C 069775 reg 0x:19 = 0x49 069775 reg 0x:1A = 0xB7 069775 reg 0x:1B = 0x93 069775 reg 0x:1C = 0x2E 069775 reg 0x:1D = 0x00 069775 reg 0x:1E = 0x20 069775 reg 0x:1F = 0x00 069776 reg 0x:20 = 0x33 069776 reg 0x:21 = 0x6F 069776 reg 0x:22 = 0x3D 069776 compat> ``` you can also peek and poke individual registers, ill manually take it out of standby ``` 074759 compat> drv2605 poke 1 0 drv2605 poke 1 0 083307 Wrote: 0x00 to 0x01 083307 compat> drv2605 peek 1 drv2605 peek 1 083883 Value: 0x00 ```
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services