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-03-23 23:48:34 +08:00
|
|
|
#if 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-23 23:48:34 +08:00
|
|
|
#endif /* CONFIG_IEEE802154_CC2520 */
|
2017-08-21 21:42:45 +08:00
|
|
|
|
|
|
|
#if defined(CONFIG_IEEE802154_CC1200)
|
|
|
|
|
|
|
|
#include <ieee802154/cc1200.h>
|
|
|
|
#include <gpio.h>
|
|
|
|
|
|
|
|
static struct cc1200_gpio_configuration cc1200_gpios[CC1200_GPIO_IDX_MAX] = {
|
|
|
|
{ .dev = NULL, .pin = CC1200_GPIO_GPIO0, },
|
|
|
|
};
|
|
|
|
|
|
|
|
struct cc1200_gpio_configuration *cc1200_configure_gpios(void)
|
|
|
|
{
|
|
|
|
const int flags_int_in = (GPIO_DIR_IN | GPIO_INT |
|
|
|
|
GPIO_INT_EDGE |
|
|
|
|
GPIO_INT_DOUBLE_EDGE |
|
|
|
|
GPIO_INT_DEBOUNCE);
|
|
|
|
struct device *gpio;
|
|
|
|
|
|
|
|
gpio = device_get_binding(CONFIG_IEEE802154_CC1200_GPIO_0_NAME);
|
|
|
|
gpio_pin_configure(gpio, cc1200_gpios[CC1200_GPIO_IDX_GPIO0].pin,
|
|
|
|
flags_int_in);
|
|
|
|
|
|
|
|
cc1200_gpios[CC1200_GPIO_IDX_GPIO0].dev = gpio;
|
|
|
|
|
|
|
|
return cc1200_gpios;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_IEEE802154_CC1200 */
|