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_PORTIN_H
lharoon 0:22612ae617a0 6 #define MBED_PORTIN_H
lharoon 0:22612ae617a0 7
lharoon 0:22612ae617a0 8 #include "device.h"
lharoon 0:22612ae617a0 9
lharoon 0:22612ae617a0 10 #if DEVICE_PORTIN
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: PortIn
lharoon 0:22612ae617a0 18 * A multiple pin digital input
lharoon 0:22612ae617a0 19 *
lharoon 0:22612ae617a0 20 * Example:
lharoon 0:22612ae617a0 21 * > // Switch on an LED if any of mbed pins 21-26 is high
lharoon 0:22612ae617a0 22 * >
lharoon 0:22612ae617a0 23 * > #include "mbed.h"
lharoon 0:22612ae617a0 24 * >
lharoon 0:22612ae617a0 25 * > PortIn p(Port2, 0x0000003F); // p21-p26
lharoon 0:22612ae617a0 26 * > DigitalOut ind(LED4);
lharoon 0:22612ae617a0 27 * >
lharoon 0:22612ae617a0 28 * > int main() {
lharoon 0:22612ae617a0 29 * > while(1) {
lharoon 0:22612ae617a0 30 * > int pins = p.read();
lharoon 0:22612ae617a0 31 * > if(pins) {
lharoon 0:22612ae617a0 32 * > ind = 1;
lharoon 0:22612ae617a0 33 * > } else {
lharoon 0:22612ae617a0 34 * > ind = 0;
lharoon 0:22612ae617a0 35 * > }
lharoon 0:22612ae617a0 36 * > }
lharoon 0:22612ae617a0 37 * > }
lharoon 0:22612ae617a0 38 */
lharoon 0:22612ae617a0 39 class PortIn {
lharoon 0:22612ae617a0 40 public:
lharoon 0:22612ae617a0 41
lharoon 0:22612ae617a0 42 /* Constructor: PortIn
lharoon 0:22612ae617a0 43 * Create an PortIn, connected to the specified port
lharoon 0:22612ae617a0 44 *
lharoon 0:22612ae617a0 45 * Variables:
lharoon 0:22612ae617a0 46 * port - Port to connect to (Port0-Port5)
lharoon 0:22612ae617a0 47 * mask - A bitmask to identify which bits in the port should be included (0 - ignore)
lharoon 0:22612ae617a0 48 */
lharoon 0:22612ae617a0 49 PortIn(PortName port, int mask = 0xFFFFFFFF);
lharoon 0:22612ae617a0 50
lharoon 0:22612ae617a0 51 /* Function: read
lharoon 0:22612ae617a0 52 * Read the value currently output on the port
lharoon 0:22612ae617a0 53 *
lharoon 0:22612ae617a0 54 * Variables:
lharoon 0:22612ae617a0 55 * returns - An integer with each bit corresponding to associated port pin setting
lharoon 0:22612ae617a0 56 */
lharoon 0:22612ae617a0 57 int read();
lharoon 0:22612ae617a0 58
lharoon 0:22612ae617a0 59 /* Function: mode
lharoon 0:22612ae617a0 60 * Set the input pin mode
lharoon 0:22612ae617a0 61 *
lharoon 0:22612ae617a0 62 * Variables:
lharoon 0:22612ae617a0 63 * mode - PullUp, PullDown, PullNone, OpenDrain
lharoon 0:22612ae617a0 64 */
lharoon 0:22612ae617a0 65 void mode(PinMode mode);
lharoon 0:22612ae617a0 66
lharoon 0:22612ae617a0 67 /* Function: operator int()
lharoon 0:22612ae617a0 68 * A shorthand for <read>
lharoon 0:22612ae617a0 69 */
lharoon 0:22612ae617a0 70 operator int() {
lharoon 0:22612ae617a0 71 return read();
lharoon 0:22612ae617a0 72 }
lharoon 0:22612ae617a0 73
lharoon 0:22612ae617a0 74 private:
lharoon 0:22612ae617a0 75 #if defined(TARGET_LPC1768) || defined(TARGET_LPC2368)
lharoon 0:22612ae617a0 76 LPC_GPIO_TypeDef *_gpio;
lharoon 0:22612ae617a0 77 #endif
lharoon 0:22612ae617a0 78 PortName _port;
lharoon 0:22612ae617a0 79 uint32_t _mask;
lharoon 0:22612ae617a0 80 };
lharoon 0:22612ae617a0 81
lharoon 0:22612ae617a0 82 } // namespace mbed
lharoon 0:22612ae617a0 83
lharoon 0:22612ae617a0 84 #endif
lharoon 0:22612ae617a0 85
lharoon 0:22612ae617a0 86 #endif