下载 FreeRTOS
 

出色的 RTOS & 嵌入式软件

最新资讯
简化任何设备的身份验证云连接。
利用 CoAP 设计节能型云连接 IoT 解决方案。
11.0.0 版 FreeRTOS 内核简介:
FreeRTOS 路线图和代码贡献流程。
使用 FreeRTOS 实现 OPC-UA over TSN。

FreeRTOS_open()

[FreeRTOS-Plus-IO API]

FreeRTOS_IO.h
Peripheral_Descriptor_t FreeRTOS_open( const int8_t *pcPath, const uint32_t ulFlags );
		

使用 FreeRTOS-Plus-IO 打开外围设备以供使用。 此 板级支持包 可定义哪些外围设备在任何特定平台上均可用。

参数:

pcPath   根据板级支持包的定义打开的外围设备的文本名称

ulFlags   模式标志。 当前未使用此参数。 有两个原因 收录此参数——其可使 FreeRTOS_open() 原型符合标准 open() 原型, 原型,并确保未来 FreeRTOS-Plus-IO 开发的向后兼容性。
返回:

如果无法打开外围设备,则返回 NULL,否则返回 一个 Peripheral_Descriptor_t 类型的变量,可用于 之后调用 FreeRTOS_read()、 FreeRTOS_write() and FreeRTOS_ioctl() 访问打开的外围设备。

用法示例:


/* FreeRTOS-Plus-IO includes. */
#include "FreeRTOS_IO.h"

void vAFunction( void )
{
/* The Peripheral_Descriptor_t type is the FreeRTOS-Plus-IO equivalent of a descriptor. */
Peripheral_Descriptor_t xOpenedPort;

/* Open the SPI port identified in the board support package as using the
path string "/SPI2/". The second parameter is not currently used and can
be set to anything, although, for future compatibility, it is recommended
that it is set to NULL. */

xOpenedPort = FreeRTOS_open( "/SPI2/", NULL );

if( xOpenedPort != NULL )
{
/* xOpenedPort now contains a valid descriptor that can be used with
other FreeRTOS-Plus-IO API functions. */


. . .
}
else
{
/* The port was not opened successfully. */
}
}

FreeRTOS_open() example
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.