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) 反転させることにより、疑似リセットクロックを生成します。
その後は、通常の起動手順に復帰し、以降はこれまでと同様の動作をします。
edge_sensor/edge_pressure.h@2:de22987be9ba, 2018-06-18 (annotated)
- Committer:
- gaku_miyagawa
- Date:
- Mon Jun 18 02:55:38 2018 +0000
- Revision:
- 2:de22987be9ba
- Parent:
- 0:d895cd1cd897
SBU SPECIAL
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Rhyme | 0:d895cd1cd897 | 1 | #ifndef _EDGE_PRESSURE_H_ |
Rhyme | 0:d895cd1cd897 | 2 | #define _EDGE_PRESSURE_H_ |
Rhyme | 0:d895cd1cd897 | 3 | #include "mbed.h" |
Rhyme | 0:d895cd1cd897 | 4 | #include "edge_sensor.h" |
Rhyme | 0:d895cd1cd897 | 5 | #include "PSE530.h" |
Rhyme | 0:d895cd1cd897 | 6 | |
Rhyme | 0:d895cd1cd897 | 7 | /** |
Rhyme | 0:d895cd1cd897 | 8 | * edge_pressure edge_sensor for measuring gas presssure |
Rhyme | 0:d895cd1cd897 | 9 | */ |
Rhyme | 0:d895cd1cd897 | 10 | |
Rhyme | 0:d895cd1cd897 | 11 | class edge_pressure : public edge_sensor { |
Rhyme | 0:d895cd1cd897 | 12 | public: |
Rhyme | 0:d895cd1cd897 | 13 | /** |
Rhyme | 0:d895cd1cd897 | 14 | * constructor |
Rhyme | 0:d895cd1cd897 | 15 | * @param *pse PSE530 pressure sensor object |
Rhyme | 0:d895cd1cd897 | 16 | */ |
Rhyme | 0:d895cd1cd897 | 17 | edge_pressure(PSE530 *pse, DigitalOut *en) ; |
Rhyme | 0:d895cd1cd897 | 18 | |
Rhyme | 0:d895cd1cd897 | 19 | /** |
Rhyme | 0:d895cd1cd897 | 20 | * destructor |
Rhyme | 0:d895cd1cd897 | 21 | */ |
Rhyme | 0:d895cd1cd897 | 22 | ~edge_pressure(void) ; |
Rhyme | 0:d895cd1cd897 | 23 | |
Rhyme | 0:d895cd1cd897 | 24 | /** |
Rhyme | 0:d895cd1cd897 | 25 | * reset and clear internal values |
Rhyme | 0:d895cd1cd897 | 26 | */ |
Rhyme | 0:d895cd1cd897 | 27 | virtual void reset(void) ; |
Rhyme | 0:d895cd1cd897 | 28 | |
Rhyme | 0:d895cd1cd897 | 29 | /** |
Rhyme | 0:d895cd1cd897 | 30 | * prepare for sampling (not used) |
Rhyme | 0:d895cd1cd897 | 31 | */ |
Rhyme | 0:d895cd1cd897 | 32 | virtual void prepare(void) ; |
Rhyme | 0:d895cd1cd897 | 33 | |
Rhyme | 0:d895cd1cd897 | 34 | /** |
Rhyme | 0:d895cd1cd897 | 35 | * sample the value |
Rhyme | 0:d895cd1cd897 | 36 | * @returns 0: success non-0: failure |
Rhyme | 0:d895cd1cd897 | 37 | */ |
Rhyme | 0:d895cd1cd897 | 38 | virtual int sample(void) ; |
Rhyme | 0:d895cd1cd897 | 39 | |
Rhyme | 0:d895cd1cd897 | 40 | /** |
Rhyme | 0:d895cd1cd897 | 41 | * deliver the sampled value to afero cloud |
Rhyme | 0:d895cd1cd897 | 42 | */ |
Rhyme | 0:d895cd1cd897 | 43 | virtual int deliver(void) ; |
Rhyme | 0:d895cd1cd897 | 44 | |
Rhyme | 0:d895cd1cd897 | 45 | /** |
Rhyme | 0:d895cd1cd897 | 46 | * show the value in the display (TFT) |
Rhyme | 0:d895cd1cd897 | 47 | */ |
Rhyme | 0:d895cd1cd897 | 48 | virtual void show(void) ; |
Rhyme | 0:d895cd1cd897 | 49 | // virtual void send_config(void) ; /* send config data to cloud */ |
Rhyme | 0:d895cd1cd897 | 50 | // virtual void recv_config(void) ; /* receive config data from cloud */ |
Rhyme | 0:d895cd1cd897 | 51 | |
Rhyme | 0:d895cd1cd897 | 52 | /** |
Rhyme | 0:d895cd1cd897 | 53 | * get_value sample sensor value and calcurate it to the metric value |
Rhyme | 0:d895cd1cd897 | 54 | * @returns measured value in kgf/cm2 |
Rhyme | 0:d895cd1cd897 | 55 | */ |
Rhyme | 0:d895cd1cd897 | 56 | float get_value(void) ; |
Rhyme | 0:d895cd1cd897 | 57 | |
Rhyme | 0:d895cd1cd897 | 58 | /** |
Rhyme | 0:d895cd1cd897 | 59 | * Set threshold mode |
Rhyme | 0:d895cd1cd897 | 60 | * @param mode int 0: absolute value 1: relative value in percent |
Rhyme | 0:d895cd1cd897 | 61 | */ |
Rhyme | 0:d895cd1cd897 | 62 | void set_thr_mode(int mode) { _thr_mode = mode ; } |
Rhyme | 0:d895cd1cd897 | 63 | |
Rhyme | 0:d895cd1cd897 | 64 | /** |
Rhyme | 0:d895cd1cd897 | 65 | * Get threshold mode |
Rhyme | 0:d895cd1cd897 | 66 | * @returns the mode 0: absolute value 1: relative value in percent |
Rhyme | 0:d895cd1cd897 | 67 | */ |
Rhyme | 0:d895cd1cd897 | 68 | int get_thr_mode(void) { return _thr_mode ; } |
Rhyme | 0:d895cd1cd897 | 69 | |
Rhyme | 0:d895cd1cd897 | 70 | /** |
Rhyme | 0:d895cd1cd897 | 71 | * Set higher threshold |
Rhyme | 0:d895cd1cd897 | 72 | * @param thr_high int16_t the higher threshold |
Rhyme | 0:d895cd1cd897 | 73 | */ |
Rhyme | 0:d895cd1cd897 | 74 | void set_thr_high(int16_t thr_high) ; |
Rhyme | 0:d895cd1cd897 | 75 | |
Rhyme | 0:d895cd1cd897 | 76 | /** |
Rhyme | 0:d895cd1cd897 | 77 | * Get higher threshold, the value is calcurated with expected value |
Rhyme | 0:d895cd1cd897 | 78 | * @param expected float the expected pressure value for current temperature |
Rhyme | 0:d895cd1cd897 | 79 | */ |
Rhyme | 0:d895cd1cd897 | 80 | float get_thr_high(float expected) ; |
Rhyme | 0:d895cd1cd897 | 81 | |
Rhyme | 0:d895cd1cd897 | 82 | /** |
Rhyme | 0:d895cd1cd897 | 83 | * Set lower threshold |
Rhyme | 0:d895cd1cd897 | 84 | * @param thr_low int16_t the lower threshold |
Rhyme | 0:d895cd1cd897 | 85 | */ |
Rhyme | 0:d895cd1cd897 | 86 | void set_thr_low(int16_t thr_low) ; |
Rhyme | 0:d895cd1cd897 | 87 | |
Rhyme | 0:d895cd1cd897 | 88 | /** |
Rhyme | 0:d895cd1cd897 | 89 | * Get lower threshold, the value is calcurated with expected value |
Rhyme | 0:d895cd1cd897 | 90 | * @param expected float the expected pressure value for current temperature |
Rhyme | 0:d895cd1cd897 | 91 | */ |
Rhyme | 0:d895cd1cd897 | 92 | float get_thr_low(float expected) ; |
Rhyme | 0:d895cd1cd897 | 93 | |
Rhyme | 0:d895cd1cd897 | 94 | /** |
Rhyme | 0:d895cd1cd897 | 95 | * draw triangle pointer for GAS pressure mode display |
Rhyme | 0:d895cd1cd897 | 96 | */ |
Rhyme | 0:d895cd1cd897 | 97 | |
Rhyme | 0:d895cd1cd897 | 98 | void drawPointer(int c) ; |
Rhyme | 0:d895cd1cd897 | 99 | |
Rhyme | 0:d895cd1cd897 | 100 | private: |
Rhyme | 0:d895cd1cd897 | 101 | PSE530 *_pse ; |
Rhyme | 0:d895cd1cd897 | 102 | DigitalOut *_en ; |
Rhyme | 0:d895cd1cd897 | 103 | float _value ; |
Rhyme | 0:d895cd1cd897 | 104 | float _thr_high ; |
Rhyme | 0:d895cd1cd897 | 105 | float _thr_low ; |
Rhyme | 0:d895cd1cd897 | 106 | int _thr_mode ; |
Rhyme | 0:d895cd1cd897 | 107 | float _expected ; |
Rhyme | 0:d895cd1cd897 | 108 | float _higher ; |
Rhyme | 0:d895cd1cd897 | 109 | float _lower ; |
Rhyme | 0:d895cd1cd897 | 110 | } ; |
Rhyme | 0:d895cd1cd897 | 111 | |
Rhyme | 0:d895cd1cd897 | 112 | float temp2expected(float temp) ; |
Rhyme | 0:d895cd1cd897 | 113 | extern float *current_temp ; |
Rhyme | 0:d895cd1cd897 | 114 | |
Rhyme | 0:d895cd1cd897 | 115 | #endif /* _EDGE_PRESSURE_H_ */ |