upm  0.5.1
Sensor/Actuator repository for libmraa (v0.9.1)
 All Data Structures Files Functions Variables Enumerations Enumerator Macros Groups Pages
hal_platform.h
Go to the documentation of this file.
1 /* Copyright (c) 2014, Nordic Semiconductor ASA
2  *
3  * Permission is hereby granted, free of charge, to any person obtaining a copy
4  * of this software and associated documentation files (the "Software"), to deal
5  * in the Software without restriction, including without limitation the rights
6  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7  * copies of the Software, and to permit persons to whom the Software is
8  * furnished to do so, subject to the following conditions:
9  *
10  * The above copyright notice and this permission notice shall be included in all
11  * copies or substantial portions of the Software.
12  *
13  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19  * SOFTWARE.
20  */
21 
28 #ifndef PLATFORM_H__
29 #define PLATFORM_H__
30 
31 //Board dependent defines
32 #if defined (__AVR__)
33  //For Arduino this AVR specific library has to be used for reading from Flash memory
34  #include <avr/pgmspace.h>
35  #include "Arduino.h"
36  #ifdef PROGMEM
37  #undef PROGMEM
38  #define PROGMEM __attribute__(( section(".progmem.data") ))
39  #endif
40 #elif defined(__PIC32MX__)
41  //For Chipkit add the following libraries.
42  #include <stdint.h>
43  #include <stdbool.h>
44  #include <string.h>
45  #include <wiring.h>
46  #include <WProgram.h>
47 
48  //For making the Serial.Print compatible between Arduino and Chipkit
49  #define F(X) (X)
50 
51  //For ChipKit neither PROGMEM or PSTR are needed for PIC32
52  #define PROGMEM
53  #define PSTR(s) (s)
54 
55  #define pgm_read_byte(x) (*((char *)x))
56  #define pgm_read_byte_near(x) (*((char *)x))
57  #define pgm_read_byte_far(x) (*((char *)x))
58  #define pgm_read_word(x) (*((short *)x))
59  #define pgm_read_word_near(x) (*((short *)x))
60  #define pgm_read_workd_far(x) (*((short *)x))
61 
62  #define prog_void const void
63  #define prog_char const char
64  #define prog_uchar const unsigned char
65  #define prog_int8_t const int8_t
66  #define prog_uint8_t const uint8_t
67  #define prog_int16_t const int16_t
68  #define prog_uint16_t const uint16_t
69  #define prog_int32_t const int32_t
70  #define prog_uint32_t const uint32_t
71  #define prog_int64_t const int64_t
72  #define prog_uint64_t const uint64_t
73 
74  //Redefine the function for reading from flash in ChipKit
75  #define memcpy_P memcpy
76 #endif
77 
78 #endif /* PLATFORM_H__ */