トランジスタ技術2015年6月号 mbed ラジコン・カーp169-p184掲載

Dependencies:   mbed

Committer:
YoshihitoShimada
Date:
Mon Jun 01 02:03:38 2015 +0000
Revision:
0:6228c3688e54
mbed test sample code

Who changed what in which revision?

UserRevisionLine numberNew contents of line
YoshihitoShimada 0:6228c3688e54 1 #include "mbed.h"
YoshihitoShimada 0:6228c3688e54 2 #pragma once
YoshihitoShimada 0:6228c3688e54 3
YoshihitoShimada 0:6228c3688e54 4 #define AQTK_I2C_ADDR (0x2E<<1)
YoshihitoShimada 0:6228c3688e54 5 #define AQTK_STARTUP_WAIT_MS 80
YoshihitoShimada 0:6228c3688e54 6 #define AQTK_POLL_WAIT_MS 10
YoshihitoShimada 0:6228c3688e54 7
YoshihitoShimada 0:6228c3688e54 8 /** ATP3012 class
YoshihitoShimada 0:6228c3688e54 9 *
YoshihitoShimada 0:6228c3688e54 10 * AquesTalk pico LSI I2C interface
YoshihitoShimada 0:6228c3688e54 11 * Example:
YoshihitoShimada 0:6228c3688e54 12 * @code
YoshihitoShimada 0:6228c3688e54 13 * #include "ATP3012.h"
YoshihitoShimada 0:6228c3688e54 14 * ATP3012 talk(P0_10,P0_11); // I2C sda scl
YoshihitoShimada 0:6228c3688e54 15 *
YoshihitoShimada 0:6228c3688e54 16 * int main() {
YoshihitoShimada 0:6228c3688e54 17 * talk.Synthe("konnichiwa.");
YoshihitoShimada 0:6228c3688e54 18 * for(int n = 1; ; n++) {
YoshihitoShimada 0:6228c3688e54 19 * char buf[32];
YoshihitoShimada 0:6228c3688e54 20 * snprintf(buf, sizeof(buf), "<NUMK VAL=%d>.", n);
YoshihitoShimada 0:6228c3688e54 21 * talk.Synthe(buf);
YoshihitoShimada 0:6228c3688e54 22 * }
YoshihitoShimada 0:6228c3688e54 23 * }
YoshihitoShimada 0:6228c3688e54 24 * @endcode
YoshihitoShimada 0:6228c3688e54 25 *
YoshihitoShimada 0:6228c3688e54 26 */
YoshihitoShimada 0:6228c3688e54 27 class ATP3012 {
YoshihitoShimada 0:6228c3688e54 28 public:
YoshihitoShimada 0:6228c3688e54 29 /** Create a AquesTalk pico LSI I2C interface
YoshihitoShimada 0:6228c3688e54 30 *
YoshihitoShimada 0:6228c3688e54 31 * @param sda I2C data pin
YoshihitoShimada 0:6228c3688e54 32 * @param scl I2C clock pin
YoshihitoShimada 0:6228c3688e54 33 * @param addr I2C address
YoshihitoShimada 0:6228c3688e54 34 */
YoshihitoShimada 0:6228c3688e54 35 ATP3012(PinName sda, PinName scl, int addr = AQTK_I2C_ADDR);
YoshihitoShimada 0:6228c3688e54 36 bool IsActive(int timeout_ms = 500);
YoshihitoShimada 0:6228c3688e54 37 void Synthe(const char* msg);
YoshihitoShimada 0:6228c3688e54 38 void Write(const char* msg);
YoshihitoShimada 0:6228c3688e54 39 bool IsBusy();
YoshihitoShimada 0:6228c3688e54 40 private:
YoshihitoShimada 0:6228c3688e54 41 int _addr;
YoshihitoShimada 0:6228c3688e54 42 I2C _i2c;
YoshihitoShimada 0:6228c3688e54 43 Timer _poll_wait;
YoshihitoShimada 0:6228c3688e54 44 };
YoshihitoShimada 0:6228c3688e54 45