Temporary Connector Reversed Version
Dependencies: UniGraphic mbed vt100
afero_poc15_180403R , J1 のピン配置を反転させたヴァージョンです。
Color2系を使用するためには以下のピンをジャンパで接続してください。
J1-D7 <-> J1-D0
J1-D6 <-> J1-D1
(調査中) また、こちらでテストした範囲では、
FRDM-KL25Z の V3.3 を、Modulo2 の VCC_3V3 ピンに接続してやる必要がありました。
尚、J1-D1, D0 を使用するために UART を無効にしているため
ログは表示されません。
TFTモジュールについて
aitendoのTFTモジュールはデフォルトでは8bit bus モードになっています。

半田のジャンパを変えて、SPIの設定にしてください。

サーミスタについて
POC1.5 では サーミスタは 25℃の時に抵抗値が 50.0kΩになる502AT-11 が
4.95kΩのプルアップ(実際は10kΩx2の並列)で使用されていました。
今回の試作では抵抗値が 10.0kΩの 103AT-11 が
5.1kΩのプルアップで使用されていますので、係数を合わせるために
SMTC502AT-11 のコンストラクタを
R0 = 10.0
R1 = 5.1
B = 3435
T0 = 298.15
で呼ぶように変更しました。
afLib/afLib.h@0:0b6732b53bf4, 2018-04-24 (annotated)
- Committer:
- Rhyme
- Date:
- Tue Apr 24 08:58:33 2018 +0000
- Revision:
- 0:0b6732b53bf4
Temporary Connector Reversed Version
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| Rhyme | 0:0b6732b53bf4 | 1 | /** |
| Rhyme | 0:0b6732b53bf4 | 2 | * Copyright 2015 Afero, Inc. |
| Rhyme | 0:0b6732b53bf4 | 3 | * |
| Rhyme | 0:0b6732b53bf4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| Rhyme | 0:0b6732b53bf4 | 5 | * you may not use this file except in compliance with the License. |
| Rhyme | 0:0b6732b53bf4 | 6 | * You may obtain a copy of the License at |
| Rhyme | 0:0b6732b53bf4 | 7 | * |
| Rhyme | 0:0b6732b53bf4 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| Rhyme | 0:0b6732b53bf4 | 9 | * |
| Rhyme | 0:0b6732b53bf4 | 10 | * Unless required by applicable law or agreed to in writing, software |
| Rhyme | 0:0b6732b53bf4 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| Rhyme | 0:0b6732b53bf4 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| Rhyme | 0:0b6732b53bf4 | 13 | * See the License for the specific language governing permissions and |
| Rhyme | 0:0b6732b53bf4 | 14 | * limitations under the License. |
| Rhyme | 0:0b6732b53bf4 | 15 | */ |
| Rhyme | 0:0b6732b53bf4 | 16 | |
| Rhyme | 0:0b6732b53bf4 | 17 | #ifndef AFLIB_H__ |
| Rhyme | 0:0b6732b53bf4 | 18 | #define AFLIB_H__ |
| Rhyme | 0:0b6732b53bf4 | 19 | |
| Rhyme | 0:0b6732b53bf4 | 20 | #include "mbed.h" |
| Rhyme | 0:0b6732b53bf4 | 21 | #include "iafLib.h" |
| Rhyme | 0:0b6732b53bf4 | 22 | #include "SPI.h" |
| Rhyme | 0:0b6732b53bf4 | 23 | #include "Command.h" |
| Rhyme | 0:0b6732b53bf4 | 24 | #include "StatusCommand.h" |
| Rhyme | 0:0b6732b53bf4 | 25 | #include "afSPI.h" |
| Rhyme | 0:0b6732b53bf4 | 26 | // #include "WatchDogWrapper.hpp" |
| Rhyme | 0:0b6732b53bf4 | 27 | |
| Rhyme | 0:0b6732b53bf4 | 28 | #define STATE_IDLE 0 |
| Rhyme | 0:0b6732b53bf4 | 29 | #define STATE_STATUS_SYNC 1 |
| Rhyme | 0:0b6732b53bf4 | 30 | #define STATE_STATUS_ACK 3 |
| Rhyme | 0:0b6732b53bf4 | 31 | #define STATE_SEND_BYTES 4 |
| Rhyme | 0:0b6732b53bf4 | 32 | #define STATE_RECV_BYTES 5 |
| Rhyme | 0:0b6732b53bf4 | 33 | #define STATE_CMD_COMPLETE 6 |
| Rhyme | 0:0b6732b53bf4 | 34 | |
| Rhyme | 0:0b6732b53bf4 | 35 | #define SPI_FRAME_LEN 16 |
| Rhyme | 0:0b6732b53bf4 | 36 | |
| Rhyme | 0:0b6732b53bf4 | 37 | #define REQUEST_QUEUE_SIZE 10 |
| Rhyme | 0:0b6732b53bf4 | 38 | |
| Rhyme | 0:0b6732b53bf4 | 39 | typedef struct { |
| Rhyme | 0:0b6732b53bf4 | 40 | uint8_t messageType; |
| Rhyme | 0:0b6732b53bf4 | 41 | uint16_t attrId; |
| Rhyme | 0:0b6732b53bf4 | 42 | uint8_t requestId; |
| Rhyme | 0:0b6732b53bf4 | 43 | uint16_t valueLen; |
| Rhyme | 0:0b6732b53bf4 | 44 | uint8_t *p_value; |
| Rhyme | 0:0b6732b53bf4 | 45 | } request_t; |
| Rhyme | 0:0b6732b53bf4 | 46 | |
| Rhyme | 0:0b6732b53bf4 | 47 | class afLib : public iafLib { |
| Rhyme | 0:0b6732b53bf4 | 48 | public: |
| Rhyme | 0:0b6732b53bf4 | 49 | afLib(PinName mcuInterrupt, isr isrWrapper, |
| Rhyme | 0:0b6732b53bf4 | 50 | onAttributeSet attrSet, onAttributeSetComplete attrSetComplete, afSPI *theSPI); |
| Rhyme | 0:0b6732b53bf4 | 51 | //wsugi 20161128 |
| Rhyme | 0:0b6732b53bf4 | 52 | ~afLib(); |
| Rhyme | 0:0b6732b53bf4 | 53 | //wsugi 20161128 |
| Rhyme | 0:0b6732b53bf4 | 54 | |
| Rhyme | 0:0b6732b53bf4 | 55 | // motoo tanaka 20171116 |
| Rhyme | 0:0b6732b53bf4 | 56 | virtual int getRequestId(void) ; |
| Rhyme | 0:0b6732b53bf4 | 57 | // motoo tanaka 20171116 |
| Rhyme | 0:0b6732b53bf4 | 58 | // motoo tanaka 20171229 |
| Rhyme | 0:0b6732b53bf4 | 59 | virtual void disable_irq(void) { fco.disable_irq() ; } |
| Rhyme | 0:0b6732b53bf4 | 60 | virtual void enable_irq(void) { fco.enable_irq() ; } |
| Rhyme | 0:0b6732b53bf4 | 61 | |
| Rhyme | 0:0b6732b53bf4 | 62 | virtual void loop(void); |
| Rhyme | 0:0b6732b53bf4 | 63 | |
| Rhyme | 0:0b6732b53bf4 | 64 | virtual int getAttribute(const uint16_t attrId); |
| Rhyme | 0:0b6732b53bf4 | 65 | |
| Rhyme | 0:0b6732b53bf4 | 66 | virtual int setAttributeBool(const uint16_t attrId, const bool value); |
| Rhyme | 0:0b6732b53bf4 | 67 | |
| Rhyme | 0:0b6732b53bf4 | 68 | virtual int setAttribute8(const uint16_t attrId, const int8_t value); |
| Rhyme | 0:0b6732b53bf4 | 69 | |
| Rhyme | 0:0b6732b53bf4 | 70 | virtual int setAttribute16(const uint16_t attrId, const int16_t value); |
| Rhyme | 0:0b6732b53bf4 | 71 | |
| Rhyme | 0:0b6732b53bf4 | 72 | virtual int setAttribute32(const uint16_t attrId, const int32_t value); |
| Rhyme | 0:0b6732b53bf4 | 73 | |
| Rhyme | 0:0b6732b53bf4 | 74 | virtual int setAttribute64(const uint16_t attrId, const int64_t value); |
| Rhyme | 0:0b6732b53bf4 | 75 | |
| Rhyme | 0:0b6732b53bf4 | 76 | virtual int setAttribute(const uint16_t attrId, const string &value); |
| Rhyme | 0:0b6732b53bf4 | 77 | |
| Rhyme | 0:0b6732b53bf4 | 78 | virtual int setAttribute(const uint16_t attrId, const uint16_t valueLen, const char *value); |
| Rhyme | 0:0b6732b53bf4 | 79 | |
| Rhyme | 0:0b6732b53bf4 | 80 | virtual int setAttribute(const uint16_t attrId, const uint16_t valueLen, const uint8_t *value); |
| Rhyme | 0:0b6732b53bf4 | 81 | |
| Rhyme | 0:0b6732b53bf4 | 82 | virtual int setAttributeComplete(uint8_t requestId, const uint16_t attrId, const uint16_t valueLen, const uint8_t *value); |
| Rhyme | 0:0b6732b53bf4 | 83 | |
| Rhyme | 0:0b6732b53bf4 | 84 | virtual bool isIdle(); |
| Rhyme | 0:0b6732b53bf4 | 85 | |
| Rhyme | 0:0b6732b53bf4 | 86 | virtual void mcuISR(); |
| Rhyme | 0:0b6732b53bf4 | 87 | |
| Rhyme | 0:0b6732b53bf4 | 88 | private: |
| Rhyme | 0:0b6732b53bf4 | 89 | Timeout deathWish; |
| Rhyme | 0:0b6732b53bf4 | 90 | Timer *checkLastSync; |
| Rhyme | 0:0b6732b53bf4 | 91 | static void kick_the_bucket(); |
| Rhyme | 0:0b6732b53bf4 | 92 | afSPI *_theSPI; |
| Rhyme | 0:0b6732b53bf4 | 93 | |
| Rhyme | 0:0b6732b53bf4 | 94 | //SPISettings _spiSettings; |
| Rhyme | 0:0b6732b53bf4 | 95 | volatile int _interrupts_pending; |
| Rhyme | 0:0b6732b53bf4 | 96 | int _state; |
| Rhyme | 0:0b6732b53bf4 | 97 | uint16_t _bytesToSend; |
| Rhyme | 0:0b6732b53bf4 | 98 | uint16_t _bytesToRecv; |
| Rhyme | 0:0b6732b53bf4 | 99 | uint8_t _requestId; |
| Rhyme | 0:0b6732b53bf4 | 100 | uint16_t _outstandingSetGetAttrId; |
| Rhyme | 0:0b6732b53bf4 | 101 | |
| Rhyme | 0:0b6732b53bf4 | 102 | // Application Callbacks. |
| Rhyme | 0:0b6732b53bf4 | 103 | onAttributeSet _onAttrSet; |
| Rhyme | 0:0b6732b53bf4 | 104 | onAttributeSetComplete _onAttrSetComplete; |
| Rhyme | 0:0b6732b53bf4 | 105 | |
| Rhyme | 0:0b6732b53bf4 | 106 | Command *_writeCmd; |
| Rhyme | 0:0b6732b53bf4 | 107 | uint16_t _writeBufferLen; |
| Rhyme | 0:0b6732b53bf4 | 108 | uint8_t *_writeBuffer; |
| Rhyme | 0:0b6732b53bf4 | 109 | |
| Rhyme | 0:0b6732b53bf4 | 110 | Command *_readCmd; |
| Rhyme | 0:0b6732b53bf4 | 111 | uint16_t _readBufferLen; |
| Rhyme | 0:0b6732b53bf4 | 112 | uint8_t *_readBuffer; |
| Rhyme | 0:0b6732b53bf4 | 113 | |
| Rhyme | 0:0b6732b53bf4 | 114 | int _writeCmdOffset; |
| Rhyme | 0:0b6732b53bf4 | 115 | int _readCmdOffset; |
| Rhyme | 0:0b6732b53bf4 | 116 | |
| Rhyme | 0:0b6732b53bf4 | 117 | StatusCommand *_txStatus; |
| Rhyme | 0:0b6732b53bf4 | 118 | StatusCommand *_rxStatus; |
| Rhyme | 0:0b6732b53bf4 | 119 | |
| Rhyme | 0:0b6732b53bf4 | 120 | request_t _request; |
| Rhyme | 0:0b6732b53bf4 | 121 | request_t _requestQueue[REQUEST_QUEUE_SIZE]; |
| Rhyme | 0:0b6732b53bf4 | 122 | |
| Rhyme | 0:0b6732b53bf4 | 123 | #ifdef ATTRIBUTE_CLI |
| Rhyme | 0:0b6732b53bf4 | 124 | int parseCommand(const char *cmd); |
| Rhyme | 0:0b6732b53bf4 | 125 | #endif |
| Rhyme | 0:0b6732b53bf4 | 126 | |
| Rhyme | 0:0b6732b53bf4 | 127 | void sendCommand(void); |
| Rhyme | 0:0b6732b53bf4 | 128 | |
| Rhyme | 0:0b6732b53bf4 | 129 | void runStateMachine(void); |
| Rhyme | 0:0b6732b53bf4 | 130 | |
| Rhyme | 0:0b6732b53bf4 | 131 | void printState(int state); |
| Rhyme | 0:0b6732b53bf4 | 132 | |
| Rhyme | 0:0b6732b53bf4 | 133 | //void beginSPI(); |
| Rhyme | 0:0b6732b53bf4 | 134 | |
| Rhyme | 0:0b6732b53bf4 | 135 | //void endSPI(); |
| Rhyme | 0:0b6732b53bf4 | 136 | |
| Rhyme | 0:0b6732b53bf4 | 137 | int exchangeStatus(StatusCommand *tx, StatusCommand *rx); |
| Rhyme | 0:0b6732b53bf4 | 138 | |
| Rhyme | 0:0b6732b53bf4 | 139 | bool inSync(StatusCommand *tx, StatusCommand *rx); |
| Rhyme | 0:0b6732b53bf4 | 140 | |
| Rhyme | 0:0b6732b53bf4 | 141 | int writeStatus(StatusCommand *c); |
| Rhyme | 0:0b6732b53bf4 | 142 | |
| Rhyme | 0:0b6732b53bf4 | 143 | void sendBytes(); |
| Rhyme | 0:0b6732b53bf4 | 144 | |
| Rhyme | 0:0b6732b53bf4 | 145 | void recvBytes(); |
| Rhyme | 0:0b6732b53bf4 | 146 | |
| Rhyme | 0:0b6732b53bf4 | 147 | void dumpBytes(char *label, int len, uint8_t *bytes); |
| Rhyme | 0:0b6732b53bf4 | 148 | |
| Rhyme | 0:0b6732b53bf4 | 149 | void updateIntsPending(int amount); |
| Rhyme | 0:0b6732b53bf4 | 150 | |
| Rhyme | 0:0b6732b53bf4 | 151 | void queueInit(void); |
| Rhyme | 0:0b6732b53bf4 | 152 | |
| Rhyme | 0:0b6732b53bf4 | 153 | int queuePut(uint8_t messageType, uint8_t requestId, const uint16_t attributeId, uint16_t valueLen, const uint8_t *value); |
| Rhyme | 0:0b6732b53bf4 | 154 | |
| Rhyme | 0:0b6732b53bf4 | 155 | int queueGet(uint8_t *messageType, uint8_t *requestId, uint16_t *attributeId, uint16_t *valueLen, uint8_t **value); |
| Rhyme | 0:0b6732b53bf4 | 156 | |
| Rhyme | 0:0b6732b53bf4 | 157 | int doGetAttribute(uint8_t requestId, uint16_t attrId); |
| Rhyme | 0:0b6732b53bf4 | 158 | |
| Rhyme | 0:0b6732b53bf4 | 159 | int doSetAttribute(uint8_t requestId, uint16_t attrId, uint16_t valueLen, uint8_t *value); |
| Rhyme | 0:0b6732b53bf4 | 160 | |
| Rhyme | 0:0b6732b53bf4 | 161 | int doUpdateAttribute(uint8_t requestId, uint16_t attrId, uint8_t status, uint16_t valueLen, uint8_t *value); |
| Rhyme | 0:0b6732b53bf4 | 162 | |
| Rhyme | 0:0b6732b53bf4 | 163 | void onStateIdle(void); |
| Rhyme | 0:0b6732b53bf4 | 164 | void onStateSync(void); |
| Rhyme | 0:0b6732b53bf4 | 165 | void onStateAck(void); |
| Rhyme | 0:0b6732b53bf4 | 166 | void onStateSendBytes(void); |
| Rhyme | 0:0b6732b53bf4 | 167 | void onStateRecvBytes(void); |
| Rhyme | 0:0b6732b53bf4 | 168 | void onStateCmdComplete(void); |
| Rhyme | 0:0b6732b53bf4 | 169 | void printTransaction(uint8_t *rbytes, int len); |
| Rhyme | 0:0b6732b53bf4 | 170 | InterruptIn fco; |
| Rhyme | 0:0b6732b53bf4 | 171 | }; |
| Rhyme | 0:0b6732b53bf4 | 172 | |
| Rhyme | 0:0b6732b53bf4 | 173 | #endif // AFLIB_H__ |
La Suno