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) 反転させることにより、疑似リセットクロックを生成します。
その後は、通常の起動手順に復帰し、以降はこれまでと同様の動作をします。
afLib/Command.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 | /** |
Rhyme | 0:d895cd1cd897 | 2 | * Copyright 2015 Afero, Inc. |
Rhyme | 0:d895cd1cd897 | 3 | * |
Rhyme | 0:d895cd1cd897 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
Rhyme | 0:d895cd1cd897 | 5 | * you may not use this file except in compliance with the License. |
Rhyme | 0:d895cd1cd897 | 6 | * You may obtain a copy of the License at |
Rhyme | 0:d895cd1cd897 | 7 | * |
Rhyme | 0:d895cd1cd897 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Rhyme | 0:d895cd1cd897 | 9 | * |
Rhyme | 0:d895cd1cd897 | 10 | * Unless required by applicable law or agreed to in writing, software |
Rhyme | 0:d895cd1cd897 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
Rhyme | 0:d895cd1cd897 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
Rhyme | 0:d895cd1cd897 | 13 | * See the License for the specific language governing permissions and |
Rhyme | 0:d895cd1cd897 | 14 | * limitations under the License. |
Rhyme | 0:d895cd1cd897 | 15 | */ |
Rhyme | 0:d895cd1cd897 | 16 | |
Rhyme | 0:d895cd1cd897 | 17 | #ifndef COMMAND_H__ |
Rhyme | 0:d895cd1cd897 | 18 | #define COMMAND_H__ |
Rhyme | 0:d895cd1cd897 | 19 | |
Rhyme | 0:d895cd1cd897 | 20 | #include "mbed.h" //wsugi |
Rhyme | 0:d895cd1cd897 | 21 | #include <string> //wsugi |
Rhyme | 0:d895cd1cd897 | 22 | |
Rhyme | 0:d895cd1cd897 | 23 | using namespace std; //wsugi |
Rhyme | 0:d895cd1cd897 | 24 | |
Rhyme | 0:d895cd1cd897 | 25 | #define SPI_CMD_MAX_LEN 256 |
Rhyme | 0:d895cd1cd897 | 26 | |
Rhyme | 0:d895cd1cd897 | 27 | #define UPDATE_REASON_UNKNOWN 0 |
Rhyme | 0:d895cd1cd897 | 28 | #define UPDATE_REASON_LOCAL_UPDATE 1 |
Rhyme | 0:d895cd1cd897 | 29 | #define UPDATE_REASON_SERVICE_SET 2 |
Rhyme | 0:d895cd1cd897 | 30 | #define UPDATE_REASON_MCU_SET 3 |
Rhyme | 0:d895cd1cd897 | 31 | #define UPDATE_REASON_RELINK 4 |
Rhyme | 0:d895cd1cd897 | 32 | #define UPDATE_REASON_REBOOT 5 |
Rhyme | 0:d895cd1cd897 | 33 | |
Rhyme | 0:d895cd1cd897 | 34 | class Command { |
Rhyme | 0:d895cd1cd897 | 35 | public: |
Rhyme | 0:d895cd1cd897 | 36 | Command(uint16_t len, uint8_t *bytes); |
Rhyme | 0:d895cd1cd897 | 37 | |
Rhyme | 0:d895cd1cd897 | 38 | Command(uint8_t requestId, const char *str); |
Rhyme | 0:d895cd1cd897 | 39 | |
Rhyme | 0:d895cd1cd897 | 40 | Command(uint8_t requestId, uint8_t cmd, uint16_t attrId); |
Rhyme | 0:d895cd1cd897 | 41 | |
Rhyme | 0:d895cd1cd897 | 42 | Command(uint8_t requestId, uint8_t cmd, uint16_t attrId, uint16_t valueLen, uint8_t *value); |
Rhyme | 0:d895cd1cd897 | 43 | |
Rhyme | 0:d895cd1cd897 | 44 | Command(uint8_t requestId, uint8_t cmd, uint16_t attrId, uint8_t status, uint8_t reason, uint16_t valueLen, |
Rhyme | 0:d895cd1cd897 | 45 | uint8_t *value); |
Rhyme | 0:d895cd1cd897 | 46 | |
Rhyme | 0:d895cd1cd897 | 47 | Command(); |
Rhyme | 0:d895cd1cd897 | 48 | |
Rhyme | 0:d895cd1cd897 | 49 | ~Command(); |
Rhyme | 0:d895cd1cd897 | 50 | |
Rhyme | 0:d895cd1cd897 | 51 | uint8_t getCommand(); |
Rhyme | 0:d895cd1cd897 | 52 | |
Rhyme | 0:d895cd1cd897 | 53 | uint8_t getReqId(); |
Rhyme | 0:d895cd1cd897 | 54 | |
Rhyme | 0:d895cd1cd897 | 55 | uint16_t getAttrId(); |
Rhyme | 0:d895cd1cd897 | 56 | |
Rhyme | 0:d895cd1cd897 | 57 | uint16_t getValueLen(); |
Rhyme | 0:d895cd1cd897 | 58 | |
Rhyme | 0:d895cd1cd897 | 59 | void getValue(uint8_t *value); |
Rhyme | 0:d895cd1cd897 | 60 | |
Rhyme | 0:d895cd1cd897 | 61 | uint8_t *getValueP(); |
Rhyme | 0:d895cd1cd897 | 62 | |
Rhyme | 0:d895cd1cd897 | 63 | uint16_t getSize(); |
Rhyme | 0:d895cd1cd897 | 64 | |
Rhyme | 0:d895cd1cd897 | 65 | uint16_t getBytes(uint8_t *bytes); |
Rhyme | 0:d895cd1cd897 | 66 | |
Rhyme | 0:d895cd1cd897 | 67 | bool isValid(); |
Rhyme | 0:d895cd1cd897 | 68 | |
Rhyme | 0:d895cd1cd897 | 69 | void dump(); |
Rhyme | 0:d895cd1cd897 | 70 | |
Rhyme | 0:d895cd1cd897 | 71 | void dumpBytes(); |
Rhyme | 0:d895cd1cd897 | 72 | |
Rhyme | 0:d895cd1cd897 | 73 | private: |
Rhyme | 0:d895cd1cd897 | 74 | uint8_t getVal(char c); |
Rhyme | 0:d895cd1cd897 | 75 | int strToValue(char *valueStr, uint8_t *value); |
Rhyme | 0:d895cd1cd897 | 76 | |
Rhyme | 0:d895cd1cd897 | 77 | uint8_t strToCmd(char *cmdStr); |
Rhyme | 0:d895cd1cd897 | 78 | |
Rhyme | 0:d895cd1cd897 | 79 | uint16_t strToAttrId(char *attrIdStr); |
Rhyme | 0:d895cd1cd897 | 80 | |
Rhyme | 0:d895cd1cd897 | 81 | uint16_t _len; |
Rhyme | 0:d895cd1cd897 | 82 | uint8_t _cmd; |
Rhyme | 0:d895cd1cd897 | 83 | uint8_t _requestId; |
Rhyme | 0:d895cd1cd897 | 84 | uint16_t _attrId; |
Rhyme | 0:d895cd1cd897 | 85 | uint8_t _status; |
Rhyme | 0:d895cd1cd897 | 86 | uint8_t _reason; |
Rhyme | 0:d895cd1cd897 | 87 | uint16_t _valueLen; |
Rhyme | 0:d895cd1cd897 | 88 | uint8_t *_value; |
Rhyme | 0:d895cd1cd897 | 89 | |
Rhyme | 0:d895cd1cd897 | 90 | char _printBuf[256]; |
Rhyme | 0:d895cd1cd897 | 91 | |
Rhyme | 0:d895cd1cd897 | 92 | }; |
Rhyme | 0:d895cd1cd897 | 93 | |
Rhyme | 0:d895cd1cd897 | 94 | #endif // COMMAND_H__ |