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.
Dependencies: mbed
ATP3012.cpp
00001 #include "ATP3012.h" 00002 00003 ATP3012::ATP3012(PinName sda, PinName scl, int addr):_i2c(sda, scl) 00004 { 00005 _addr = addr; 00006 _poll_wait.reset(); 00007 _poll_wait.start(); 00008 } 00009 00010 bool ATP3012::IsActive(int timeout_ms) 00011 { 00012 wait_ms(AQTK_STARTUP_WAIT_MS); 00013 Timer t; 00014 t.reset(); 00015 t.start(); 00016 while(t.read_ms() < timeout_ms) { 00017 _poll_wait.reset(); 00018 if (_i2c.write(_addr, NULL, 0) == 0) { 00019 return true; 00020 } 00021 wait_ms(AQTK_POLL_WAIT_MS); 00022 } 00023 return false; 00024 } 00025 00026 void ATP3012::Synthe(const char* msg) 00027 { 00028 while(IsBusy()) { 00029 ; 00030 } 00031 Write(msg); 00032 Write("\r"); 00033 } 00034 00035 void ATP3012::Write(const char *msg) 00036 { 00037 _i2c.write(_addr, msg, strlen(msg)); 00038 _poll_wait.reset(); 00039 } 00040 00041 bool ATP3012::IsBusy() 00042 { 00043 if (AQTK_POLL_WAIT_MS > _poll_wait.read_ms()) { 00044 return true; 00045 } 00046 _poll_wait.reset(); 00047 char c = 0x00; 00048 if (_i2c.read(_addr, &c, 1) != 0) { 00049 return false; 00050 } 00051 return c == '*' || c == 0xff; 00052 }
Generated on Wed Jul 13 2022 17:54:14 by
1.7.2