File tree 3 files changed +27
-17
lines changed
cv18xx_risc-v/applications
3 files changed +27
-17
lines changed Original file line number Diff line number Diff line change 10
10
11
11
#include <rtthread.h>
12
12
#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
13
20
14
21
int main (void )
15
22
{
@@ -18,5 +25,23 @@ int main(void)
18
25
#else
19
26
rt_kprintf ("Hello RISC-V!\n" );
20
27
#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
+
21
46
return 0 ;
22
47
}
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ cwd = GetCurrentDir()
4
4
src = Split ('''
5
5
drv_uart.c
6
6
drv_por.c
7
+ drv_gpio.c
7
8
''' )
8
9
CPPDEFINES = []
9
10
@@ -18,9 +19,6 @@ elif GetDepend('BOARD_TYPE_MILKV_DUO') or GetDepend('BOARD_TYPE_MILKV_DUO_SPINOR
18
19
CPPPATH += [cwd + r'/libraries' ]
19
20
CPPPATH += [cwd + r'/libraries/' + CHIP_TYPE ]
20
21
21
- if GetDepend ('BSP_USING_CV18XX' ):
22
- src += ['drv_gpio.c' ]
23
-
24
22
if GetDepend ('BSP_USING_I2C' ):
25
23
src += ['drv_hw_i2c.c' ]
26
24
Original file line number Diff line number Diff line change 1
1
/*
2
- * Copyright (c) 2006-2023 , RT-Thread Development Team
2
+ * Copyright (c) 2006-2024 , RT-Thread Development Team
3
3
*
4
4
* SPDX-License-Identifier: Apache-2.0
5
5
*
29
29
30
30
#define GPIO_EXT_PORTA 0x50
31
31
32
- #define DWAPB_DRIVER_NAME "gpio-dwapb"
33
-
34
32
#define DWAPB_GPIOA_BASE 0x03020000
35
33
#define DWAPB_GPIOE_BASE 0x05021000
36
34
@@ -307,17 +305,6 @@ static void rt_hw_gpio_isr(int irqno, void *param)
307
305
308
306
int rt_hw_gpio_init (void )
309
307
{
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
-
321
308
rt_device_pin_register ("gpio" , & _dwapb_ops , RT_NULL );
322
309
323
310
#define INT_INSTALL_GPIO_DEVICE (no ) \
You can’t perform that action at this time.
0 commit comments