SD card interface

Committer:
lharoon
Date:
Mon Oct 08 11:14:07 2012 +0000
Revision:
0:22612ae617a0
1st edition

Who changed what in which revision?

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