1 /* mbed Microcontroller Library
2 * Copyright (c) 2006-2013 ARM Limited
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 BusInOut::BusInOut(PinName p0
, PinName p1
, PinName p2
, PinName p3
, PinName p4
, PinName p5
, PinName p6
, PinName p7
, PinName p8
, PinName p9
, PinName p10
, PinName p11
, PinName p12
, PinName p13
, PinName p14
, PinName p15
) {
21 PinName pins
[16] = {p0
, p1
, p2
, p3
, p4
, p5
, p6
, p7
, p8
, p9
, p10
, p11
, p12
, p13
, p14
, p15
};
23 for (int i
=0; i
<16; i
++) {
24 _pin
[i
] = (pins
[i
] != NC
) ? new DigitalInOut(pins
[i
]) : 0;
28 BusInOut::BusInOut(PinName pins
[16]) {
29 for (int i
=0; i
<16; i
++) {
30 _pin
[i
] = (pins
[i
] != NC
) ? new DigitalInOut(pins
[i
]) : 0;
34 BusInOut::~BusInOut() {
35 for (int i
=0; i
<16; i
++) {
42 void BusInOut::write(int value
) {
43 for (int i
=0; i
<16; i
++) {
45 _pin
[i
]->write((value
>> i
) & 1);
50 int BusInOut::read() {
52 for (int i
=0; i
<16; i
++) {
54 v
|= _pin
[i
]->read() << i
;
60 void BusInOut::output() {
61 for (int i
=0; i
<16; i
++) {
68 void BusInOut::input() {
69 for (int i
=0; i
<16; i
++) {
76 void BusInOut::mode(PinMode pull
) {
77 for (int i
=0; i
<16; i
++) {
85 BusInOut
& BusInOut::operator= (int v
) {
90 BusInOut
& BusInOut::operator= (BusInOut
& rhs
) {
95 BusInOut::operator int() {