drv_gpio.h 907 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023-12-02 Meco Man the first version
  9. */
  10. #ifndef __DRV_GPIO_H__
  11. #define __DRV_GPIO_H__
  12. #include <rtdef.h>
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. #define PIN_LOW 0x00
  17. #define PIN_HIGH 0x01
  18. #define PIN_MODE_OUTPUT 0x00
  19. #define PIN_MODE_INPUT 0x01
  20. #define PIN_MODE_INPUT_PULLUP 0x02
  21. #define PIN_MODE_INPUT_PULLDOWN 0x03
  22. #define PIN_MODE_OUTPUT_OD 0x04
  23. #define GET_PIN(PORTx,PIN) (rt_uint64_t)((((rt_uint64_t)GPIO_PIN_##PIN) << 32) | (rt_uint64_t)(rt_ubase_t)GPIO##PORTx)
  24. void rt_pin_mode(rt_uint64_t pin, rt_uint8_t mode);
  25. void rt_pin_write(rt_uint64_t pin, rt_uint8_t value);
  26. rt_int8_t rt_pin_read(rt_uint64_t pin);
  27. #ifdef __cplusplus
  28. }
  29. #endif
  30. #endif /* __DRV_GPIO_H__ */