![](/media/cache/group/1711.jpg.50x50_q85.jpg)
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: edge_utils/edge_chart.cpp
- Revision:
- 0:d895cd1cd897
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/edge_utils/edge_chart.cpp Tue Apr 03 08:30:29 2018 +0000 @@ -0,0 +1,56 @@ +#include "mbed.h" +#include "edge_mgr.h" +#include "edge_reset_mgr.h" +#include "edge_chart.h" +#if 0 +typedef struct _edge_chart_st { + char *name ; + int left ; + int top ; + int width ; + int height ; + int index ; + int min ; + int max ; +} edge_chart_type ; + +extern edge_chart_type edge_chart[] ; +#endif + +edge_chart_type edge_chart[] = { +/* name, left, top, width, height, index, min, max */ + { "Accel", 0, 0, 160, 60, 0, -0.2, 0.2 }, + { "Color", 160, 0, 160, 120, 0, 0.0, 10000.0 }, + { "Color2", 160, 120, 160, 120, 0, 0.0, 10000.0 }, + { "Temp", 0, 120, 160, 120, 0, -10.0, 50.0 }, + { "Press", 0, 60, 160, 60, 0, -1.0, 5.0 }, + { 0, 0, 0, 0, 0, 0, 0.0, 0.0 } +} ; + +void draw_chart_frame(edge_chart_type *p) +{ + if (display) { + display->fillrect(p->left+1, p->top+1, + p->left + p->width - 2, p->top + p->height - 2, Black) ; + display->rect(p->left, p->top, + p->left + p->width - 1, + p->top + p->height -1, Blue) ; + display->set_font((unsigned char*) Arial12x12); + display->foreground(White) ; + display->locate(p->left + 5, p->top + 5) ; + display->printf(p->name) ; + } +} + +void draw_all_chart_frame(void) +{ + edge_chart_type *p ; + if (display) { + reset_watch_dog() ; + display->BusEnable(true) ; + for(p = edge_chart ; p->name ; p++ ) { + draw_chart_frame(p) ; + } + display->BusEnable(false) ; + } +} \ No newline at end of file