drv_gpio.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. */
  11. #ifndef __DRV_GPIO_H__
  12. #define __DRV_GPIO_H__
  13. #include <drv_common.h>
  14. #include <board.h>
  15. #define __STM32_PORT(port) GPIO##port##_BASE
  16. #if defined(SOC_SERIES_STM32MP1)
  17. #define GET_PIN(PORTx,PIN) (rt_base_t)((16 * ( ((rt_base_t)__STM32_PORT(PORTx) - (rt_base_t)GPIOA_BASE)/(0x1000UL) )) + PIN)
  18. #else
  19. #define GET_PIN(PORTx,PIN) (rt_base_t)((16 * ( ((rt_base_t)__STM32_PORT(PORTx) - (rt_base_t)GPIOA_BASE)/(0x0400UL) )) + PIN)
  20. #endif
  21. #define __STM32_PIN(index, gpio, gpio_index) \
  22. { \
  23. index, GPIO##gpio, GPIO_PIN_##gpio_index \
  24. }
  25. #define __STM32_PIN_RESERVE \
  26. { \
  27. -1, 0, 0 \
  28. }
  29. /* STM32 GPIO driver */
  30. struct pin_index
  31. {
  32. int index;
  33. GPIO_TypeDef *gpio;
  34. uint32_t pin;
  35. };
  36. struct pin_irq_map
  37. {
  38. rt_uint16_t pinbit;
  39. IRQn_Type irqno;
  40. };
  41. int rt_hw_pin_init(void);
  42. #endif /* __DRV_GPIO_H__ */