Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Drivers Adapter
提交
e01a43f2
D
Drivers Adapter
项目概览
OpenHarmony
/
Drivers Adapter
9 个月 前同步成功
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Drivers Adapter
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
e01a43f2
编写于
10月 13, 2022
作者:
O
openharmony_ci
提交者:
Gitee
10月 13, 2022
浏览文件
操作
浏览文件
下载
差异文件
!618 sync bes hal apis from master
Merge pull request !618 from weidong1987/OpenHarmony-3.1-Release
上级
dc38d92a
33853d36
变更
9
展开全部
隐藏空白更改
内联
并排
Showing
9 changed file
with
577 addition
and
395 deletion
+577
-395
platform/gpio/gpio_bes.c
platform/gpio/gpio_bes.c
+51
-31
platform/i2c/i2c_bes.c
platform/i2c/i2c_bes.c
+69
-100
platform/i2c/i2c_bes.h
platform/i2c/i2c_bes.h
+2
-0
platform/pwm/pwm_bes.c
platform/pwm/pwm_bes.c
+12
-11
platform/pwm/pwm_bes.h
platform/pwm/pwm_bes.h
+2
-0
platform/spi/spi_bes.c
platform/spi/spi_bes.c
+187
-136
platform/spi/spi_bes.h
platform/spi/spi_bes.h
+2
-0
platform/uart/uart_bes.c
platform/uart/uart_bes.c
+250
-115
platform/watchdog/watchdog_bes.c
platform/watchdog/watchdog_bes.c
+2
-2
未找到文件。
platform/gpio/gpio_bes.c
浏览文件 @
e01a43f2
...
...
@@ -69,26 +69,10 @@ typedef int32_t (*oem_gpio_irq_handler_t)(uint16_t gpio, void *data);
#define OCTALNUM 8
static
struct
GpioCntlr
g_gpioCntlr
;
struct
OemGpioIrqHandler
{
uint8_t
port
;
GpioIrqFunc
func
;
void
*
arg
;
};
enum
HAL_GPIO_PIN_T
g_gpioPinReflectionMap
[
HAL_GPIO_PIN_LED_NUM
]
=
{
0
};
static
struct
HAL_GPIO_IRQ_CFG_T
g_gpioIrqCfg
[
HAL_GPIO_PIN_LED_NUM
]
=
{
0
};
static
struct
HAL_GPIO_IRQ_CFG_T
HalGpioGetIrqConfig
(
enum
HAL_GPIO_PIN_T
pin
)
{
struct
HAL_GPIO_IRQ_CFG_T
irqCfg
;
irqCfg
.
irq_enable
=
g_gpioIrqCfg
[
pin
].
irq_enable
;
irqCfg
.
irq_debounce
=
g_gpioIrqCfg
[
pin
].
irq_debounce
;
irqCfg
.
irq_type
=
g_gpioIrqCfg
[
pin
].
irq_type
;
irqCfg
.
irq_polarity
=
g_gpioIrqCfg
[
pin
].
irq_polarity
;
return
irqCfg
;
}
static
struct
HAL_GPIO_IRQ_CFG_T
g_gpioIrqCfg
[
HAL_GPIO_PIN_LED_NUM
]
=
{
0
};
static
void
OemGpioIrqHdl
(
enum
HAL_GPIO_PIN_T
pin
)
{
...
...
@@ -216,8 +200,7 @@ static uint32_t GetGpioDeviceResource(struct GpioDevice *device)
return
HDF_SUCCESS
;
}
#else
static
uint32_t
GetGpioDeviceResource
(
struct
GpioDevice
*
device
,
const
struct
DeviceResourceNode
*
resourceNode
)
static
uint32_t
GetGpioDeviceResource
(
struct
GpioDevice
*
device
,
const
struct
DeviceResourceNode
*
resourceNode
)
{
uint32_t
relPin
;
int32_t
ret
;
...
...
@@ -271,12 +254,10 @@ static uint32_t GetGpioDeviceResource(
return
HDF_FAILURE
;
}
}
return
HDF_SUCCESS
;
}
#endif
static
int32_t
AttachGpioDevice
(
struct
GpioCntlr
*
gpioCntlr
,
struct
HdfDeviceObject
*
device
)
{
int32_t
ret
;
...
...
@@ -302,12 +283,12 @@ static int32_t AttachGpioDevice(struct GpioCntlr *gpioCntlr, struct HdfDeviceObj
ret
=
GetGpioDeviceResource
(
gpioDevice
,
device
->
property
);
#endif
if
(
ret
!=
HDF_SUCCESS
)
{
(
void
)
OsalMemFree
(
gpioDevice
);
OsalMemFree
(
gpioDevice
);
return
HDF_FAILURE
;
}
gpioCntlr
->
count
=
gpioDevice
->
resource
.
pinNum
;
gpioCntlr
->
priv
=
(
void
*
)
gpioDevice
;
return
HDF_SUCCESS
;
}
...
...
@@ -363,7 +344,8 @@ static void GpioDriverRelease(struct HdfDeviceObject *device)
return
HDF_DEV_ERR_NO_DEVICE_SERVICE
;
}
(
void
)
OsalMemFree
(
gpioCntlr
->
priv
);
gpioCntlr
->
ops
=
NULL
;
OsalMemFree
(
gpioCntlr
->
priv
);
gpioCntlr
->
count
=
0
;
}
...
...
@@ -371,9 +353,13 @@ static void GpioDriverRelease(struct HdfDeviceObject *device)
static
int32_t
GpioDevWrite
(
struct
GpioCntlr
*
cntlr
,
uint16_t
gpio
,
uint16_t
val
)
{
(
void
)
cntlr
;
if
(
gpio
>=
HAL_GPIO_PIN_LED_NUM
)
{
HDF_LOGE
(
"%s %d, error pin:%hu"
,
__func__
,
__LINE__
,
gpio
);
return
HDF_ERR_NOT_SUPPORT
;
}
uint16_t
halGpio
=
g_gpioPinReflectionMap
[
gpio
];
if
((
enum
HAL_GPIO_PIN_T
)
halGpio
>=
HAL_GPIO_PIN_LED_NUM
)
{
HDF_LOGE
(
"%s %d, error pin:%
d
"
,
__func__
,
__LINE__
,
halGpio
);
HDF_LOGE
(
"%s %d, error pin:%
hu
"
,
__func__
,
__LINE__
,
halGpio
);
return
HDF_ERR_NOT_SUPPORT
;
}
...
...
@@ -386,9 +372,13 @@ static int32_t GpioDevRead(struct GpioCntlr *cntlr, uint16_t gpio, uint16_t *val
{
(
void
)
cntlr
;
uint16_t
value
;
if
(
gpio
>=
HAL_GPIO_PIN_LED_NUM
)
{
HDF_LOGE
(
"%s %d, error pin:%hu"
,
__func__
,
__LINE__
,
gpio
);
return
HDF_ERR_NOT_SUPPORT
;
}
uint16_t
halGpio
=
g_gpioPinReflectionMap
[
gpio
];
if
((
enum
HAL_GPIO_PIN_T
)
halGpio
>=
HAL_GPIO_PIN_LED_NUM
)
{
HDF_LOGE
(
"%s %d, error pin:%
d
"
,
__func__
,
__LINE__
,
halGpio
);
HDF_LOGE
(
"%s %d, error pin:%
hu
"
,
__func__
,
__LINE__
,
halGpio
);
return
HDF_ERR_NOT_SUPPORT
;
}
...
...
@@ -401,9 +391,13 @@ static int32_t GpioDevRead(struct GpioCntlr *cntlr, uint16_t gpio, uint16_t *val
static
int32_t
GpioDevSetDir
(
struct
GpioCntlr
*
cntlr
,
uint16_t
gpio
,
uint16_t
dir
)
{
(
void
)
cntlr
;
if
(
gpio
>=
HAL_GPIO_PIN_LED_NUM
)
{
HDF_LOGE
(
"%s %d, error pin:%hu"
,
__func__
,
__LINE__
,
gpio
);
return
HDF_ERR_NOT_SUPPORT
;
}
uint16_t
halGpio
=
g_gpioPinReflectionMap
[
gpio
];
if
((
enum
HAL_GPIO_PIN_T
)
halGpio
>=
HAL_GPIO_PIN_LED_NUM
)
{
HDF_LOGE
(
"%s %d, error pin:%
d
"
,
__func__
,
__LINE__
,
halGpio
);
HDF_LOGE
(
"%s %d, error pin:%
hu
"
,
__func__
,
__LINE__
,
halGpio
);
return
HDF_ERR_NOT_SUPPORT
;
}
...
...
@@ -416,9 +410,13 @@ static int32_t GpioDevGetDir(struct GpioCntlr *cntlr, uint16_t gpio, uint16_t *d
{
(
void
)
cntlr
;
uint16_t
value
;
if
(
gpio
>=
HAL_GPIO_PIN_LED_NUM
)
{
HDF_LOGE
(
"%s %d, error pin:%hu"
,
__func__
,
__LINE__
,
gpio
);
return
HDF_ERR_NOT_SUPPORT
;
}
uint16_t
halGpio
=
g_gpioPinReflectionMap
[
gpio
];
if
((
enum
HAL_GPIO_PIN_T
)
halGpio
>=
HAL_GPIO_PIN_LED_NUM
)
{
HDF_LOGE
(
"%s %d, error pin:%
d"
,
__func__
,
__LINE__
,
g
pio
);
HDF_LOGE
(
"%s %d, error pin:%
hu"
,
__func__
,
__LINE__
,
halG
pio
);
return
HDF_ERR_NOT_SUPPORT
;
}
...
...
@@ -431,9 +429,13 @@ static int32_t GpioDevGetDir(struct GpioCntlr *cntlr, uint16_t gpio, uint16_t *d
static
int32_t
GpioDevSetIrq
(
struct
GpioCntlr
*
cntlr
,
uint16_t
gpio
,
uint16_t
mode
)
{
(
void
)
cntlr
;
if
(
gpio
>=
HAL_GPIO_PIN_LED_NUM
)
{
HDF_LOGE
(
"%s %d, error pin:%hu"
,
__func__
,
__LINE__
,
gpio
);
return
HDF_ERR_NOT_SUPPORT
;
}
enum
HAL_GPIO_PIN_T
pin
=
(
enum
HAL_GPIO_PIN_T
)
g_gpioPinReflectionMap
[
gpio
];
if
(
pin
>=
HAL_GPIO_PIN_LED_NUM
)
{
HDF_LOGE
(
"%s %d, error pin:%
d
"
,
__func__
,
__LINE__
,
pin
);
HDF_LOGE
(
"%s %d, error pin:%
hu
"
,
__func__
,
__LINE__
,
pin
);
return
HDF_ERR_NOT_SUPPORT
;
}
...
...
@@ -442,10 +444,16 @@ static int32_t GpioDevSetIrq(struct GpioCntlr *cntlr, uint16_t gpio, uint16_t mo
}
else
if
((
mode
==
OSAL_IRQF_TRIGGER_HIGH
)
||
(
mode
==
OSAL_IRQF_TRIGGER_LOW
))
{
g_gpioIrqCfg
[
pin
].
irq_type
=
HAL_GPIO_IRQ_TYPE_LEVEL_SENSITIVE
;
}
else
{
HDF_LOGE
(
"%s %d, error mode:%
d
"
,
__func__
,
__LINE__
,
mode
);
HDF_LOGE
(
"%s %d, error mode:%
hu
"
,
__func__
,
__LINE__
,
mode
);
return
HDF_ERR_NOT_SUPPORT
;
}
if
(
mode
==
OSAL_IRQF_TRIGGER_HIGH
||
mode
==
OSAL_IRQF_TRIGGER_RISING
)
{
mode
=
HAL_GPIO_IRQ_POLARITY_HIGH_RISING
;
}
else
{
mode
=
HAL_GPIO_IRQ_POLARITY_LOW_FALLING
;
}
g_gpioIrqCfg
[
pin
].
irq_polarity
=
mode
;
return
HDF_SUCCESS
;
...
...
@@ -454,6 +462,10 @@ static int32_t GpioDevSetIrq(struct GpioCntlr *cntlr, uint16_t gpio, uint16_t mo
static
int32_t
GpioDevUnSetIrq
(
struct
GpioCntlr
*
cntlr
,
uint16_t
gpio
)
{
(
void
)
cntlr
;
if
(
gpio
>=
HAL_GPIO_PIN_LED_NUM
)
{
HDF_LOGE
(
"%s %d, error pin:%hu"
,
__func__
,
__LINE__
,
gpio
);
return
HDF_ERR_NOT_SUPPORT
;
}
enum
HAL_GPIO_PIN_T
pin
=
(
enum
HAL_GPIO_PIN_T
)
g_gpioPinReflectionMap
[
gpio
];
if
(
pin
>=
HAL_GPIO_PIN_LED_NUM
)
{
HDF_LOGE
(
"%s %d, error pin:%d"
,
__func__
,
__LINE__
,
pin
);
...
...
@@ -467,6 +479,10 @@ static int32_t GpioDevEnableIrq(struct GpioCntlr *cntlr, uint16_t gpio)
{
(
void
)
cntlr
;
struct
HAL_GPIO_IRQ_CFG_T
gpioCfg
;
if
(
gpio
>=
HAL_GPIO_PIN_LED_NUM
)
{
HDF_LOGE
(
"%s %d, error pin:%hu"
,
__func__
,
__LINE__
,
gpio
);
return
HDF_ERR_NOT_SUPPORT
;
}
uint16_t
halGpio
=
(
enum
HAL_GPIO_PIN_T
)
g_gpioPinReflectionMap
[
gpio
];
if
((
enum
HAL_GPIO_PIN_T
)
halGpio
>=
HAL_GPIO_PIN_LED_NUM
)
{
HDF_LOGE
(
"%s %d, error pin:%d"
,
__func__
,
__LINE__
,
(
enum
HAL_GPIO_PIN_T
)
halGpio
);
...
...
@@ -490,9 +506,13 @@ static int32_t GpioDevEnableIrq(struct GpioCntlr *cntlr, uint16_t gpio)
static
int32_t
GpioDevDisableIrq
(
struct
GpioCntlr
*
cntlr
,
uint16_t
gpio
)
{
(
void
)
cntlr
;
if
(
gpio
>=
HAL_GPIO_PIN_LED_NUM
)
{
HDF_LOGE
(
"%s %d, error pin:%hu"
,
__func__
,
__LINE__
,
gpio
);
return
HDF_ERR_NOT_SUPPORT
;
}
uint16_t
halGpio
=
(
enum
HAL_GPIO_PIN_T
)
g_gpioPinReflectionMap
[
gpio
];
if
((
enum
HAL_GPIO_PIN_T
)
halGpio
>=
HAL_GPIO_PIN_LED_NUM
)
{
HDF_LOGE
(
"%s %d, error pin:%
d
"
,
__func__
,
__LINE__
,
halGpio
);
HDF_LOGE
(
"%s %d, error pin:%
hu
"
,
__func__
,
__LINE__
,
halGpio
);
return
HDF_ERR_NOT_SUPPORT
;
}
...
...
platform/i2c/i2c_bes.c
浏览文件 @
e01a43f2
...
...
@@ -48,25 +48,9 @@ struct I2cMethod g_i2cHostMethod = {
.
transfer
=
i2cHostTransfer
,
};
int32_t
InitI2cDevice
(
struct
I2cDevice
*
devi
ce
)
static
int32_t
I2cDeviceIomuxInit
(
uint32_t
i2cId
,
struct
I2cResource
*
resour
ce
)
{
int32_t
ret
=
-
1
;
uint32_t
i2cPort
;
struct
I2cResource
*
resource
=
NULL
;
struct
HAL_I2C_CONFIG_T
*
i2cConfig
=
NULL
;
if
(
device
==
NULL
)
{
HDF_LOGE
(
"device is NULL
\r\n
"
);
return
HDF_ERR_INVALID_PARAM
;
}
resource
=
&
device
->
resource
;
if
(
resource
==
NULL
)
{
HDF_LOGE
(
"%s %d: invalid parameter
\r\n
"
,
__func__
,
__LINE__
);
return
HDF_ERR_INVALID_PARAM
;
}
i2cConfig
=
&
device
->
i2cCfg
;
if
(
i2cConfig
==
NULL
)
{
if
(
i2cId
>
HAL_I2C_ID_NUM
||
resource
==
NULL
)
{
HDF_LOGE
(
"%s %d: invalid parameter
\r\n
"
,
__func__
,
__LINE__
);
return
HDF_ERR_INVALID_PARAM
;
}
...
...
@@ -76,63 +60,52 @@ int32_t InitI2cDevice(struct I2cDevice *device)
{
0
,
0
,
HAL_IOMUX_PIN_VOLTAGE_VIO
,
HAL_IOMUX_PIN_PULLUP_ENABLE
},
};
device
->
port
=
resource
->
port
;
i2cPort
=
device
->
port
;
if
(
i2cPort
>
HAL_I2C_ID_NUM
)
{
HDF_LOGE
(
"i2c port %u not support
\r\n
"
,
i2cPort
);
return
HDF_ERR_NOT_SUPPORT
;
}
if
(
i2cPort
==
0
)
{
#ifdef LOSCFG_SOC_SERIES_BES2600
if
(
i2cId
==
0
)
{
pinMuxI2c
[
0
].
function
=
HAL_IOMUX_FUNC_I2C_M0_SCL
;
pinMuxI2c
[
1
].
function
=
HAL_IOMUX_FUNC_I2C_M0_SDA
;
}
else
{
pinMuxI2c
[
0
].
function
=
HAL_IOMUX_FUNC_I2C_M1_SCL
;
pinMuxI2c
[
1
].
function
=
HAL_IOMUX_FUNC_I2C_M1_SDA
;
}
if
(
OsalMutexInit
(
&
device
->
mutex
)
!=
HDF_SUCCESS
)
{
HDF_LOGE
(
"%s %d OsalMutexInit fail
\r\n
"
,
__func__
,
__LINE__
);
return
HDF_FAILURE
;
}
if
(
HDF_SUCCESS
!=
OsalMutexLock
(
&
device
->
mutex
))
{
HDF_LOGE
(
"%s %d osMutexWait fail
\r\n
"
,
__func__
,
__LINE__
);
return
HDF_ERR_TIMEOUT
;
#elif defined (LOSCFG_SOC_SERIES_BES2700)
if
(
i2cId
==
0
)
{
pinMuxI2c
[
0
].
function
=
HAL_IOMUX_FUNC_SYS_I2C_M0_SCL
;
pinMuxI2c
[
1
].
function
=
HAL_IOMUX_FUNC_SYS_I2C_M0_SDA
;
}
else
{
pinMuxI2c
[
0
].
function
=
HAL_IOMUX_FUNC_SYS_I2C_M1_SCL
;
pinMuxI2c
[
1
].
function
=
HAL_IOMUX_FUNC_SYS_I2C_M1_SDA
;
}
#endif
pinMuxI2c
[
0
].
pin
=
resource
->
sclPin
;
pinMuxI2c
[
1
].
pin
=
resource
->
sdaPin
;
hal_iomux_init
(
pinMuxI2c
,
ARRAY_SIZE
(
pinMuxI2c
));
ret
=
hal_i2c_open
(
i2cPort
,
i2cConfig
);
if
(
ret
==
HDF_SUCCESS
)
{
HDF_LOGD
(
"open %u i2c succ.
\r\n
"
,
i2cPort
);
}
OsalMutexUnlock
(
&
device
->
mutex
);
return
ret
;
return
HDF_SUCCESS
;
}
static
int32_t
HostRes
tI2cDevice
(
struct
I2cDevice
*
device
)
int32_t
Ini
tI2cDevice
(
struct
I2cDevice
*
device
)
{
int32_t
ret
=
-
1
;
int32_t
ret
;
uint32_t
i2cPort
;
struct
I2cResource
*
resource
=
NULL
;
struct
HAL_I2C_CONFIG_T
*
i2cConfig
=
NULL
;
uint32_t
i2cPort
;
if
(
device
==
NULL
)
{
HDF_LOGE
(
"%s %d
device is null
\r\n
"
,
__func__
,
__LINE__
);
HDF_LOGE
(
"%s %d
:device is NULL
\r\n
"
,
__func__
,
__LINE__
);
return
HDF_ERR_INVALID_PARAM
;
}
resource
=
&
device
->
resource
;
if
(
resource
==
NULL
)
{
HDF_LOGE
(
"%s %d: invalid parameter
\r\n
"
,
__func__
,
__LINE__
);
return
HDF_ERR_INVALID_
OBJECT
;
return
HDF_ERR_INVALID_
PARAM
;
}
i2cConfig
=
&
device
->
i2cCfg
;
if
(
i2cConfig
==
NULL
)
{
HDF_LOGE
(
"%s %d: invalid parameter
\r\n
"
,
__func__
,
__LINE__
);
return
HDF_ERR_INVALID_
OBJECT
;
return
HDF_ERR_INVALID_
PARAM
;
}
device
->
port
=
resource
->
port
;
i2cPort
=
device
->
port
;
if
(
i2cPort
>
HAL_I2C_ID_NUM
)
{
...
...
@@ -140,59 +113,66 @@ static int32_t HostRestI2cDevice(struct I2cDevice *device)
return
HDF_ERR_NOT_SUPPORT
;
}
hal_i2c_close
(
i2cPort
);
if
(
OsalMutexInit
(
&
device
->
mutex
)
!=
HDF_SUCCESS
)
{
HDF_LOGE
(
"%s %d OsalMutexInit fail
\r\n
"
,
__func__
,
__LINE__
);
return
HDF_FAILURE
;
}
if
(
OsalMutexLock
(
&
device
->
mutex
)
!=
HDF_SUCCESS
)
{
HDF_LOGE
(
"%s %d osMutexWait fail
\r\n
"
,
__func__
,
__LINE__
);
return
HDF_ERR_TIMEOUT
;
}
ret
=
I2cDeviceIomuxInit
(
i2cPort
,
resource
);
if
(
ret
!=
HDF_SUCCESS
)
{
HDF_LOGD
(
"I2C iomux init failed.
\r\n
"
);
OsalMutexUnlock
(
&
device
->
mutex
);
return
ret
;
}
ret
=
hal_i2c_open
(
i2cPort
,
i2cConfig
);
if
(
ret
==
HDF_SUCCESS
)
{
HDF_LOGD
(
"open %u i2c succ.
\r\n
"
,
i2cPort
);
}
OsalMutexUnlock
(
&
device
->
mutex
);
return
ret
;
}
#ifdef LOSCFG_DRIVERS_HDF_CONFIG_MACRO
#define I2C_FIND_CONFIG(node, name, resource) \
do { \
if (strcmp(HCS_PROP(node, match_attr), name) == 0) { \
resource->port = HCS_PROP(node, port); \
tempPin = HCS_PROP(node, sclPin); \
resource->sclPin = ((tempPin / DEC_NUM) * GROUP_PIN_NUM) + (tempPin % DEC_NUM); \
tempPin = HCS_PROP(node, sdaPin); \
resource->sdaPin = ((tempPin / DEC_NUM) * GROUP_PIN_NUM) + (tempPin % DEC_NUM); \
resource->speed = HCS_PROP(node, speed); \
resource->mode = HCS_PROP(node, mode); \
resource->useDma = HCS_PROP(node, useDma); \
resource->useSync = HCS_PROP(node, useSync); \
resource->asMaster = HCS_PROP(node, asMaster); \
break; \
} \
} while (0)
#define PLATFORM_I2C_CONFIG HCS_NODE(HCS_NODE(HCS_ROOT, platform), i2c_config)
static
uint32_t
GetI2cDeviceResource
(
struct
I2cDevice
*
device
,
const
char
*
deviceMatchAttr
)
static
int32_t
GetI2cDeviceIomuxConfig
(
struct
I2cResource
*
resource
,
const
struct
DeviceResourceNode
*
resourceNode
)
{
uint32_t
tempPin
=
0
;
struct
I2cResource
*
resource
=
NULL
;
if
(
device
==
NULL
)
{
HDF_LOGE
(
"device or resourceNode is NULL
\r\n
"
);
struct
DeviceResourceIface
*
dri
=
NULL
;
if
(
resource
==
NULL
||
resourceNode
==
NULL
)
{
HDF_LOGE
(
"%s %d:resource or resourceNode is NULL
\r\n
"
,
__func__
,
__LINE__
);
return
HDF_ERR_INVALID_PARAM
;
}
resource
=
&
device
->
resource
;
if
(
resource
==
NULL
)
{
HDF_LOGE
(
"%s %d: invalid parameter
\r\n
"
,
__func__
,
__LINE__
);
dri
=
DeviceResourceGetIfaceInstance
(
HDF_CONFIG_SOURCE
);
if
(
dri
==
NULL
||
dri
->
GetUint32
==
NULL
)
{
HDF_LOGE
(
"DeviceResourceIface is invalid
\r\n
"
);
return
HDF_ERR_INVALID_OBJECT
;
}
HCS_FOREACH_CHILD_VARGS
(
PLATFORM_I2C_CONFIG
,
I2C_FIND_CONFIG
,
deviceMatchAttr
,
resource
);
if
(
dri
->
GetUint32
(
resourceNode
,
"sclPin"
,
&
resource
->
sclPin
,
0
)
!=
HDF_SUCCESS
)
{
HDF_LOGE
(
"i2c config sclPin fail
\r\n
"
);
return
HDF_FAILURE
;
}
if
(
dri
->
GetUint32
(
resourceNode
,
"sdaPin"
,
&
resource
->
sdaPin
,
0
)
!=
HDF_SUCCESS
)
{
HDF_LOGE
(
"i2c config sdaPin fail
\r\n
"
);
return
HDF_FAILURE
;
}
resource
->
sclPin
=
((
resource
->
sclPin
/
DEC_NUM
)
*
GROUP_PIN_NUM
)
+
(
resource
->
sclPin
%
DEC_NUM
);
resource
->
sdaPin
=
((
resource
->
sdaPin
/
DEC_NUM
)
*
GROUP_PIN_NUM
)
+
(
resource
->
sdaPin
%
DEC_NUM
);
return
HDF_SUCCESS
;
}
#else
static
uint32_t
GetI2cDeviceResource
(
struct
I2cDevice
*
device
,
const
struct
DeviceResourceNode
*
resourceNode
)
static
int32_t
GetI2cDeviceResource
(
struct
I2cDevice
*
device
,
const
struct
DeviceResourceNode
*
resourceNode
)
{
uint32_t
tempPin
=
0
;
struct
I2cResource
*
resource
=
NULL
;
struct
DeviceResourceIface
*
dri
=
NULL
;
if
(
device
==
NULL
||
resourceNode
==
NULL
)
{
HDF_LOGE
(
"
device or resourceNode is NULL
\r\n
"
);
HDF_LOGE
(
"
%s %d:device or resourceNode is NULL
\r\n
"
,
__func__
,
__LINE__
);
return
HDF_ERR_INVALID_PARAM
;
}
resource
=
&
device
->
resource
;
...
...
@@ -211,18 +191,6 @@ static uint32_t GetI2cDeviceResource(struct I2cDevice *device,
return
HDF_FAILURE
;
}
if
(
dri
->
GetUint32
(
resourceNode
,
"sclPin"
,
&
tempPin
,
0
)
!=
HDF_SUCCESS
)
{
HDF_LOGE
(
"i2c config sclPin fail
\r\n
"
);
return
HDF_FAILURE
;
}
resource
->
sclPin
=
((
tempPin
/
DEC_NUM
)
*
GROUP_PIN_NUM
)
+
(
tempPin
%
DEC_NUM
);
if
(
dri
->
GetUint32
(
resourceNode
,
"sdaPin"
,
&
tempPin
,
0
)
!=
HDF_SUCCESS
)
{
HDF_LOGE
(
"i2c config sdaPin fail
\r\n
"
);
return
HDF_FAILURE
;
}
resource
->
sdaPin
=
((
tempPin
/
DEC_NUM
)
*
GROUP_PIN_NUM
)
+
(
tempPin
%
DEC_NUM
);
if
(
dri
->
GetUint32
(
resourceNode
,
"speed"
,
&
resource
->
speed
,
0
)
!=
HDF_SUCCESS
)
{
HDF_LOGE
(
"i2c config speed fail
\r\n
"
);
return
HDF_FAILURE
;
...
...
@@ -247,9 +215,10 @@ static uint32_t GetI2cDeviceResource(struct I2cDevice *device,
HDF_LOGE
(
"i2c config asMaster fail
\r\n
"
);
return
HDF_FAILURE
;
}
return
HDF_SUCCESS
;
return
GetI2cDeviceIomuxConfig
(
resource
,
resourceNode
);
}
#endif
static
int32_t
AttachI2cDevice
(
struct
I2cCntlr
*
host
,
struct
HdfDeviceObject
*
device
)
{
int32_t
ret
;
...
...
@@ -278,11 +247,13 @@ static int32_t AttachI2cDevice(struct I2cCntlr *host, struct HdfDeviceObject *de
resource
=
&
i2cDevice
->
resource
;
if
(
resource
==
NULL
)
{
HDF_LOGE
(
"%s %d: invalid parameter
\r\n
"
,
__func__
,
__LINE__
);
OsalMemFree
(
i2cDevice
);
return
HDF_ERR_INVALID_OBJECT
;
}
i2cConfig
=
&
i2cDevice
->
i2cCfg
;
if
(
i2cConfig
==
NULL
)
{
HDF_LOGE
(
"%s %d: invalid parameter
\r\n
"
,
__func__
,
__LINE__
);
OsalMemFree
(
i2cDevice
);
return
HDF_ERR_INVALID_OBJECT
;
}
i2cDevice
->
port
=
resource
->
port
;
...
...
@@ -320,12 +291,10 @@ static int32_t i2cDriverInit(struct HdfDeviceObject *device)
ret
=
AttachI2cDevice
(
host
,
device
);
if
(
ret
!=
HDF_SUCCESS
)
{
HDF_LOGE
(
"%s: attach error
\r\n
"
,
__func__
);
i2cDriverRelease
(
device
);
return
HDF_DEV_ERR_ATTACHDEV_FAIL
;
}
ret
=
I2cCntlrAdd
(
host
);
if
(
ret
!=
HDF_SUCCESS
)
{
i2cDriverRelease
(
device
);
return
HDF_FAILURE
;
}
return
ret
;
...
...
platform/i2c/i2c_bes.h
浏览文件 @
e01a43f2
...
...
@@ -11,7 +11,9 @@
#include "hal_i2c.h"
#include "hal_iomux.h"
#ifdef CHIP_BEST2003
#include "hal_iomux_best2003.h"
#endif
#include "device_resource_if.h"
#include "osal_mutex.h"
#ifdef __cplusplus
...
...
platform/pwm/pwm_bes.c
浏览文件 @
e01a43f2
...
...
@@ -12,7 +12,6 @@
#include "hdf_device_desc.h"
#include "hal_trace.h"
#include "hal_timer.h"
#include "hal_iomux.h"
#include "pwm_core.h"
#include "hdf_log.h"
#ifdef LOSCFG_DRIVERS_HDF_CONFIG_MACRO
...
...
@@ -22,7 +21,13 @@
#include "device_resource_if.h"
#endif
#if defined (LOSCFG_SOC_SERIES_BES2700)
#define PWM_MAX_FUNCTION 4
#elif defined (LOSCFG_SOC_SERIES_BES2600)
#include "hal_iomux.h"
#define PWM_MAX_FUNCTION 8
#endif
#define UNTIL_NAN0SECONDS 1000000000
#define PERCENT 100
#define DEC_TEN 10
...
...
@@ -33,10 +38,12 @@ static uint32_t g_pwmFunction[PWM_MAX_FUNCTION] = {
HAL_IOMUX_FUNC_PWM1
,
HAL_IOMUX_FUNC_PWM2
,
HAL_IOMUX_FUNC_PWM3
,
#if defined (LOSCFG_SOC_SERIES_BES2600)
HAL_IOMUX_FUNC_PWM4
,
HAL_IOMUX_FUNC_PWM5
,
HAL_IOMUX_FUNC_PWM6
,
HAL_IOMUX_FUNC_PWM7
,
#endif
};
static
int32_t
PwmDevSetConfig
(
struct
PwmDev
*
pwm
,
struct
PwmConfig
*
config
);
...
...
@@ -54,7 +61,7 @@ static int InitPwmDevice(struct PwmDev *host)
struct
PwmDevice
*
pwmDevice
=
NULL
;
struct
PwmResource
*
resource
=
NULL
;
if
(
host
==
NULL
||
host
->
priv
==
NULL
)
{
HDF_LOGE
(
"%s: inva
il
d parameter
\r\n
"
,
__func__
);
HDF_LOGE
(
"%s: inva
li
d parameter
\r\n
"
,
__func__
);
return
HDF_ERR_INVALID_PARAM
;
}
pwmDevice
=
(
struct
PwmDevice
*
)
host
->
priv
;
...
...
@@ -81,13 +88,7 @@ static int InitPwmDevice(struct PwmDev *host)
return
HDF_SUCCESS
;
}
#ifdef LOSCFG_DRIVERS_HDF_CONFIG_MACRO
static
uint32_t
GetPwmDeviceResource
(
struct
PwmDevice
*
device
)
{
}
#else
static
uint32_t
GetPwmDeviceResource
(
struct
PwmDevice
*
device
,
const
struct
DeviceResourceNode
*
resourceNode
)
static
uint32_t
GetPwmDeviceResource
(
struct
PwmDevice
*
device
,
const
struct
DeviceResourceNode
*
resourceNode
)
{
uint32_t
tempPin
=
0
;
struct
DeviceResourceIface
*
dri
=
NULL
;
...
...
@@ -122,7 +123,7 @@ static uint32_t GetPwmDeviceResource(
return
HDF_SUCCESS
;
}
#endif
static
int32_t
AttachPwmDevice
(
struct
PwmDev
*
host
,
struct
HdfDeviceObject
*
device
)
{
int32_t
ret
;
...
...
@@ -142,7 +143,7 @@ static int32_t AttachPwmDevice(struct PwmDev *host, struct HdfDeviceObject *devi
return
HDF_ERR_MALLOC_FAIL
;
}
#ifdef LOSCFG_DRIVERS_HDF_CONFIG_MACRO
ret
=
GetPwmDeviceResource
(
pwmDevice
);
ret
=
GetPwmDeviceResource
(
pwmDevice
,
device
->
deviceMatchAttr
);
#else
ret
=
GetPwmDeviceResource
(
pwmDevice
,
device
->
property
);
#endif
...
...
platform/pwm/pwm_bes.h
浏览文件 @
e01a43f2
...
...
@@ -11,7 +11,9 @@
#include "hal_pwm.h"
#include "hal_gpio.h"
#ifdef CHIP_BEST2003
#include "hal_iomux.h"
#endif
#include "pwm_core.h"
#ifdef __cplusplus
...
...
platform/spi/spi_bes.c
浏览文件 @
e01a43f2
此差异已折叠。
点击以展开。
platform/spi/spi_bes.h
浏览文件 @
e01a43f2
...
...
@@ -12,7 +12,9 @@
#include "hal_spi.h"
#include "hal_gpio.h"
#include "hal_iomux.h"
#ifdef CHIP_BEST2003
#include "hal_iomux_best2003.h"
#endif
#include "osal_mutex.h"
#include "osal_sem.h"
...
...
platform/uart/uart_bes.c
浏览文件 @
e01a43f2
此差异已折叠。
点击以展开。
platform/watchdog/watchdog_bes.c
浏览文件 @
e01a43f2
...
...
@@ -47,7 +47,7 @@ static int InitWatchdogDevice(struct WatchdogDevice *watchdogDevice)
struct
WatchdogResource
*
resource
=
NULL
;
int32_t
watchdogId
;
if
(
watchdogDevice
==
NULL
)
{
HDF_LOGE
(
"%s: inva
il
d parameter
\r\n
"
,
__func__
);
HDF_LOGE
(
"%s: inva
li
d parameter
\r\n
"
,
__func__
);
return
HDF_ERR_INVALID_PARAM
;
}
...
...
@@ -182,7 +182,7 @@ static int32_t WatchdogDriverInit(struct HdfDeviceObject *device)
}
watchdogCntlr
->
ops
=
&
g_WatchdogCntlrMethod
;
HDF_LOGE
(
"WatchdogDriverInit success!
\r\n
"
);
return
ret
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录