MCU driver/HAL for the Picocell Gateway concentrator board. The firmware implements either a USB CDC protocol or a UART protocol to bridge commands coming from host to the SX1308 SPI interface.

Committer:
dgabino
Date:
Wed Apr 11 14:42:47 2018 +0000
Revision:
0:c76361bd82e8
Initial commit

Who changed what in which revision?

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