mbed libraries for KL25Z

Dependents:   FRDM_RGBLED

Committer:
emilmont
Date:
Wed Oct 10 14:14:12 2012 +0000
Revision:
2:e9a661555b58
Parent:
0:8024c367e29f
Child:
7:73c5efe92a6c
Add PWM and I2C implementation;

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