mbed library sources 只保留l0和l1系列的库,修改l0的库的晶振为12m

Dependents:   SANFAN_read_analog_value nucleo-wdg Nucleo_sleep_copy

Fork of mbed-src by mbed official

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers BusIn.h Source File

BusIn.h

00001 /* mbed Microcontroller Library
00002  * Copyright (c) 2006-2013 ARM Limited
00003  *
00004  * Licensed under the Apache License, Version 2.0 (the "License");
00005  * you may not use this file except in compliance with the License.
00006  * You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 #ifndef MBED_BUSIN_H
00017 #define MBED_BUSIN_H
00018 
00019 #include "platform.h"
00020 #include "DigitalIn.h"
00021 
00022 namespace mbed {
00023 
00024 /** A digital input bus, used for reading the state of a collection of pins
00025  */
00026 class BusIn {
00027 
00028 public:
00029     /* Group: Configuration Methods */
00030 
00031     /** Create an BusIn, connected to the specified pins
00032      *
00033      * @param <n> DigitalIn pin to connect to bus bit <n> (p5-p30, NC)
00034      *
00035      * @note
00036      *  It is only required to specify as many pin variables as is required
00037      *  for the bus; the rest will default to NC (not connected)
00038      */
00039     BusIn(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC,
00040           PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC,
00041           PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
00042           PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC);
00043 
00044     BusIn(PinName pins[16]);
00045 
00046     virtual ~BusIn();
00047 
00048     /** Read the value of the input bus
00049      *
00050      *  @returns
00051      *   An integer with each bit corresponding to the value read from the associated DigitalIn pin
00052      */
00053     int read();
00054 
00055     /** Set the input pin mode
00056      *
00057      *  @param mode PullUp, PullDown, PullNone
00058      */
00059     void mode(PinMode pull);
00060 
00061     /** Binary mask of bus pins connected to actual pins (not NC pins)
00062      *  If bus pin is in NC state make corresponding bit will be cleared (set to 0), else bit will be set to 1
00063      *
00064      *  @returns
00065      *    Binary mask of connected pins
00066      */
00067     int mask() {
00068         return _nc_mask;
00069     }
00070 
00071 #ifdef MBED_OPERATORS
00072     /** A shorthand for read()
00073      */
00074     operator int();
00075 
00076     /** Access to particular bit in random-iterator fashion
00077      */
00078     DigitalIn & operator[] (int index);
00079 #endif
00080 
00081 protected:
00082     DigitalIn* _pin[16];
00083 
00084     /** Mask of bus's NC pins
00085      * If bit[n] is set to 1 - pin is connected
00086      * if bit[n] is cleared - pin is not connected (NC)
00087      */
00088     int _nc_mask;
00089 
00090     /* disallow copy constructor and assignment operators */
00091 private:
00092     BusIn(const BusIn&);
00093     BusIn & operator = (const BusIn&);
00094 };
00095 
00096 } // namespace mbed
00097 
00098 #endif