drv_common.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2018-11-7 SummerGift first version
  9. */
  10. #ifndef __DRV_COMMON_H__
  11. #define __DRV_COMMON_H__
  12. #include <rtthread.h>
  13. #include <rthw.h>
  14. #ifdef RT_USING_DEVICE
  15. #include <rtdevice.h>
  16. #endif
  17. #ifdef __cplusplus
  18. extern "C"
  19. {
  20. #endif
  21. void _Error_Handler(char *s, int num);
  22. #ifndef Error_Handler
  23. #define Error_Handler() _Error_Handler(__FILE__, __LINE__)
  24. #endif
  25. #define DMA_NOT_AVAILABLE ((DMA_INSTANCE_TYPE *)0xFFFFFFFFU)
  26. #define __STM32_PORT(port) GPIO##port##_BASE
  27. #if defined(SOC_SERIES_STM32MP1)
  28. #define GET_PIN(PORTx,PIN) (GPIO##PORTx == GPIOZ) ? (176 + PIN) : ((rt_base_t)((16 * ( ((rt_base_t)__STM32_PORT(PORTx) - (rt_base_t)GPIOA_BASE)/(0x1000UL) )) + PIN))
  29. #else
  30. #define GET_PIN(PORTx,PIN) (rt_base_t)((16 * ( ((rt_base_t)__STM32_PORT(PORTx) - (rt_base_t)GPIOA_BASE)/(0x0400UL) )) + PIN)
  31. #endif
  32. #define STM32_FLASH_START_ADRESS ROM_START
  33. #define STM32_FLASH_SIZE ROM_SIZE
  34. #define STM32_FLASH_END_ADDRESS ROM_END
  35. #define STM32_SRAM1_SIZE RAM_SIZE
  36. #define STM32_SRAM1_START RAM_START
  37. #define STM32_SRAM1_END RAM_END
  38. #if defined(__CC_ARM) || defined(__CLANG_ARM)
  39. extern int Image$$RW_IRAM1$$ZI$$Limit;
  40. #define HEAP_BEGIN ((void *)&Image$$RW_IRAM1$$ZI$$Limit)
  41. #elif __ICCARM__
  42. #pragma section="CSTACK"
  43. #define HEAP_BEGIN (__segment_end("CSTACK"))
  44. #else
  45. extern int __bss_end;
  46. #define HEAP_BEGIN ((void *)&__bss_end)
  47. #endif
  48. #define HEAP_END STM32_SRAM1_END
  49. #ifdef __cplusplus
  50. }
  51. #endif
  52. #endif