Skip to content

Commit 933fd4a

Browse files
committed
修改格式
1 parent 1d96089 commit 933fd4a

File tree

4 files changed

+36
-40
lines changed

4 files changed

+36
-40
lines changed

bsp/nrf5x/libraries/drivers/drv_gpio.c

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* 2020-06-16 guohp1128 first version
99
*/
1010

11-
1211
#include "drv_gpio.h"
1312

1413
#ifdef RT_USING_PIN
@@ -47,16 +46,16 @@ static const struct pin_index pins[] =
4746
__NRF5X_PIN(29, 0, 29),
4847
__NRF5X_PIN(30, 0, 30),
4948
__NRF5X_PIN(31, 0, 31),
50-
__NRF5X_PIN(32, 1, 0),
51-
__NRF5X_PIN(33, 1, 1),
52-
__NRF5X_PIN(34, 1, 2),
53-
__NRF5X_PIN(35, 1, 3),
54-
__NRF5X_PIN(36, 1, 4),
55-
__NRF5X_PIN(37, 1, 5),
56-
__NRF5X_PIN(38, 1, 6),
57-
__NRF5X_PIN(39, 1, 7),
58-
__NRF5X_PIN(40, 1, 8),
59-
__NRF5X_PIN(41, 1, 9),
49+
__NRF5X_PIN(32, 1, 0 ),
50+
__NRF5X_PIN(33, 1, 1 ),
51+
__NRF5X_PIN(34, 1, 2 ),
52+
__NRF5X_PIN(35, 1, 3 ),
53+
__NRF5X_PIN(36, 1, 4 ),
54+
__NRF5X_PIN(37, 1, 5 ),
55+
__NRF5X_PIN(38, 1, 6 ),
56+
__NRF5X_PIN(39, 1, 7 ),
57+
__NRF5X_PIN(40, 1, 8 ),
58+
__NRF5X_PIN(41, 1, 9 ),
6059
__NRF5X_PIN(42, 1, 10),
6160
__NRF5X_PIN(43, 1, 11),
6261
__NRF5X_PIN(44, 1, 12),
@@ -65,7 +64,7 @@ static const struct pin_index pins[] =
6564
__NRF5X_PIN(47, 1, 15),
6665
};
6766

68-
/* EVENTS_IN[n](n=0..7), EVENTS_PORT */
67+
/* EVENTS_IN[n](n=0..7) and EVENTS_PORT */
6968
static struct rt_pin_irq_hdr pin_irq_hdr_tab[] =
7069
{
7170
{-1, 0, RT_NULL, RT_NULL},
@@ -76,12 +75,12 @@ static struct rt_pin_irq_hdr pin_irq_hdr_tab[] =
7675
{-1, 0, RT_NULL, RT_NULL},
7776
{-1, 0, RT_NULL, RT_NULL},
7877
{-1, 0, RT_NULL, RT_NULL},
79-
{-1, 0, RT_NULL, RT_NULL},
78+
{-1, 0, RT_NULL, RT_NULL},
8079
};
8180

8281
#define ITEM_NUM(items) sizeof(items) / sizeof(items[0])
8382

84-
/*pin: 引脚编号*/
83+
/*pin: the number of pins*/
8584
static const struct pin_index *get_pin(uint8_t pin)
8685
{
8786
const struct pin_index *index;
@@ -143,7 +142,7 @@ static void nrf5x_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode)
143142

