[bsp/cvitek]update gpio driver (#8946)

update gpio driver
This commit is contained in:
flyingcys 2024-05-14 06:20:57 +08:00 committed by GitHub
parent 78bdf67ab2
commit ec8ff90a4a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 27 additions and 17 deletions

View File

@ -10,6 +10,13 @@
#include <rtthread.h>
#include <stdio.h>
#include <drivers/pin.h>
#if defined(BOARD_TYPE_MILKV_DUO256M) || defined(BOARD_TYPE_MILKV_DUO256M_SPINOR)
#define LED_PIN "E02" /* Onboard LED pins */
#elif defined(BOARD_TYPE_MILKV_DUO) || defined(BOARD_TYPE_MILKV_DUO_SPINOR)
#define LED_PIN "C24" /* Onboard LED pins */
#endif
int main(void)
{
@ -18,5 +25,23 @@ int main(void)
#else
rt_kprintf("Hello RISC-V!\n");
#endif
/* LED pin: C24 */
rt_uint16_t led = rt_pin_get(LED_PIN);
/* set LED pin mode to output */
rt_pin_mode(led, PIN_MODE_OUTPUT);
while (1)
{
rt_pin_write(led, PIN_HIGH);
rt_thread_mdelay(500);
rt_pin_write(led, PIN_LOW);
rt_thread_mdelay(500);
}
return 0;
}

View File

@ -4,6 +4,7 @@ cwd = GetCurrentDir()
src = Split('''
drv_uart.c
drv_por.c
drv_gpio.c
''')
CPPDEFINES = []
@ -18,9 +19,6 @@ elif GetDepend('BOARD_TYPE_MILKV_DUO') or GetDepend('BOARD_TYPE_MILKV_DUO_SPINOR
CPPPATH += [cwd + r'/libraries']
CPPPATH += [cwd + r'/libraries/' + CHIP_TYPE]
if GetDepend('BSP_USING_CV18XX'):
src += ['drv_gpio.c']
if GetDepend('BSP_USING_I2C'):
src += ['drv_hw_i2c.c']

15
bsp/cvitek/drivers/drv_gpio.c Executable file → Normal file
View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006-2023, RT-Thread Development Team
* Copyright (c) 2006-2024, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
@ -29,8 +29,6 @@
#define GPIO_EXT_PORTA 0x50
#define DWAPB_DRIVER_NAME "gpio-dwapb"
#define DWAPB_GPIOA_BASE 0x03020000
#define DWAPB_GPIOE_BASE 0x05021000
@ -307,17 +305,6 @@ static void rt_hw_gpio_isr(int irqno, void *param)
int rt_hw_gpio_init(void)
{
#ifdef RT_USING_SMART
#define BSP_IOREMAP_GPIO_DEVICE(no) \
rt_ioremap((void *)(DWAPB_GPIOA_BASE + (no) * DWAPB_GPIO_SIZE), DWAPB_GPIO_SIZE);
dwapb_gpio_base = (rt_size_t)BSP_IOREMAP_GPIO_DEVICE(0);
BSP_IOREMAP_GPIO_DEVICE(1);
BSP_IOREMAP_GPIO_DEVICE(2);
BSP_IOREMAP_GPIO_DEVICE(3);
dwapb_gpio_base_e = (rt_size_t)rt_ioremap((void *)DWAPB_GPIOE_BASE, DWAPB_GPIO_SIZE);
#endif
rt_device_pin_register("gpio", &_dwapb_ops, RT_NULL);
#define INT_INSTALL_GPIO_DEVICE(no) \