Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
cb54ac81
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
cb54ac81
编写于
6月 19, 2015
作者:
I
ItsEddy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[BSP] Add gpio driver support for beaglebone
上级
562ac32e
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
114 addition
and
0 deletion
+114
-0
bsp/beaglebone/drivers/gpio.c
bsp/beaglebone/drivers/gpio.c
+95
-0
bsp/beaglebone/drivers/gpio.h
bsp/beaglebone/drivers/gpio.h
+17
-0
bsp/beaglebone/rtconfig.h
bsp/beaglebone/rtconfig.h
+2
-0
未找到文件。
bsp/beaglebone/drivers/gpio.c
0 → 100644
浏览文件 @
cb54ac81
/*
* File : gpio.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2015, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
*/
#include <rthw.h>
#include <rtthread.h>
#include <rtdevice.h>
#include <am33xx.h>
#include "gpio.h"
#ifdef RT_USING_PIN
#define reg(base) *(int*)(base)
#define GPIO_PIN_LOW (0x0)
#define GPIO_PIN_HIGH (0x1)
#define GPIO_CLEARDATAOUT (0x190)
#define GPIO_SETDATAOUT (0x194)
#define GPIO_DATAIN (0x138)
#define GPIO_OE (0x134)
static
rt_base_t
GPIO_BASE
[]
=
{
AM33XX_GPIO_0_REGS
,
AM33XX_GPIO_1_REGS
,
AM33XX_GPIO_2_REGS
,
AM33XX_GPIO_3_REGS
};
static
void
am33xx_pin_mode
(
struct
rt_device
*
device
,
rt_base_t
pin
,
rt_base_t
mode
)
{
RT_ASSERT
(
pin
>=
0
&&
pin
<
128
);
RT_ASSERT
(
mode
!=
PIN_MODE_INPUT_PULLUP
);
/* Mode not supported */
rt_base_t
gpiox
=
pin
>>
5
;
rt_base_t
pinNumber
=
pin
&
0x1F
;
if
(
PIN_MODE_OUTPUT
==
mode
)
{
reg
(
GPIO_BASE
[
gpiox
]
+
GPIO_OE
)
&=
~
(
1
<<
pinNumber
);
}
else
if
(
PIN_MODE_INPUT
==
mode
)
{
reg
(
GPIO_BASE
[
gpiox
]
+
GPIO_OE
)
|=
(
1
<<
pinNumber
);
}
}
static
void
am33xx_pin_write
(
struct
rt_device
*
device
,
rt_base_t
pin
,
rt_base_t
value
)
{
RT_ASSERT
(
pin
>=
0
&&
pin
<
128
);
rt_base_t
gpiox
=
pin
>>
5
;
rt_base_t
pinNumber
=
pin
&
0x1F
;
if
(
GPIO_PIN_HIGH
==
value
)
{
reg
(
GPIO_BASE
[
gpiox
]
+
GPIO_SETDATAOUT
)
=
(
1
<<
pinNumber
);
}
else
/* GPIO_PIN_LOW */
{
reg
(
GPIO_BASE
[
gpiox
]
+
GPIO_CLEARDATAOUT
)
=
(
1
<<
pinNumber
);
}
}
static
int
am33xx_pin_read
(
struct
rt_device
*
device
,
rt_base_t
pin
)
{
RT_ASSERT
(
pin
>=
0
&&
pin
<
128
);
rt_base_t
gpiox
=
pin
>>
5
;
rt_base_t
pinNumber
=
pin
&
0x1F
;
return
reg
(
GPIO_BASE
[
gpiox
]
+
GPIO_DATAIN
)
&
(
1
<<
pinNumber
)
?
1
:
0
;
}
static
struct
rt_pin_ops
am33xx_pin_ops
=
{
am33xx_pin_mode
,
am33xx_pin_write
,
am33xx_pin_read
,
};
int
rt_hw_gpio_init
(
void
)
{
rt_device_pin_register
(
"gpio"
,
&
am33xx_pin_ops
,
RT_NULL
);
return
0
;
}
INIT_BOARD_EXPORT
(
rt_hw_gpio_init
);
#endif
bsp/beaglebone/drivers/gpio.h
0 → 100644
浏览文件 @
cb54ac81
/*
* File : gpio.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2015, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE
*
*/
#ifndef __GPIO_H__
#define __GPIO_H__
int
rt_hw_gpio_init
(
void
);
#endif
bsp/beaglebone/rtconfig.h
浏览文件 @
cb54ac81
...
...
@@ -91,6 +91,8 @@
#define RT_USING_UART4
// <bool name="RT_USING_UART5" description="Using uart5" default="true" >
#define RT_USING_UART5
// <bool name="RT_USING_PIN" description="Using GPIO Device Driver Framework" default="true" >
#define RT_USING_PIN
// <integer name="RT_UART_RX_BUFFER_SIZE" description="The buffer size for UART reception" default="64" />
#define RT_UART_RX_BUFFER_SIZE 64
// <bool name=RT_USING_INTERRUPT_INFO description="Using interrupt information description" default="true" />
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录