Library to allow the use of Arduino specific language with the mbed

Dependents:   mbed_shiftreg mbed_shiftreg mbed_shiftreg_4 mbed_shiftreg_3

Fork of Arduino by Chris Dick

Committer:
TheChrisyd
Date:
Sun Oct 21 14:48:35 2012 +0000
Revision:
2:622cd7b451f8
Parent:
1:b22cf6a5957d
Child:
3:272d0276d474
added Macro documentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TheChrisyd 0:8d785e80d3ba 1 /**
TheChrisyd 0:8d785e80d3ba 2 * @section LICENSE
TheChrisyd 0:8d785e80d3ba 3 * Copyright (c) 2012 Chris Dick
TheChrisyd 0:8d785e80d3ba 4 *
TheChrisyd 0:8d785e80d3ba 5 * Permission is hereby granted, free of charge, to any person obtaining a copy
TheChrisyd 0:8d785e80d3ba 6 * of this software and associated documentation files (the "Software"), to deal
TheChrisyd 0:8d785e80d3ba 7 * in the Software without restriction, including without limitation the rights
TheChrisyd 0:8d785e80d3ba 8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
TheChrisyd 0:8d785e80d3ba 9 * copies of the Software, and to permit persons to whom the Software is
TheChrisyd 0:8d785e80d3ba 10 * furnished to do so, subject to the following conditions:
TheChrisyd 0:8d785e80d3ba 11 *
TheChrisyd 0:8d785e80d3ba 12 * The above copyright notice and this permission notice shall be included in
TheChrisyd 0:8d785e80d3ba 13 * all copies or substantial portions of the Software.
TheChrisyd 0:8d785e80d3ba 14 *
TheChrisyd 0:8d785e80d3ba 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
TheChrisyd 0:8d785e80d3ba 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
TheChrisyd 0:8d785e80d3ba 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
TheChrisyd 0:8d785e80d3ba 18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
TheChrisyd 0:8d785e80d3ba 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
TheChrisyd 0:8d785e80d3ba 20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
TheChrisyd 0:8d785e80d3ba 21 * THE SOFTWARE.
TheChrisyd 0:8d785e80d3ba 22 *
TheChrisyd 0:8d785e80d3ba 23 * @section DESCRIPTION
TheChrisyd 0:8d785e80d3ba 24 * This is a library for allowing the use of programs written for the Arduino
TheChrisyd 0:8d785e80d3ba 25 * with the mbed. This was started for use with the Gameduino shield Library
TheChrisyd 0:8d785e80d3ba 26 *
TheChrisyd 2:622cd7b451f8 27 * @file "arduino.h"
TheChrisyd 0:8d785e80d3ba 28 */
TheChrisyd 0:8d785e80d3ba 29 #ifndef ARDUINO_H
TheChrisyd 0:8d785e80d3ba 30 #define ARDUINO_H
TheChrisyd 0:8d785e80d3ba 31
TheChrisyd 0:8d785e80d3ba 32 #include "mbed.h"
TheChrisyd 0:8d785e80d3ba 33 #include "math.h"
TheChrisyd 0:8d785e80d3ba 34 // Macros
TheChrisyd 0:8d785e80d3ba 35
TheChrisyd 0:8d785e80d3ba 36 #define pgm_read_word_near(x) (*(const unsigned int*)x)
TheChrisyd 0:8d785e80d3ba 37 #define pgm_read_int_near(x) (*(const int*)x)
TheChrisyd 0:8d785e80d3ba 38 #define pgm_read_int(x) (*(const int*)x)
TheChrisyd 0:8d785e80d3ba 39 #define pgm_read_byte(x) (*(const char*)x)
TheChrisyd 0:8d785e80d3ba 40 #define pgm_read_byte_near(x) (*(const char*)x)
TheChrisyd 0:8d785e80d3ba 41 #define PROGMEM const
TheChrisyd 0:8d785e80d3ba 42 #define char(x) ((char)x)
TheChrisyd 0:8d785e80d3ba 43 #define byte(x) ((byte)x)
TheChrisyd 0:8d785e80d3ba 44 #define int(x) ((int)x)
TheChrisyd 0:8d785e80d3ba 45 #define word(x) ((word)x)
TheChrisyd 0:8d785e80d3ba 46 #define long(x) ((long)x)
TheChrisyd 0:8d785e80d3ba 47 #define float(x) ((float)x)
TheChrisyd 1:b22cf6a5957d 48
TheChrisyd 1:b22cf6a5957d 49 /** Macro for delay()
TheChrisyd 1:b22cf6a5957d 50 *
TheChrisyd 1:b22cf6a5957d 51 * @param void
TheChrisyd 1:b22cf6a5957d 52 */
TheChrisyd 1:b22cf6a5957d 53 #define delay(x) (wait_ms(x))
TheChrisyd 1:b22cf6a5957d 54 /** Macro for delayMicroseconds()
TheChrisyd 1:b22cf6a5957d 55 *
TheChrisyd 1:b22cf6a5957d 56 * @param void
TheChrisyd 1:b22cf6a5957d 57 */
TheChrisyd 1:b22cf6a5957d 58 #define delayMicroseconds(x) (wait_us(x))
TheChrisyd 1:b22cf6a5957d 59
TheChrisyd 1:b22cf6a5957d 60 /** Macro for min()
TheChrisyd 1:b22cf6a5957d 61 *
TheChrisyd 1:b22cf6a5957d 62 * @param any
TheChrisyd 1:b22cf6a5957d 63 */
TheChrisyd 1:b22cf6a5957d 64 #define min(a,b) ((a)<(b)?(a):(b))
TheChrisyd 1:b22cf6a5957d 65 /** Macro for max()
TheChrisyd 1:b22cf6a5957d 66 *
TheChrisyd 1:b22cf6a5957d 67 * @param any
TheChrisyd 1:b22cf6a5957d 68 */
TheChrisyd 1:b22cf6a5957d 69 #define max(a,b) ((a)>(b)?(a):(b))
TheChrisyd 1:b22cf6a5957d 70 /** Macro for abs()
TheChrisyd 1:b22cf6a5957d 71 *
TheChrisyd 1:b22cf6a5957d 72 * @param any
TheChrisyd 1:b22cf6a5957d 73 */
TheChrisyd 1:b22cf6a5957d 74 #define abs(x) ((x)>0?(x):(x*-1))
TheChrisyd 1:b22cf6a5957d 75
TheChrisyd 1:b22cf6a5957d 76 /** Macro for randomSeed()
TheChrisyd 1:b22cf6a5957d 77 *
TheChrisyd 1:b22cf6a5957d 78 * @param int
TheChrisyd 1:b22cf6a5957d 79 */
TheChrisyd 1:b22cf6a5957d 80 #define randomSeed(x) srand(x)
TheChrisyd 1:b22cf6a5957d 81
TheChrisyd 1:b22cf6a5957d 82
TheChrisyd 0:8d785e80d3ba 83 // typedefs
TheChrisyd 0:8d785e80d3ba 84
TheChrisyd 0:8d785e80d3ba 85 typedef unsigned char prog_uint8_t;
TheChrisyd 0:8d785e80d3ba 86 typedef unsigned int prog_uint16_t;
TheChrisyd 0:8d785e80d3ba 87 typedef unsigned char byte;
TheChrisyd 0:8d785e80d3ba 88 typedef bool boolean;
TheChrisyd 0:8d785e80d3ba 89 typedef unsigned char prog_uchar;
TheChrisyd 0:8d785e80d3ba 90 typedef signed char prog_char;
TheChrisyd 0:8d785e80d3ba 91 typedef signed long int word;
TheChrisyd 0:8d785e80d3ba 92
TheChrisyd 0:8d785e80d3ba 93 // function prototypes
TheChrisyd 0:8d785e80d3ba 94
TheChrisyd 0:8d785e80d3ba 95 void timer_start(void);
TheChrisyd 0:8d785e80d3ba 96 long millis(void);
TheChrisyd 0:8d785e80d3ba 97 long micros(void);
TheChrisyd 0:8d785e80d3ba 98 byte lowByte(short int low);
TheChrisyd 0:8d785e80d3ba 99 byte highByte(short int high);
TheChrisyd 0:8d785e80d3ba 100 int random(int number);
TheChrisyd 0:8d785e80d3ba 101 int random(int numberone, int numbertwo);
TheChrisyd 0:8d785e80d3ba 102 #endif