dport_access.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #include <stdint.h>
  7. #include <sdkconfig.h>
  8. #include "soc/soc_caps.h"
  9. #include "soc/dport_access.h"
  10. #include "esp_attr.h"
  11. IRAM_ATTR uint32_t esp_dport_access_reg_read(uint32_t reg)
  12. {
  13. #if defined(BOOTLOADER_BUILD) || defined(CONFIG_FREERTOS_UNICORE) || !SOC_DPORT_WORKAROUND
  14. return _DPORT_REG_READ(reg);
  15. #else
  16. uint32_t apb;
  17. unsigned int intLvl;
  18. __asm__ __volatile__ (\
  19. "rsil %[LVL], "XTSTR(SOC_DPORT_WORKAROUND_DIS_INTERRUPT_LVL)"\n"\
  20. "movi %[APB], "XTSTR(0x3ff40078)"\n"\
  21. "l32i %[APB], %[APB], 0\n"\
  22. "l32i %[REG], %[REG], 0\n"\
  23. "wsr %[LVL], "XTSTR(PS)"\n"\
  24. "rsync\n"\
  25. : [APB]"=a"(apb), [REG]"+a"(reg), [LVL]"=a"(intLvl)\
  26. : \
  27. : "memory" \
  28. );
  29. return reg;
  30. #endif
  31. }
  32. IRAM_ATTR uint32_t esp_dport_access_sequence_reg_read(uint32_t reg)
  33. {
  34. #if defined(BOOTLOADER_BUILD) || defined(CONFIG_FREERTOS_UNICORE) || !SOC_DPORT_WORKAROUND
  35. return _DPORT_REG_READ(reg);
  36. #else
  37. uint32_t apb;
  38. __asm__ __volatile__ (\
  39. "movi %[APB], "XTSTR(0x3ff40078)"\n"\
  40. "l32i %[APB], %[APB], 0\n"\
  41. "l32i %[REG], %[REG], 0\n"\
  42. : [APB]"=a"(apb), [REG]"+a"(reg)\
  43. : \
  44. : "memory" \
  45. );
  46. return reg;
  47. #endif
  48. }