You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.3 KiB

  1. From 30a2323bc0a95cda4eca818fe1d523a2e5c031f3 Mon Sep 17 00:00:00 2001
  2. From: Pawel Dembicki <paweldembicki@gmail.com>
  3. Date: Mon, 2 Nov 2020 14:50:34 +0100
  4. Subject: [PATCH] support gpio with number bigger than 255
  5. Change 8-bit gpio value to 16-bit, which allow to use gpio >255.
  6. Signed-off-by: Pawel Dembicki <paweldembicki@gmail.com>
  7. ---
  8. src/data_types.h | 16 ++++++++--------
  9. src/relay_drv_gpio.c | 10 +++++-----
  10. 2 files changed, 13 insertions(+), 13 deletions(-)
  11. --- a/src/data_types.h
  12. +++ b/src/data_types.h
  13. @@ -56,14 +56,14 @@ typedef struct
  14. /* [GPIO drv] */
  15. uint8_t gpio_num_relays;
  16. uint8_t gpio_active_value;
  17. - uint8_t relay1_gpio_pin;
  18. - uint8_t relay2_gpio_pin;
  19. - uint8_t relay3_gpio_pin;
  20. - uint8_t relay4_gpio_pin;
  21. - uint8_t relay5_gpio_pin;
  22. - uint8_t relay6_gpio_pin;
  23. - uint8_t relay7_gpio_pin;
  24. - uint8_t relay8_gpio_pin;
  25. + uint16_t relay1_gpio_pin;
  26. + uint16_t relay2_gpio_pin;
  27. + uint16_t relay3_gpio_pin;
  28. + uint16_t relay4_gpio_pin;
  29. + uint16_t relay5_gpio_pin;
  30. + uint16_t relay6_gpio_pin;
  31. + uint16_t relay7_gpio_pin;
  32. + uint16_t relay8_gpio_pin;
  33. /* [Sainsmart drv] */
  34. uint8_t sainsmart_num_relays;
  35. --- a/src/relay_drv_gpio.c
  36. +++ b/src/relay_drv_gpio.c
  37. @@ -53,7 +53,7 @@
  38. #define GPIO_BASE_FILE GPIO_BASE_DIR"gpio"
  39. -static uint8_t pins[] =
  40. +static uint16_t pins[] =
  41. {
  42. 0, // dummy
  43. 0, // pin 1
  44. @@ -85,7 +85,7 @@ int set_relay_generic_gpio(char* portnam
  45. * -1 - fail
  46. * -2 - already exported
  47. *********************************************************/
  48. -static int do_export(uint8_t pin)
  49. +static int do_export(uint16_t pin)
  50. {
  51. int fd;
  52. char b[64];
  53. @@ -151,7 +151,7 @@ static int do_export(uint8_t pin)
  54. * Return: 0 - success
  55. * -1 - fail
  56. *********************************************************/
  57. -static int do_unexport(uint8_t pin)
  58. +static int do_unexport(uint16_t pin)
  59. {
  60. int fd;
  61. char b[64];
  62. @@ -261,7 +261,7 @@ int get_relay_generic_gpio(char* portnam
  63. int fd;
  64. char b[64];
  65. char d[1];
  66. - uint8_t pin;
  67. + uint16_t pin;
  68. if (relay<FIRST_RELAY || relay>(FIRST_RELAY+g_num_relays-1))
  69. {
  70. @@ -324,7 +324,7 @@ int set_relay_generic_gpio(char* portnam
  71. int fd;
  72. char b[64];
  73. char d[1];
  74. - uint8_t pin;
  75. + uint16_t pin;
  76. if (relay<FIRST_RELAY || relay>(FIRST_RELAY+g_num_relays-1))
  77. {