Release candidate version. The pointer in GAS Pressure display is changed to a triangle.

Dependencies:   UniGraphic mbed vt100

Please note, at 2-Mar-2018 the current version of mbed-lib has a defect in Ticker.
https://os.mbed.com/forum/bugs-suggestions/topic/29287/

So, mbed lib version 157 is intentionally being used.
Please do not update mbed library until the problem in the above URL is fixed.

In this version, format of GAS Pressure Display has been changed.
/media/uploads/Rhyme/low.jpg

/media/uploads/Rhyme/good.jpg

/media/uploads/Rhyme/high.jpg

moto

Committer:
Rhyme
Date:
Fri Mar 02 07:56:09 2018 +0000
Revision:
0:774324cbc5a6
Release candidate version. GAS Pressure pointer is now a triangle.; Some source file clean-up was done.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:774324cbc5a6 1 /**
Rhyme 0:774324cbc5a6 2 * Copyright 2015 Afero, Inc.
Rhyme 0:774324cbc5a6 3 *
Rhyme 0:774324cbc5a6 4 * Licensed under the Apache License, Version 2.0 (the "License");
Rhyme 0:774324cbc5a6 5 * you may not use this file except in compliance with the License.
Rhyme 0:774324cbc5a6 6 * You may obtain a copy of the License at
Rhyme 0:774324cbc5a6 7 *
Rhyme 0:774324cbc5a6 8 * http://www.apache.org/licenses/LICENSE-2.0
Rhyme 0:774324cbc5a6 9 *
Rhyme 0:774324cbc5a6 10 * Unless required by applicable law or agreed to in writing, software
Rhyme 0:774324cbc5a6 11 * distributed under the License is distributed on an "AS IS" BASIS,
Rhyme 0:774324cbc5a6 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
Rhyme 0:774324cbc5a6 13 * See the License for the specific language governing permissions and
Rhyme 0:774324cbc5a6 14 * limitations under the License.
Rhyme 0:774324cbc5a6 15 */
Rhyme 0:774324cbc5a6 16
Rhyme 0:774324cbc5a6 17 #ifndef AFLIB_H__
Rhyme 0:774324cbc5a6 18 #define AFLIB_H__
Rhyme 0:774324cbc5a6 19
Rhyme 0:774324cbc5a6 20 #include "mbed.h"
Rhyme 0:774324cbc5a6 21 #include "iafLib.h"
Rhyme 0:774324cbc5a6 22 #include "SPI.h"
Rhyme 0:774324cbc5a6 23 #include "Command.h"
Rhyme 0:774324cbc5a6 24 #include "StatusCommand.h"
Rhyme 0:774324cbc5a6 25 #include "afSPI.h"
Rhyme 0:774324cbc5a6 26 // #include "WatchDogWrapper.hpp"
Rhyme 0:774324cbc5a6 27
Rhyme 0:774324cbc5a6 28 #define STATE_IDLE 0
Rhyme 0:774324cbc5a6 29 #define STATE_STATUS_SYNC 1
Rhyme 0:774324cbc5a6 30 #define STATE_STATUS_ACK 3
Rhyme 0:774324cbc5a6 31 #define STATE_SEND_BYTES 4
Rhyme 0:774324cbc5a6 32 #define STATE_RECV_BYTES 5
Rhyme 0:774324cbc5a6 33 #define STATE_CMD_COMPLETE 6
Rhyme 0:774324cbc5a6 34
Rhyme 0:774324cbc5a6 35 #define SPI_FRAME_LEN 16
Rhyme 0:774324cbc5a6 36
Rhyme 0:774324cbc5a6 37 #define REQUEST_QUEUE_SIZE 10
Rhyme 0:774324cbc5a6 38
Rhyme 0:774324cbc5a6 39 typedef struct {
Rhyme 0:774324cbc5a6 40 uint8_t messageType;
Rhyme 0:774324cbc5a6 41 uint16_t attrId;
Rhyme 0:774324cbc5a6 42 uint8_t requestId;
Rhyme 0:774324cbc5a6 43 uint16_t valueLen;
Rhyme 0:774324cbc5a6 44 uint8_t *p_value;
Rhyme 0:774324cbc5a6 45 } request_t;
Rhyme 0:774324cbc5a6 46
Rhyme 0:774324cbc5a6 47 class afLib : public iafLib {
Rhyme 0:774324cbc5a6 48 public:
Rhyme 0:774324cbc5a6 49 afLib(PinName mcuInterrupt, isr isrWrapper,
Rhyme 0:774324cbc5a6 50 onAttributeSet attrSet, onAttributeSetComplete attrSetComplete, afSPI *theSPI);
Rhyme 0:774324cbc5a6 51 //wsugi 20161128
Rhyme 0:774324cbc5a6 52 ~afLib();
Rhyme 0:774324cbc5a6 53 //wsugi 20161128
Rhyme 0:774324cbc5a6 54
Rhyme 0:774324cbc5a6 55 // motoo tanaka 20171116
Rhyme 0:774324cbc5a6 56 virtual int getRequestId(void) ;
Rhyme 0:774324cbc5a6 57 // motoo tanaka 20171116
Rhyme 0:774324cbc5a6 58 // motoo tanaka 20171229
Rhyme 0:774324cbc5a6 59 virtual void disable_irq(void) { fco.disable_irq() ; }
Rhyme 0:774324cbc5a6 60 virtual void enable_irq(void) { fco.enable_irq() ; }
Rhyme 0:774324cbc5a6 61
Rhyme 0:774324cbc5a6 62 virtual void loop(void);
Rhyme 0:774324cbc5a6 63
Rhyme 0:774324cbc5a6 64 virtual int getAttribute(const uint16_t attrId);
Rhyme 0:774324cbc5a6 65
Rhyme 0:774324cbc5a6 66 virtual int setAttributeBool(const uint16_t attrId, const bool value);
Rhyme 0:774324cbc5a6 67
Rhyme 0:774324cbc5a6 68 virtual int setAttribute8(const uint16_t attrId, const int8_t value);
Rhyme 0:774324cbc5a6 69
Rhyme 0:774324cbc5a6 70 virtual int setAttribute16(const uint16_t attrId, const int16_t value);
Rhyme 0:774324cbc5a6 71
Rhyme 0:774324cbc5a6 72 virtual int setAttribute32(const uint16_t attrId, const int32_t value);
Rhyme 0:774324cbc5a6 73
Rhyme 0:774324cbc5a6 74 virtual int setAttribute64(const uint16_t attrId, const int64_t value);
Rhyme 0:774324cbc5a6 75
Rhyme 0:774324cbc5a6 76 virtual int setAttribute(const uint16_t attrId, const string &value);
Rhyme 0:774324cbc5a6 77
Rhyme 0:774324cbc5a6 78 virtual int setAttribute(const uint16_t attrId, const uint16_t valueLen, const char *value);
Rhyme 0:774324cbc5a6 79
Rhyme 0:774324cbc5a6 80 virtual int setAttribute(const uint16_t attrId, const uint16_t valueLen, const uint8_t *value);
Rhyme 0:774324cbc5a6 81
Rhyme 0:774324cbc5a6 82 virtual int setAttributeComplete(uint8_t requestId, const uint16_t attrId, const uint16_t valueLen, const uint8_t *value);
Rhyme 0:774324cbc5a6 83
Rhyme 0:774324cbc5a6 84 virtual bool isIdle();
Rhyme 0:774324cbc5a6 85
Rhyme 0:774324cbc5a6 86 virtual void mcuISR();
Rhyme 0:774324cbc5a6 87
Rhyme 0:774324cbc5a6 88 private:
Rhyme 0:774324cbc5a6 89 Timeout deathWish;
Rhyme 0:774324cbc5a6 90 Timer *checkLastSync;
Rhyme 0:774324cbc5a6 91 static void kick_the_bucket();
Rhyme 0:774324cbc5a6 92 afSPI *_theSPI;
Rhyme 0:774324cbc5a6 93
Rhyme 0:774324cbc5a6 94 //SPISettings _spiSettings;
Rhyme 0:774324cbc5a6 95 volatile int _interrupts_pending;
Rhyme 0:774324cbc5a6 96 int _state;
Rhyme 0:774324cbc5a6 97 uint16_t _bytesToSend;
Rhyme 0:774324cbc5a6 98 uint16_t _bytesToRecv;
Rhyme 0:774324cbc5a6 99 uint8_t _requestId;
Rhyme 0:774324cbc5a6 100 uint16_t _outstandingSetGetAttrId;
Rhyme 0:774324cbc5a6 101
Rhyme 0:774324cbc5a6 102 // Application Callbacks.
Rhyme 0:774324cbc5a6 103 onAttributeSet _onAttrSet;
Rhyme 0:774324cbc5a6 104 onAttributeSetComplete _onAttrSetComplete;
Rhyme 0:774324cbc5a6 105
Rhyme 0:774324cbc5a6 106 Command *_writeCmd;
Rhyme 0:774324cbc5a6 107 uint16_t _writeBufferLen;
Rhyme 0:774324cbc5a6 108 uint8_t *_writeBuffer;
Rhyme 0:774324cbc5a6 109
Rhyme 0:774324cbc5a6 110 Command *_readCmd;
Rhyme 0:774324cbc5a6 111 uint16_t _readBufferLen;
Rhyme 0:774324cbc5a6 112 uint8_t *_readBuffer;
Rhyme 0:774324cbc5a6 113
Rhyme 0:774324cbc5a6 114 int _writeCmdOffset;
Rhyme 0:774324cbc5a6 115 int _readCmdOffset;
Rhyme 0:774324cbc5a6 116
Rhyme 0:774324cbc5a6 117 StatusCommand *_txStatus;
Rhyme 0:774324cbc5a6 118 StatusCommand *_rxStatus;
Rhyme 0:774324cbc5a6 119
Rhyme 0:774324cbc5a6 120 request_t _request;
Rhyme 0:774324cbc5a6 121 request_t _requestQueue[REQUEST_QUEUE_SIZE];
Rhyme 0:774324cbc5a6 122
Rhyme 0:774324cbc5a6 123 #ifdef ATTRIBUTE_CLI
Rhyme 0:774324cbc5a6 124 int parseCommand(const char *cmd);
Rhyme 0:774324cbc5a6 125 #endif
Rhyme 0:774324cbc5a6 126
Rhyme 0:774324cbc5a6 127 void sendCommand(void);
Rhyme 0:774324cbc5a6 128
Rhyme 0:774324cbc5a6 129 void runStateMachine(void);
Rhyme 0:774324cbc5a6 130
Rhyme 0:774324cbc5a6 131 void printState(int state);
Rhyme 0:774324cbc5a6 132
Rhyme 0:774324cbc5a6 133 //void beginSPI();
Rhyme 0:774324cbc5a6 134
Rhyme 0:774324cbc5a6 135 //void endSPI();
Rhyme 0:774324cbc5a6 136
Rhyme 0:774324cbc5a6 137 int exchangeStatus(StatusCommand *tx, StatusCommand *rx);
Rhyme 0:774324cbc5a6 138
Rhyme 0:774324cbc5a6 139 bool inSync(StatusCommand *tx, StatusCommand *rx);
Rhyme 0:774324cbc5a6 140
Rhyme 0:774324cbc5a6 141 int writeStatus(StatusCommand *c);
Rhyme 0:774324cbc5a6 142
Rhyme 0:774324cbc5a6 143 void sendBytes();
Rhyme 0:774324cbc5a6 144
Rhyme 0:774324cbc5a6 145 void recvBytes();
Rhyme 0:774324cbc5a6 146
Rhyme 0:774324cbc5a6 147 void dumpBytes(char *label, int len, uint8_t *bytes);
Rhyme 0:774324cbc5a6 148
Rhyme 0:774324cbc5a6 149 void updateIntsPending(int amount);
Rhyme 0:774324cbc5a6 150
Rhyme 0:774324cbc5a6 151 void queueInit(void);
Rhyme 0:774324cbc5a6 152
Rhyme 0:774324cbc5a6 153 int queuePut(uint8_t messageType, uint8_t requestId, const uint16_t attributeId, uint16_t valueLen, const uint8_t *value);
Rhyme 0:774324cbc5a6 154
Rhyme 0:774324cbc5a6 155 int queueGet(uint8_t *messageType, uint8_t *requestId, uint16_t *attributeId, uint16_t *valueLen, uint8_t **value);
Rhyme 0:774324cbc5a6 156
Rhyme 0:774324cbc5a6 157 int doGetAttribute(uint8_t requestId, uint16_t attrId);
Rhyme 0:774324cbc5a6 158
Rhyme 0:774324cbc5a6 159 int doSetAttribute(uint8_t requestId, uint16_t attrId, uint16_t valueLen, uint8_t *value);
Rhyme 0:774324cbc5a6 160
Rhyme 0:774324cbc5a6 161 int doUpdateAttribute(uint8_t requestId, uint16_t attrId, uint8_t status, uint16_t valueLen, uint8_t *value);
Rhyme 0:774324cbc5a6 162
Rhyme 0:774324cbc5a6 163 void onStateIdle(void);
Rhyme 0:774324cbc5a6 164 void onStateSync(void);
Rhyme 0:774324cbc5a6 165 void onStateAck(void);
Rhyme 0:774324cbc5a6 166 void onStateSendBytes(void);
Rhyme 0:774324cbc5a6 167 void onStateRecvBytes(void);
Rhyme 0:774324cbc5a6 168 void onStateCmdComplete(void);
Rhyme 0:774324cbc5a6 169 void printTransaction(uint8_t *rbytes, int len);
Rhyme 0:774324cbc5a6 170 InterruptIn fco;
Rhyme 0:774324cbc5a6 171 };
Rhyme 0:774324cbc5a6 172
Rhyme 0:774324cbc5a6 173 #endif // AFLIB_H__