Public fork of mbed-src to add generic stm32f030k6 target

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Tue Jan 27 13:30:08 2015 +0000
Revision:
455:8bc3a354916d
Parent:
212:34d62c0b2af6
Synchronized with git revision de09d163deef812a246ac8c48fb2978385bc7b53

Full URL: https://github.com/mbedmicro/mbed/commit/de09d163deef812a246ac8c48fb2978385bc7b53/

Who changed what in which revision?

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