drv_common.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 RAM1_SIZE
  36. #define STM32_SRAM1_START RAM1_START
  37. #define STM32_SRAM1_END RAM1_END
  38. #define STM32_SRAM2_SIZE RAM2_SIZE
  39. #define STM32_SRAM2_START RAM2_START
  40. #define STM32_SRAM2_END RAM2_END
  41. #if defined(__CC_ARM) || defined(__CLANG_ARM)
  42. extern int Image$$RW_IRAM1$$ZI$$Limit;
  43. extern int Image$$RW_IRAM2$$ZI$$Limit;
  44. #define HEAP_BEGIN1 ((void *)&Image$$RW_IRAM1$$ZI$$Limit)
  45. #define HEAP_BEGIN2 ((void *)&Image$$RW_IRAM2$$ZI$$Limit)
  46. #elif __ICCARM__
  47. #pragma section="CSTACK"
  48. #define HEAP_BEGIN (__segment_end("CSTACK"))
  49. #else
  50. extern int __bss_end;
  51. #define HEAP_BEGIN ((void *)&__bss_end)
  52. #endif
  53. #define HEAP_END1 STM32_SRAM1_END
  54. #define HEAP_END2 STM32_SRAM2_END
  55. #ifdef __cplusplus
  56. }
  57. #endif
  58. #endif