drv_gpio.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 change to new framework
  9. */
  10. #ifndef __DRV_GPIO_H__
  11. #define __DRV_GPIO_H__
  12. #include <drv_common.h>
  13. #define __STM32_PORT(port) GPIO##port
  14. #define GET_PIN(PORTx,PIN) (rt_base_t)((16 * ( ((rt_base_t)__STM32_PORT(PORTx) - (rt_base_t)GPIOA)/(0x0400UL) )) + PIN)
  15. #define __STM32_PIN(index, gpio, gpio_index) \
  16. { \
  17. index, GPIO##gpio, GPIO_PIN_##gpio_index \
  18. }
  19. #define __STM32_PIN_RESERVE \
  20. { \
  21. -1, 0, 0 \
  22. }
  23. /* STM32 GPIO driver */
  24. struct pin_index
  25. {
  26. int index;
  27. GPIO_TypeDef *gpio;
  28. uint32_t pin;
  29. };
  30. struct pin_irq_map
  31. {
  32. rt_uint16_t pinbit;
  33. IRQn_Type irqno;
  34. };
  35. int rt_hw_pin_init(void);
  36. #endif /* __DRV_GPIO_H__ */