No Description

hal_platform.h 2.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. #ifndef PLATFORM_H__
  22. #define PLATFORM_H__
  23. /** @file
  24. * @brief
  25. */
  26. //Board dependent defines
  27. #if defined (__AVR__)
  28. //For Arduino this AVR specific library has to be used for reading from Flash memory
  29. #include <avr/pgmspace.h>
  30. #include "Arduino.h"
  31. #ifdef PROGMEM
  32. #undef PROGMEM
  33. #define PROGMEM __attribute__(( section(".progmem.data") ))
  34. #endif
  35. #elif defined(__PIC32MX__)
  36. //For Chipkit add the following libraries.
  37. #include <stdint.h>
  38. #include <stdbool.h>
  39. #include <string.h>
  40. #include <wiring.h>
  41. #include <WProgram.h>
  42. //For making the Serial.Print compatible between Arduino and Chipkit
  43. #define F(X) (X)
  44. //For ChipKit neither PROGMEM or PSTR are needed for PIC32
  45. #define PROGMEM
  46. #define PSTR(s) (s)
  47. #define pgm_read_byte(x) (*((char *)x))
  48. #define pgm_read_byte_near(x) (*((char *)x))
  49. #define pgm_read_byte_far(x) (*((char *)x))
  50. #define pgm_read_word(x) (*((short *)x))
  51. #define pgm_read_word_near(x) (*((short *)x))
  52. #define pgm_read_workd_far(x) (*((short *)x))
  53. #define prog_void const void
  54. #define prog_char const char
  55. #define prog_uchar const unsigned char
  56. #define prog_int8_t const int8_t
  57. #define prog_uint8_t const uint8_t
  58. #define prog_int16_t const int16_t
  59. #define prog_uint16_t const uint16_t
  60. #define prog_int32_t const int32_t
  61. #define prog_uint32_t const uint32_t
  62. #define prog_int64_t const int64_t
  63. #define prog_uint64_t const uint64_t
  64. //Redefine the function for reading from flash in ChipKit
  65. #define memcpy_P memcpy
  66. #endif
  67. #endif /* PLATFORM_H__ */