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 - PortOut
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_PORTOUT_H
ClementBreteau 1:f3f702086a30 6 #define MBED_PORTOUT_H
ClementBreteau 1:f3f702086a30 7
ClementBreteau 1:f3f702086a30 8 #include "device.h"
ClementBreteau 1:f3f702086a30 9
ClementBreteau 1:f3f702086a30 10 #if DEVICE_PORTOUT
ClementBreteau 1:f3f702086a30 11
ClementBreteau 1:f3f702086a30 12 #include "platform.h"
ClementBreteau 1:f3f702086a30 13 #include "PinNames.h"
ClementBreteau 1:f3f702086a30 14 #include "Base.h"
ClementBreteau 1:f3f702086a30 15
ClementBreteau 1:f3f702086a30 16 #include "PortNames.h"
ClementBreteau 1:f3f702086a30 17
ClementBreteau 1:f3f702086a30 18 namespace mbed {
ClementBreteau 1:f3f702086a30 19 /* Class: PortOut
ClementBreteau 1:f3f702086a30 20 * A multiple pin digital out
ClementBreteau 1:f3f702086a30 21 *
ClementBreteau 1:f3f702086a30 22 * Example:
ClementBreteau 1:f3f702086a30 23 * > // Toggle all four LEDs
ClementBreteau 1:f3f702086a30 24 * >
ClementBreteau 1:f3f702086a30 25 * > #include "mbed.h"
ClementBreteau 1:f3f702086a30 26 * >
ClementBreteau 1:f3f702086a30 27 * > // LED1 = P1.18 LED2 = P1.20 LED3 = P1.21 LED4 = P1.23
ClementBreteau 1:f3f702086a30 28 * > #define LED_MASK 0x00B40000
ClementBreteau 1:f3f702086a30 29 * >
ClementBreteau 1:f3f702086a30 30 * > PortOut ledport(Port1, LED_MASK);
ClementBreteau 1:f3f702086a30 31 * >
ClementBreteau 1:f3f702086a30 32 * > int main() {
ClementBreteau 1:f3f702086a30 33 * > while(1) {
ClementBreteau 1:f3f702086a30 34 * > ledport = LED_MASK;
ClementBreteau 1:f3f702086a30 35 * > wait(1);
ClementBreteau 1:f3f702086a30 36 * > ledport = 0;
ClementBreteau 1:f3f702086a30 37 * > wait(1);
ClementBreteau 1:f3f702086a30 38 * > }
ClementBreteau 1:f3f702086a30 39 * > }
ClementBreteau 1:f3f702086a30 40 */
ClementBreteau 1:f3f702086a30 41 class PortOut {
ClementBreteau 1:f3f702086a30 42 public:
ClementBreteau 1:f3f702086a30 43
ClementBreteau 1:f3f702086a30 44 /* Constructor: PortOut
ClementBreteau 1:f3f702086a30 45 * Create an PortOut, connected to the specified port
ClementBreteau 1:f3f702086a30 46 *
ClementBreteau 1:f3f702086a30 47 * Variables:
ClementBreteau 1:f3f702086a30 48 * port - Port to connect to (Port0-Port5)
ClementBreteau 1:f3f702086a30 49 * mask - A bitmask to identify which bits in the port should be included (0 - ignore)
ClementBreteau 1:f3f702086a30 50 */
ClementBreteau 1:f3f702086a30 51 PortOut(PortName port, int mask = 0xFFFFFFFF);
ClementBreteau 1:f3f702086a30 52
ClementBreteau 1:f3f702086a30 53 /* Function: write
ClementBreteau 1:f3f702086a30 54 * Write the value to the output port
ClementBreteau 1:f3f702086a30 55 *
ClementBreteau 1:f3f702086a30 56 * Variables:
ClementBreteau 1:f3f702086a30 57 * value - An integer specifying a bit to write for every corresponding PortOut pin
ClementBreteau 1:f3f702086a30 58 */
ClementBreteau 1:f3f702086a30 59 void write(int value);
ClementBreteau 1:f3f702086a30 60
ClementBreteau 1:f3f702086a30 61 /* Function: read
ClementBreteau 1:f3f702086a30 62 * Read the value currently output on the port
ClementBreteau 1:f3f702086a30 63 *
ClementBreteau 1:f3f702086a30 64 * Variables:
ClementBreteau 1:f3f702086a30 65 * returns - An integer with each bit corresponding to associated PortOut pin setting
ClementBreteau 1:f3f702086a30 66 */
ClementBreteau 1:f3f702086a30 67 int read();
ClementBreteau 1:f3f702086a30 68
ClementBreteau 1:f3f702086a30 69 /* Function: operator=
ClementBreteau 1:f3f702086a30 70 * A shorthand for <write>
ClementBreteau 1:f3f702086a30 71 */
ClementBreteau 1:f3f702086a30 72 PortOut& operator= (int value) {
ClementBreteau 1:f3f702086a30 73 write(value);
ClementBreteau 1:f3f702086a30 74 return *this;
ClementBreteau 1:f3f702086a30 75 }
ClementBreteau 1:f3f702086a30 76
ClementBreteau 1:f3f702086a30 77 PortOut& operator= (PortOut& rhs) {
ClementBreteau 1:f3f702086a30 78 write(rhs.read());
ClementBreteau 1:f3f702086a30 79 return *this;
ClementBreteau 1:f3f702086a30 80 }
ClementBreteau 1:f3f702086a30 81
ClementBreteau 1:f3f702086a30 82 /* Function: operator int()
ClementBreteau 1:f3f702086a30 83 * A shorthand for <read>
ClementBreteau 1:f3f702086a30 84 */
ClementBreteau 1:f3f702086a30 85 operator int() {
ClementBreteau 1:f3f702086a30 86 return read();
ClementBreteau 1:f3f702086a30 87 }
ClementBreteau 1:f3f702086a30 88
ClementBreteau 1:f3f702086a30 89 private:
ClementBreteau 1:f3f702086a30 90 #if defined(TARGET_LPC1768) || defined(TARGET_LPC2368)
ClementBreteau 1:f3f702086a30 91 LPC_GPIO_TypeDef *_gpio;
ClementBreteau 1:f3f702086a30 92 #endif
ClementBreteau 1:f3f702086a30 93 PortName _port;
ClementBreteau 1:f3f702086a30 94 uint32_t _mask;
ClementBreteau 1:f3f702086a30 95 };
ClementBreteau 1:f3f702086a30 96
ClementBreteau 1:f3f702086a30 97 } // namespace mbed
ClementBreteau 1:f3f702086a30 98
ClementBreteau 1:f3f702086a30 99 #endif
ClementBreteau 1:f3f702086a30 100
ClementBreteau 1:f3f702086a30 101 #endif