Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Vendor Huawei Hdf
提交
f6f06834
V
Vendor Huawei Hdf
项目概览
OpenHarmony
/
Vendor Huawei Hdf
8 个月 前同步成功
通知
4
Star
20
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
Vendor Huawei Hdf
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f6f06834
编写于
9月 11, 2020
作者:
A
aqxyjay
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #I1US8P, rename the driver, host and deivce method names
上级
485286c5
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
53 addition
and
53 deletion
+53
-53
sample/platform/uart/include/uart_dev_sample.h
sample/platform/uart/include/uart_dev_sample.h
+2
-2
sample/platform/uart/src/uart_dev_sample.c
sample/platform/uart/src/uart_dev_sample.c
+5
-5
sample/platform/uart/src/uart_sample.c
sample/platform/uart/src/uart_sample.c
+46
-46
未找到文件。
sample/platform/uart/include/uart_dev_sample.h
浏览文件 @
f6f06834
...
...
@@ -30,8 +30,8 @@ extern "C" {
/* baudrate config */
#define UART_CFG_BAUDRATE _IO(UART_IOC_MAGIC, 1)
void
UartSampleAddDev
(
struct
UartHost
*
host
);
void
UartSampleRemoveDev
(
struct
UartHost
*
host
);
void
AddUartDevice
(
struct
UartHost
*
host
);
void
RemoveUartDevice
(
struct
UartHost
*
host
);
#ifdef __cplusplus
#if __cplusplus
...
...
sample/platform/uart/src/uart_dev_sample.c
浏览文件 @
f6f06834
...
...
@@ -157,7 +157,7 @@ const struct file_operations_vfs g_uartSampleDevFops = {
};
#define MAX_DEV_NAME_SIZE 32
static
void
UartSampleAddRemove
Dev
(
struct
UartHost
*
host
,
bool
add
)
static
void
AddRemoveUart
Dev
(
struct
UartHost
*
host
,
bool
add
)
{
int32_t
ret
;
char
*
devName
=
NULL
;
...
...
@@ -193,12 +193,12 @@ static void UartSampleAddRemoveDev(struct UartHost *host, bool add)
OsalMemFree
(
devName
);
}
void
UartSampleAddDev
(
struct
UartHost
*
host
)
void
AddUartDevice
(
struct
UartHost
*
host
)
{
UartSampleAddRemove
Dev
(
host
,
true
);
AddRemoveUart
Dev
(
host
,
true
);
}
void
UartSampleRemoveDev
(
struct
UartHost
*
host
)
void
RemoveUartDevice
(
struct
UartHost
*
host
)
{
UartSampleAddRemove
Dev
(
host
,
false
);
AddRemoveUart
Dev
(
host
,
false
);
}
sample/platform/uart/src/uart_sample.c
浏览文件 @
f6f06834
...
...
@@ -31,44 +31,44 @@
static
uint8_t
g_fifoBuffer
[
UART_RX_FIFO_SIZE
]
=
{
0
};
/* HdfDriverEntry method definitions */
static
int32_t
HdfUartSample
Bind
(
struct
HdfDeviceObject
*
device
);
static
int32_t
HdfUartSample
Init
(
struct
HdfDeviceObject
*
device
);
static
void
HdfUartSample
Release
(
struct
HdfDeviceObject
*
device
);
static
int32_t
SampleUartDriver
Bind
(
struct
HdfDeviceObject
*
device
);
static
int32_t
SampleUartDriver
Init
(
struct
HdfDeviceObject
*
device
);
static
void
SampleUartDriver
Release
(
struct
HdfDeviceObject
*
device
);
/* HdfDriverEntry definitions */
struct
HdfDriverEntry
g_
hdfUartSample
=
{
struct
HdfDriverEntry
g_
sampleUartDriverEntry
=
{
.
moduleVersion
=
1
,
.
moduleName
=
"UART_SAMPLE"
,
.
Bind
=
HdfUartSample
Bind
,
.
Init
=
HdfUartSample
Init
,
.
Release
=
HdfUartSample
Release
,
.
Bind
=
SampleUartDriver
Bind
,
.
Init
=
SampleUartDriver
Init
,
.
Release
=
SampleUartDriver
Release
,
};
// Initialize HdfDriverEntry
HDF_INIT
(
g_
hdfUartSample
);
HDF_INIT
(
g_
sampleUartDriverEntry
);
/* UartHostMethod method definitions */
static
int32_t
SampleInit
(
struct
UartHost
*
host
);
static
int32_t
SampleDeinit
(
struct
UartHost
*
host
);
static
int32_t
SampleWrite
(
struct
UartHost
*
host
,
uint8_t
*
data
,
uint32_t
size
);
static
int32_t
SampleSetBaud
(
struct
UartHost
*
host
,
uint32_t
baudRate
);
static
int32_t
SampleGetBaud
(
struct
UartHost
*
host
,
uint32_t
*
baudRate
);
static
int32_t
Sample
UartHost
Init
(
struct
UartHost
*
host
);
static
int32_t
Sample
UartHost
Deinit
(
struct
UartHost
*
host
);
static
int32_t
Sample
UartHost
Write
(
struct
UartHost
*
host
,
uint8_t
*
data
,
uint32_t
size
);
static
int32_t
Sample
UartHost
SetBaud
(
struct
UartHost
*
host
,
uint32_t
baudRate
);
static
int32_t
Sample
UartHost
GetBaud
(
struct
UartHost
*
host
,
uint32_t
*
baudRate
);
/* UartHostMethod definitions */
struct
UartHostMethod
g_
uartSample
HostMethod
=
{
.
Init
=
SampleInit
,
.
Deinit
=
SampleDeinit
,
struct
UartHostMethod
g_
sampleUart
HostMethod
=
{
.
Init
=
Sample
UartHost
Init
,
.
Deinit
=
Sample
UartHost
Deinit
,
.
Read
=
NULL
,
.
Write
=
SampleWrite
,
.
SetBaud
=
SampleSetBaud
,
.
GetBaud
=
SampleGetBaud
,
.
Write
=
Sample
UartHost
Write
,
.
SetBaud
=
Sample
UartHost
SetBaud
,
.
GetBaud
=
Sample
UartHost
GetBaud
,
.
SetAttribute
=
NULL
,
.
GetAttribute
=
NULL
,
.
SetTransMode
=
NULL
,
};
/* UartHostMethod implementations */
static
int32_t
SampleInit
(
struct
UartHost
*
host
)
static
int32_t
Sample
UartHost
Init
(
struct
UartHost
*
host
)
{
HDF_LOGI
(
"%s: Enter"
,
__func__
);
if
(
host
==
NULL
)
{
...
...
@@ -78,7 +78,7 @@ static int32_t SampleInit(struct UartHost *host)
return
HDF_SUCCESS
;
}
static
int32_t
SampleDeinit
(
struct
UartHost
*
host
)
static
int32_t
Sample
UartHost
Deinit
(
struct
UartHost
*
host
)
{
HDF_LOGI
(
"%s: Enter"
,
__func__
);
if
(
host
==
NULL
)
{
...
...
@@ -88,7 +88,7 @@ static int32_t SampleDeinit(struct UartHost *host)
return
HDF_SUCCESS
;
}
static
int32_t
SampleWrite
(
struct
UartHost
*
host
,
uint8_t
*
data
,
uint32_t
size
)
static
int32_t
Sample
UartHost
Write
(
struct
UartHost
*
host
,
uint8_t
*
data
,
uint32_t
size
)
{
HDF_LOGI
(
"%s: Enter"
,
__func__
);
uint32_t
idx
;
...
...
@@ -111,7 +111,7 @@ static int32_t SampleWrite(struct UartHost *host, uint8_t *data, uint32_t size)
return
HDF_SUCCESS
;
}
static
int32_t
SampleSetBaud
(
struct
UartHost
*
host
,
uint32_t
baudRate
)
static
int32_t
Sample
UartHost
SetBaud
(
struct
UartHost
*
host
,
uint32_t
baudRate
)
{
HDF_LOGI
(
"%s: Enter"
,
__func__
);
struct
UartDevice
*
device
=
NULL
;
...
...
@@ -141,7 +141,7 @@ static int32_t SampleSetBaud(struct UartHost *host, uint32_t baudRate)
return
err
;
}
static
int32_t
SampleGetBaud
(
struct
UartHost
*
host
,
uint32_t
*
baudRate
)
static
int32_t
Sample
UartHost
GetBaud
(
struct
UartHost
*
host
,
uint32_t
*
baudRate
)
{
HDF_LOGI
(
"%s: Enter"
,
__func__
);
struct
UartDevice
*
device
=
NULL
;
...
...
@@ -159,7 +159,7 @@ static int32_t SampleGetBaud(struct UartHost *host, uint32_t *baudRate)
return
HDF_SUCCESS
;
}
static
int
UartDeviceInit
(
struct
UartDevice
*
device
)
static
int
InitUartDevice
(
struct
UartDevice
*
device
)
{
UartPl011Error
err
;
struct
UartResource
*
resource
=
&
device
->
resource
;
...
...
@@ -187,7 +187,7 @@ static int UartDeviceInit(struct UartDevice *device)
return
HDF_SUCCESS
;
}
static
uint32_t
UartDeviceGet
Resource
(
static
uint32_t
GetUartDevice
Resource
(
struct
UartDevice
*
device
,
const
struct
DeviceResourceNode
*
resourceNode
)
{
struct
UartResource
*
resource
=
&
device
->
resource
;
...
...
@@ -199,11 +199,11 @@ static uint32_t UartDeviceGetResource(
}
if
(
dri
->
GetUint32
(
resourceNode
,
"num"
,
&
resource
->
num
,
0
)
!=
HDF_SUCCESS
)
{
HDF_LOGE
(
"uart config
read num fail"
);
HDF_LOGE
(
"uart config read num fail"
);
return
HDF_FAILURE
;
}
if
(
dri
->
GetUint32
(
resourceNode
,
"base"
,
&
resource
->
base
,
0
)
!=
HDF_SUCCESS
)
{
HDF_LOGE
(
"uart config
read base fail"
);
HDF_LOGE
(
"uart config read base fail"
);
return
HDF_FAILURE
;
}
resource
->
physBase
=
(
unsigned
long
)
OsalIoRemap
(
resource
->
base
,
0x48
);
...
...
@@ -216,29 +216,29 @@ static uint32_t UartDeviceGetResource(
return
HDF_FAILURE
;
}
if
(
dri
->
GetUint32
(
resourceNode
,
"baudrate"
,
&
resource
->
baudrate
,
0
)
!=
HDF_SUCCESS
)
{
HDF_LOGE
(
"uart config
read baudrate fail"
);
HDF_LOGE
(
"uart config read baudrate fail"
);
return
HDF_FAILURE
;
}
if
(
dri
->
GetUint32
(
resourceNode
,
"wlen"
,
&
resource
->
wlen
,
0
)
!=
HDF_SUCCESS
)
{
HDF_LOGE
(
"uart config
read wlen fail"
);
HDF_LOGE
(
"uart config read wlen fail"
);
return
HDF_FAILURE
;
}
if
(
dri
->
GetUint32
(
resourceNode
,
"parity"
,
&
resource
->
parity
,
0
)
!=
HDF_SUCCESS
)
{
HDF_LOGE
(
"uart config
read parity fail"
);
HDF_LOGE
(
"uart config read parity fail"
);
return
HDF_FAILURE
;
}
if
(
dri
->
GetUint32
(
resourceNode
,
"stopBit"
,
&
resource
->
stopBit
,
0
)
!=
HDF_SUCCESS
)
{
HDF_LOGE
(
"uart config
read stopBit fail"
);
HDF_LOGE
(
"uart config read stopBit fail"
);
return
HDF_FAILURE
;
}
if
(
dri
->
GetUint32
(
resourceNode
,
"uartClk"
,
&
resource
->
uartClk
,
0
)
!=
HDF_SUCCESS
)
{
HDF_LOGE
(
"uart config
read uartClk fail"
);
HDF_LOGE
(
"uart config read uartClk fail"
);
return
HDF_FAILURE
;
}
return
HDF_SUCCESS
;
}
static
int32_t
SampleAttach
(
struct
UartHost
*
host
,
struct
HdfDeviceObject
*
device
)
static
int32_t
AttachUartDevice
(
struct
UartHost
*
host
,
struct
HdfDeviceObject
*
device
)
{
int32_t
ret
;
struct
UartDevice
*
uartDevice
=
NULL
;
...
...
@@ -251,18 +251,18 @@ static int32_t SampleAttach(struct UartHost *host, struct HdfDeviceObject *devic
HDF_LOGE
(
"%s: OsalMemCalloc uartDevice error"
,
__func__
);
return
HDF_ERR_MALLOC_FAIL
;
}
ret
=
UartDeviceGet
Resource
(
uartDevice
,
device
->
property
);
ret
=
GetUartDevice
Resource
(
uartDevice
,
device
->
property
);
if
(
ret
!=
HDF_SUCCESS
)
{
(
void
)
OsalMemFree
(
uartDevice
);
return
HDF_FAILURE
;
}
host
->
num
=
uartDevice
->
resource
.
num
;
host
->
priv
=
uartDevice
;
UartSampleAddDev
(
host
);
return
UartDeviceInit
(
uartDevice
);
AddUartDevice
(
host
);
return
InitUartDevice
(
uartDevice
);
}
static
void
UartDeviceDeinit
(
struct
UartDevice
*
device
)
static
void
DeinitUartDevice
(
struct
UartDevice
*
device
)
{
struct
UartRegisterMap
*
regMap
=
(
struct
UartRegisterMap
*
)
device
->
resource
.
physBase
;
/* wait for uart enter idle. */
...
...
@@ -273,7 +273,7 @@ static void UartDeviceDeinit(struct UartDevice *device)
device
->
state
=
UART_DEVICE_UNINITIALIZED
;
}
static
void
SampleDetach
(
struct
UartHost
*
host
)
static
void
DetachUartDevice
(
struct
UartHost
*
host
)
{
struct
UartDevice
*
uartDevice
=
NULL
;
...
...
@@ -282,13 +282,13 @@ static void SampleDetach(struct UartHost *host)
return
;
}
uartDevice
=
host
->
priv
;
UartDeviceDeinit
(
uartDevice
);
DeinitUartDevice
(
uartDevice
);
(
void
)
OsalMemFree
(
uartDevice
);
host
->
priv
=
NULL
;
}
/* HdfDriverEntry implementations */
static
int32_t
HdfUartSample
Bind
(
struct
HdfDeviceObject
*
device
)
static
int32_t
SampleUartDriver
Bind
(
struct
HdfDeviceObject
*
device
)
{
struct
UartHost
*
uartHost
=
NULL
;
...
...
@@ -306,7 +306,7 @@ static int32_t HdfUartSampleBind(struct HdfDeviceObject *device)
return
HDF_SUCCESS
;
}
static
int32_t
HdfUartSample
Init
(
struct
HdfDeviceObject
*
device
)
static
int32_t
SampleUartDriver
Init
(
struct
HdfDeviceObject
*
device
)
{
int32_t
ret
;
struct
UartHost
*
host
=
NULL
;
...
...
@@ -321,16 +321,16 @@ static int32_t HdfUartSampleInit(struct HdfDeviceObject *device)
HDF_LOGE
(
"%s: host is NULL"
,
__func__
);
return
HDF_FAILURE
;
}
ret
=
SampleAttach
(
host
,
device
);
ret
=
AttachUartDevice
(
host
,
device
);
if
(
ret
!=
HDF_SUCCESS
)
{
HDF_LOGE
(
"%s: attach error"
,
__func__
);
return
HDF_FAILURE
;
}
host
->
method
=
&
g_
uartSample
HostMethod
;
host
->
method
=
&
g_
sampleUart
HostMethod
;
return
ret
;
}
static
void
HdfUartSample
Release
(
struct
HdfDeviceObject
*
device
)
static
void
SampleUartDriver
Release
(
struct
HdfDeviceObject
*
device
)
{
struct
UartHost
*
host
=
NULL
;
HDF_LOGI
(
"Enter %s:"
,
__func__
);
...
...
@@ -345,7 +345,7 @@ static void HdfUartSampleRelease(struct HdfDeviceObject *device)
return
;
}
if
(
host
->
priv
!=
NULL
)
{
SampleDetach
(
host
);
DetachUartDevice
(
host
);
}
UartHostDestroy
(
host
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录