5.2.1 - Updated I2C files

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

Committer:
group-onsemi
Date:
Wed Jan 25 20:34:15 2017 +0000
Revision:
0:098463de4c5d
Initial commit

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_BUSOUT_H
group-onsemi 0:098463de4c5d 17 #define MBED_BUSOUT_H
group-onsemi 0:098463de4c5d 18
group-onsemi 0:098463de4c5d 19 #include "drivers/DigitalOut.h"
group-onsemi 0:098463de4c5d 20 #include "platform/PlatformMutex.h"
group-onsemi 0:098463de4c5d 21
group-onsemi 0:098463de4c5d 22 namespace mbed {
group-onsemi 0:098463de4c5d 23 /** \addtogroup drivers */
group-onsemi 0:098463de4c5d 24 /** @{*/
group-onsemi 0:098463de4c5d 25
group-onsemi 0:098463de4c5d 26 /** A digital output bus, used for setting the state of a collection of pins
group-onsemi 0:098463de4c5d 27 */
group-onsemi 0:098463de4c5d 28 class BusOut {
group-onsemi 0:098463de4c5d 29
group-onsemi 0:098463de4c5d 30 public:
group-onsemi 0:098463de4c5d 31
group-onsemi 0:098463de4c5d 32 /** Create an BusOut, connected to the specified pins
group-onsemi 0:098463de4c5d 33 *
group-onsemi 0:098463de4c5d 34 * @param p<n> DigitalOut pin to connect to bus bit <n> (p5-p30, NC)
group-onsemi 0:098463de4c5d 35 *
group-onsemi 0:098463de4c5d 36 * @Note Synchronization level: Thread safe
group-onsemi 0:098463de4c5d 37 *
group-onsemi 0:098463de4c5d 38 * @note
group-onsemi 0:098463de4c5d 39 * It is only required to specify as many pin variables as is required
group-onsemi 0:098463de4c5d 40 * for the bus; the rest will default to NC (not connected)
group-onsemi 0:098463de4c5d 41 */
group-onsemi 0:098463de4c5d 42 BusOut(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC,
group-onsemi 0:098463de4c5d 43 PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC,
group-onsemi 0:098463de4c5d 44 PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
group-onsemi 0:098463de4c5d 45 PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC);
group-onsemi 0:098463de4c5d 46
group-onsemi 0:098463de4c5d 47 BusOut(PinName pins[16]);
group-onsemi 0:098463de4c5d 48
group-onsemi 0:098463de4c5d 49 virtual ~BusOut();
group-onsemi 0:098463de4c5d 50
group-onsemi 0:098463de4c5d 51 /** Write the value to the output bus
group-onsemi 0:098463de4c5d 52 *
group-onsemi 0:098463de4c5d 53 * @param value An integer specifying a bit to write for every corresponding DigitalOut pin
group-onsemi 0:098463de4c5d 54 */
group-onsemi 0:098463de4c5d 55 void write(int value);
group-onsemi 0:098463de4c5d 56
group-onsemi 0:098463de4c5d 57 /** Read the value currently output on the bus
group-onsemi 0:098463de4c5d 58 *
group-onsemi 0:098463de4c5d 59 * @returns
group-onsemi 0:098463de4c5d 60 * An integer with each bit corresponding to associated DigitalOut pin setting
group-onsemi 0:098463de4c5d 61 */
group-onsemi 0:098463de4c5d 62 int read();
group-onsemi 0:098463de4c5d 63
group-onsemi 0:098463de4c5d 64 /** Binary mask of bus pins connected to actual pins (not NC pins)
group-onsemi 0:098463de4c5d 65 * If bus pin is in NC state make corresponding bit will be cleared (set to 0), else bit will be set to 1
group-onsemi 0:098463de4c5d 66 *
group-onsemi 0:098463de4c5d 67 * @returns
group-onsemi 0:098463de4c5d 68 * Binary mask of connected pins
group-onsemi 0:098463de4c5d 69 */
group-onsemi 0:098463de4c5d 70 int mask() {
group-onsemi 0:098463de4c5d 71 // No lock needed since _nc_mask is not modified outside the constructor
group-onsemi 0:098463de4c5d 72 return _nc_mask;
group-onsemi 0:098463de4c5d 73 }
group-onsemi 0:098463de4c5d 74
group-onsemi 0:098463de4c5d 75 /** A shorthand for write()
group-onsemi 0:098463de4c5d 76 */
group-onsemi 0:098463de4c5d 77 BusOut& operator= (int v);
group-onsemi 0:098463de4c5d 78 BusOut& operator= (BusOut& rhs);
group-onsemi 0:098463de4c5d 79
group-onsemi 0:098463de4c5d 80 /** Access to particular bit in random-iterator fashion
group-onsemi 0:098463de4c5d 81 */
group-onsemi 0:098463de4c5d 82 DigitalOut& operator[] (int index);
group-onsemi 0:098463de4c5d 83
group-onsemi 0:098463de4c5d 84 /** A shorthand for read()
group-onsemi 0:098463de4c5d 85 */
group-onsemi 0:098463de4c5d 86 operator int();
group-onsemi 0:098463de4c5d 87
group-onsemi 0:098463de4c5d 88 protected:
group-onsemi 0:098463de4c5d 89 virtual void lock();
group-onsemi 0:098463de4c5d 90 virtual void unlock();
group-onsemi 0:098463de4c5d 91 DigitalOut* _pin[16];
group-onsemi 0:098463de4c5d 92
group-onsemi 0:098463de4c5d 93 /** Mask of bus's NC pins
group-onsemi 0:098463de4c5d 94 * If bit[n] is set to 1 - pin is connected
group-onsemi 0:098463de4c5d 95 * if bit[n] is cleared - pin is not connected (NC)
group-onsemi 0:098463de4c5d 96 */
group-onsemi 0:098463de4c5d 97 int _nc_mask;
group-onsemi 0:098463de4c5d 98
group-onsemi 0:098463de4c5d 99 PlatformMutex _mutex;
group-onsemi 0:098463de4c5d 100
group-onsemi 0:098463de4c5d 101 /* disallow copy constructor and assignment operators */
group-onsemi 0:098463de4c5d 102 private:
group-onsemi 0:098463de4c5d 103 BusOut(const BusOut&);
group-onsemi 0:098463de4c5d 104 BusOut & operator = (const BusOut&);
group-onsemi 0:098463de4c5d 105 };
group-onsemi 0:098463de4c5d 106
group-onsemi 0:098463de4c5d 107 } // namespace mbed
group-onsemi 0:098463de4c5d 108
group-onsemi 0:098463de4c5d 109 #endif
group-onsemi 0:098463de4c5d 110
group-onsemi 0:098463de4c5d 111 /** @}*/