5.2.1 - Updated I2C files

Dependents:   mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510

Committer:
jacobjohnson
Date:
Mon Feb 27 17:45:05 2017 +0000
Revision:
1:f30bdcd2b33b
Parent:
0:098463de4c5d
changed the inputscale from 1 to 7 in analogin_api.c.  This will need to be changed later, and accessed from the main level, but for now this allows the  adc to read a value from 0 to 3.7V, instead of just up to 1V.;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
group-onsemi 0:098463de4c5d 1 /* mbed Microcontroller Library
group-onsemi 0:098463de4c5d 2 * Copyright (c) 2006-2013 ARM Limited
group-onsemi 0:098463de4c5d 3 *
group-onsemi 0:098463de4c5d 4 * Licensed under the Apache License, Version 2.0 (the "License");
group-onsemi 0:098463de4c5d 5 * you may not use this file except in compliance with the License.
group-onsemi 0:098463de4c5d 6 * You may obtain a copy of the License at
group-onsemi 0:098463de4c5d 7 *
group-onsemi 0:098463de4c5d 8 * http://www.apache.org/licenses/LICENSE-2.0
group-onsemi 0:098463de4c5d 9 *
group-onsemi 0:098463de4c5d 10 * Unless required by applicable law or agreed to in writing, software
group-onsemi 0:098463de4c5d 11 * distributed under the License is distributed on an "AS IS" BASIS,
group-onsemi 0:098463de4c5d 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
group-onsemi 0:098463de4c5d 13 * See the License for the specific language governing permissions and
group-onsemi 0:098463de4c5d 14 * limitations under the License.
group-onsemi 0:098463de4c5d 15 */
group-onsemi 0:098463de4c5d 16 #ifndef MBED_TICKER_H
group-onsemi 0:098463de4c5d 17 #define MBED_TICKER_H
group-onsemi 0:098463de4c5d 18
group-onsemi 0:098463de4c5d 19 #include "drivers/TimerEvent.h"
group-onsemi 0:098463de4c5d 20 #include "platform/Callback.h"
group-onsemi 0:098463de4c5d 21 #include "platform/toolchain.h"
group-onsemi 0:098463de4c5d 22
group-onsemi 0:098463de4c5d 23 namespace mbed {
group-onsemi 0:098463de4c5d 24 /** \addtogroup drivers */
group-onsemi 0:098463de4c5d 25 /** @{*/
group-onsemi 0:098463de4c5d 26
group-onsemi 0:098463de4c5d 27 /** A Ticker is used to call a function at a recurring interval
group-onsemi 0:098463de4c5d 28 *
group-onsemi 0:098463de4c5d 29 * You can use as many seperate Ticker objects as you require.
group-onsemi 0:098463de4c5d 30 *
group-onsemi 0:098463de4c5d 31 * @Note Synchronization level: Interrupt safe
group-onsemi 0:098463de4c5d 32 *
group-onsemi 0:098463de4c5d 33 * Example:
group-onsemi 0:098463de4c5d 34 * @code
group-onsemi 0:098463de4c5d 35 * // Toggle the blinking led after 5 seconds
group-onsemi 0:098463de4c5d 36 *
group-onsemi 0:098463de4c5d 37 * #include "mbed.h"
group-onsemi 0:098463de4c5d 38 *
group-onsemi 0:098463de4c5d 39 * Ticker timer;
group-onsemi 0:098463de4c5d 40 * DigitalOut led1(LED1);
group-onsemi 0:098463de4c5d 41 * DigitalOut led2(LED2);
group-onsemi 0:098463de4c5d 42 *
group-onsemi 0:098463de4c5d 43 * int flip = 0;
group-onsemi 0:098463de4c5d 44 *
group-onsemi 0:098463de4c5d 45 * void attime() {
group-onsemi 0:098463de4c5d 46 * flip = !flip;
group-onsemi 0:098463de4c5d 47 * }
group-onsemi 0:098463de4c5d 48 *
group-onsemi 0:098463de4c5d 49 * int main() {
group-onsemi 0:098463de4c5d 50 * timer.attach(&attime, 5);
group-onsemi 0:098463de4c5d 51 * while(1) {
group-onsemi 0:098463de4c5d 52 * if(flip == 0) {
group-onsemi 0:098463de4c5d 53 * led1 = !led1;
group-onsemi 0:098463de4c5d 54 * } else {
group-onsemi 0:098463de4c5d 55 * led2 = !led2;
group-onsemi 0:098463de4c5d 56 * }
group-onsemi 0:098463de4c5d 57 * wait(0.2);
group-onsemi 0:098463de4c5d 58 * }
group-onsemi 0:098463de4c5d 59 * }
group-onsemi 0:098463de4c5d 60 * @endcode
group-onsemi 0:098463de4c5d 61 */
group-onsemi 0:098463de4c5d 62 class Ticker : public TimerEvent {
group-onsemi 0:098463de4c5d 63
group-onsemi 0:098463de4c5d 64 public:
group-onsemi 0:098463de4c5d 65 Ticker() : TimerEvent() {
group-onsemi 0:098463de4c5d 66 }
group-onsemi 0:098463de4c5d 67
group-onsemi 0:098463de4c5d 68 Ticker(const ticker_data_t *data) : TimerEvent(data) {
group-onsemi 0:098463de4c5d 69 data->interface->init();
group-onsemi 0:098463de4c5d 70 }
group-onsemi 0:098463de4c5d 71
group-onsemi 0:098463de4c5d 72 /** Attach a function to be called by the Ticker, specifiying the interval in seconds
group-onsemi 0:098463de4c5d 73 *
group-onsemi 0:098463de4c5d 74 * @param func pointer to the function to be called
group-onsemi 0:098463de4c5d 75 * @param t the time between calls in seconds
group-onsemi 0:098463de4c5d 76 */
group-onsemi 0:098463de4c5d 77 void attach(Callback<void()> func, float t) {
group-onsemi 0:098463de4c5d 78 attach_us(func, t * 1000000.0f);
group-onsemi 0:098463de4c5d 79 }
group-onsemi 0:098463de4c5d 80
group-onsemi 0:098463de4c5d 81 /** Attach a member function to be called by the Ticker, specifiying the interval in seconds
group-onsemi 0:098463de4c5d 82 *
group-onsemi 0:098463de4c5d 83 * @param obj pointer to the object to call the member function on
group-onsemi 0:098463de4c5d 84 * @param method pointer to the member function to be called
group-onsemi 0:098463de4c5d 85 * @param t the time between calls in seconds
group-onsemi 0:098463de4c5d 86 * @deprecated
group-onsemi 0:098463de4c5d 87 * The attach function does not support cv-qualifiers. Replaced by
group-onsemi 0:098463de4c5d 88 * attach(callback(obj, method), t).
group-onsemi 0:098463de4c5d 89 */
group-onsemi 0:098463de4c5d 90 template<typename T, typename M>
group-onsemi 0:098463de4c5d 91 MBED_DEPRECATED_SINCE("mbed-os-5.1",
group-onsemi 0:098463de4c5d 92 "The attach function does not support cv-qualifiers. Replaced by "
group-onsemi 0:098463de4c5d 93 "attach(callback(obj, method), t).")
group-onsemi 0:098463de4c5d 94 void attach(T *obj, M method, float t) {
group-onsemi 0:098463de4c5d 95 attach(callback(obj, method), t);
group-onsemi 0:098463de4c5d 96 }
group-onsemi 0:098463de4c5d 97
group-onsemi 0:098463de4c5d 98 /** Attach a function to be called by the Ticker, specifiying the interval in micro-seconds
group-onsemi 0:098463de4c5d 99 *
group-onsemi 0:098463de4c5d 100 * @param fptr pointer to the function to be called
group-onsemi 0:098463de4c5d 101 * @param t the time between calls in micro-seconds
group-onsemi 0:098463de4c5d 102 */
group-onsemi 0:098463de4c5d 103 void attach_us(Callback<void()> func, timestamp_t t) {
group-onsemi 0:098463de4c5d 104 _function.attach(func);
group-onsemi 0:098463de4c5d 105 setup(t);
group-onsemi 0:098463de4c5d 106 }
group-onsemi 0:098463de4c5d 107
group-onsemi 0:098463de4c5d 108 /** Attach a member function to be called by the Ticker, specifiying the interval in micro-seconds
group-onsemi 0:098463de4c5d 109 *
group-onsemi 0:098463de4c5d 110 * @param tptr pointer to the object to call the member function on
group-onsemi 0:098463de4c5d 111 * @param mptr pointer to the member function to be called
group-onsemi 0:098463de4c5d 112 * @param t the time between calls in micro-seconds
group-onsemi 0:098463de4c5d 113 * @deprecated
group-onsemi 0:098463de4c5d 114 * The attach_us function does not support cv-qualifiers. Replaced by
group-onsemi 0:098463de4c5d 115 * attach_us(callback(obj, method), t).
group-onsemi 0:098463de4c5d 116 */
group-onsemi 0:098463de4c5d 117 template<typename T, typename M>
group-onsemi 0:098463de4c5d 118 MBED_DEPRECATED_SINCE("mbed-os-5.1",
group-onsemi 0:098463de4c5d 119 "The attach_us function does not support cv-qualifiers. Replaced by "
group-onsemi 0:098463de4c5d 120 "attach_us(callback(obj, method), t).")
group-onsemi 0:098463de4c5d 121 void attach_us(T *obj, M method, timestamp_t t) {
group-onsemi 0:098463de4c5d 122 attach_us(Callback<void()>(obj, method), t);
group-onsemi 0:098463de4c5d 123 }
group-onsemi 0:098463de4c5d 124
group-onsemi 0:098463de4c5d 125 virtual ~Ticker() {
group-onsemi 0:098463de4c5d 126 detach();
group-onsemi 0:098463de4c5d 127 }
group-onsemi 0:098463de4c5d 128
group-onsemi 0:098463de4c5d 129 /** Detach the function
group-onsemi 0:098463de4c5d 130 */
group-onsemi 0:098463de4c5d 131 void detach();
group-onsemi 0:098463de4c5d 132
group-onsemi 0:098463de4c5d 133 protected:
group-onsemi 0:098463de4c5d 134 void setup(timestamp_t t);
group-onsemi 0:098463de4c5d 135 virtual void handler();
group-onsemi 0:098463de4c5d 136
group-onsemi 0:098463de4c5d 137 protected:
group-onsemi 0:098463de4c5d 138 timestamp_t _delay; /**< Time delay (in microseconds) for re-setting the multi-shot callback. */
group-onsemi 0:098463de4c5d 139 Callback<void()> _function; /**< Callback. */
group-onsemi 0:098463de4c5d 140 };
group-onsemi 0:098463de4c5d 141
group-onsemi 0:098463de4c5d 142 } // namespace mbed
group-onsemi 0:098463de4c5d 143
group-onsemi 0:098463de4c5d 144 #endif
group-onsemi 0:098463de4c5d 145
group-onsemi 0:098463de4c5d 146 /** @}*/