Programme d'utilisation des AX12 avec rajout de l'MX12

Fork of test_carteAToutFaire_PR by CRAC Team

Committer:
R66Y
Date:
Sat May 20 15:23:58 2017 +0000
Revision:
3:1bb26049bdd1
Parent:
1:f3f702086a30
Programme de contr?le des AX12 avec rajout de l'MX12;

Who changed what in which revision?

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