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) 反転させることにより、疑似リセットクロックを生成します。

その後は、通常の起動手順に復帰し、以降はこれまでと同様の動作をします。

Committer:
Rhyme
Date:
Tue Apr 03 08:30:29 2018 +0000
Revision:
0:d895cd1cd897
Initial I2C Pin force reset function added

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:d895cd1cd897 1 #include "mbed.h"
Rhyme 0:d895cd1cd897 2 #include "edge_time.h"
Rhyme 0:d895cd1cd897 3 #include "pending.h"
Rhyme 0:d895cd1cd897 4
Rhyme 0:d895cd1cd897 5 /*
Rhyme 0:d895cd1cd897 6 class pending_class {
Rhyme 0:d895cd1cd897 7 public:
Rhyme 0:d895cd1cd897 8 pending_class() ;
Rhyme 0:d895cd1cd897 9 ~pending_class() ;
Rhyme 0:d895cd1cd897 10
Rhyme 0:d895cd1cd897 11 request_t *request ;
Rhyme 0:d895cd1cd897 12 uint32_t submit_time ;
Rhyme 0:d895cd1cd897 13 uint32_t replied_time ;
Rhyme 0:d895cd1cd897 14 } ;
Rhyme 0:d895cd1cd897 15 */
Rhyme 0:d895cd1cd897 16
Rhyme 0:d895cd1cd897 17 pending_class::pending_class()
Rhyme 0:d895cd1cd897 18 {
Rhyme 0:d895cd1cd897 19 submit_time = edge_time ; /* save current time */
Rhyme 0:d895cd1cd897 20 replied_time = 0 ;
Rhyme 0:d895cd1cd897 21 request = new request_t ;
Rhyme 0:d895cd1cd897 22 request->messageType = 0 ;
Rhyme 0:d895cd1cd897 23 request->attrId = 0 ;
Rhyme 0:d895cd1cd897 24 request->requestId = 0 ;
Rhyme 0:d895cd1cd897 25 request->valueLen = 0 ;
Rhyme 0:d895cd1cd897 26 request->p_value = new uint8_t[256] ;
Rhyme 0:d895cd1cd897 27 }
Rhyme 0:d895cd1cd897 28
Rhyme 0:d895cd1cd897 29 pending_class::pending_class(
Rhyme 0:d895cd1cd897 30 uint8_t messageType,
Rhyme 0:d895cd1cd897 31 uint16_t attrId,
Rhyme 0:d895cd1cd897 32 uint8_t requestId,
Rhyme 0:d895cd1cd897 33 uint16_t valueLen,
Rhyme 0:d895cd1cd897 34 uint8_t *value
Rhyme 0:d895cd1cd897 35 )
Rhyme 0:d895cd1cd897 36 {
Rhyme 0:d895cd1cd897 37 submit_time = edge_time ; /* save current time */
Rhyme 0:d895cd1cd897 38 replied_time = 0 ;
Rhyme 0:d895cd1cd897 39 request = new request_t ;
Rhyme 0:d895cd1cd897 40 request->p_value = new uint8_t[256] ;
Rhyme 0:d895cd1cd897 41 request->messageType = messageType ;
Rhyme 0:d895cd1cd897 42 request->attrId = attrId ;
Rhyme 0:d895cd1cd897 43 request->requestId = requestId ;
Rhyme 0:d895cd1cd897 44 request->valueLen = valueLen ;
Rhyme 0:d895cd1cd897 45 memcpy(request->p_value, value, valueLen) ;
Rhyme 0:d895cd1cd897 46 }
Rhyme 0:d895cd1cd897 47
Rhyme 0:d895cd1cd897 48 pending_class::~pending_class()
Rhyme 0:d895cd1cd897 49 {
Rhyme 0:d895cd1cd897 50 submit_time = 0 ;
Rhyme 0:d895cd1cd897 51 replied_time = 0 ;
Rhyme 0:d895cd1cd897 52 delete [] request->p_value ;
Rhyme 0:d895cd1cd897 53 request->p_value = 0 ;
Rhyme 0:d895cd1cd897 54 delete request ;
Rhyme 0:d895cd1cd897 55 }