change some io settings for TWR-K22F-120M

Dependents:   twr_helloworld

Committer:
Jasper_lee
Date:
Tue Dec 23 03:35:08 2014 +0000
Revision:
0:b16d94660a33
change some io setting used in TWR-K22F120M

Who changed what in which revision?

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