mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-10-07 00:59:00 +08:00
[bsp/raspi3-64]fix gpio drvier
This commit is contained in:
@@ -146,7 +146,7 @@ CONFIG_RT_USING_SERIAL=y
|
||||
# CONFIG_RT_SERIAL_USING_DMA is not set
|
||||
CONFIG_RT_SERIAL_RB_BUFSZ=64
|
||||
# CONFIG_RT_USING_CAN is not set
|
||||
# CONFIG_RT_USING_HWTIMER is not set
|
||||
CONFIG_RT_USING_HWTIMER=y
|
||||
# CONFIG_RT_USING_CPUTIME is not set
|
||||
# CONFIG_RT_USING_I2C is not set
|
||||
CONFIG_RT_USING_PIN=y
|
||||
@@ -465,7 +465,9 @@ CONFIG_BSP_USING_UART=y
|
||||
CONFIG_RT_USING_UART1=y
|
||||
CONFIG_BSP_USING_PIN=y
|
||||
CONFIG_BSP_USING_CORETIMER=y
|
||||
# CONFIG_BSP_USING_SYSTIMER is not set
|
||||
CONFIG_BSP_USING_SYSTIMER=y
|
||||
CONFIG_RT_USING_SYSTIMER1=y
|
||||
# CONFIG_RT_USING_SYSTIMER3 is not set
|
||||
# CONFIG_BSP_USING_I2C is not set
|
||||
# CONFIG_BSP_USING_SPI is not set
|
||||
# CONFIG_BSP_USING_WDT is not set
|
||||
|
||||
@@ -5,7 +5,6 @@ from building import *
|
||||
cwd = GetCurrentDir()
|
||||
src = Split('''
|
||||
board.c
|
||||
bcm283x.c
|
||||
drv_uart.c
|
||||
''')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,7 @@
|
||||
|
||||
#include "cp15.h"
|
||||
#include "mmu.h"
|
||||
#include "raspi.h"
|
||||
|
||||
#ifdef BSP_USING_CORETIMER
|
||||
static rt_uint64_t timerStep;
|
||||
|
||||
@@ -13,10 +13,6 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include <rthw.h>
|
||||
#include <bcm283x.h>
|
||||
|
||||
#define __REG32 HWREG32
|
||||
extern unsigned char __bss_start;
|
||||
extern unsigned char __bss_end;
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,19 +11,20 @@
|
||||
#ifndef __DRV_GPIO_H__
|
||||
#define __DRV_GPIO_H__
|
||||
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include <rtdebug.h>
|
||||
#include <rtdbg.h>
|
||||
|
||||
#include "interrupt.h"
|
||||
#include "bcm283x.h"
|
||||
#include "raspi.h"
|
||||
#include "board.h"
|
||||
#include "interrupt.h"
|
||||
|
||||
|
||||
#define GPIO_IRQ_NUM 3
|
||||
|
||||
#define IRQ_GPIO0 49
|
||||
#define IRQ_GPIO1 50
|
||||
#define IRQ_GPIO2 51
|
||||
#define IRQ_GPIO3 52
|
||||
|
||||
struct gpio_irq_def
|
||||
{
|
||||
void *irq_arg[32];
|
||||
|
||||
@@ -8,58 +8,60 @@
|
||||
* 2019-07-29 zdzn first version
|
||||
*/
|
||||
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
#include "bcm283x.h"
|
||||
#include "drv_timer.h"
|
||||
#include <drivers/hwtimer.h>
|
||||
#include "cp15.h"
|
||||
#include "interrupt.h"
|
||||
#include "raspi.h"
|
||||
|
||||
static void rt_systimer_init(rt_hwtimer_t *hwtimer, rt_uint32_t state)
|
||||
#ifdef BSP_USING_SYSTIMER
|
||||
|
||||
static void raspi_systimer_init(rt_hwtimer_t *hwtimer, rt_uint32_t state)
|
||||
{
|
||||
if (state == 0)
|
||||
hwtimer->ops->stop(hwtimer);
|
||||
}
|
||||
|
||||
static rt_err_t rt_systimer_start(rt_hwtimer_t *hwtimer, rt_uint32_t cnt, rt_hwtimer_mode_t mode)
|
||||
static rt_err_t raspi_systimer_start(rt_hwtimer_t *hwtimer, rt_uint32_t cnt, rt_hwtimer_mode_t mode)
|
||||
{
|
||||
rt_err_t result = RT_EOK;
|
||||
rt_systimer_t *timer = (rt_systimer_t *)hwtimer->parent.user_data;
|
||||
int timer_id = timer->timer_id;
|
||||
|
||||
if (mode == HWTIMER_MODE_PERIOD)
|
||||
timer->cnt = cnt;
|
||||
else
|
||||
timer->cnt = 0;
|
||||
__DSB();
|
||||
|
||||
__sync_synchronize();
|
||||
if (timer_id == 1)
|
||||
{
|
||||
rt_hw_interrupt_umask(IRQ_SYSTIMER_MATCH_1);
|
||||
rt_hw_interrupt_umask(IRQ_SYSTEM_TIMER_1);
|
||||
STIMER_C1 = STIMER_CLO + cnt;
|
||||
}
|
||||
else if (timer_id == 3)
|
||||
{
|
||||
rt_hw_interrupt_umask(IRQ_SYSTIMER_MATCH_3);
|
||||
rt_hw_interrupt_umask(IRQ_SYSTEM_TIMER_3);
|
||||
STIMER_C3 = STIMER_CLO + cnt;
|
||||
}
|
||||
else
|
||||
result = -RT_ERROR;
|
||||
__DSB();
|
||||
|
||||
__sync_synchronize();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static void rt_systimer_stop(rt_hwtimer_t *hwtimer)
|
||||
static void raspi_systimer_stop(rt_hwtimer_t *hwtimer)
|
||||
{
|
||||
rt_systimer_t *timer = (rt_systimer_t *)hwtimer->parent.user_data;
|
||||
int timer_id = timer->timer_id;
|
||||
if (timer_id == 1)
|
||||
rt_hw_interrupt_mask(IRQ_SYSTIMER_MATCH_1);
|
||||
rt_hw_interrupt_mask(IRQ_SYSTEM_TIMER_1);
|
||||
else if (timer_id == 3)
|
||||
rt_hw_interrupt_mask(IRQ_SYSTIMER_MATCH_3);
|
||||
rt_hw_interrupt_mask(IRQ_SYSTEM_TIMER_3);
|
||||
|
||||
}
|
||||
|
||||
static rt_err_t rt_systimer_ctrl(rt_hwtimer_t *timer, rt_uint32_t cmd, void *arg)
|
||||
static rt_err_t raspi_systimer_ctrl(rt_hwtimer_t *timer, rt_uint32_t cmd, void *arg)
|
||||
{
|
||||
/* The frequency value is an immutable value. */
|
||||
if (cmd == HWTIMER_CTRL_FREQ_SET)
|
||||
@@ -72,23 +74,17 @@ static rt_err_t rt_systimer_ctrl(rt_hwtimer_t *timer, rt_uint32_t cmd, void *arg
|
||||
}
|
||||
}
|
||||
|
||||
const static struct rt_hwtimer_ops systimer_ops =
|
||||
{
|
||||
rt_systimer_init,
|
||||
rt_systimer_start,
|
||||
rt_systimer_stop,
|
||||
RT_NULL,
|
||||
rt_systimer_ctrl
|
||||
};
|
||||
|
||||
void rt_device_systimer_isr(int vector, void *param)
|
||||
{
|
||||
|
||||
rt_hwtimer_t *hwtimer = (rt_hwtimer_t *) param;
|
||||
rt_systimer_t *timer = (rt_systimer_t *)hwtimer->parent.user_data;
|
||||
RT_ASSERT(timer != RT_NULL);
|
||||
|
||||
int timer_id = timer->timer_id;
|
||||
|
||||
__DSB();
|
||||
__sync_synchronize();
|
||||
if (timer_id == 1)
|
||||
{
|
||||
STIMER_CS = 0x2;
|
||||
@@ -99,15 +95,29 @@ void rt_device_systimer_isr(int vector, void *param)
|
||||
STIMER_CS = 0x8;
|
||||
STIMER_C3 = STIMER_CLO + timer->cnt;
|
||||
}
|
||||
|
||||
__DSB();
|
||||
__sync_synchronize();
|
||||
|
||||
rt_device_hwtimer_isr(hwtimer);
|
||||
}
|
||||
|
||||
|
||||
#ifdef RT_USING_SYSTIMER1
|
||||
static struct rt_hwtimer_device _hwtimer1;
|
||||
static rt_systimer_t _systimer1;
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_SYSTIMER3
|
||||
static struct rt_hwtimer_device _hwtimer3;
|
||||
static struct rt_systimer_device _systimer1;
|
||||
static struct rt_systimer_device _systimer3;
|
||||
static rt_systimer_t _systimer3;
|
||||
#endif
|
||||
|
||||
const static struct rt_hwtimer_ops systimer_ops =
|
||||
{
|
||||
raspi_systimer_init,
|
||||
raspi_systimer_start,
|
||||
raspi_systimer_stop,
|
||||
RT_NULL,
|
||||
raspi_systimer_ctrl
|
||||
};
|
||||
|
||||
static const struct rt_hwtimer_info _info =
|
||||
{
|
||||
@@ -117,15 +127,20 @@ static const struct rt_hwtimer_info _info =
|
||||
HWTIMER_CNTMODE_UP /* count mode (inc/dec) */
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
int rt_hw_systimer_init(void)
|
||||
{
|
||||
|
||||
#ifdef BSP_USING_SYSTIMER
|
||||
|
||||
#ifdef RT_USING_SYSTIMER1
|
||||
_systimer1.timer_id =1;
|
||||
_hwtimer1.ops = &systimer_ops;
|
||||
_hwtimer1.info = &_info;
|
||||
rt_device_hwtimer_register(&_hwtimer1, "timer1",&_systimer1);
|
||||
rt_hw_interrupt_install(IRQ_SYSTIMER_MATCH_1, rt_device_systimer_isr, &_hwtimer1, "systimer1");
|
||||
rt_hw_interrupt_umask(IRQ_SYSTIMER_MATCH_1);
|
||||
rt_hw_interrupt_install(IRQ_SYSTEM_TIMER_1, rt_device_systimer_isr, &_hwtimer1, "systimer1");
|
||||
rt_hw_interrupt_umask(IRQ_SYSTEM_TIMER_1);
|
||||
#endif
|
||||
|
||||
#ifdef RT_USING_SYSTIMER3
|
||||
@@ -133,9 +148,12 @@ int rt_hw_systimer_init(void)
|
||||
_hwtimer3.ops = &systimer_ops;
|
||||
_hwtimer3.info = &_info;
|
||||
rt_device_hwtimer_register(&_hwtimer3, "timer3",&_systimer3);
|
||||
rt_hw_interrupt_install(IRQ_SYSTIMER_MATCH_3, rt_device_systimer_isr, &_hwtimer3, "systimer3");
|
||||
|
||||
rt_hw_interrupt_install(IRQ_SYSTEM_TIMER_3, rt_device_systimer_isr, &_hwtimer3, "systimer3");
|
||||
rt_hw_interrupt_umask(IRQ_SYSTEM_TIMER_3);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
INIT_DEVICE_EXPORT(rt_hw_systimer_init);
|
||||
|
||||
@@ -12,11 +12,10 @@
|
||||
#include <rtthread.h>
|
||||
#include <rtdevice.h>
|
||||
|
||||
#include "raspi.h"
|
||||
#include "board.h"
|
||||
#include "drv_uart.h"
|
||||
|
||||
#include <rtdevice.h>
|
||||
|
||||
#define AUX_BASE (0x3F000000 + 0x215000)
|
||||
|
||||
struct hw_uart_device
|
||||
@@ -34,20 +33,19 @@ static rt_err_t uart_configure(struct rt_serial_device *serial, struct serial_co
|
||||
|
||||
if (uart->hw_base == AUX_BASE)
|
||||
{
|
||||
rt_uint32_t value;
|
||||
rt_uint32_t value;
|
||||
|
||||
/* GPIO function set */
|
||||
value = GPIO_GPFSEL1;
|
||||
value &= ~(7<<12); /* GPIO14 */
|
||||
value |= 2<<12 ; /* ALT5 */
|
||||
value &= ~(7<<15); /* GPIO15 */
|
||||
value |= 2<<15 ; /* ALT5 */
|
||||
GPIO_GPFSEL1 = value;
|
||||
value = BCM283X_GPIO_GPFSEL(1);
|
||||
value &= ~(7 << 12); /* GPIO14 */
|
||||
value |= 2 << 12 ; /* ALT5 */
|
||||
value &= ~(7 << 15); /* GPIO15 */
|
||||
value |= 2 << 15 ; /* ALT5 */
|
||||
BCM283X_GPIO_GPFSEL(1) = value;
|
||||
|
||||
/* PullUD disable */
|
||||
GPIO_GPPUD = 0;
|
||||
GPIO_GPPUDCLK0 = (1 << 14) | (1 << 15);
|
||||
GPIO_GPPUDCLK0 = 0;
|
||||
BCM283X_GPIO_GPPUD = 0;
|
||||
BCM283X_GPIO_GPPUDCLK(0) = (1 << 14) | (1 << 15);
|
||||
BCM283X_GPIO_GPPUDCLK(0) = 0;
|
||||
|
||||
AUX_ENABLES(uart->hw_base) = 1; /* Enable UART1 */
|
||||
AUX_MU_IER_REG(uart->hw_base) = 0; /* Disable interrupt */
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -101,6 +101,7 @@
|
||||
#define RT_PIPE_BUFSZ 512
|
||||
#define RT_USING_SERIAL
|
||||
#define RT_SERIAL_RB_BUFSZ 64
|
||||
#define RT_USING_HWTIMER
|
||||
#define RT_USING_PIN
|
||||
#define RT_USING_SDIO
|
||||
#define RT_SDIO_STACK_SIZE 2048
|
||||
@@ -193,6 +194,8 @@
|
||||
#define RT_USING_UART1
|
||||
#define BSP_USING_PIN
|
||||
#define BSP_USING_CORETIMER
|
||||
#define BSP_USING_SYSTIMER
|
||||
#define RT_USING_SYSTIMER1
|
||||
#define BSP_USING_SDIO
|
||||
#define BSP_USING_SDIO0
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
#ifndef __CP15_H__
|
||||
#define __CP15_H__
|
||||
|
||||
#include "bcm283x.h"
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __attribute__((always_inline)) static inline
|
||||
#endif
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
#include <board.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "cp15.h"
|
||||
#include "armv8.h"
|
||||
|
||||
#include <board.h>
|
||||
#include "interrupt.h"
|
||||
|
||||
#define MAX_HANDLERS 72
|
||||
|
||||
|
||||
@@ -14,6 +14,8 @@
|
||||
#include <rthw.h>
|
||||
#include <board.h>
|
||||
|
||||
#include "raspi.h"
|
||||
|
||||
#define INT_IRQ 0x00
|
||||
#define INT_FIQ 0x01
|
||||
|
||||
|
||||
Reference in New Issue
Block a user