esp_attr.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 a string into DRAM instead of flash
  24. // Use as ets_printf(DRAM_STR("Hello world!\n"));
  25. #define DRAM_STR(str) (__extension__({static const DRAM_ATTR char __c[] = (str); (const char *)&__c;}))
  26. // Forces code into RTC fast memory. See "docs/deep-sleep-stub.rst"
  27. #define RTC_IRAM_ATTR __attribute__((section(".rtc.text")))
  28. // Forces data into RTC slow memory. See "docs/deep-sleep-stub.rst"
  29. // Any variable marked with this attribute will keep its value
  30. // during a deep sleep / wake cycle.
  31. #define RTC_DATA_ATTR __attribute__((section(".rtc.data")))
  32. // Forces read-only data into RTC slow memory. See "docs/deep-sleep-stub.rst"
  33. #define RTC_RODATA_ATTR __attribute__((section(".rtc.rodata")))
  34. #endif /* __ESP_ATTR_H__ */