Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
TA8428.cpp@0:655b0ede301b, 2013-05-29 (annotated)
- Committer:
- ogata_lab
- Date:
- Wed May 29 13:02:47 2013 +0000
- Revision:
- 0:655b0ede301b
First Commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ogata_lab | 0:655b0ede301b | 1 | /** |
ogata_lab | 0:655b0ede301b | 2 | * @file TA8428.cpp |
ogata_lab | 0:655b0ede301b | 3 | * @brief This library is for controlling TA8428 (full-bridge driver (mainly for motor drive.) |
ogata_lab | 0:655b0ede301b | 4 | * @author Yuki Suga |
ogata_lab | 0:655b0ede301b | 5 | * @mail ysuga@ysuga.net |
ogata_lab | 0:655b0ede301b | 6 | * @affilication Ogata Laboratory, Waseda University |
ogata_lab | 0:655b0ede301b | 7 | * @url http://ogata-lab.jp/ |
ogata_lab | 0:655b0ede301b | 8 | * @copyright 2013, Ogata Laboratory |
ogata_lab | 0:655b0ede301b | 9 | * @license public domain |
ogata_lab | 0:655b0ede301b | 10 | */ |
ogata_lab | 0:655b0ede301b | 11 | |
ogata_lab | 0:655b0ede301b | 12 | #include "mbed.h" |
ogata_lab | 0:655b0ede301b | 13 | #include "TA8428.h" |
ogata_lab | 0:655b0ede301b | 14 | |
ogata_lab | 0:655b0ede301b | 15 | |
ogata_lab | 0:655b0ede301b | 16 | TA8428::TA8428(PinName pin0, PinName pin1, const float period) : |
ogata_lab | 0:655b0ede301b | 17 | p0(pin0), p1(pin1) |
ogata_lab | 0:655b0ede301b | 18 | { |
ogata_lab | 0:655b0ede301b | 19 | p0.period(period); |
ogata_lab | 0:655b0ede301b | 20 | p1.period(period); |
ogata_lab | 0:655b0ede301b | 21 | } |
ogata_lab | 0:655b0ede301b | 22 | |
ogata_lab | 0:655b0ede301b | 23 | TA8428::~TA8428() |
ogata_lab | 0:655b0ede301b | 24 | { |
ogata_lab | 0:655b0ede301b | 25 | |
ogata_lab | 0:655b0ede301b | 26 | } |
ogata_lab | 0:655b0ede301b | 27 | |
ogata_lab | 0:655b0ede301b | 28 | void TA8428::drive(const float pwmPercent) |
ogata_lab | 0:655b0ede301b | 29 | { |
ogata_lab | 0:655b0ede301b | 30 | if (pwmPercent < 0) { |
ogata_lab | 0:655b0ede301b | 31 | p0.write(0.0); |
ogata_lab | 0:655b0ede301b | 32 | p1.write(-pwmPercent); |
ogata_lab | 0:655b0ede301b | 33 | } else { |
ogata_lab | 0:655b0ede301b | 34 | p0.write(pwmPercent); |
ogata_lab | 0:655b0ede301b | 35 | p1.write(0.0); |
ogata_lab | 0:655b0ede301b | 36 | } |
ogata_lab | 0:655b0ede301b | 37 | } |