I2C hang recover function added
Dependencies: UniGraphic mbed vt100
In this version, check_i2c_pins function was added in edge_mgr.cpp.
プログラムの起動時、I2Cモジュールを初期化する前に、I2Cに使用するピンの電位を確認し
もし一方でも Low に張り付いていた場合、SCL を GPIO 出力に設定して
所定回数 (I2C_UNLOCK_TRIAL_CYCLE) 反転させることにより、疑似リセットクロックを生成します。
その後は、通常の起動手順に復帰し、以降はこれまでと同様の動作をします。
Diff: af_utils/pending.cpp
- Revision:
- 0:d895cd1cd897
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/af_utils/pending.cpp Tue Apr 03 08:30:29 2018 +0000 @@ -0,0 +1,55 @@ +#include "mbed.h" +#include "edge_time.h" +#include "pending.h" + +/* +class pending_class { +public: +pending_class() ; +~pending_class() ; + +request_t *request ; +uint32_t submit_time ; +uint32_t replied_time ; +} ; +*/ + +pending_class::pending_class() +{ + submit_time = edge_time ; /* save current time */ + replied_time = 0 ; + request = new request_t ; + request->messageType = 0 ; + request->attrId = 0 ; + request->requestId = 0 ; + request->valueLen = 0 ; + request->p_value = new uint8_t[256] ; +} + +pending_class::pending_class( + uint8_t messageType, + uint16_t attrId, + uint8_t requestId, + uint16_t valueLen, + uint8_t *value +) +{ + submit_time = edge_time ; /* save current time */ + replied_time = 0 ; + request = new request_t ; + request->p_value = new uint8_t[256] ; + request->messageType = messageType ; + request->attrId = attrId ; + request->requestId = requestId ; + request->valueLen = valueLen ; + memcpy(request->p_value, value, valueLen) ; +} + +pending_class::~pending_class() +{ + submit_time = 0 ; + replied_time = 0 ; + delete [] request->p_value ; + request->p_value = 0 ; + delete request ; +} \ No newline at end of file