2015-11-20 21:37:13 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Intel Corporation
|
|
|
|
*
|
2017-01-19 09:01:01 +08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2015-11-20 21:37:13 +08:00
|
|
|
*/
|
|
|
|
|
2016-12-03 07:03:20 +08:00
|
|
|
#include <kernel.h>
|
2015-11-20 21:37:13 +08:00
|
|
|
#include "board.h"
|
|
|
|
#include <uart.h>
|
|
|
|
#include <device.h>
|
|
|
|
#include <init.h>
|
2015-11-24 20:44:28 +08:00
|
|
|
|
2017-02-06 18:49:16 +08:00
|
|
|
#if defined(CONFIG_IEEE802154_CC2520_LEGACY) || \
|
2017-03-21 17:11:53 +08:00
|
|
|
defined(CONFIG_IEEE802154_CC2520)
|
2015-11-24 20:44:28 +08:00
|
|
|
|
2016-11-29 00:06:15 +08:00
|
|
|
#include <ieee802154/cc2520.h>
|
2016-03-18 20:08:40 +08:00
|
|
|
#include <gpio.h>
|
2015-11-24 20:44:28 +08:00
|
|
|
|
2016-11-29 00:06:15 +08:00
|
|
|
static struct cc2520_gpio_configuration cc2520_gpios[CC2520_GPIO_IDX_MAX] = {
|
|
|
|
{ .dev = NULL, .pin = CC2520_GPIO_VREG_EN, },
|
|
|
|
{ .dev = NULL, .pin = CC2520_GPIO_RESET, },
|
|
|
|
{ .dev = NULL, .pin = CC2520_GPIO_FIFO, },
|
|
|
|
{ .dev = NULL, .pin = CC2520_GPIO_CCA, },
|
|
|
|
{ .dev = NULL, .pin = CC2520_GPIO_SFD, },
|
|
|
|
{ .dev = NULL, .pin = CC2520_GPIO_FIFOP, },
|
|
|
|
};
|
2016-03-18 20:08:40 +08:00
|
|
|
|
2016-11-29 00:06:15 +08:00
|
|
|
struct cc2520_gpio_configuration *cc2520_configure_gpios(void)
|
2015-11-24 20:44:28 +08:00
|
|
|
{
|
2016-03-18 20:08:40 +08:00
|
|
|
const int flags_noint_out = GPIO_DIR_OUT;
|
|
|
|
const int flags_noint_in = GPIO_DIR_IN;
|
|
|
|
const int flags_int_in = (GPIO_DIR_IN | GPIO_INT | GPIO_INT_EDGE |
|
|
|
|
GPIO_INT_ACTIVE_HIGH | GPIO_INT_DEBOUNCE);
|
2016-11-29 00:06:15 +08:00
|
|
|
struct device *gpio;
|
2016-03-18 20:08:40 +08:00
|
|
|
|
2017-02-06 18:49:16 +08:00
|
|
|
gpio = device_get_binding(CONFIG_IEEE802154_CC2520_GPIO_1_NAME);
|
2016-11-29 00:06:15 +08:00
|
|
|
gpio_pin_configure(gpio, cc2520_gpios[CC2520_GPIO_IDX_VREG_EN].pin,
|
|
|
|
flags_noint_out);
|
|
|
|
gpio_pin_configure(gpio, cc2520_gpios[CC2520_GPIO_IDX_RESET].pin,
|
|
|
|
flags_noint_out);
|
2016-03-18 20:08:40 +08:00
|
|
|
|
2016-11-29 00:06:15 +08:00
|
|
|
cc2520_gpios[CC2520_GPIO_IDX_VREG_EN].dev = gpio;
|
|
|
|
cc2520_gpios[CC2520_GPIO_IDX_RESET].dev = gpio;
|
2015-11-24 20:44:28 +08:00
|
|
|
|
2017-02-06 18:49:16 +08:00
|
|
|
gpio = device_get_binding(CONFIG_IEEE802154_CC2520_GPIO_0_NAME);
|
2016-11-29 00:06:15 +08:00
|
|
|
gpio_pin_configure(gpio, cc2520_gpios[CC2520_GPIO_IDX_SFD].pin,
|
|
|
|
flags_int_in);
|
|
|
|
gpio_pin_configure(gpio, cc2520_gpios[CC2520_GPIO_IDX_FIFOP].pin,
|
|
|
|
flags_int_in);
|
|
|
|
gpio_pin_configure(gpio, cc2520_gpios[CC2520_GPIO_IDX_FIFO].pin,
|
|
|
|
flags_noint_in);
|
|
|
|
gpio_pin_configure(gpio, cc2520_gpios[CC2520_GPIO_IDX_CCA].pin,
|
|
|
|
flags_noint_in);
|
2015-11-24 20:44:28 +08:00
|
|
|
|
2016-11-29 00:06:15 +08:00
|
|
|
cc2520_gpios[CC2520_GPIO_IDX_FIFOP].dev = gpio;
|
|
|
|
cc2520_gpios[CC2520_GPIO_IDX_FIFO].dev = gpio;
|
|
|
|
cc2520_gpios[CC2520_GPIO_IDX_SFD].dev = gpio;
|
|
|
|
cc2520_gpios[CC2520_GPIO_IDX_CCA].dev = gpio;
|
2015-11-24 20:44:28 +08:00
|
|
|
|
2016-11-29 00:06:15 +08:00
|
|
|
return cc2520_gpios;
|
2015-11-24 20:44:28 +08:00
|
|
|
}
|
|
|
|
|
2017-03-21 17:11:53 +08:00
|
|
|
#endif /* CONFIG_IEEE802154_CC2520_LEGACY || CONFIG_IEEE802154_CC2520 */
|