drv_gpio.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (c) 2006-2018, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2018-11-06 balanceTWK first version
  9. * 2020-06-16 thread-liu add stm32mp1
  10. * 2020-09-01 thread-liu add GPIOZ
  11. */
  12. #ifndef __DRV_GPIO_H__
  13. #define __DRV_GPIO_H__
  14. #include <drv_common.h>
  15. #include <board.h>
  16. #define __STM32_PORT(port) GPIO##port##_BASE
  17. #if defined(SOC_SERIES_STM32MP1)
  18. #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))
  19. #else
  20. #define GET_PIN(PORTx,PIN) (rt_base_t)((16 * ( ((rt_base_t)__STM32_PORT(PORTx) - (rt_base_t)GPIOA_BASE)/(0x0400UL) )) + PIN)
  21. #endif
  22. #define __STM32_PIN(index, gpio, gpio_index) \
  23. { \
  24. index, GPIO##gpio, GPIO_PIN_##gpio_index \
  25. }
  26. #define __STM32_PIN_RESERVE \
  27. { \
  28. -1, 0, 0 \
  29. }
  30. /* STM32 GPIO driver */
  31. struct pin_index
  32. {
  33. int index;
  34. GPIO_TypeDef *gpio;
  35. uint32_t pin;
  36. };
  37. struct pin_irq_map
  38. {
  39. rt_uint16_t pinbit;
  40. IRQn_Type irqno;
  41. };
  42. int rt_hw_pin_init(void);
  43. #endif /* __DRV_GPIO_H__ */