drv_gpio.h 752 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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-06 balanceTWK first version
  9. * 2020-09-18 geniusgogo optimization design pin-index algorithm
  10. */
  11. #ifndef __DRV_GPIO_H__
  12. #define __DRV_GPIO_H__
  13. #include <drv_common.h>
  14. #include <board.h>
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #define __STM32_PORT(port) GPIO##port##_BASE
  19. #define GET_PIN(PORTx,PIN) (rt_base_t)((16 * ( ((rt_base_t)__STM32_PORT(PORTx) - (rt_base_t)GPIOA_BASE)/(0x0400UL) )) + PIN)
  20. struct pin_irq_map
  21. {
  22. rt_uint16_t pinbit;
  23. IRQn_Type irqno;
  24. };
  25. int rt_hw_pin_init(void);
  26. #ifdef __cplusplus
  27. }
  28. #endif
  29. #endif /* __DRV_GPIO_H__ */