mbed libraries for KL25Z

Dependents:   FRDM_RGBLED

Committer:
emilmont
Date:
Fri Nov 09 11:33:53 2012 +0000
Revision:
8:c14af7958ef5
Parent:
0:8024c367e29f
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 0:8024c367e29f 1 /* mbed Microcontroller Library - BusInOut
emilmont 0:8024c367e29f 2 * Copyright (c) 2009 ARM Limited. All rights reserved.
emilmont 0:8024c367e29f 3 */
emilmont 0:8024c367e29f 4 #ifndef MBED_BUSINOUT_H
emilmont 0:8024c367e29f 5 #define MBED_BUSINOUT_H
emilmont 0:8024c367e29f 6
emilmont 0:8024c367e29f 7 #include "DigitalInOut.h"
emilmont 0:8024c367e29f 8
emilmont 0:8024c367e29f 9 namespace mbed {
emilmont 0:8024c367e29f 10
emilmont 8:c14af7958ef5 11 /** A digital input output bus, used for setting the state of a collection of pins
emilmont 0:8024c367e29f 12 */
emilmont 8:c14af7958ef5 13 class BusInOut {
emilmont 0:8024c367e29f 14
emilmont 0:8024c367e29f 15 public:
emilmont 0:8024c367e29f 16
emilmont 8:c14af7958ef5 17 /** Create an BusInOut, connected to the specified pins
emilmont 0:8024c367e29f 18 *
emilmont 8:c14af7958ef5 19 * @param p<n> DigitalInOut pin to connect to bus bit p<n> (p5-p30, NC)
emilmont 0:8024c367e29f 20 *
emilmont 8:c14af7958ef5 21 * @note
emilmont 0:8024c367e29f 22 * It is only required to specify as many pin variables as is required
emilmont 0:8024c367e29f 23 * for the bus; the rest will default to NC (not connected)
emilmont 0:8024c367e29f 24 */
emilmont 0:8024c367e29f 25 BusInOut(PinName p0, PinName p1 = NC, PinName p2 = NC, PinName p3 = NC,
emilmont 0:8024c367e29f 26 PinName p4 = NC, PinName p5 = NC, PinName p6 = NC, PinName p7 = NC,
emilmont 0:8024c367e29f 27 PinName p8 = NC, PinName p9 = NC, PinName p10 = NC, PinName p11 = NC,
emilmont 8:c14af7958ef5 28 PinName p12 = NC, PinName p13 = NC, PinName p14 = NC, PinName p15 = NC);
emilmont 0:8024c367e29f 29
emilmont 8:c14af7958ef5 30 BusInOut(PinName pins[16]);
emilmont 0:8024c367e29f 31
emilmont 0:8024c367e29f 32 virtual ~BusInOut();
emilmont 0:8024c367e29f 33
emilmont 0:8024c367e29f 34 /* Group: Access Methods */
emilmont 8:c14af7958ef5 35
emilmont 8:c14af7958ef5 36 /** Write the value to the output bus
emilmont 0:8024c367e29f 37 *
emilmont 8:c14af7958ef5 38 * @param value An integer specifying a bit to write for every corresponding DigitalInOut pin
emilmont 0:8024c367e29f 39 */
emilmont 0:8024c367e29f 40 void write(int value);
emilmont 0:8024c367e29f 41
emilmont 0:8024c367e29f 42
emilmont 8:c14af7958ef5 43 /** Read the value currently output on the bus
emilmont 0:8024c367e29f 44 *
emilmont 8:c14af7958ef5 45 * @returns
emilmont 8:c14af7958ef5 46 * An integer with each bit corresponding to associated DigitalInOut pin setting
emilmont 0:8024c367e29f 47 */
emilmont 0:8024c367e29f 48 int read();
emilmont 0:8024c367e29f 49
emilmont 8:c14af7958ef5 50 /** Set as an output
emilmont 0:8024c367e29f 51 */
emilmont 0:8024c367e29f 52 void output();
emilmont 0:8024c367e29f 53
emilmont 8:c14af7958ef5 54 /** Set as an input
emilmont 0:8024c367e29f 55 */
emilmont 0:8024c367e29f 56 void input();
emilmont 0:8024c367e29f 57
emilmont 8:c14af7958ef5 58 /** Set the input pin mode
emilmont 0:8024c367e29f 59 *
emilmont 8:c14af7958ef5 60 * @param mode PullUp, PullDown, PullNone
emilmont 0:8024c367e29f 61 */
emilmont 0:8024c367e29f 62 void mode(PinMode pull);
emilmont 0:8024c367e29f 63
emilmont 0:8024c367e29f 64 #ifdef MBED_OPERATORS
emilmont 8:c14af7958ef5 65 /** A shorthand for write()
emilmont 0:8024c367e29f 66 */
emilmont 0:8024c367e29f 67 BusInOut& operator= (int v);
emilmont 0:8024c367e29f 68 BusInOut& operator= (BusInOut& rhs);
emilmont 0:8024c367e29f 69
emilmont 8:c14af7958ef5 70 /** A shorthand for read()
emilmont 0:8024c367e29f 71 */
emilmont 0:8024c367e29f 72 operator int();
emilmont 0:8024c367e29f 73 #endif
emilmont 0:8024c367e29f 74
emilmont 0:8024c367e29f 75 protected:
emilmont 0:8024c367e29f 76 DigitalInOut* _pin[16];
emilmont 0:8024c367e29f 77 };
emilmont 0:8024c367e29f 78
emilmont 0:8024c367e29f 79 } // namespace mbed
emilmont 0:8024c367e29f 80
emilmont 0:8024c367e29f 81 #endif