144143
if (mode == PIN_MODE_OUTPUT)
145144
{
146-
/* output setting */
145+
/* output setting */
147146
nrf_gpio_cfg_output(pin);
148147
}
149148
else if (mode == PIN_MODE_INPUT)
@@ -154,17 +153,17 @@ static void nrf5x_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode)
154153
else if (mode == PIN_MODE_INPUT_PULLUP)
155154
{
156155
/* input setting: pull up. */
157-
nrf_gpio_cfg_input(pin, NRF_GPIO_PIN_PULLUP);
156+
nrf_gpio_cfg_input(pin, NRF_GPIO_PIN_PULLUP);
158157
}
159158
else if (mode == PIN_MODE_INPUT_PULLDOWN)
160159
{
161160
/* input setting: pull down. */
162-
nrf_gpio_cfg_input(pin, NRF_GPIO_PIN_PULLDOWN);
161+
nrf_gpio_cfg_input(pin, NRF_GPIO_PIN_PULLDOWN);
163162
}
164163
else if (mode == PIN_MODE_OUTPUT_OD)
165164
{
166165
/* output setting: od. */
167-
nrf_gpio_cfg(
166+
nrf_gpio_cfg(
168167
pin,
169168
NRF_GPIO_PIN_DIR_OUTPUT,
170169
NRF_GPIO_PIN_INPUT_DISCONNECT,
@@ -189,13 +188,13 @@ static void pin_irq_hdr(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action)
189188
}
190189
}
191190

192-
/*args = true : hi_accuracy(IN_EVENT)
193-
args = false: lo_accuracy(PORT_EVENT)
194-
*/
191+
/* args = true : hi_accuracy(IN_EVENT)
192+
* args = false: lo_accuracy(PORT_EVENT)
193+
*/
195194
static rt_err_t nrf5x_pin_attach_irq(struct rt_device *device, rt_int32_t pin,
196195
rt_uint32_t mode, void (*hdr)(void *args), void *args)
197196
{
198-
const struct pin_index *index;
197+
const struct pin_index *index;
199198
rt_int32_t irqindex = -1;
200199
rt_base_t level;
201200
nrfx_err_t err_code;
@@ -205,7 +204,7 @@ static rt_err_t nrf5x_pin_attach_irq(struct rt_device *device, rt_int32_t pin,
205204
index = get_pin(pin);
206205
if (index == RT_NULL)
207206
{
208-
return RT_ENOSYS;
207+
return RT_ENOSYS;
209208
}
210209

211210
irq_quantity = ITEM_NUM(pin_irq_hdr_tab);
@@ -228,29 +227,29 @@ static rt_err_t nrf5x_pin_attach_irq(struct rt_device *device, rt_int32_t pin,
228227
}
229228

230229
level = rt_hw_interrupt_disable();
231-
pin_irq_hdr_tab[irqindex].pin = pin;
232-
pin_irq_hdr_tab[irqindex].hdr = hdr;
230+
pin_irq_hdr_tab[irqindex].pin = pin;
231+
pin_irq_hdr_tab[irqindex].hdr = hdr;
233232
pin_irq_hdr_tab[irqindex].mode = mode;
234233
pin_irq_hdr_tab[irqindex].args = args;
235234

236235
if(mode == PIN_IRQ_MODE_RISING)
237236
{
238237
nrfx_gpiote_in_config_t inConfig = NRFX_GPIOTE_CONFIG_IN_SENSE_LOTOHI(args);
239-
inConfig.pull=NRF_GPIO_PIN_PULLDOWN;
238+
inConfig.pull = NRF_GPIO_PIN_PULLDOWN;
240239
err_code = nrfx_gpiote_in_init(pin, &inConfig, pin_irq_hdr);
241240
}
242241

243242
else if(mode == PIN_IRQ_MODE_FALLING)
244243
{
245244
nrfx_gpiote_in_config_t inConfig = NRFX_GPIOTE_CONFIG_IN_SENSE_HITOLO(args);
246-
inConfig.pull=NRF_GPIO_PIN_PULLUP;
245+
inConfig.pull = NRF_GPIO_PIN_PULLUP;
247246
err_code = nrfx_gpiote_in_init(pin, &inConfig, pin_irq_hdr);
248247
}
249248

250249
else if(mode == PIN_IRQ_MODE_RISING_FALLING)
251250
{
252251
nrfx_gpiote_in_config_t inConfig = NRFX_GPIOTE_CONFIG_IN_SENSE_TOGGLE(args);
253-
inConfig.pull=NRF_GPIO_PIN_PULLUP;
252+
inConfig.pull = NRF_GPIO_PIN_PULLUP;
254253
err_code = nrfx_gpiote_in_init(pin, &inConfig, pin_irq_hdr);
255254
}
256255

@@ -288,8 +287,8 @@ static rt_err_t nrf5x_pin_dettach_irq(struct rt_device *device, rt_int32_t pin)
288287
if(pin_irq_hdr_tab[i].pin == pin)
289288
{
290289
level = rt_hw_interrupt_disable();
291-
pin_irq_hdr_tab[i].pin = -1;
292-
pin_irq_hdr_tab[i].hdr = RT_NULL;
290+
pin_irq_hdr_tab[i].pin = -1;
291+
pin_irq_hdr_tab[i].hdr = RT_NULL;
293292
pin_irq_hdr_tab[i].mode = 0;
294293
pin_irq_hdr_tab[i].args = RT_NULL;
295294
nrfx_gpiote_in_uninit(pin);
@@ -307,15 +306,15 @@ static rt_err_t nrf5x_pin_dettach_irq(struct rt_device *device, rt_int32_t pin)
307306
static rt_err_t nrf5x_pin_irq_enable(struct rt_device *device, rt_base_t pin,
308307
rt_uint32_t enabled)
309308
{
310-
const struct pin_index *index;
309+
const struct pin_index *index;
311310
rt_base_t level;
312311
int i;
313312
int irq_quantity;
314313

315314
index = get_pin(pin);
316315
if (index == RT_NULL)
317316
{
318-
return RT_ENOSYS;
317+
return RT_ENOSYS;
319318
}
320319

321320
irq_quantity = ITEM_NUM(pin_irq_hdr_tab);
@@ -358,7 +357,7 @@ int rt_hw_pin_init(void)
358357
{
359358
nrfx_err_t err_code;
360359

361-
err_code = (nrfx_err_t)rt_device_pin_register("pin", &_nrf5x_pin_ops, RT_NULL);
360+
err_code = (nrfx_err_t)rt_device_pin_register("pin", &_nrf5x_pin_ops, RT_NULL);
362361
err_code = nrfx_gpiote_init(NRFX_GPIOTE_CONFIG_IRQ_PRIORITY);
363362

364363
switch(err_code)

bsp/nrf5x/libraries/drivers/drv_gpio.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#define __NRF5X_PIN(index, gpio, gpio_index) \
2525
{ \
26-
index, NRF_P##gpio, gpio_index \
26+
index, NRF_P##gpio, gpio_index \
2727
}
2828

2929
#define __NRF5X_PIN_RESERVE \
@@ -39,7 +39,6 @@ struct pin_index
3939
uint32_t pin;
4040
};
4141

42-
4342
static void nrf5x_pin_write(rt_device_t dev, rt_base_t pin, rt_base_t value);
4443
static int nrf5x_pin_read(rt_device_t dev, rt_base_t pin);
4544
static void nrf5x_pin_mode(rt_device_t dev, rt_base_t pin, rt_base_t mode);

bsp/nrf5x/nrf52840/applications/application.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,13 @@ int main(void)
3535

3636
while (count++)
3737
{
38-
rt_pin_write(DK_BOARD_LED_1, PIN_HIGH);
38+
rt_pin_write(DK_BOARD_LED_1, PIN_HIGH);
3939
rt_thread_mdelay(500);
4040

4141
rt_pin_write(DK_BOARD_LED_1, PIN_LOW);
42-
rt_thread_mdelay(500);
43-
42+
rt_thread_mdelay(500);
4443
}
4544
return RT_EOK;
4645
}
4746

48-
4947
/*@}*/

bsp/nrf5x/nrf52840/board/sdk_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11694,7 +11694,7 @@
1169411694
#endif
1169511695
// </e>
1169611696

11697-
// </h>
11697+
// </h>
1169811698
//==========================================================
1169911699
#ifndef NRFX_SYSTICK_ENABLED
1170011700
#define NRFX_SYSTICK_ENABLED 1

0 commit comments

Comments
 (0)