Programme d'utilisation servomotors MX12 V1

Committer:
R66Y
Date:
Fri May 19 14:32:14 2017 +0000
Revision:
0:80df663dd15e
programme pour utiliser les servomoteurs MX12.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
R66Y 0:80df663dd15e 1 /* mbed Microcontroller Library - error
R66Y 0:80df663dd15e 2 * Copyright (c) 2006-2009 ARM Limited. All rights reserved.
R66Y 0:80df663dd15e 3 */
R66Y 0:80df663dd15e 4
R66Y 0:80df663dd15e 5 #ifndef MBED_ERROR_H
R66Y 0:80df663dd15e 6 #define MBED_ERROR_H
R66Y 0:80df663dd15e 7
R66Y 0:80df663dd15e 8 /* Reporting Compile-Time Errors:
R66Y 0:80df663dd15e 9 * To generate a fatal compile-time error, you can use the pre-processor #error directive.
R66Y 0:80df663dd15e 10 *
R66Y 0:80df663dd15e 11 * > #error "That shouldn't have happened!"
R66Y 0:80df663dd15e 12 *
R66Y 0:80df663dd15e 13 * If the compiler evaluates this line, it will report the error and stop the compile.
R66Y 0:80df663dd15e 14 *
R66Y 0:80df663dd15e 15 * For example, you could use this to check some user-defined compile-time variables:
R66Y 0:80df663dd15e 16 *
R66Y 0:80df663dd15e 17 * > #define NUM_PORTS 7
R66Y 0:80df663dd15e 18 * > #if (NUM_PORTS > 4)
R66Y 0:80df663dd15e 19 * > #error "NUM_PORTS must be less than 4"
R66Y 0:80df663dd15e 20 * > #endif
R66Y 0:80df663dd15e 21 *
R66Y 0:80df663dd15e 22 * Reporting Run-Time Errors:
R66Y 0:80df663dd15e 23 * To generate a fatal run-time error, you can use the mbed error() function.
R66Y 0:80df663dd15e 24 *
R66Y 0:80df663dd15e 25 * > error("That shouldn't have happened!");
R66Y 0:80df663dd15e 26 *
R66Y 0:80df663dd15e 27 * If the mbed running the program executes this function, it will print the
R66Y 0:80df663dd15e 28 * message via the USB serial port, and then die with the blue lights of death!
R66Y 0:80df663dd15e 29 *
R66Y 0:80df663dd15e 30 * The message can use printf-style formatting, so you can report variables in the
R66Y 0:80df663dd15e 31 * message too. For example, you could use this to check a run-time condition:
R66Y 0:80df663dd15e 32 *
R66Y 0:80df663dd15e 33 * > if(x >= 5) {
R66Y 0:80df663dd15e 34 * > error("expected x to be less than 5, but got %d", x);
R66Y 0:80df663dd15e 35 * > }
R66Y 0:80df663dd15e 36 */
R66Y 0:80df663dd15e 37
R66Y 0:80df663dd15e 38 #if 0 // for documentation only
R66Y 0:80df663dd15e 39 /* Function: error
R66Y 0:80df663dd15e 40 * Report a fatal runtime error
R66Y 0:80df663dd15e 41 *
R66Y 0:80df663dd15e 42 * Outputs the specified error message to stderr so it will appear via the USB
R66Y 0:80df663dd15e 43 * serial port, and then calls exit(1) to die with the blue lights of death.
R66Y 0:80df663dd15e 44 *
R66Y 0:80df663dd15e 45 * Variables:
R66Y 0:80df663dd15e 46 * format - printf-style format string, followed by associated variables
R66Y 0:80df663dd15e 47 */
R66Y 0:80df663dd15e 48 void error(const char* format, ...);
R66Y 0:80df663dd15e 49 #endif
R66Y 0:80df663dd15e 50
R66Y 0:80df663dd15e 51 #include <stdlib.h>
R66Y 0:80df663dd15e 52
R66Y 0:80df663dd15e 53 #ifdef NDEBUG
R66Y 0:80df663dd15e 54 #define error(...) (exit(1))
R66Y 0:80df663dd15e 55 #else
R66Y 0:80df663dd15e 56 #include <stdio.h>
R66Y 0:80df663dd15e 57 #define error(...) (fprintf(stderr, __VA_ARGS__), exit(1))
R66Y 0:80df663dd15e 58 #endif
R66Y 0:80df663dd15e 59
R66Y 0:80df663dd15e 60 #endif