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