esp_attr.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. // http://www.apache.org/licenses/LICENSE-2.0
  7. //
  8. // Unless required by applicable law or agreed to in writing, software
  9. // distributed under the License is distributed on an "AS IS" BASIS,
  10. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. // See the License for the specific language governing permissions and
  12. // limitations under the License.
  13. #ifndef __ESP_ATTR_H__
  14. #define __ESP_ATTR_H__
  15. #define ROMFN_ATTR
  16. //Normally, the linker script will put all code and rodata in flash,
  17. //and all variables in shared RAM. These macros can be used to redirect
  18. //particular functions/variables to other memory regions.
  19. // Forces code into IRAM instead of flash.
  20. #define IRAM_ATTR __attribute__((section(".iram1")))
  21. // Forces data into DRAM instead of flash
  22. #define DRAM_ATTR __attribute__((section(".dram1")))
  23. // Forces data to be 4 bytes aligned
  24. #define WORD_ALIGNED_ATTR __attribute__((aligned(4)))
  25. // Forces data to be placed to DMA-capable places
  26. #define DMA_ATTR WORD_ALIGNED_ATTR DRAM_ATTR
  27. // Forces a string into DRAM instead of flash
  28. // Use as ets_printf(DRAM_STR("Hello world!\n"));
  29. #define DRAM_STR(str) (__extension__({static const DRAM_ATTR char __c[] = (str); (const char *)&__c;}))
  30. // Forces code into RTC fast memory. See "docs/deep-sleep-stub.rst"
  31. #define RTC_IRAM_ATTR __attribute__((section(".rtc.text")))
  32. // Forces data into RTC slow memory. See "docs/deep-sleep-stub.rst"
  33. // Any variable marked with this attribute will keep its value
  34. // during a deep sleep / wake cycle.
  35. #define RTC_DATA_ATTR __attribute__((section(".rtc.data")))
  36. // Forces read-only data into RTC slow memory. See "docs/deep-sleep-stub.rst"
  37. #define RTC_RODATA_ATTR __attribute__((section(".rtc.rodata")))
  38. // Forces data into noinit section to avoid initialization after restart.
  39. #define __NOINIT_ATTR __attribute__((section(".noinit")))
  40. // Forces data into RTC slow memory of .noinit section.
  41. // Any variable marked with this attribute will keep its value
  42. // after restart or during a deep sleep / wake cycle.
  43. #define RTC_NOINIT_ATTR __attribute__((section(".rtc_noinit")))
  44. #endif /* __ESP_ATTR_H__ */