AquesTalk pico LSI I2C interface

Dependents:   CanSat-C

音声合成LSI AquesTalk pico ATP3011のI2Cインターフェースです。

main.cpp

#include "mbed.h"
#include "ATP3011.h"
ATP3011 talk(P0_0, P0_1); // sda,scl LPC810
RawSerial pc(P0_4, P0_6); // tx,rx

int main()
{
    if (talk.IsActive()) {
        pc.puts("ATP3011 OK\r\n");
    } else {
        pc.puts("ATP3011 NG\r\n");
        while(1); // forever
    }
    const char* msg = "konnitiwa.";
    pc.puts(msg);pc.puts("\r\n");
    talk.Synthe(msg);
    char buf[32];
    for(int n = 1; ; n++) {
        snprintf(buf, sizeof(buf), "<NUMK VAL=%d>.", n);
        pc.puts(buf);pc.puts("\r\n");
        talk.Synthe(buf);
    }
}


参考:
[Arduino] AquesTalk pico LSI を I2C で制御する | N.Yamazaki's blog
音声記号列生成 Webサービス - AquesTalk - 株式会社アクエスト

Revision:
0:afbfc810f82e
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ATP3011.h	Tue Jan 07 23:57:49 2014 +0000
@@ -0,0 +1,44 @@
+#include "mbed.h"
+#pragma once
+
+#define AQTK_I2C_ADDR (0x2E<<1)
+#define AQTK_STARTUP_WAIT_MS 80
+#define AQTK_POLL_WAIT_MS 10
+
+/** ATP3011 class
+ *
+ * AquesTalk pico LSI I2C interface
+ * Example:
+ * @code
+ *      #include "ATP3011.h"
+ *      ATP3011 talk(P0_10,P0_11); // I2C sda scl
+ *      
+ *      int main() {
+ *          talk.Synthe("konnichiwa.");
+ *          for(int n = 1; ; n++) {
+ *              char buf[32];
+ *              snprintf(buf, sizeof(buf), "<NUMK VAL=%d>.", n);
+ *              talk.Synthe(buf);
+ *          }
+ *      } 
+ * @endcode
+ *
+ */
+class ATP3011 {
+public:
+    /** Create a AquesTalk pico LSI I2C interface
+     *
+     * @param sda  I2C data pin
+     * @param scl  I2C clock pin
+     * @param addr I2C address
+     */
+    ATP3011(PinName sda, PinName scl, int addr = AQTK_I2C_ADDR);
+    bool IsActive(int timeout_ms = 500);
+    void Synthe(const char* msg);
+    void Write(const char* msg);
+    bool IsBusy();
+private:
+    int _addr;
+    I2C _i2c; 
+    Timer _poll_wait;
+};