USBclock 48Mhz, enable serial4 and serial5.

Fork of mbed-src by mbed official

Import programL152RE_serial45_example

NUCLEO-L152RE serial4,5 test program

Committer:
mbed_official
Date:
Tue Jan 27 13:30:08 2015 +0000
Revision:
455:8bc3a354916d
Parent:
13:0645d8841f51
Child:
457:777fdfed0738
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 #include "BusOut.h"
bogdanm 13:0645d8841f51 17
bogdanm 13:0645d8841f51 18 namespace mbed {
bogdanm 13:0645d8841f51 19
bogdanm 13:0645d8841f51 20 BusOut::BusOut(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) {
bogdanm 13:0645d8841f51 21 PinName pins[16] = {p0, p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, p11, p12, p13, p14, p15};
bogdanm 13:0645d8841f51 22
mbed_official 455:8bc3a354916d 23 _nc_mask = 0;
bogdanm 13:0645d8841f51 24 for (int i=0; i<16; i++) {
bogdanm 13:0645d8841f51 25 _pin[i] = (pins[i] != NC) ? new DigitalOut(pins[i]) : 0;
mbed_official 455:8bc3a354916d 26 if (pins[i] != NC) {
mbed_official 455:8bc3a354916d 27 _nc_mask |= (1 << i);
mbed_official 455:8bc3a354916d 28 }
bogdanm 13:0645d8841f51 29 }
bogdanm 13:0645d8841f51 30 }
bogdanm 13:0645d8841f51 31
bogdanm 13:0645d8841f51 32 BusOut::BusOut(PinName pins[16]) {
mbed_official 455:8bc3a354916d 33 _nc_mask = 0;
bogdanm 13:0645d8841f51 34 for (int i=0; i<16; i++) {
bogdanm 13:0645d8841f51 35 _pin[i] = (pins[i] != NC) ? new DigitalOut(pins[i]) : 0;
mbed_official 455:8bc3a354916d 36 if (pins[i] != NC) {
mbed_official 455:8bc3a354916d 37 _nc_mask |= (1 << i);
mbed_official 455:8bc3a354916d 38 }
bogdanm 13:0645d8841f51 39 }
bogdanm 13:0645d8841f51 40 }
bogdanm 13:0645d8841f51 41
bogdanm 13:0645d8841f51 42 BusOut::~BusOut() {
bogdanm 13:0645d8841f51 43 for (int i=0; i<16; i++) {
bogdanm 13:0645d8841f51 44 if (_pin[i] != 0) {
bogdanm 13:0645d8841f51 45 delete _pin[i];
bogdanm 13:0645d8841f51 46 }
bogdanm 13:0645d8841f51 47 }
bogdanm 13:0645d8841f51 48 }
bogdanm 13:0645d8841f51 49
bogdanm 13:0645d8841f51 50 void BusOut::write(int value) {
bogdanm 13:0645d8841f51 51 for (int i=0; i<16; i++) {
bogdanm 13:0645d8841f51 52 if (_pin[i] != 0) {
bogdanm 13:0645d8841f51 53 _pin[i]->write((value >> i) & 1);
bogdanm 13:0645d8841f51 54 }
bogdanm 13:0645d8841f51 55 }
bogdanm 13:0645d8841f51 56 }
bogdanm 13:0645d8841f51 57
bogdanm 13:0645d8841f51 58 int BusOut::read() {
bogdanm 13:0645d8841f51 59 int v = 0;
bogdanm 13:0645d8841f51 60 for (int i=0; i<16; i++) {
bogdanm 13:0645d8841f51 61 if (_pin[i] != 0) {
bogdanm 13:0645d8841f51 62 v |= _pin[i]->read() << i;
bogdanm 13:0645d8841f51 63 }
bogdanm 13:0645d8841f51 64 }
bogdanm 13:0645d8841f51 65 return v;
bogdanm 13:0645d8841f51 66 }
bogdanm 13:0645d8841f51 67
bogdanm 13:0645d8841f51 68 #ifdef MBED_OPERATORS
bogdanm 13:0645d8841f51 69 BusOut& BusOut::operator= (int v) {
bogdanm 13:0645d8841f51 70 write(v);
bogdanm 13:0645d8841f51 71 return *this;
bogdanm 13:0645d8841f51 72 }
bogdanm 13:0645d8841f51 73
bogdanm 13:0645d8841f51 74 BusOut& BusOut::operator= (BusOut& rhs) {
bogdanm 13:0645d8841f51 75 write(rhs.read());
bogdanm 13:0645d8841f51 76 return *this;
bogdanm 13:0645d8841f51 77 }
bogdanm 13:0645d8841f51 78
mbed_official 455:8bc3a354916d 79 DigitalOut& BusOut::operator[] (int index) {
mbed_official 455:8bc3a354916d 80 MBED_ASSERT(index >= 0 && index <= 16);
mbed_official 455:8bc3a354916d 81 MBED_ASSERT(_pin[index]);
mbed_official 455:8bc3a354916d 82 return *_pin[index];
mbed_official 455:8bc3a354916d 83 }
mbed_official 455:8bc3a354916d 84
bogdanm 13:0645d8841f51 85 BusOut::operator int() {
bogdanm 13:0645d8841f51 86 return read();
bogdanm 13:0645d8841f51 87 }
bogdanm 13:0645d8841f51 88 #endif
bogdanm 13:0645d8841f51 89
bogdanm 13:0645d8841f51 90 } // namespace mbed