nothing changed

Fork of mbed by gokmen ascioglu

Committer:
gokmenascioglu
Date:
Sat Sep 22 10:32:07 2012 +0000
Revision:
0:a8fa94490a0a
alican library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
gokmenascioglu 0:a8fa94490a0a 1 /* mbed Microcontroller Library - PortInOut
gokmenascioglu 0:a8fa94490a0a 2 * Copyright (c) 2006-2011 ARM Limited. All rights reserved.
gokmenascioglu 0:a8fa94490a0a 3 */
gokmenascioglu 0:a8fa94490a0a 4
gokmenascioglu 0:a8fa94490a0a 5 #ifndef MBED_PORTINOUT_H
gokmenascioglu 0:a8fa94490a0a 6 #define MBED_PORTINOUT_H
gokmenascioglu 0:a8fa94490a0a 7
gokmenascioglu 0:a8fa94490a0a 8 #include "device.h"
gokmenascioglu 0:a8fa94490a0a 9
gokmenascioglu 0:a8fa94490a0a 10 #if DEVICE_PORTINOUT
gokmenascioglu 0:a8fa94490a0a 11
gokmenascioglu 0:a8fa94490a0a 12 #include "PortNames.h"
gokmenascioglu 0:a8fa94490a0a 13 #include "PinNames.h"
gokmenascioglu 0:a8fa94490a0a 14
gokmenascioglu 0:a8fa94490a0a 15 namespace mbed {
gokmenascioglu 0:a8fa94490a0a 16
gokmenascioglu 0:a8fa94490a0a 17 /* Class: PortInOut
gokmenascioglu 0:a8fa94490a0a 18 * A multiple pin digital in/out used to set/read multiple bi-directional pins
gokmenascioglu 0:a8fa94490a0a 19 */
gokmenascioglu 0:a8fa94490a0a 20 class PortInOut {
gokmenascioglu 0:a8fa94490a0a 21 public:
gokmenascioglu 0:a8fa94490a0a 22
gokmenascioglu 0:a8fa94490a0a 23 /* Constructor: PortInOut
gokmenascioglu 0:a8fa94490a0a 24 * Create an PortInOut, connected to the specified port
gokmenascioglu 0:a8fa94490a0a 25 *
gokmenascioglu 0:a8fa94490a0a 26 * Variables:
gokmenascioglu 0:a8fa94490a0a 27 * port - Port to connect to (Port0-Port5)
gokmenascioglu 0:a8fa94490a0a 28 * mask - A bitmask to identify which bits in the port should be included (0 - ignore)
gokmenascioglu 0:a8fa94490a0a 29 */
gokmenascioglu 0:a8fa94490a0a 30 PortInOut(PortName port, int mask = 0xFFFFFFFF);
gokmenascioglu 0:a8fa94490a0a 31
gokmenascioglu 0:a8fa94490a0a 32 /* Function: write
gokmenascioglu 0:a8fa94490a0a 33 * Write the value to the output port
gokmenascioglu 0:a8fa94490a0a 34 *
gokmenascioglu 0:a8fa94490a0a 35 * Variables:
gokmenascioglu 0:a8fa94490a0a 36 * value - An integer specifying a bit to write for every corresponding port pin
gokmenascioglu 0:a8fa94490a0a 37 */
gokmenascioglu 0:a8fa94490a0a 38 void write(int value);
gokmenascioglu 0:a8fa94490a0a 39
gokmenascioglu 0:a8fa94490a0a 40 /* Function: read
gokmenascioglu 0:a8fa94490a0a 41 * Read the value currently output on the port
gokmenascioglu 0:a8fa94490a0a 42 *
gokmenascioglu 0:a8fa94490a0a 43 * Variables:
gokmenascioglu 0:a8fa94490a0a 44 * returns - An integer with each bit corresponding to associated port pin setting
gokmenascioglu 0:a8fa94490a0a 45 */
gokmenascioglu 0:a8fa94490a0a 46 int read();
gokmenascioglu 0:a8fa94490a0a 47
gokmenascioglu 0:a8fa94490a0a 48 /* Function: output
gokmenascioglu 0:a8fa94490a0a 49 * Set as an output
gokmenascioglu 0:a8fa94490a0a 50 */
gokmenascioglu 0:a8fa94490a0a 51 void output();
gokmenascioglu 0:a8fa94490a0a 52
gokmenascioglu 0:a8fa94490a0a 53 /* Function: input
gokmenascioglu 0:a8fa94490a0a 54 * Set as an input
gokmenascioglu 0:a8fa94490a0a 55 */
gokmenascioglu 0:a8fa94490a0a 56 void input();
gokmenascioglu 0:a8fa94490a0a 57
gokmenascioglu 0:a8fa94490a0a 58 /* Function: mode
gokmenascioglu 0:a8fa94490a0a 59 * Set the input pin mode
gokmenascioglu 0:a8fa94490a0a 60 *
gokmenascioglu 0:a8fa94490a0a 61 * Variables:
gokmenascioglu 0:a8fa94490a0a 62 * mode - PullUp, PullDown, PullNone, OpenDrain
gokmenascioglu 0:a8fa94490a0a 63 */
gokmenascioglu 0:a8fa94490a0a 64 void mode(PinMode mode);
gokmenascioglu 0:a8fa94490a0a 65
gokmenascioglu 0:a8fa94490a0a 66 /* Function: operator=
gokmenascioglu 0:a8fa94490a0a 67 * A shorthand for <write>
gokmenascioglu 0:a8fa94490a0a 68 */
gokmenascioglu 0:a8fa94490a0a 69 PortInOut& operator= (int value) {
gokmenascioglu 0:a8fa94490a0a 70 write(value);
gokmenascioglu 0:a8fa94490a0a 71 return *this;
gokmenascioglu 0:a8fa94490a0a 72 }
gokmenascioglu 0:a8fa94490a0a 73
gokmenascioglu 0:a8fa94490a0a 74 PortInOut& operator= (PortInOut& rhs) {
gokmenascioglu 0:a8fa94490a0a 75 write(rhs.read());
gokmenascioglu 0:a8fa94490a0a 76 return *this;
gokmenascioglu 0:a8fa94490a0a 77 }
gokmenascioglu 0:a8fa94490a0a 78
gokmenascioglu 0:a8fa94490a0a 79 /* Function: operator int()
gokmenascioglu 0:a8fa94490a0a 80 * A shorthand for <read>
gokmenascioglu 0:a8fa94490a0a 81 */
gokmenascioglu 0:a8fa94490a0a 82 operator int() {
gokmenascioglu 0:a8fa94490a0a 83 return read();
gokmenascioglu 0:a8fa94490a0a 84 }
gokmenascioglu 0:a8fa94490a0a 85
gokmenascioglu 0:a8fa94490a0a 86 private:
gokmenascioglu 0:a8fa94490a0a 87 #if defined(TARGET_LPC1768) || defined(TARGET_LPC2368)
gokmenascioglu 0:a8fa94490a0a 88 LPC_GPIO_TypeDef *_gpio;
gokmenascioglu 0:a8fa94490a0a 89 #endif
gokmenascioglu 0:a8fa94490a0a 90 PortName _port;
gokmenascioglu 0:a8fa94490a0a 91 uint32_t _mask;
gokmenascioglu 0:a8fa94490a0a 92 };
gokmenascioglu 0:a8fa94490a0a 93
gokmenascioglu 0:a8fa94490a0a 94 } // namespace mbed
gokmenascioglu 0:a8fa94490a0a 95
gokmenascioglu 0:a8fa94490a0a 96 #endif
gokmenascioglu 0:a8fa94490a0a 97
gokmenascioglu 0:a8fa94490a0a 98 #endif