Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion boards/shields/link_board_eth/link_board_eth.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
enc424j600@0 {
compatible = "microchip,enc424j600";
spi-max-frequency = <14000000>;
int-gpios = <&arduino_header 15 0>; /* D9 */
int-gpios = <&arduino_header 15 GPIO_ACTIVE_LOW>; /* D9 */
status = "okay";
label = "ETH_0";
reg = <0>;
Expand Down
13 changes: 6 additions & 7 deletions drivers/ethernet/eth_enc28j60.c
Original file line number Diff line number Diff line change
Expand Up @@ -694,10 +694,8 @@ static int eth_enc28j60_init(struct device *dev)
}

if (gpio_pin_configure(context->gpio, config->gpio_pin,
(GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE
| GPIO_INT_ACTIVE_LOW | GPIO_INT_DEBOUNCE))) {
LOG_ERR("Unable to configure GPIO pin %u",
config->gpio_pin);
GPIO_INPUT | config->gpio_flags)) {
LOG_ERR("Unable to configure GPIO pin %u", config->gpio_pin);
return -EINVAL;
}

Expand All @@ -708,9 +706,9 @@ static int eth_enc28j60_init(struct device *dev)
return -EINVAL;
}

if (gpio_pin_enable_callback(context->gpio, config->gpio_pin)) {
return -EINVAL;
}
gpio_pin_interrupt_configure(context->gpio,
config->gpio_pin,
GPIO_INT_EDGE_TO_ACTIVE);

if (eth_enc28j60_soft_reset(dev)) {
LOG_ERR("Soft-reset failed");
Expand Down Expand Up @@ -763,6 +761,7 @@ static struct eth_enc28j60_runtime eth_enc28j60_0_runtime = {
static const struct eth_enc28j60_config eth_enc28j60_0_config = {
.gpio_port = DT_INST_0_MICROCHIP_ENC28J60_INT_GPIOS_CONTROLLER,
.gpio_pin = DT_INST_0_MICROCHIP_ENC28J60_INT_GPIOS_PIN,
.gpio_flags = DT_INST_0_MICROCHIP_ENC28J60_INT_GPIOS_FLAGS,
.spi_port = DT_INST_0_MICROCHIP_ENC28J60_BUS_NAME,
.spi_freq = DT_INST_0_MICROCHIP_ENC28J60_SPI_MAX_FREQUENCY,
.spi_slave = DT_INST_0_MICROCHIP_ENC28J60_BASE_ADDRESS,
Expand Down
1 change: 1 addition & 0 deletions drivers/ethernet/eth_enc28j60_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
struct eth_enc28j60_config {
const char *gpio_port;
u8_t gpio_pin;
gpio_devicetree_flags_t gpio_flags;
const char *spi_port;
u8_t spi_cs_pin;
const char *spi_cs_port;
Expand Down
13 changes: 6 additions & 7 deletions drivers/ethernet/eth_enc424j600.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,8 @@ static int enc424j600_init(struct device *dev)
}

if (gpio_pin_configure(context->gpio, config->gpio_pin,
(GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE
| GPIO_INT_ACTIVE_LOW | GPIO_INT_DEBOUNCE))) {
LOG_ERR("Unable to configure GPIO pin %u",
config->gpio_pin);
GPIO_INPUT | config->gpio_flags)) {
LOG_ERR("Unable to configure GPIO pin %u", config->gpio_pin);
return -EINVAL;
}

Expand All @@ -644,9 +642,9 @@ static int enc424j600_init(struct device *dev)
return -EINVAL;
}

if (gpio_pin_enable_callback(context->gpio, config->gpio_pin)) {
return -EINVAL;
}
gpio_pin_interrupt_configure(context->gpio,
config->gpio_pin,
GPIO_INT_EDGE_TO_ACTIVE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

isn't GPIO_INT_ENABLE missing?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPIO_INT_ENABLE is a part of GPIO_INT_EDGE_TO_ACTIVE macro.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, the documentation is a bit misleading

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GPIO_INT_EDGE_TO_ACTIVE is a convenience macro targeted at users of the GPIO API. GPIO_INT_ENABLE is a macro targeted at the GPIO driver developers. In the doxygen generated documentation only convenience flags will be visible. This is fairly popular convention. Nevertheless, if someone has an idea how this can be improved it's not too late.


/* Check SPI connection */
do {
Expand Down Expand Up @@ -756,6 +754,7 @@ static struct enc424j600_runtime enc424j600_0_runtime = {
static const struct enc424j600_config enc424j600_0_config = {
.gpio_port = DT_INST_0_MICROCHIP_ENC424J600_INT_GPIOS_CONTROLLER,
.gpio_pin = DT_INST_0_MICROCHIP_ENC424J600_INT_GPIOS_PIN,
.gpio_flags = DT_INST_0_MICROCHIP_ENC424J600_INT_GPIOS_FLAGS,
.spi_port = DT_INST_0_MICROCHIP_ENC424J600_BUS_NAME,
.spi_freq = DT_INST_0_MICROCHIP_ENC424J600_SPI_MAX_FREQUENCY,
.spi_slave = DT_INST_0_MICROCHIP_ENC424J600_BASE_ADDRESS,
Expand Down
1 change: 1 addition & 0 deletions drivers/ethernet/eth_enc424j600_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@
struct enc424j600_config {
const char *gpio_port;
u8_t gpio_pin;
gpio_devicetree_flags_t gpio_flags;
const char *spi_port;
u8_t spi_cs_pin;
const char *spi_cs_port;
Expand Down
5 changes: 5 additions & 0 deletions dts/bindings/ethernet/microchip,enc28j60.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ properties:
int-gpios:
type: phandle-array
required: true
description: Interrupt pin.

The interrupt pin of ENC28J60 is active low.
If connected directly the MCU pin should be configured
as active low.
5 changes: 5 additions & 0 deletions dts/bindings/ethernet/microchip,enc424j600.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ properties:
int-gpios:
type: phandle-array
required: true
description: Interrupt pin.

The interrupt pin of ENC424J600 is active low.
If connected directly the MCU pin should be configured
as active low.