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

Dependents:   Gameduino Factory_monitor_0v1 mbed_mindflex NEW_NFC_TEST

This is a library for allowing the use of programs written for the Arduino with the mbed. This was started for use with the Gameduino shield Library. It is currently uncomplete and not fully tested, but I don't see myself spending time on it. See TODOs and check http://arduino.cc/en/Reference/HomePage for missing parts

Committer:
TheChrisyd
Date:
Thu Dec 20 23:00:25 2012 +0000
Revision:
3:272d0276d474
Parent:
2:622cd7b451f8
updated macros and typedefs

Who changed what in which revision?

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