nrfx_config.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * This file is part of the MicroPython project, http://micropython.org/
  3. *
  4. * The MIT License (MIT)
  5. *
  6. * Copyright (c) 2018 Glenn Ruben Bakke
  7. * Copyright (c) 2018 Ayke van Laethem
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a copy
  10. * of this software and associated documentation files (the "Software"), to deal
  11. * in the Software without restriction, including without limitation the rights
  12. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  13. * copies of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be included in
  17. * all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  20. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  21. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  22. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  23. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  24. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  25. * THE SOFTWARE.
  26. */
  27. #ifndef NRFX_CONFIG_H
  28. #define NRFX_CONFIG_H
  29. #include "mpconfigport.h"
  30. #include "nrf.h"
  31. // Port specific defines
  32. #ifndef NRFX_LOG_ENABLED
  33. #define NRFX_LOG_ENABLED 0
  34. #endif
  35. #define NRFX_LOG_UART_DISABLED 1
  36. // NRFX configurations
  37. #if NRF51 || NRF52832
  38. #define GPIO_COUNT 1
  39. #elif NRF52840 || NRF52840_XXAA
  40. #define GPIO_COUNT 2
  41. #endif
  42. #define NRFX_GPIOTE_ENABLED 1
  43. #define NRFX_GPIOTE_CONFIG_NUM_OF_LOW_POWER_EVENTS 1
  44. #if NRF51
  45. #define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 3
  46. #else
  47. #define NRFX_GPIOTE_CONFIG_IRQ_PRIORITY 6
  48. #endif
  49. #define NRFX_UART_ENABLED 1
  50. #define NRFX_UART0_ENABLED 1
  51. #define NRFX_TWI_ENABLED (MICROPY_PY_MACHINE_I2C)
  52. #define NRFX_TWI0_ENABLED 1
  53. #define NRFX_TWI1_ENABLED 1
  54. #if defined(NRF51) || defined(NRF52832)
  55. #define NRFX_SPI_ENABLED (MICROPY_PY_MACHINE_HW_SPI)
  56. #define NRFX_SPI0_ENABLED 1
  57. #define NRFX_SPI1_ENABLED 1
  58. #if defined(NRF52832)
  59. #define NRFX_SPI2_ENABLED 1
  60. #endif
  61. #elif defined(NRF52840)
  62. #define NRFX_SPIM_ENABLED (MICROPY_PY_MACHINE_HW_SPI)
  63. #define NRFX_SPIM0_ENABLED 1
  64. #define NRFX_SPIM1_ENABLED 1
  65. #define NRFX_SPIM2_ENABLED 1
  66. #define NRFX_SPIM3_ENABLED (NRF52840)
  67. #endif // NRF51
  68. // 0 NRF_GPIO_PIN_NOPULL
  69. // 1 NRF_GPIO_PIN_PULLDOWN
  70. // 3 NRF_GPIO_PIN_PULLUP
  71. #define NRFX_SPI_MISO_PULL_CFG 1
  72. #define NRFX_SPIM_MISO_PULL_CFG 1
  73. #define NRFX_RTC_ENABLED (MICROPY_PY_MACHINE_RTCOUNTER)
  74. #define NRFX_RTC0_ENABLED 1
  75. #define NRFX_RTC1_ENABLED 1
  76. #define NRFX_RTC2_ENABLED (!NRF51)
  77. #define NRFX_TIMER_ENABLED (MICROPY_PY_MACHINE_TIMER)
  78. #define NRFX_TIMER0_ENABLED 1
  79. #define NRFX_TIMER1_ENABLED (!MICROPY_PY_MACHINE_SOFT_PWM)
  80. #define NRFX_TIMER2_ENABLED 1
  81. #define NRFX_TIMER3_ENABLED (!NRF51)
  82. #define NRFX_TIMER4_ENABLED (!NRF51)
  83. #define NRFX_PWM_ENABLED (!NRF51) && MICROPY_PY_MACHINE_HW_PWM
  84. #define NRFX_PWM0_ENABLED 1
  85. #define NRFX_PWM1_ENABLED 1
  86. #define NRFX_PWM2_ENABLED 1
  87. #define NRFX_PWM3_ENABLED (NRF52840)
  88. // Peripheral Resource Sharing
  89. #if defined(NRF51) || defined(NRF52832)
  90. #define NRFX_PRS_BOX_0_ENABLED (NRFX_TWI_ENABLED && NRFX_TWI0_ENABLED && NRFX_SPI_ENABLED && NRFX_SPI0_ENABLED)
  91. #define NRFX_PRS_BOX_1_ENABLED (NRFX_TWI_ENABLED && NRFX_TWI1_ENABLED && NRFX_SPI_ENABLED && NRFX_SPI1_ENABLED)
  92. #if defined(NRF52832)
  93. #define NRFX_PRS_BOX_2_ENABLED (NRFX_TWI_ENABLED && NRFX_TWI1_ENABLED && NRFX_SPI_ENABLED && NRFX_SPI1_ENABLED)
  94. #endif
  95. #elif defined(NRF52840)
  96. #define NRFX_PRS_BOX_0_ENABLED (NRFX_TWI_ENABLED && NRFX_TWI0_ENABLED && NRFX_SPIM_ENABLED && NRFX_SPIM0_ENABLED)
  97. #define NRFX_PRS_BOX_1_ENABLED (NRFX_TWI_ENABLED && NRFX_TWI1_ENABLED && NRFX_SPIM_ENABLED && NRFX_SPIM1_ENABLED)
  98. #define NRFX_PRS_BOX_2_ENABLED (NRFX_TWI_ENABLED && NRFX_TWI2_ENABLED && NRFX_SPIM_ENABLED && NRFX_SPIM2_ENABLED)
  99. #endif
  100. #define NRFX_PRS_ENABLED (NRFX_PRS_BOX_0_ENABLED || NRFX_PRS_BOX_1_ENABLED || NRFX_PRS_BOX_2_ENABLED)
  101. #define NRFX_SAADC_ENABLED !(NRF51) && (MICROPY_PY_MACHINE_ADC)
  102. #define NRFX_ADC_ENABLED (NRF51) && (MICROPY_PY_MACHINE_ADC)
  103. #endif // NRFX_CONFIG_H