トランジスタ技術2015年6月号mbedラジコン・カーp182 リスト3 音声合成LSIのmbedメイン・プログラム

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers ATP3012.h Source File

ATP3012.h

00001 #include "mbed.h"
00002 #pragma once
00003  
00004 #define AQTK_I2C_ADDR (0x2E<<1)
00005 #define AQTK_STARTUP_WAIT_MS 80
00006 #define AQTK_POLL_WAIT_MS 10
00007  
00008 /** ATP3012 class
00009  *
00010  * AquesTalk pico LSI I2C interface
00011  * Example:
00012  * @code
00013  *      #include "ATP3012.h"
00014  *      ATP3012 talk(P0_10,P0_11); // I2C sda scl
00015  *      
00016  *      int main() {
00017  *          talk.Synthe("konnichiwa.");
00018  *          for(int n = 1; ; n++) {
00019  *              char buf[32];
00020  *              snprintf(buf, sizeof(buf), "<NUMK VAL=%d>.", n);
00021  *              talk.Synthe(buf);
00022  *          }
00023  *      } 
00024  * @endcode
00025  *
00026  */
00027 class ATP3012 {
00028 public:
00029     /** Create a AquesTalk pico LSI I2C interface
00030      *
00031      * @param sda  I2C data pin
00032      * @param scl  I2C clock pin
00033      * @param addr I2C address
00034      */
00035     ATP3012(PinName sda, PinName scl, int addr = AQTK_I2C_ADDR);
00036     bool IsActive(int timeout_ms = 500);
00037     void Synthe(const char* msg);
00038     void Write(const char* msg);
00039     bool IsBusy();
00040 private:
00041     int _addr;
00042     I2C _i2c; 
00043     Timer _poll_wait;
00044 };
00045