修改格式
This commit is contained in:
parent
1d960894ff
commit
933fd4a05c
@ -8,7 +8,6 @@
|
||||
* 2020-06-16 guohp1128 first version
|
||||
*/
|
||||
|
||||
|
||||
#include "drv_gpio.h"
|
||||
|
||||
#ifdef RT_USING_PIN
|
||||
@ -47,16 +46,16 @@ static const struct pin_index pins[] =
|
||||
__NRF5X_PIN(29, 0, 29),
|
||||
__NRF5X_PIN(30, 0, 30),
|
||||
__NRF5X_PIN(31, 0, 31),
|
||||
__NRF5X_PIN(32, 1, 0),
|
||||
__NRF5X_PIN(33, 1, 1),
|
||||
__NRF5X_PIN(34, 1, 2),
|
||||
__NRF5X_PIN(35, 1, 3),
|
||||
__NRF5X_PIN(36, 1, 4),
|
||||
__NRF5X_PIN(37, 1, 5),
|
||||
__NRF5X_PIN(38, 1, 6),
|
||||
__NRF5X_PIN(39, 1, 7),
|
||||
__NRF5X_PIN(40, 1, 8),
|
||||
__NRF5X_PIN(41, 1, 9),
|
||||
__NRF5X_PIN(32, 1, 0 ),
|
||||
__NRF5X_PIN(33, 1, 1 ),
|
||||
__NRF5X_PIN(34, 1, 2 ),
|
||||
__NRF5X_PIN(35, 1, 3 ),
|
||||
__NRF5X_PIN(36, 1, 4 ),
|
||||
__NRF5X_PIN(37, 1, 5 ),
|
||||
__NRF5X_PIN(38, 1, 6 ),
|
||||
__NRF5X_PIN(39, 1, 7 ),
|
||||
__NRF5X_PIN(40, 1, 8 ),
|
||||
__NRF5X_PIN(41, 1, 9 ),
|
||||
__NRF5X_PIN(42, 1, 10),
|
||||
__NRF5X_PIN(43, 1, 11),
|
||||
__NRF5X_PIN(44, 1, 12),
|
||||
@ -65,7 +64,7 @@ static const struct pin_index pins[] =
|
||||
__NRF5X_PIN(47, 1, 15),
|
||||
};
|
||||
|
||||
/* EVENTS_IN[n](n=0..7), EVENTS_PORT */
|
||||
/* EVENTS_IN[n](n=0..7) and EVENTS_PORT */
|
||||
static struct rt_pin_irq_hdr pin_irq_hdr_tab[] =
|
||||
{
|
||||
{-1, 0, RT_NULL, RT_NULL},
|
||||
@ -81,7 +80,7 @@ static struct rt_pin_irq_hdr pin_irq_hdr_tab[] =
|
||||
|
||||
#define ITEM_NUM(items) sizeof(items) / sizeof(items[0])
|
||||
|
||||
/*pin: 引脚编号*/
|
||||
/*pin: the number of pins*/
|
||||
static const struct pin_index *get_pin(uint8_t pin)
|
||||
{
|
||||
const struct pin_index *index;
|
||||
@ -189,9 +188,9 @@ static void pin_irq_hdr(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
|
||||
}
|
||||
}
|
||||
|
||||
/*args = true : hi_accuracy(IN_EVENT)
|
||||
args = false: lo_accuracy(PORT_EVENT)
|
||||
*/
|
||||
/* args = true : hi_accuracy(IN_EVENT)
|
||||
* args = false: lo_accuracy(PORT_EVENT)
|
||||
*/
|
||||
static rt_err_t nrf5x_pin_attach_irq(struct rt_device *device, rt_int32_t pin,
|
||||
rt_uint32_t mode, void (*hdr)(void *args), void *args)
|
||||
{
|
||||
@ -236,21 +235,21 @@ static rt_err_t nrf5x_pin_attach_irq(struct rt_device *device, rt_int32_t pin,
|
||||
if(mode == PIN_IRQ_MODE_RISING)
|
||||
{
|
||||
nrfx_gpiote_in_config_t inConfig = NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI(args);
|
||||
inConfig.pull=NRF_GPIO_PIN_PULLDOWN;
|
||||
inConfig.pull = NRF_GPIO_PIN_PULLDOWN;
|
||||
err_code = nrfx_gpiote_in_init(pin, &inConfig, pin_irq_hdr);
|
||||
}
|
||||
|
||||
else if(mode == PIN_IRQ_MODE_FALLING)
|
||||
{
|
||||
nrfx_gpiote_in_config_t inConfig = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(args);
|
||||
inConfig.pull=NRF_GPIO_PIN_PULLUP;
|
||||
inConfig.pull = NRF_GPIO_PIN_PULLUP;
|
||||
err_code = nrfx_gpiote_in_init(pin, &inConfig, pin_irq_hdr);
|
||||
}
|
||||
|
||||
else if(mode == PIN_IRQ_MODE_RISING_FALLING)
|
||||
{
|
||||
nrfx_gpiote_in_config_t inConfig = NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE(args);
|
||||
inConfig.pull=NRF_GPIO_PIN_PULLUP;
|
||||
inConfig.pull = NRF_GPIO_PIN_PULLUP;
|
||||
err_code = nrfx_gpiote_in_init(pin, &inConfig, pin_irq_hdr);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,6 @@ struct pin_index
|
||||
uint32_t pin;
|
||||
};
|
||||
|
||||
|
||||
static void nrf5x_pin_write(rt_device_t dev, rt_base_t pin, rt_base_t value);
|
||||
static int nrf5x_pin_read(rt_device_t dev, rt_base_t pin);
|
||||
static void nrf5x_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode);
|
||||
|
@ -40,10 +40,8 @@ int main(void)
|
||||
|
||||
rt_pin_write(DK_BOARD_LED_1, PIN_LOW);
|
||||
rt_thread_mdelay(500);
|
||||
|
||||
}
|
||||
return RT_EOK;
|
||||
}
|
||||
|
||||
|
||||
/*@}*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user