mbed libraries for KL25Z

Dependents:   FRDM_RGBLED

Committer:
emilmont
Date:
Fri Nov 09 11:33:53 2012 +0000
Revision:
8:c14af7958ef5
Parent:
7:73c5efe92a6c
Child:
9:663789d7729f
SPI driver; ADC driver; DAC driver; microlib support; general bugfixing

Who changed what in which revision?

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