Skip to content

Commit ec8ff90

Browse files
authored
[bsp/cvitek]update gpio driver (#8946)
update gpio driver
1 parent 78bdf67 commit ec8ff90

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

bsp/cvitek/cv18xx_risc-v/applications/main.c

+25
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@
1010

1111
#include <rtthread.h>
1212
#include <stdio.h>
13+
#include <drivers/pin.h>
14+
15+
#if defined(BOARD_TYPE_MILKV_DUO256M) || defined(BOARD_TYPE_MILKV_DUO256M_SPINOR)
16+
#define LED_PIN "E02" /* Onboard LED pins */
17+
#elif defined(BOARD_TYPE_MILKV_DUO) || defined(BOARD_TYPE_MILKV_DUO_SPINOR)
18+
#define LED_PIN "C24" /* Onboard LED pins */
19+
#endif
1320

1421
int main(void)
1522
{
@@ -18,5 +25,23 @@ int main(void)
1825
#else
1926
rt_kprintf("Hello RISC-V!\n");
2027
#endif
28+
29+
/* LED pin: C24 */
30+
rt_uint16_t led = rt_pin_get(LED_PIN);
31+
32+
/* set LED pin mode to output */
33+
rt_pin_mode(led, PIN_MODE_OUTPUT);
34+
35+
while (1)
36+
{
37+
rt_pin_write(led, PIN_HIGH);
38+
39+
rt_thread_mdelay(500);
40+
41+
rt_pin_write(led, PIN_LOW);
42+
43+
rt_thread_mdelay(500);
44+
}
45+
2146
return 0;
2247
}

bsp/cvitek/drivers/SConscript

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ cwd = GetCurrentDir()
44
src = Split('''
55
drv_uart.c
66
drv_por.c
7+
drv_gpio.c
78
''')
89
CPPDEFINES = []
910

@@ -18,9 +19,6 @@ elif GetDepend('BOARD_TYPE_MILKV_DUO') or GetDepend('BOARD_TYPE_MILKV_DUO_SPINOR
1819
CPPPATH += [cwd + r'/libraries']
1920
CPPPATH += [cwd + r'/libraries/' + CHIP_TYPE]
2021

21-
if GetDepend('BSP_USING_CV18XX'):
22-
src += ['drv_gpio.c']
23-
2422
if GetDepend('BSP_USING_I2C'):
2523
src += ['drv_hw_i2c.c']
2624

bsp/cvitek/drivers/drv_gpio.c

100755100644
+1-14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2006-2023, RT-Thread Development Team
2+
* Copyright (c) 2006-2024, RT-Thread Development Team
33
*
44
* SPDX-License-Identifier: Apache-2.0
55
*
@@ -29,8 +29,6 @@
2929

3030
#define GPIO_EXT_PORTA 0x50
3131

32-
#define DWAPB_DRIVER_NAME "gpio-dwapb"
33-
3432
#define DWAPB_GPIOA_BASE 0x03020000
3533
#define DWAPB_GPIOE_BASE 0x05021000
3634

@@ -307,17 +305,6 @@ static void rt_hw_gpio_isr(int irqno, void *param)
307305

308306
int rt_hw_gpio_init(void)
309307
{
310-
#ifdef RT_USING_SMART
311-
#define BSP_IOREMAP_GPIO_DEVICE(no) \
312-
rt_ioremap((void *)(DWAPB_GPIOA_BASE + (no) * DWAPB_GPIO_SIZE), DWAPB_GPIO_SIZE);
313-
314-
dwapb_gpio_base = (rt_size_t)BSP_IOREMAP_GPIO_DEVICE(0);
315-
BSP_IOREMAP_GPIO_DEVICE(1);
316-
BSP_IOREMAP_GPIO_DEVICE(2);
317-
BSP_IOREMAP_GPIO_DEVICE(3);
318-
dwapb_gpio_base_e = (rt_size_t)rt_ioremap((void *)DWAPB_GPIOE_BASE, DWAPB_GPIO_SIZE);
319-
#endif
320-
321308
rt_device_pin_register("gpio", &_dwapb_ops, RT_NULL);
322309

323310
#define INT_INSTALL_GPIO_DEVICE(no) \

0 commit comments

Comments
 (0)