LPC11U35 ADC Tick & USBSerial

Dependencies:   mbed

Dependents:   SmallDoseMeter_SingleCH_AE_lpc11u35_V1_00

Committer:
H_Tsunemoto
Date:
Mon Feb 19 09:09:52 2018 +0000
Revision:
1:b1a3be5f48ab
Parent:
0:871ab6846b18
test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
H_Tsunemoto 0:871ab6846b18 1 /* mbed Microcontroller Library
H_Tsunemoto 0:871ab6846b18 2 * Copyright (c) 2006-2013 ARM Limited
H_Tsunemoto 0:871ab6846b18 3 *
H_Tsunemoto 0:871ab6846b18 4 * Licensed under the Apache License, Version 2.0 (the "License");
H_Tsunemoto 0:871ab6846b18 5 * you may not use this file except in compliance with the License.
H_Tsunemoto 0:871ab6846b18 6 * You may obtain a copy of the License at
H_Tsunemoto 0:871ab6846b18 7 *
H_Tsunemoto 0:871ab6846b18 8 * http://www.apache.org/licenses/LICENSE-2.0
H_Tsunemoto 0:871ab6846b18 9 *
H_Tsunemoto 0:871ab6846b18 10 * Unless required by applicable law or agreed to in writing, software
H_Tsunemoto 0:871ab6846b18 11 * distributed under the License is distributed on an "AS IS" BASIS,
H_Tsunemoto 0:871ab6846b18 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
H_Tsunemoto 0:871ab6846b18 13 * See the License for the specific language governing permissions and
H_Tsunemoto 0:871ab6846b18 14 * limitations under the License.
H_Tsunemoto 0:871ab6846b18 15 */
H_Tsunemoto 0:871ab6846b18 16 #ifndef MBED_PORTINOUT_H
H_Tsunemoto 0:871ab6846b18 17 #define MBED_PORTINOUT_H
H_Tsunemoto 0:871ab6846b18 18
H_Tsunemoto 0:871ab6846b18 19 #include "platform.h"
H_Tsunemoto 0:871ab6846b18 20
H_Tsunemoto 0:871ab6846b18 21 #if DEVICE_PORTINOUT
H_Tsunemoto 0:871ab6846b18 22
H_Tsunemoto 0:871ab6846b18 23 #include "port_api.h"
H_Tsunemoto 0:871ab6846b18 24
H_Tsunemoto 0:871ab6846b18 25 namespace mbed {
H_Tsunemoto 0:871ab6846b18 26
H_Tsunemoto 0:871ab6846b18 27 /** A multiple pin digital in/out used to set/read multiple bi-directional pins
H_Tsunemoto 0:871ab6846b18 28 */
H_Tsunemoto 0:871ab6846b18 29 class PortInOut {
H_Tsunemoto 0:871ab6846b18 30 public:
H_Tsunemoto 0:871ab6846b18 31
H_Tsunemoto 0:871ab6846b18 32 /** Create an PortInOut, connected to the specified port
H_Tsunemoto 0:871ab6846b18 33 *
H_Tsunemoto 0:871ab6846b18 34 * @param port Port to connect to (Port0-Port5)
H_Tsunemoto 0:871ab6846b18 35 * @param mask A bitmask to identify which bits in the port should be included (0 - ignore)
H_Tsunemoto 0:871ab6846b18 36 */
H_Tsunemoto 0:871ab6846b18 37 PortInOut(PortName port, int mask = 0xFFFFFFFF) {
H_Tsunemoto 0:871ab6846b18 38 port_init(&_port, port, mask, PIN_INPUT);
H_Tsunemoto 0:871ab6846b18 39 }
H_Tsunemoto 0:871ab6846b18 40
H_Tsunemoto 0:871ab6846b18 41 /** Write the value to the output port
H_Tsunemoto 0:871ab6846b18 42 *
H_Tsunemoto 0:871ab6846b18 43 * @param value An integer specifying a bit to write for every corresponding port pin
H_Tsunemoto 0:871ab6846b18 44 */
H_Tsunemoto 0:871ab6846b18 45 void write(int value) {
H_Tsunemoto 0:871ab6846b18 46 port_write(&_port, value);
H_Tsunemoto 0:871ab6846b18 47 }
H_Tsunemoto 0:871ab6846b18 48
H_Tsunemoto 0:871ab6846b18 49 /** Read the value currently output on the port
H_Tsunemoto 0:871ab6846b18 50 *
H_Tsunemoto 0:871ab6846b18 51 * @returns
H_Tsunemoto 0:871ab6846b18 52 * An integer with each bit corresponding to associated port pin setting
H_Tsunemoto 0:871ab6846b18 53 */
H_Tsunemoto 0:871ab6846b18 54 int read() {
H_Tsunemoto 0:871ab6846b18 55 return port_read(&_port);
H_Tsunemoto 0:871ab6846b18 56 }
H_Tsunemoto 0:871ab6846b18 57
H_Tsunemoto 0:871ab6846b18 58 /** Set as an output
H_Tsunemoto 0:871ab6846b18 59 */
H_Tsunemoto 0:871ab6846b18 60 void output() {
H_Tsunemoto 0:871ab6846b18 61 port_dir(&_port, PIN_OUTPUT);
H_Tsunemoto 0:871ab6846b18 62 }
H_Tsunemoto 0:871ab6846b18 63
H_Tsunemoto 0:871ab6846b18 64 /** Set as an input
H_Tsunemoto 0:871ab6846b18 65 */
H_Tsunemoto 0:871ab6846b18 66 void input() {
H_Tsunemoto 0:871ab6846b18 67 port_dir(&_port, PIN_INPUT);
H_Tsunemoto 0:871ab6846b18 68 }
H_Tsunemoto 0:871ab6846b18 69
H_Tsunemoto 0:871ab6846b18 70 /** Set the input pin mode
H_Tsunemoto 0:871ab6846b18 71 *
H_Tsunemoto 0:871ab6846b18 72 * @param mode PullUp, PullDown, PullNone, OpenDrain
H_Tsunemoto 0:871ab6846b18 73 */
H_Tsunemoto 0:871ab6846b18 74 void mode(PinMode mode) {
H_Tsunemoto 0:871ab6846b18 75 port_mode(&_port, mode);
H_Tsunemoto 0:871ab6846b18 76 }
H_Tsunemoto 0:871ab6846b18 77
H_Tsunemoto 0:871ab6846b18 78 /** A shorthand for write()
H_Tsunemoto 0:871ab6846b18 79 */
H_Tsunemoto 0:871ab6846b18 80 PortInOut& operator= (int value) {
H_Tsunemoto 0:871ab6846b18 81 write(value);
H_Tsunemoto 0:871ab6846b18 82 return *this;
H_Tsunemoto 0:871ab6846b18 83 }
H_Tsunemoto 0:871ab6846b18 84
H_Tsunemoto 0:871ab6846b18 85 PortInOut& operator= (PortInOut& rhs) {
H_Tsunemoto 0:871ab6846b18 86 write(rhs.read());
H_Tsunemoto 0:871ab6846b18 87 return *this;
H_Tsunemoto 0:871ab6846b18 88 }
H_Tsunemoto 0:871ab6846b18 89
H_Tsunemoto 0:871ab6846b18 90 /** A shorthand for read()
H_Tsunemoto 0:871ab6846b18 91 */
H_Tsunemoto 0:871ab6846b18 92 operator int() {
H_Tsunemoto 0:871ab6846b18 93 return read();
H_Tsunemoto 0:871ab6846b18 94 }
H_Tsunemoto 0:871ab6846b18 95
H_Tsunemoto 0:871ab6846b18 96 private:
H_Tsunemoto 0:871ab6846b18 97 port_t _port;
H_Tsunemoto 0:871ab6846b18 98 };
H_Tsunemoto 0:871ab6846b18 99
H_Tsunemoto 0:871ab6846b18 100 } // namespace mbed
H_Tsunemoto 0:871ab6846b18 101
H_Tsunemoto 0:871ab6846b18 102 #endif
H_Tsunemoto 0:871ab6846b18 103
H_Tsunemoto 0:871ab6846b18 104 #endif