variant.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #include "variant.h"
  2. #include "nrf.h"
  3. #include "wiring_constants.h"
  4. #include "wiring_digital.h"
  5. const uint32_t g_ADigitalPinMap[] = {
  6. // D0 .. D10
  7. 2, // D0 is P0.02 (A0)
  8. 3, // D1 is P0.03 (A1)
  9. 28, // D2 is P0.28 (A2)
  10. 29, // D3 is P0.29 (A3)
  11. 4, // D4 is P0.04 (A4,SDA)
  12. 5, // D5 is P0.05 (A5,SCL)
  13. 43, // D6 is P1.11 (TX)
  14. 44, // D7 is P1.12 (RX)
  15. 45, // D8 is P1.13 (SCK)
  16. 46, // D9 is P1.14 (MISO)
  17. 47, // D10 is P1.15 (MOSI)
  18. // LEDs
  19. 26, // D11 is P0.26 (LED RED)
  20. 6, // D12 is P0.06 (LED BLUE)
  21. 30, // D13 is P0.30 (LED GREEN)
  22. 14, // D14 is P0.14 (READ_BAT)
  23. // LSM6DS3TR
  24. 40, // D15 is P1.08 (6D_PWR)
  25. 27, // D16 is P0.27 (6D_I2C_SCL)
  26. 7, // D17 is P0.07 (6D_I2C_SDA)
  27. 11, // D18 is P0.11 (6D_INT1)
  28. // MIC
  29. 42, // D19 is P1.10 (MIC_PWR)
  30. 32, // D20 is P1.00 (PDM_CLK)
  31. 16, // D21 is P0.16 (PDM_DATA)
  32. // BQ25100
  33. 13, // D22 is P0.13 (HICHG)
  34. 17, // D23 is P0.17 (~CHG)
  35. //
  36. 21, // D24 is P0.21 (QSPI_SCK)
  37. 25, // D25 is P0.25 (QSPI_CSN)
  38. 20, // D26 is P0.20 (QSPI_SIO_0 DI)
  39. 24, // D27 is P0.24 (QSPI_SIO_1 DO)
  40. 22, // D28 is P0.22 (QSPI_SIO_2 WP)
  41. 23, // D29 is P0.23 (QSPI_SIO_3 HOLD)
  42. // NFC
  43. 9, // D30 is P0.09 (NFC1)
  44. 10, // D31 is P0.10 (NFC2)
  45. // VBAT
  46. 31, // D32 is P0.31 (VBAT)
  47. };
  48. void initVariant() {
  49. // Disable reading of the BAT voltage.
  50. // https://wiki.seeedstudio.com/XIAO_BLE#q3-what-are-the-considerations-when-using-xiao-nrf52840-sense-for-battery-charging
  51. pinMode(VBAT_ENABLE, OUTPUT);
  52. // digitalWrite(VBAT_ENABLE, HIGH);
  53. // This was taken from Seeed github butis not coherent with the doc,
  54. // VBAT_ENABLE should be kept to LOW to protect P0.14, (1500/500)*(4.2-3.3)+3.3 = 3.9V > 3.6V
  55. // This induces a 3mA current in the resistors :( but it's better than burning the nrf
  56. digitalWrite(VBAT_ENABLE, LOW);
  57. // disable xiao charging current, the handheld uses a tp4056 to charge
  58. // instead of the onboard xiao charging circuit. This charges at a max of
  59. // 780ma instead of 100ma. In theory you could enable both, but in practice
  60. // fire is scary.
  61. pinMode(PIN_CHARGING_CURRENT, OUTPUT);
  62. digitalWrite(PIN_CHARGING_CURRENT, HIGH);
  63. pinMode(PIN_QSPI_CS, OUTPUT);
  64. digitalWrite(PIN_QSPI_CS, HIGH);
  65. pinMode(LED_RED, OUTPUT);
  66. digitalWrite(LED_RED, HIGH);
  67. pinMode(LED_GREEN, OUTPUT);
  68. digitalWrite(LED_GREEN, HIGH);
  69. pinMode(LED_BLUE, OUTPUT);
  70. digitalWrite(LED_BLUE, HIGH);
  71. }