Fix RZ/A1H target issues

Fork of mbed-src by mbed official

Committer:
emilmont
Date:
Mon Feb 18 11:44:18 2013 +0000
Revision:
2:143cac498751
Parent:
0:fd0d7bdfcdc2
Update mbed sources to Rev 59

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 0:fd0d7bdfcdc2 1 /* mbed Microcontroller Library
emilmont 2:143cac498751 2 * Copyright (c) 2006-2013 ARM Limited
mbed_official 0:fd0d7bdfcdc2 3 *
emilmont 2:143cac498751 4 * Licensed under the Apache License, Version 2.0 (the "License");
emilmont 2:143cac498751 5 * you may not use this file except in compliance with the License.
emilmont 2:143cac498751 6 * You may obtain a copy of the License at
mbed_official 0:fd0d7bdfcdc2 7 *
emilmont 2:143cac498751 8 * http://www.apache.org/licenses/LICENSE-2.0
mbed_official 0:fd0d7bdfcdc2 9 *
emilmont 2:143cac498751 10 * Unless required by applicable law or agreed to in writing, software
emilmont 2:143cac498751 11 * distributed under the License is distributed on an "AS IS" BASIS,
emilmont 2:143cac498751 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
emilmont 2:143cac498751 13 * See the License for the specific language governing permissions and
emilmont 2:143cac498751 14 * limitations under the License.
mbed_official 0:fd0d7bdfcdc2 15 */
mbed_official 0:fd0d7bdfcdc2 16 #ifndef MBED_DIGITALIN_H
mbed_official 0:fd0d7bdfcdc2 17 #define MBED_DIGITALIN_H
mbed_official 0:fd0d7bdfcdc2 18
mbed_official 0:fd0d7bdfcdc2 19 #include "platform.h"
mbed_official 0:fd0d7bdfcdc2 20
mbed_official 0:fd0d7bdfcdc2 21 #include "gpio_api.h"
mbed_official 0:fd0d7bdfcdc2 22
mbed_official 0:fd0d7bdfcdc2 23 namespace mbed {
mbed_official 0:fd0d7bdfcdc2 24
mbed_official 0:fd0d7bdfcdc2 25 /** A digital input, used for reading the state of a pin
mbed_official 0:fd0d7bdfcdc2 26 *
mbed_official 0:fd0d7bdfcdc2 27 * Example:
mbed_official 0:fd0d7bdfcdc2 28 * @code
mbed_official 0:fd0d7bdfcdc2 29 * // Flash an LED while a DigitalIn is true
emilmont 2:143cac498751 30 *
mbed_official 0:fd0d7bdfcdc2 31 * #include "mbed.h"
emilmont 2:143cac498751 32 *
mbed_official 0:fd0d7bdfcdc2 33 * DigitalIn enable(p5);
mbed_official 0:fd0d7bdfcdc2 34 * DigitalOut led(LED1);
emilmont 2:143cac498751 35 *
mbed_official 0:fd0d7bdfcdc2 36 * int main() {
mbed_official 0:fd0d7bdfcdc2 37 * while(1) {
mbed_official 0:fd0d7bdfcdc2 38 * if(enable) {
mbed_official 0:fd0d7bdfcdc2 39 * led = !led;
mbed_official 0:fd0d7bdfcdc2 40 * }
mbed_official 0:fd0d7bdfcdc2 41 * wait(0.25);
mbed_official 0:fd0d7bdfcdc2 42 * }
mbed_official 0:fd0d7bdfcdc2 43 * }
mbed_official 0:fd0d7bdfcdc2 44 * @endcode
mbed_official 0:fd0d7bdfcdc2 45 */
mbed_official 0:fd0d7bdfcdc2 46 class DigitalIn {
mbed_official 0:fd0d7bdfcdc2 47
mbed_official 0:fd0d7bdfcdc2 48 public:
mbed_official 0:fd0d7bdfcdc2 49 /** Create a DigitalIn connected to the specified pin
mbed_official 0:fd0d7bdfcdc2 50 *
mbed_official 0:fd0d7bdfcdc2 51 * @param pin DigitalIn pin to connect to
mbed_official 0:fd0d7bdfcdc2 52 * @param name (optional) A string to identify the object
mbed_official 0:fd0d7bdfcdc2 53 */
mbed_official 0:fd0d7bdfcdc2 54 DigitalIn(PinName pin) {
mbed_official 0:fd0d7bdfcdc2 55 gpio_init(&gpio, pin, PIN_INPUT);
mbed_official 0:fd0d7bdfcdc2 56 }
emilmont 2:143cac498751 57
mbed_official 0:fd0d7bdfcdc2 58 /** Read the input, represented as 0 or 1 (int)
mbed_official 0:fd0d7bdfcdc2 59 *
mbed_official 0:fd0d7bdfcdc2 60 * @returns
emilmont 2:143cac498751 61 * An integer representing the state of the input pin,
mbed_official 0:fd0d7bdfcdc2 62 * 0 for logical 0, 1 for logical 1
mbed_official 0:fd0d7bdfcdc2 63 */
mbed_official 0:fd0d7bdfcdc2 64 int read() {
mbed_official 0:fd0d7bdfcdc2 65 return gpio_read(&gpio);
mbed_official 0:fd0d7bdfcdc2 66 }
emilmont 2:143cac498751 67
mbed_official 0:fd0d7bdfcdc2 68 /** Set the input pin mode
mbed_official 0:fd0d7bdfcdc2 69 *
mbed_official 0:fd0d7bdfcdc2 70 * @param mode PullUp, PullDown, PullNone, OpenDrain
mbed_official 0:fd0d7bdfcdc2 71 */
mbed_official 0:fd0d7bdfcdc2 72 void mode(PinMode pull) {
mbed_official 0:fd0d7bdfcdc2 73 gpio_mode(&gpio, pull);
mbed_official 0:fd0d7bdfcdc2 74 }
emilmont 2:143cac498751 75
mbed_official 0:fd0d7bdfcdc2 76 #ifdef MBED_OPERATORS
mbed_official 0:fd0d7bdfcdc2 77 /** An operator shorthand for read()
mbed_official 0:fd0d7bdfcdc2 78 */
mbed_official 0:fd0d7bdfcdc2 79 operator int() {
mbed_official 0:fd0d7bdfcdc2 80 return read();
mbed_official 0:fd0d7bdfcdc2 81 }
mbed_official 0:fd0d7bdfcdc2 82 #endif
mbed_official 0:fd0d7bdfcdc2 83
mbed_official 0:fd0d7bdfcdc2 84 protected:
mbed_official 0:fd0d7bdfcdc2 85 gpio_t gpio;
mbed_official 0:fd0d7bdfcdc2 86 };
mbed_official 0:fd0d7bdfcdc2 87
mbed_official 0:fd0d7bdfcdc2 88 } // namespace mbed
mbed_official 0:fd0d7bdfcdc2 89
mbed_official 0:fd0d7bdfcdc2 90 #endif