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:
Wed Mar 08 10:24:56 2017 +0000
Revision:
2:c69117fc79da
Parent:
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_BUSOUT_H
16038618 1:4bdfa7d7e8bf 17 #define MBED_BUSOUT_H
16038618 1:4bdfa7d7e8bf 18
16038618 1:4bdfa7d7e8bf 19 #include "DigitalOut.h"
16038618 1:4bdfa7d7e8bf 20
16038618 1:4bdfa7d7e8bf 21 namespace mbed {
16038618 1:4bdfa7d7e8bf 22
16038618 1:4bdfa7d7e8bf 23 /** A digital output bus, used for setting the state of a collection of pins
16038618 1:4bdfa7d7e8bf 24 */
16038618 1:4bdfa7d7e8bf 25 class BusOut {
16038618 1:4bdfa7d7e8bf 26
16038618 1:4bdfa7d7e8bf 27 public:
16038618 1:4bdfa7d7e8bf 28
16038618 1:4bdfa7d7e8bf 29 /** Create an BusOut, connected to the specified pins
16038618 1:4bdfa7d7e8bf 30 *
16038618 1:4bdfa7d7e8bf 31 * @param p<n> DigitalOut pin to connect to bus bit <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 BusOut(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 BusOut(PinName pins[16]);
16038618 1:4bdfa7d7e8bf 43
16038618 1:4bdfa7d7e8bf 44 virtual ~BusOut();
16038618 1:4bdfa7d7e8bf 45
16038618 1:4bdfa7d7e8bf 46 /** Write the value to the output bus
16038618 1:4bdfa7d7e8bf 47 *
16038618 1:4bdfa7d7e8bf 48 * @param value An integer specifying a bit to write for every corresponding DigitalOut pin
16038618 1:4bdfa7d7e8bf 49 */
16038618 1:4bdfa7d7e8bf 50 void write(int value);
16038618 1:4bdfa7d7e8bf 51
16038618 1:4bdfa7d7e8bf 52 /** Read the value currently output on the bus
16038618 1:4bdfa7d7e8bf 53 *
16038618 1:4bdfa7d7e8bf 54 * @returns
16038618 1:4bdfa7d7e8bf 55 * An integer with each bit corresponding to associated DigitalOut pin setting
16038618 1:4bdfa7d7e8bf 56 */
16038618 1:4bdfa7d7e8bf 57 int read();
16038618 1:4bdfa7d7e8bf 58
16038618 1:4bdfa7d7e8bf 59 /** Binary mask of bus pins connected to actual pins (not NC pins)
16038618 1:4bdfa7d7e8bf 60 * 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 61 *
16038618 1:4bdfa7d7e8bf 62 * @returns
16038618 1:4bdfa7d7e8bf 63 * Binary mask of connected pins
16038618 1:4bdfa7d7e8bf 64 */
16038618 1:4bdfa7d7e8bf 65 int mask() {
16038618 1:4bdfa7d7e8bf 66 return _nc_mask;
16038618 1:4bdfa7d7e8bf 67 }
16038618 1:4bdfa7d7e8bf 68
16038618 1:4bdfa7d7e8bf 69 #ifdef MBED_OPERATORS
16038618 1:4bdfa7d7e8bf 70 /** A shorthand for write()
16038618 1:4bdfa7d7e8bf 71 */
16038618 1:4bdfa7d7e8bf 72 BusOut& operator= (int v);
16038618 1:4bdfa7d7e8bf 73 BusOut& operator= (BusOut& rhs);
16038618 1:4bdfa7d7e8bf 74
16038618 1:4bdfa7d7e8bf 75 /** Access to particular bit in random-iterator fashion
16038618 1:4bdfa7d7e8bf 76 */
16038618 1:4bdfa7d7e8bf 77 DigitalOut& operator[] (int index);
16038618 1:4bdfa7d7e8bf 78
16038618 1:4bdfa7d7e8bf 79 /** A shorthand for read()
16038618 1:4bdfa7d7e8bf 80 */
16038618 1:4bdfa7d7e8bf 81 operator int();
16038618 1:4bdfa7d7e8bf 82 #endif
16038618 1:4bdfa7d7e8bf 83
16038618 1:4bdfa7d7e8bf 84 protected:
16038618 1:4bdfa7d7e8bf 85 DigitalOut* _pin[16];
16038618 1:4bdfa7d7e8bf 86
16038618 1:4bdfa7d7e8bf 87 /** Mask of bus's NC pins
16038618 1:4bdfa7d7e8bf 88 * If bit[n] is set to 1 - pin is connected
16038618 1:4bdfa7d7e8bf 89 * if bit[n] is cleared - pin is not connected (NC)
16038618 1:4bdfa7d7e8bf 90 */
16038618 1:4bdfa7d7e8bf 91 int _nc_mask;
16038618 1:4bdfa7d7e8bf 92
16038618 1:4bdfa7d7e8bf 93 /* disallow copy constructor and assignment operators */
16038618 1:4bdfa7d7e8bf 94 private:
16038618 1:4bdfa7d7e8bf 95 BusOut(const BusOut&);
16038618 1:4bdfa7d7e8bf 96 BusOut & operator = (const BusOut&);
16038618 1:4bdfa7d7e8bf 97 };
16038618 1:4bdfa7d7e8bf 98
16038618 1:4bdfa7d7e8bf 99 } // namespace mbed
16038618 1:4bdfa7d7e8bf 100
16038618 1:4bdfa7d7e8bf 101 #endif