Skip to content

Commit

Permalink
remove char-dev debouncing; add 5us delay for ce() on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Feb 25, 2024
1 parent 6ef68cd commit 18045c7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
3 changes: 3 additions & 0 deletions RF24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ void RF24::ce(bool level)
if (ce_pin != csn_pin) {
#endif
digitalWrite(ce_pin, level);
#ifdef RF24_LINUX
delayMicroseconds(5);
#endif
#ifndef RF24_LINUX
}
#endif
Expand Down
10 changes: 2 additions & 8 deletions utility/SPIDEV/gpio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ struct gpio_v2_line_request request;
struct gpio_v2_line_values data;
struct gpio_v2_line_config_attribute attr_input;
struct gpio_v2_line_config_attribute attr_output;
struct gpio_v2_line_config_attribute attr_debounce;

// use this struct to keep a track of open file descriptors
struct GlobalCache
Expand Down Expand Up @@ -62,14 +61,10 @@ struct GlobalCache
attr_output.attr.id = GPIO_V2_LINE_ATTR_ID_FLAGS;
attr_output.attr.flags = GPIO_V2_LINE_FLAG_OUTPUT;

attr_debounce.attr.id = GPIO_V2_LINE_ATTR_ID_DEBOUNCE;
attr_debounce.attr.debounce_period_us = 5;

strcpy(request.consumer, "RF24 lib");
request.config.num_attrs = 3;
request.config.num_attrs = 2;
request.config.attrs[0] = attr_input;
request.config.attrs[1] = attr_output;
request.config.attrs[2] = attr_debounce;
}

// Should be called automatically on program exit.
Expand Down Expand Up @@ -104,10 +99,9 @@ void GPIO::open(rf24_gpio_pin_t port, int DDR)
request.num_lines += 1;
}

// (re)assign attribute(s) specific to the pin
// adjust attribute's mask specific to the pin and direction
if (DDR) {
attr_output.mask |= (1LL << offset);
attr_debounce.mask = attr_output.mask;
}
else {
attr_input.mask |= (1LL << offset);
Expand Down

0 comments on commit 18045c7

Please sign in to comment.