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 - AnalogIn
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_ANALOGIN_H
ClementBreteau 1:f3f702086a30 6 #define MBED_ANALOGIN_H
ClementBreteau 1:f3f702086a30 7
ClementBreteau 1:f3f702086a30 8 #include "device.h"
ClementBreteau 1:f3f702086a30 9
ClementBreteau 1:f3f702086a30 10 #if DEVICE_ANALOGIN
ClementBreteau 1:f3f702086a30 11
ClementBreteau 1:f3f702086a30 12 #include "platform.h"
ClementBreteau 1:f3f702086a30 13 #include "PinNames.h"
ClementBreteau 1:f3f702086a30 14 #include "PeripheralNames.h"
ClementBreteau 1:f3f702086a30 15 #include "Base.h"
ClementBreteau 1:f3f702086a30 16
ClementBreteau 1:f3f702086a30 17 namespace mbed {
ClementBreteau 1:f3f702086a30 18
ClementBreteau 1:f3f702086a30 19 /* Class: AnalogIn
ClementBreteau 1:f3f702086a30 20 * An analog input, used for reading the voltage on a pin
ClementBreteau 1:f3f702086a30 21 *
ClementBreteau 1:f3f702086a30 22 * Example:
ClementBreteau 1:f3f702086a30 23 * > // Print messages when the AnalogIn is greater than 50%
ClementBreteau 1:f3f702086a30 24 * >
ClementBreteau 1:f3f702086a30 25 * > #include "mbed.h"
ClementBreteau 1:f3f702086a30 26 * >
ClementBreteau 1:f3f702086a30 27 * > AnalogIn temperature(p20);
ClementBreteau 1:f3f702086a30 28 * >
ClementBreteau 1:f3f702086a30 29 * > int main() {
ClementBreteau 1:f3f702086a30 30 * > while(1) {
ClementBreteau 1:f3f702086a30 31 * > if(temperature > 0.5) {
ClementBreteau 1:f3f702086a30 32 * > printf("Too hot! (%f)", temperature.read());
ClementBreteau 1:f3f702086a30 33 * > }
ClementBreteau 1:f3f702086a30 34 * > }
ClementBreteau 1:f3f702086a30 35 * > }
ClementBreteau 1:f3f702086a30 36 */
ClementBreteau 1:f3f702086a30 37 class AnalogIn : public Base {
ClementBreteau 1:f3f702086a30 38
ClementBreteau 1:f3f702086a30 39 public:
ClementBreteau 1:f3f702086a30 40
ClementBreteau 1:f3f702086a30 41 /* Constructor: AnalogIn
ClementBreteau 1:f3f702086a30 42 * Create an AnalogIn, connected to the specified pin
ClementBreteau 1:f3f702086a30 43 *
ClementBreteau 1:f3f702086a30 44 * Variables:
ClementBreteau 1:f3f702086a30 45 * pin - AnalogIn pin to connect to
ClementBreteau 1:f3f702086a30 46 * name - (optional) A string to identify the object
ClementBreteau 1:f3f702086a30 47 */
ClementBreteau 1:f3f702086a30 48 AnalogIn(PinName pin, const char *name = NULL);
ClementBreteau 1:f3f702086a30 49
ClementBreteau 1:f3f702086a30 50 /* Function: read
ClementBreteau 1:f3f702086a30 51 * Read the input voltage, represented as a float in the range [0.0, 1.0]
ClementBreteau 1:f3f702086a30 52 *
ClementBreteau 1:f3f702086a30 53 * Variables:
ClementBreteau 1:f3f702086a30 54 * returns - A floating-point value representing the current input voltage,
ClementBreteau 1:f3f702086a30 55 * measured as a percentage
ClementBreteau 1:f3f702086a30 56 */
ClementBreteau 1:f3f702086a30 57 float read();
ClementBreteau 1:f3f702086a30 58
ClementBreteau 1:f3f702086a30 59 /* Function: read_u16
ClementBreteau 1:f3f702086a30 60 * Read the input voltage, represented as an unsigned short in the range [0x0, 0xFFFF]
ClementBreteau 1:f3f702086a30 61 *
ClementBreteau 1:f3f702086a30 62 * Variables:
ClementBreteau 1:f3f702086a30 63 * returns - 16-bit unsigned short representing the current input voltage,
ClementBreteau 1:f3f702086a30 64 * normalised to a 16-bit value
ClementBreteau 1:f3f702086a30 65 */
ClementBreteau 1:f3f702086a30 66 unsigned short read_u16();
ClementBreteau 1:f3f702086a30 67
ClementBreteau 1:f3f702086a30 68 #ifdef MBED_OPERATORS
ClementBreteau 1:f3f702086a30 69 /* Function: operator float
ClementBreteau 1:f3f702086a30 70 * An operator shorthand for <read()>
ClementBreteau 1:f3f702086a30 71 *
ClementBreteau 1:f3f702086a30 72 * The float() operator can be used as a shorthand for <read()> to simplify common code sequences
ClementBreteau 1:f3f702086a30 73 *
ClementBreteau 1:f3f702086a30 74 * Example:
ClementBreteau 1:f3f702086a30 75 * > float x = volume.read();
ClementBreteau 1:f3f702086a30 76 * > float x = volume;
ClementBreteau 1:f3f702086a30 77 * >
ClementBreteau 1:f3f702086a30 78 * > if(volume.read() > 0.25) { ... }
ClementBreteau 1:f3f702086a30 79 * > if(volume > 0.25) { ... }
ClementBreteau 1:f3f702086a30 80 */
ClementBreteau 1:f3f702086a30 81 operator float();
ClementBreteau 1:f3f702086a30 82 #endif
ClementBreteau 1:f3f702086a30 83
ClementBreteau 1:f3f702086a30 84 #ifdef MBED_RPC
ClementBreteau 1:f3f702086a30 85 virtual const struct rpc_method *get_rpc_methods();
ClementBreteau 1:f3f702086a30 86 static struct rpc_class *get_rpc_class();
ClementBreteau 1:f3f702086a30 87 #endif
ClementBreteau 1:f3f702086a30 88
ClementBreteau 1:f3f702086a30 89 protected:
ClementBreteau 1:f3f702086a30 90
ClementBreteau 1:f3f702086a30 91 ADCName _adc;
ClementBreteau 1:f3f702086a30 92
ClementBreteau 1:f3f702086a30 93 };
ClementBreteau 1:f3f702086a30 94
ClementBreteau 1:f3f702086a30 95 } // namespace mbed
ClementBreteau 1:f3f702086a30 96
ClementBreteau 1:f3f702086a30 97 #endif
ClementBreteau 1:f3f702086a30 98
ClementBreteau 1:f3f702086a30 99 #endif