PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

70 rindas
1.7KB

  1. /* Copyright (c) 2011 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRENTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. * $LastChangedRevision$
  12. */
  13. #ifndef PLATFORM_H__
  14. #define PLATFORM_H__
  15. /** @file
  16. * @brief
  17. */
  18. #include "Arduino.h"
  19. #define hal_pltf_clear_spi_master_config() do { SPCR = 0; } while(0)
  20. //SPI2X=1 SPS0=1 SPR0=1 -> 250KHz
  21. //DORD=1 LSBit first
  22. //SPE=1 Enable the SPI
  23. //MSTR=1 Enable master mode
  24. //CPOL=0 See Section 7 in the nRF8001 PS (Clock Polarity)
  25. //CPHA=0 See Section 7 in the nRF8001 PS (Clock Phase)
  26. /*
  27. Atmega328
  28. Table 18-5. Relationship Between SCK and the Oscillator Frequency
  29. SPI2X SPR1 SPR0 SCK Frequency
  30. 0 0 0 fosc/4
  31. 0 0 1 fosc/16
  32. 0 1 0 fosc/64
  33. 0 1 1 fosc/128
  34. 1 0 0 fosc/2
  35. 1 0 1 fosc/8
  36. 1 1 0 fosc/32
  37. 1 1 1 fosc/64
  38. */
  39. /*
  40. #define hal_pltf_spi_master_config() do { \
  41. pinMode(SCK, OUTPUT);\
  42. pinMode(MOSI, OUTPUT);\
  43. pinMode(SS, OUTPUT);\
  44. pinMode(MISO, INPUT);\
  45. digitalWrite(SCK, LOW);\
  46. digitalWrite(MOSI, LOW);\
  47. digitalWrite(SS, HIGH);\
  48. SPCR = 0; \
  49. SPSR = 0; \
  50. SPSR = (1<<SPI2X);\
  51. SPCR = ((1<<SPE)|(1<<MSTR)|(0<<SPR1) | (1<<SPR0) | (1<<DORD) | (0<<CPOL) | (0<<CPHA));}\
  52. while(0)
  53. */
  54. #define hal_pltf_enable_spi() do { SPCR |= _BV(SPE); } while(0)
  55. #define hal_pltf_disable_spi() do { SPCR &= ~_BV(SPE); } while(0)
  56. #define hal_pltf_configure_spi_for_aci() do{\
  57. hal_pltf_spi_master_config();\
  58. }while(0)
  59. #endif /* PLATFORM_H__ */