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 - DigitalIn
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_DIGITALIN_H
ClementBreteau 1:f3f702086a30 6 #define MBED_DIGITALIN_H
ClementBreteau 1:f3f702086a30 7
ClementBreteau 1:f3f702086a30 8 #include "platform.h"
ClementBreteau 1:f3f702086a30 9 #include "PinNames.h"
ClementBreteau 1:f3f702086a30 10 #include "PeripheralNames.h"
ClementBreteau 1:f3f702086a30 11 #include "Base.h"
ClementBreteau 1:f3f702086a30 12
ClementBreteau 1:f3f702086a30 13 namespace mbed {
ClementBreteau 1:f3f702086a30 14
ClementBreteau 1:f3f702086a30 15 /* Class: DigitalIn
ClementBreteau 1:f3f702086a30 16 * A digital input, used for reading the state of a pin
ClementBreteau 1:f3f702086a30 17 *
ClementBreteau 1:f3f702086a30 18 * Example:
ClementBreteau 1:f3f702086a30 19 * > // Flash an LED while a DigitalIn is true
ClementBreteau 1:f3f702086a30 20 * >
ClementBreteau 1:f3f702086a30 21 * > #include "mbed.h"
ClementBreteau 1:f3f702086a30 22 * >
ClementBreteau 1:f3f702086a30 23 * > DigitalIn enable(p5);
ClementBreteau 1:f3f702086a30 24 * > DigitalOut led(LED1);
ClementBreteau 1:f3f702086a30 25 * >
ClementBreteau 1:f3f702086a30 26 * > int main() {
ClementBreteau 1:f3f702086a30 27 * > while(1) {
ClementBreteau 1:f3f702086a30 28 * > if(enable) {
ClementBreteau 1:f3f702086a30 29 * > led = !led;
ClementBreteau 1:f3f702086a30 30 * > }
ClementBreteau 1:f3f702086a30 31 * > wait(0.25);
ClementBreteau 1:f3f702086a30 32 * > }
ClementBreteau 1:f3f702086a30 33 * > }
ClementBreteau 1:f3f702086a30 34 */
ClementBreteau 1:f3f702086a30 35 class DigitalIn : public Base {
ClementBreteau 1:f3f702086a30 36
ClementBreteau 1:f3f702086a30 37 public:
ClementBreteau 1:f3f702086a30 38
ClementBreteau 1:f3f702086a30 39 /* Constructor: DigitalIn
ClementBreteau 1:f3f702086a30 40 * Create a DigitalIn connected to the specified pin
ClementBreteau 1:f3f702086a30 41 *
ClementBreteau 1:f3f702086a30 42 * Variables:
ClementBreteau 1:f3f702086a30 43 * pin - DigitalIn pin to connect to
ClementBreteau 1:f3f702086a30 44 * name - (optional) A string to identify the object
ClementBreteau 1:f3f702086a30 45 */
ClementBreteau 1:f3f702086a30 46 DigitalIn(PinName pin, const char *name = NULL);
ClementBreteau 1:f3f702086a30 47
ClementBreteau 1:f3f702086a30 48 /* Function: read
ClementBreteau 1:f3f702086a30 49 * Read the input, represented as 0 or 1 (int)
ClementBreteau 1:f3f702086a30 50 *
ClementBreteau 1:f3f702086a30 51 * Variables:
ClementBreteau 1:f3f702086a30 52 * returns - An integer representing the state of the input pin,
ClementBreteau 1:f3f702086a30 53 * 0 for logical 0 and 1 for logical 1
ClementBreteau 1:f3f702086a30 54 */
ClementBreteau 1:f3f702086a30 55 int read() {
ClementBreteau 1:f3f702086a30 56 #if defined(TARGET_LPC1768) || defined(TARGET_LPC2368)
ClementBreteau 1:f3f702086a30 57 return ((_gpio->FIOPIN & _mask) ? 1 : 0);
ClementBreteau 1:f3f702086a30 58 #elif defined(TARGET_LPC11U24)
ClementBreteau 1:f3f702086a30 59 return ((LPC_GPIO->PIN[_index] & _mask) ? 1 : 0);
ClementBreteau 1:f3f702086a30 60 #endif
ClementBreteau 1:f3f702086a30 61 }
ClementBreteau 1:f3f702086a30 62
ClementBreteau 1:f3f702086a30 63
ClementBreteau 1:f3f702086a30 64 /* Function: mode
ClementBreteau 1:f3f702086a30 65 * Set the input pin mode
ClementBreteau 1:f3f702086a30 66 *
ClementBreteau 1:f3f702086a30 67 * Variables:
ClementBreteau 1:f3f702086a30 68 * mode - PullUp, PullDown, PullNone, OpenDrain
ClementBreteau 1:f3f702086a30 69 */
ClementBreteau 1:f3f702086a30 70 void mode(PinMode pull);
ClementBreteau 1:f3f702086a30 71
ClementBreteau 1:f3f702086a30 72 #ifdef MBED_OPERATORS
ClementBreteau 1:f3f702086a30 73 /* Function: operator int()
ClementBreteau 1:f3f702086a30 74 * An operator shorthand for <read()>
ClementBreteau 1:f3f702086a30 75 */
ClementBreteau 1:f3f702086a30 76 operator int() {
ClementBreteau 1:f3f702086a30 77 return read();
ClementBreteau 1:f3f702086a30 78 }
ClementBreteau 1:f3f702086a30 79
ClementBreteau 1:f3f702086a30 80 #endif
ClementBreteau 1:f3f702086a30 81
ClementBreteau 1:f3f702086a30 82 #ifdef MBED_RPC
ClementBreteau 1:f3f702086a30 83 virtual const struct rpc_method *get_rpc_methods();
ClementBreteau 1:f3f702086a30 84 static struct rpc_class *get_rpc_class();
ClementBreteau 1:f3f702086a30 85 #endif
ClementBreteau 1:f3f702086a30 86
ClementBreteau 1:f3f702086a30 87 protected:
ClementBreteau 1:f3f702086a30 88
ClementBreteau 1:f3f702086a30 89 PinName _pin;
ClementBreteau 1:f3f702086a30 90 #if defined(TARGET_LPC1768) || defined(TARGET_LPC2368)
ClementBreteau 1:f3f702086a30 91 LPC_GPIO_TypeDef *_gpio;
ClementBreteau 1:f3f702086a30 92 #elif defined(TARGET_LPC11U24)
ClementBreteau 1:f3f702086a30 93 int _index;
ClementBreteau 1:f3f702086a30 94 #endif
ClementBreteau 1:f3f702086a30 95 uint32_t _mask;
ClementBreteau 1:f3f702086a30 96
ClementBreteau 1:f3f702086a30 97 };
ClementBreteau 1:f3f702086a30 98
ClementBreteau 1:f3f702086a30 99 } // namespace mbed
ClementBreteau 1:f3f702086a30 100
ClementBreteau 1:f3f702086a30 101 #endif
ClementBreteau 1:f3f702086a30 102