extend_io.h 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /**
  2. * @Author: DELL
  3. * @Date: 2025/5/22 上午9:18
  4. * Description:
  5. * Copyright: Copyright (©) 2025 永续绿建. All rights reserved.
  6. */
  7. #ifndef WIRE_CONTROLLER_EXTEND_IO_H
  8. #define WIRE_CONTROLLER_EXTEND_IO_H
  9. #pragma once
  10. #include "esp_err.h"
  11. #include "driver/gpio.h"
  12. typedef enum {
  13. GPIO_NUM_Q0 = 0, /*!< GPIO0, input and output */
  14. GPIO_NUM_Q1 = 1, /*!< GPIO1, input and output */
  15. GPIO_NUM_Q2 = 2, /*!< GPIO2, input and output */
  16. GPIO_NUM_Q3 = 3, /*!< GPIO3, input and output */
  17. GPIO_NUM_Q4 = 4, /*!< GPIO4, input and output */
  18. GPIO_NUM_Q5 = 5, /*!< GPIO5, input and output */
  19. GPIO_NUM_Q6 = 6, /*!< GPIO6, input and output */
  20. GPIO_NUM_Q7 = 7, /*!< GPIO7, input and output */
  21. /** @endcond */
  22. } extend_gpio_num_t;
  23. // 74HC595引脚定义 (根据实际电路修改)
  24. #define DATA_PIN 40 // DS (串行数据输入)
  25. #define CLOCK_PIN 42 // SHCP (移位寄存器时钟)
  26. #define LATCH_PIN 41 // STCP (存储寄存器时钟)
  27. #define HC595_SHCP_Low() gpio_set_level(CLOCK_PIN, 0)
  28. #define HC595_SHCP_High() gpio_set_level( CLOCK_PIN, 1 )
  29. #define HC595_STCP_Low() gpio_set_level( LATCH_PIN, 0 )
  30. #define HC595_STCP_High() gpio_set_level( LATCH_PIN, 1 )
  31. #define HC595_Data_Low() gpio_set_level( DATA_PIN, 0 )
  32. #define HC595_Data_High() gpio_set_level( DATA_PIN, 1 )
  33. void extend_io_init();
  34. void hc595_init();
  35. esp_err_t hc595_gpio_write(extend_gpio_num_t gpio_num, uint32_t level) ;
  36. #endif //WIRE_CONTROLLER_EXTEND_IO_H