strat des robots

Fork of CRAC-Strat_2017 by CRAC Team

Committer:
ClementBreteau
Date:
Fri May 19 17:14:07 2017 +0000
Revision:
17:d1594579eec6
Parent:
0:ad97421fb1fb
strat du robot, 19-05-2017, 19h

Who changed what in which revision?

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