|
楼主 |
发表于 2018-7-20 10:21:36
|
显示全部楼层
#define BUTTONS_NUMBER 5
#define BUTTON_START 13
#define BUTTON_1 13
#define BUTTON_2 14
#define BUTTON_3 15
#define BUTTON_4 16
#define BUTTON_5 3
#define BUTTON_STOP 16
#define BUTTON_PULL NRF_GPIO_PIN_PULLUP
#define BUTTONS_ACTIVE_STATE 0
#define BUTTONS_LIST { BUTTON_1, BUTTON_2, BUTTON_3, BUTTON_4,BUTTON_5}
#define BSP_BUTTON_0 BUTTON_1
#define BSP_BUTTON_1 BUTTON_2
#define BSP_BUTTON_2 BUTTON_3
#define BSP_BUTTON_3 BUTTON_4
#define BSP_BUTTON_4 BUTTON_5
#define RX_PIN_NUMBER 8
#define TX_PIN_NUMBER 6
#define CTS_PIN_NUMBER 7
#define RTS_PIN_NUMBER 5
在函数里面分配第5个button 就申请不了channel
ret_code_t nrf_drv_gpiote_in_init(nrf_drv_gpiote_pin_t pin,
nrf_drv_gpiote_in_config_t const * p_config,
nrf_drv_gpiote_evt_handler_t evt_handler)
{
ASSERT(pin < NUMBER_OF_PINS);
ret_code_t err_code = NRF_SUCCESS;
/* Only one GPIOTE channel can be assigned to one physical pin. */
if (pin_in_use_by_gpiote(pin))
{
err_code = NRF_ERROR_INVALID_STATE;
}
else
{
int8_t channel = channel_port_alloc(pin, evt_handler, p_config->hi_accuracy);
if (channel != NO_CHANNELS)
{
if (p_config->is_watcher)
{
nrf_gpio_cfg_watcher(pin);
}
else
{
nrf_gpio_cfg_input(pin, p_config->pull);
}
if (p_config->hi_accuracy)
{
nrf_gpiote_event_configure(channel, pin, p_config->sense);
}
else
{
m_cb.port_handlers_pins[channel -
GPIOTE_CH_NUM] |= (p_config->sense) << SENSE_FIELD_POS;
}
}
else
{
err_code = NRF_ERROR_NO_MEM;
}
}
NRF_LOG_INFO("Function: %s, error code: %s.\r\n", (uint32_t)__func__,
(uint32_t)ERR_TO_STR(err_code));
return err_code;
} |
|