code petit robot pour homologation

Fork of CRAC-Strat_2017_V2 by CRAC Team

Committer:
antbig
Date:
Wed Apr 13 22:04:54 2016 +0000
Revision:
0:ad97421fb1fb
Ajout interruption fin de match

Who changed what in which revision?

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