mbed libraries for KL25Z

Dependents:   FRDM_RGBLED

Committer:
emilmont
Date:
Tue Oct 23 09:20:18 2012 +0000
Revision:
7:73c5efe92a6c
Parent:
2:e9a661555b58
Child:
8:c14af7958ef5
Make the C++ library completely TARGET independent.; Implement "gpio_irq_api" and "port_api" to KL25Z.

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