pwm period is now 200us instead of the default 20ms veml6040 config is now AF_BIT | TRIG_BIT
Dependencies: mbed MMA8451Q USBDevice WakeUp vt100
Fork of afero_node_suntory_2017_06_15 by
afLib/iafLib.h@23:e4d2316383a1, 2017-10-18 (annotated)
- Committer:
- Rhyme
- Date:
- Wed Oct 18 00:31:13 2017 +0000
- Revision:
- 23:e4d2316383a1
- Parent:
- 0:20bce0dcc921
pwm period is now 200us from default 20ms; veml6040->setCOLORCOnf is now AF_BIT | TRIG_BIT from 0x00;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
wataloh | 0:20bce0dcc921 | 1 | /** |
wataloh | 0:20bce0dcc921 | 2 | * Copyright 2015 Afero, Inc. |
wataloh | 0:20bce0dcc921 | 3 | * |
wataloh | 0:20bce0dcc921 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
wataloh | 0:20bce0dcc921 | 5 | * you may not use this file except in compliance with the License. |
wataloh | 0:20bce0dcc921 | 6 | * You may obtain a copy of the License at |
wataloh | 0:20bce0dcc921 | 7 | * |
wataloh | 0:20bce0dcc921 | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
wataloh | 0:20bce0dcc921 | 9 | * |
wataloh | 0:20bce0dcc921 | 10 | * Unless required by applicable law or agreed to in writing, software |
wataloh | 0:20bce0dcc921 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
wataloh | 0:20bce0dcc921 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
wataloh | 0:20bce0dcc921 | 13 | * See the License for the specific language governing permissions and |
wataloh | 0:20bce0dcc921 | 14 | * limitations under the License. |
wataloh | 0:20bce0dcc921 | 15 | */ |
wataloh | 0:20bce0dcc921 | 16 | |
wataloh | 0:20bce0dcc921 | 17 | /** |
wataloh | 0:20bce0dcc921 | 18 | * afLib public interface |
wataloh | 0:20bce0dcc921 | 19 | * |
wataloh | 0:20bce0dcc921 | 20 | * This file defines everything your application should need for commuinicating with the Afero ASR-1 radio module. |
wataloh | 0:20bce0dcc921 | 21 | * Is there is anything missing from this file, please post a request on the developer forum and we will see what |
wataloh | 0:20bce0dcc921 | 22 | * we can do. |
wataloh | 0:20bce0dcc921 | 23 | */ |
wataloh | 0:20bce0dcc921 | 24 | #ifndef AFLIB_IAFLIB_H |
wataloh | 0:20bce0dcc921 | 25 | #define AFLIB_IAFLIB_H |
wataloh | 0:20bce0dcc921 | 26 | |
wataloh | 0:20bce0dcc921 | 27 | #include "mbed.h" |
wataloh | 0:20bce0dcc921 | 28 | #include <string> |
wataloh | 0:20bce0dcc921 | 29 | using namespace std; |
wataloh | 0:20bce0dcc921 | 30 | #include "afErrors.h" |
wataloh | 0:20bce0dcc921 | 31 | #include "afSPI.h" |
wataloh | 0:20bce0dcc921 | 32 | |
wataloh | 0:20bce0dcc921 | 33 | #if defined (TARGET_TEENSY3_1) |
wataloh | 0:20bce0dcc921 | 34 | #include "USBSerial.h" |
wataloh | 0:20bce0dcc921 | 35 | #endif |
wataloh | 0:20bce0dcc921 | 36 | |
wataloh | 0:20bce0dcc921 | 37 | #define afMINIMUM_TIME_BETWEEN_REQUESTS 1000 |
wataloh | 0:20bce0dcc921 | 38 | |
wataloh | 0:20bce0dcc921 | 39 | #define MAX_ATTRIBUTE_SIZE 255 |
wataloh | 0:20bce0dcc921 | 40 | |
wataloh | 0:20bce0dcc921 | 41 | typedef void (*isr)(); |
wataloh | 0:20bce0dcc921 | 42 | typedef void (*onAttributeSet)(const uint8_t requestId, const uint16_t attributeId, const uint16_t valueLen, const uint8_t *value); |
wataloh | 0:20bce0dcc921 | 43 | typedef void (*onAttributeSetComplete)(const uint8_t requestId, const uint16_t attributeId, const uint16_t valueLen, const uint8_t *value); |
wataloh | 0:20bce0dcc921 | 44 | |
wataloh | 0:20bce0dcc921 | 45 | class iafLib { |
wataloh | 0:20bce0dcc921 | 46 | public: |
wataloh | 0:20bce0dcc921 | 47 | /** |
wataloh | 0:20bce0dcc921 | 48 | * create |
wataloh | 0:20bce0dcc921 | 49 | * |
wataloh | 0:20bce0dcc921 | 50 | * Create an instance of the afLib object. The afLib is a singleton. Calling this method multiple |
wataloh | 0:20bce0dcc921 | 51 | * times will return the same instance. |
wataloh | 0:20bce0dcc921 | 52 | * |
wataloh | 0:20bce0dcc921 | 53 | * @param mcuInterrupt The Arduino interrupt to be used (returned from digitalPinToInterrupt) |
wataloh | 0:20bce0dcc921 | 54 | * @param isrWrapper This is the isr method that must be defined in your sketch |
wataloh | 0:20bce0dcc921 | 55 | * @param attrSet Callback for notification of attribute set requests |
wataloh | 0:20bce0dcc921 | 56 | * @param attrSetComplete Callback for notification of attribute set request completions |
wataloh | 0:20bce0dcc921 | 57 | * @return iafLib * Instance of iafLib |
wataloh | 0:20bce0dcc921 | 58 | */ |
wataloh | 0:20bce0dcc921 | 59 | static iafLib * create(PinName mcuInterrupt, isr isrWrapper, |
wataloh | 0:20bce0dcc921 | 60 | onAttributeSet attrSet, onAttributeSetComplete attrSetComplete, afSPI *theSPI); |
wataloh | 0:20bce0dcc921 | 61 | |
wataloh | 0:20bce0dcc921 | 62 | //wsugi 20161128 |
wataloh | 0:20bce0dcc921 | 63 | static void destroy(); |
wataloh | 0:20bce0dcc921 | 64 | |
wataloh | 0:20bce0dcc921 | 65 | /** |
wataloh | 0:20bce0dcc921 | 66 | * loop |
wataloh | 0:20bce0dcc921 | 67 | * |
wataloh | 0:20bce0dcc921 | 68 | * Called by the loop() method in your sketch to give afLib some CPU time |
wataloh | 0:20bce0dcc921 | 69 | */ |
wataloh | 0:20bce0dcc921 | 70 | virtual void loop(void) = 0; |
wataloh | 0:20bce0dcc921 | 71 | |
wataloh | 0:20bce0dcc921 | 72 | /** |
wataloh | 0:20bce0dcc921 | 73 | * getAttribute |
wataloh | 0:20bce0dcc921 | 74 | * |
wataloh | 0:20bce0dcc921 | 75 | * Request the value of an attribute be returned from the ASR-1. |
wataloh | 0:20bce0dcc921 | 76 | * Value will be returned in the attrSetComplete callback. |
wataloh | 0:20bce0dcc921 | 77 | */ |
wataloh | 0:20bce0dcc921 | 78 | virtual int getAttribute(const uint16_t attrId) = 0; |
wataloh | 0:20bce0dcc921 | 79 | |
wataloh | 0:20bce0dcc921 | 80 | /** |
wataloh | 0:20bce0dcc921 | 81 | * setAttribute |
wataloh | 0:20bce0dcc921 | 82 | * |
wataloh | 0:20bce0dcc921 | 83 | * Request setting an attribute. |
wataloh | 0:20bce0dcc921 | 84 | * For MCU attributes, the attribute value will be updated. |
wataloh | 0:20bce0dcc921 | 85 | * For IO attributes, the attribute value will be updated, and then onAttrSetComplete will be called. |
wataloh | 0:20bce0dcc921 | 86 | */ |
wataloh | 0:20bce0dcc921 | 87 | virtual int setAttributeBool(const uint16_t attrId, const bool value) = 0; |
wataloh | 0:20bce0dcc921 | 88 | |
wataloh | 0:20bce0dcc921 | 89 | virtual int setAttribute8(const uint16_t attrId, const int8_t value) = 0; |
wataloh | 0:20bce0dcc921 | 90 | |
wataloh | 0:20bce0dcc921 | 91 | virtual int setAttribute16(const uint16_t attrId, const int16_t value) = 0; |
wataloh | 0:20bce0dcc921 | 92 | |
wataloh | 0:20bce0dcc921 | 93 | virtual int setAttribute32(const uint16_t attrId, const int32_t value) = 0; |
wataloh | 0:20bce0dcc921 | 94 | |
wataloh | 0:20bce0dcc921 | 95 | virtual int setAttribute64(const uint16_t attrId, const int64_t value) = 0; |
wataloh | 0:20bce0dcc921 | 96 | |
wataloh | 0:20bce0dcc921 | 97 | virtual int setAttribute(const uint16_t attrId, const string &value) = 0; |
wataloh | 0:20bce0dcc921 | 98 | |
wataloh | 0:20bce0dcc921 | 99 | virtual int setAttribute(const uint16_t attrId, const uint16_t valueLen, const char *value) = 0; |
wataloh | 0:20bce0dcc921 | 100 | |
wataloh | 0:20bce0dcc921 | 101 | virtual int setAttribute(const uint16_t attrId, const uint16_t valueLen, const uint8_t *value) = 0; |
wataloh | 0:20bce0dcc921 | 102 | |
wataloh | 0:20bce0dcc921 | 103 | /** |
wataloh | 0:20bce0dcc921 | 104 | * setAttributeComplete |
wataloh | 0:20bce0dcc921 | 105 | * |
wataloh | 0:20bce0dcc921 | 106 | * Call this in response to an onAttrSet. This lets the ASR-1 know that the set request has been handled. |
wataloh | 0:20bce0dcc921 | 107 | */ |
wataloh | 0:20bce0dcc921 | 108 | virtual int setAttributeComplete(uint8_t requestId, const uint16_t attrId, const uint16_t valueLen, const uint8_t *value) = 0; |
wataloh | 0:20bce0dcc921 | 109 | |
wataloh | 0:20bce0dcc921 | 110 | /** |
wataloh | 0:20bce0dcc921 | 111 | * isIdle |
wataloh | 0:20bce0dcc921 | 112 | * |
wataloh | 0:20bce0dcc921 | 113 | * Call to find out of the ASR-1 is currently handling a request. |
wataloh | 0:20bce0dcc921 | 114 | * |
wataloh | 0:20bce0dcc921 | 115 | * @return true if an operation is in progress |
wataloh | 0:20bce0dcc921 | 116 | */ |
wataloh | 0:20bce0dcc921 | 117 | virtual bool isIdle() = 0; |
wataloh | 0:20bce0dcc921 | 118 | |
wataloh | 0:20bce0dcc921 | 119 | /** |
wataloh | 0:20bce0dcc921 | 120 | * mcuISR |
wataloh | 0:20bce0dcc921 | 121 | * |
wataloh | 0:20bce0dcc921 | 122 | * Called by your sketch to pass the interrupt along to afLib. |
wataloh | 0:20bce0dcc921 | 123 | */ |
wataloh | 0:20bce0dcc921 | 124 | virtual void mcuISR() = 0; |
wataloh | 0:20bce0dcc921 | 125 | }; |
wataloh | 0:20bce0dcc921 | 126 | #endif //AFLIB_IAFLIB_H |