variant.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #ifndef _SEEED_XIAO_NRF52840_H_
  2. #define _SEEED_XIAO_NRF52840_H_
  3. /** Master clock frequency */
  4. #define VARIANT_MCK (64000000ul)
  5. #define USE_LFXO // Board uses 32khz crystal for LF
  6. //#define USE_LFRC // Board uses RC for LF
  7. /*----------------------------------------------------------------------------
  8. * Headers
  9. *----------------------------------------------------------------------------*/
  10. #include "WVariant.h"
  11. #ifdef __cplusplus
  12. extern "C"
  13. {
  14. #endif // __cplusplus
  15. #define PINS_COUNT (33)
  16. #define NUM_DIGITAL_PINS (33)
  17. #define NUM_ANALOG_INPUTS (8)
  18. #define NUM_ANALOG_OUTPUTS (0)
  19. // LEDs
  20. #define PIN_LED (LED_RED)
  21. #define LED_PWR (PINS_COUNT)
  22. #define PIN_NEOPIXEL (PINS_COUNT)
  23. #define NEOPIXEL_NUM (0)
  24. #define LED_BUILTIN (PIN_LED)
  25. #define LED_RED (11)
  26. #define LED_GREEN (13)
  27. #define LED_BLUE (12)
  28. #define LED_STATE_ON (1) // State when LED is litted
  29. // Buttons
  30. #define PIN_BUTTON1 (PINS_COUNT)
  31. // Digital PINs
  32. static const uint8_t D0 = 0 ;
  33. static const uint8_t D1 = 1 ;
  34. static const uint8_t D2 = 2 ;
  35. static const uint8_t D3 = 3 ;
  36. static const uint8_t D4 = 4 ;
  37. static const uint8_t D5 = 5 ;
  38. static const uint8_t D6 = 6 ;
  39. static const uint8_t D7 = 7 ;
  40. static const uint8_t D8 = 8 ;
  41. static const uint8_t D9 = 9 ;
  42. static const uint8_t D10 = 10;
  43. #define VBAT_ENABLE (14) // Output LOW to enable reading of the BAT voltage.
  44. // https://wiki.seeedstudio.com/XIAO_BLE#q3-what-are-the-considerations-when-using-xiao-nrf52840-sense-for-battery-charging
  45. #define PIN_CHARGING_CURRENT (22) // Battery Charging current
  46. // https://wiki.seeedstudio.com/XIAO_BLE#battery-charging-current
  47. // Analog pins
  48. #define PIN_A0 (0)
  49. #define PIN_A1 (1)
  50. #define PIN_A2 (2)
  51. #define PIN_A3 (3)
  52. #define PIN_A4 (4)
  53. #define PIN_A5 (5)
  54. #define PIN_VBAT (32) // Read the BAT voltage.
  55. // https://wiki.seeedstudio.com/XIAO_BLE#q3-what-are-the-considerations-when-using-xiao-nrf52840-sense-for-battery-charging
  56. #define BAT_NOT_CHARGING (23) // LOW when charging
  57. #define AREF_VOLTAGE (3.0)
  58. #define ADC_MULTIPLIER (3.0F) // 1M, 512k divider bridge
  59. static const uint8_t A0 = PIN_A0;
  60. static const uint8_t A1 = PIN_A1;
  61. static const uint8_t A2 = PIN_A2;
  62. static const uint8_t A3 = PIN_A3;
  63. static const uint8_t A4 = PIN_A4;
  64. static const uint8_t A5 = PIN_A5;
  65. #define ADC_RESOLUTION (12)
  66. // Other pins
  67. #define PIN_NFC1 (30)
  68. #define PIN_NFC2 (31)
  69. // Serial interfaces
  70. #define PIN_SERIAL1_RX (7)
  71. #define PIN_SERIAL1_TX (6)
  72. // SPI Interfaces
  73. #define SPI_INTERFACES_COUNT (2)
  74. #define PIN_SPI_MISO (9)
  75. #define PIN_SPI_MOSI (10)
  76. #define PIN_SPI_SCK (8)
  77. static const uint8_t SS = D3; // NSS for sx ?
  78. static const uint8_t MOSI = PIN_SPI_MOSI;
  79. static const uint8_t MISO = PIN_SPI_MISO;
  80. static const uint8_t SCK = PIN_SPI_SCK ;
  81. #define PIN_SPI1_MISO (25)
  82. #define PIN_SPI1_MOSI (26)
  83. #define PIN_SPI1_SCK (29)
  84. // Wire Interfaces
  85. #define WIRE_INTERFACES_COUNT (1)
  86. #define PIN_WIRE_SDA (17) // 4 and 5 are used for the sx1262 !
  87. #define PIN_WIRE_SCL (16) // use WIRE1_SDA
  88. static const uint8_t SDA = PIN_WIRE_SDA;
  89. static const uint8_t SCL = PIN_WIRE_SCL;
  90. //#define PIN_WIRE1_SDA (17)
  91. //#define PIN_WIRE1_SCL (16)
  92. #define PIN_LSM6DS3TR_C_POWER (15)
  93. #define PIN_LSM6DS3TR_C_INT1 (18)
  94. // PDM Interfaces
  95. #define PIN_PDM_PWR (19)
  96. #define PIN_PDM_CLK (20)
  97. #define PIN_PDM_DIN (21)
  98. // QSPI Pins
  99. #define PIN_QSPI_SCK (24)
  100. #define PIN_QSPI_CS (25)
  101. #define PIN_QSPI_IO0 (26)
  102. #define PIN_QSPI_IO1 (27)
  103. #define PIN_QSPI_IO2 (28)
  104. #define PIN_QSPI_IO3 (29)
  105. // On-board QSPI Flash
  106. #define EXTERNAL_FLASH_DEVICES (P25Q16H)
  107. #define EXTERNAL_FLASH_USE_QSPI
  108. #ifdef __cplusplus
  109. }
  110. #endif
  111. /*----------------------------------------------------------------------------
  112. * Arduino objects - C++ only
  113. *----------------------------------------------------------------------------*/
  114. #endif