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