IOTIO

Dependencies:   Nucleo_BLE_API_IOTIO Nucleo_BLE_BlueNRG Nucleo_BLE_DemoApp Nucleo_Sensor_Shield mbed

Dependents:   Nucleo_BLE_Demo_IOTIO

Fork of Nucleo_BLE_Demo by Cortex Challenge Team

Committer:
16038618
Date:
Sat Oct 29 15:11:28 2016 +0000
Revision:
1:4bdfa7d7e8bf
IOTIO

Who changed what in which revision?

UserRevisionLine numberNew contents of line
16038618 1:4bdfa7d7e8bf 1 /* mbed Microcontroller Library
16038618 1:4bdfa7d7e8bf 2 * Copyright (c) 2006-2013 ARM Limited
16038618 1:4bdfa7d7e8bf 3 *
16038618 1:4bdfa7d7e8bf 4 * Licensed under the Apache License, Version 2.0 (the "License");
16038618 1:4bdfa7d7e8bf 5 * you may not use this file except in compliance with the License.
16038618 1:4bdfa7d7e8bf 6 * You may obtain a copy of the License at
16038618 1:4bdfa7d7e8bf 7 *
16038618 1:4bdfa7d7e8bf 8 * http://www.apache.org/licenses/LICENSE-2.0
16038618 1:4bdfa7d7e8bf 9 *
16038618 1:4bdfa7d7e8bf 10 * Unless required by applicable law or agreed to in writing, software
16038618 1:4bdfa7d7e8bf 11 * distributed under the License is distributed on an "AS IS" BASIS,
16038618 1:4bdfa7d7e8bf 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16038618 1:4bdfa7d7e8bf 13 * See the License for the specific language governing permissions and
16038618 1:4bdfa7d7e8bf 14 * limitations under the License.
16038618 1:4bdfa7d7e8bf 15 */
16038618 1:4bdfa7d7e8bf 16 #ifndef MBED_BUSINOUT_H
16038618 1:4bdfa7d7e8bf 17 #define MBED_BUSINOUT_H
16038618 1:4bdfa7d7e8bf 18
16038618 1:4bdfa7d7e8bf 19 #include "DigitalInOut.h"
16038618 1:4bdfa7d7e8bf 20
16038618 1:4bdfa7d7e8bf 21 namespace mbed {
16038618 1:4bdfa7d7e8bf 22
16038618 1:4bdfa7d7e8bf 23 /** A digital input output bus, used for setting the state of a collection of pins
16038618 1:4bdfa7d7e8bf 24 */
16038618 1:4bdfa7d7e8bf 25 class BusInOut {
16038618 1:4bdfa7d7e8bf 26
16038618 1:4bdfa7d7e8bf 27 public:
16038618 1:4bdfa7d7e8bf 28
16038618 1:4bdfa7d7e8bf 29 /** Create an BusInOut, connected to the specified pins
16038618 1:4bdfa7d7e8bf 30 *
16038618 1:4bdfa7d7e8bf 31 * @param p<n> DigitalInOut pin to connect to bus bit p<n> (p5-p30, NC)
16038618 1:4bdfa7d7e8bf 32 *
16038618 1:4bdfa7d7e8bf 33 * @note
16038618 1:4bdfa7d7e8bf 34 * It is only required to specify as many pin variables as is required
16038618 1:4bdfa7d7e8bf 35 * for the bus; the rest will default to NC (not connected)
16038618 1:4bdfa7d7e8bf 36 */
16038618 1:4bdfa7d7e8bf 37 BusInOut(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC,
16038618 1:4bdfa7d7e8bf 38 PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC,
16038618 1:4bdfa7d7e8bf 39 PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
16038618 1:4bdfa7d7e8bf 40 PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC);
16038618 1:4bdfa7d7e8bf 41
16038618 1:4bdfa7d7e8bf 42 BusInOut(PinName pins[16]);
16038618 1:4bdfa7d7e8bf 43
16038618 1:4bdfa7d7e8bf 44 virtual ~BusInOut();
16038618 1:4bdfa7d7e8bf 45
16038618 1:4bdfa7d7e8bf 46 /* Group: Access Methods */
16038618 1:4bdfa7d7e8bf 47
16038618 1:4bdfa7d7e8bf 48 /** Write the value to the output bus
16038618 1:4bdfa7d7e8bf 49 *
16038618 1:4bdfa7d7e8bf 50 * @param value An integer specifying a bit to write for every corresponding DigitalInOut pin
16038618 1:4bdfa7d7e8bf 51 */
16038618 1:4bdfa7d7e8bf 52 void write(int value);
16038618 1:4bdfa7d7e8bf 53
16038618 1:4bdfa7d7e8bf 54 /** Read the value currently output on the bus
16038618 1:4bdfa7d7e8bf 55 *
16038618 1:4bdfa7d7e8bf 56 * @returns
16038618 1:4bdfa7d7e8bf 57 * An integer with each bit corresponding to associated DigitalInOut pin setting
16038618 1:4bdfa7d7e8bf 58 */
16038618 1:4bdfa7d7e8bf 59 int read();
16038618 1:4bdfa7d7e8bf 60
16038618 1:4bdfa7d7e8bf 61 /** Set as an output
16038618 1:4bdfa7d7e8bf 62 */
16038618 1:4bdfa7d7e8bf 63 void output();
16038618 1:4bdfa7d7e8bf 64
16038618 1:4bdfa7d7e8bf 65 /** Set as an input
16038618 1:4bdfa7d7e8bf 66 */
16038618 1:4bdfa7d7e8bf 67 void input();
16038618 1:4bdfa7d7e8bf 68
16038618 1:4bdfa7d7e8bf 69 /** Set the input pin mode
16038618 1:4bdfa7d7e8bf 70 *
16038618 1:4bdfa7d7e8bf 71 * @param mode PullUp, PullDown, PullNone
16038618 1:4bdfa7d7e8bf 72 */
16038618 1:4bdfa7d7e8bf 73 void mode(PinMode pull);
16038618 1:4bdfa7d7e8bf 74
16038618 1:4bdfa7d7e8bf 75 /** Binary mask of bus pins connected to actual pins (not NC pins)
16038618 1:4bdfa7d7e8bf 76 * If bus pin is in NC state make corresponding bit will be cleared (set to 0), else bit will be set to 1
16038618 1:4bdfa7d7e8bf 77 *
16038618 1:4bdfa7d7e8bf 78 * @returns
16038618 1:4bdfa7d7e8bf 79 * Binary mask of connected pins
16038618 1:4bdfa7d7e8bf 80 */
16038618 1:4bdfa7d7e8bf 81 int mask() {
16038618 1:4bdfa7d7e8bf 82 return _nc_mask;
16038618 1:4bdfa7d7e8bf 83 }
16038618 1:4bdfa7d7e8bf 84
16038618 1:4bdfa7d7e8bf 85 #ifdef MBED_OPERATORS
16038618 1:4bdfa7d7e8bf 86 /** A shorthand for write()
16038618 1:4bdfa7d7e8bf 87 */
16038618 1:4bdfa7d7e8bf 88 BusInOut& operator= (int v);
16038618 1:4bdfa7d7e8bf 89 BusInOut& operator= (BusInOut& rhs);
16038618 1:4bdfa7d7e8bf 90
16038618 1:4bdfa7d7e8bf 91 /** Access to particular bit in random-iterator fashion
16038618 1:4bdfa7d7e8bf 92 */
16038618 1:4bdfa7d7e8bf 93 DigitalInOut& operator[] (int index);
16038618 1:4bdfa7d7e8bf 94
16038618 1:4bdfa7d7e8bf 95 /** A shorthand for read()
16038618 1:4bdfa7d7e8bf 96 */
16038618 1:4bdfa7d7e8bf 97 operator int();
16038618 1:4bdfa7d7e8bf 98 #endif
16038618 1:4bdfa7d7e8bf 99
16038618 1:4bdfa7d7e8bf 100 protected:
16038618 1:4bdfa7d7e8bf 101 DigitalInOut* _pin[16];
16038618 1:4bdfa7d7e8bf 102
16038618 1:4bdfa7d7e8bf 103 /** Mask of bus's NC pins
16038618 1:4bdfa7d7e8bf 104 * If bit[n] is set to 1 - pin is connected
16038618 1:4bdfa7d7e8bf 105 * if bit[n] is cleared - pin is not connected (NC)
16038618 1:4bdfa7d7e8bf 106 */
16038618 1:4bdfa7d7e8bf 107 int _nc_mask;
16038618 1:4bdfa7d7e8bf 108
16038618 1:4bdfa7d7e8bf 109 /* disallow copy constructor and assignment operators */
16038618 1:4bdfa7d7e8bf 110 private:
16038618 1:4bdfa7d7e8bf 111 BusInOut(const BusInOut&);
16038618 1:4bdfa7d7e8bf 112 BusInOut & operator = (const BusInOut&);
16038618 1:4bdfa7d7e8bf 113 };
16038618 1:4bdfa7d7e8bf 114
16038618 1:4bdfa7d7e8bf 115 } // namespace mbed
16038618 1:4bdfa7d7e8bf 116
16038618 1:4bdfa7d7e8bf 117 #endif