File | Called from | Code enabled by |
---|---|---|
| Application | N/A |
Open a device.
Arguments
name_dev
Device name. See µC/FS File and Directory Names and Paths for information about device names.
p_dev_cfg
Pointer to device configuration.
p_err
Pointer to variable that will receive the return error code from this function (see Note #1):
FS_ERR_NONE
Device opened successfully.
FS_ERR_DEV_ALREADY_OPEN
Device is already open.
FS_ERR_DEV_INVALID_LOW_FMT
Device needs to be low-level formatted.
FS_ERR_DEV_INVALID_NAME
Specified device name not valid.
FS_ERR_DEV_INVALID_SEC_SIZE
Invalid device sector size.
FS_ERR_DEV_INVALID_SIZE
Invalid device size.
FS_ERR_DEV_INVALID_UNIT_NBR
Specified unit number invalid.
FS_ERR_DEV_IO
Device I/O error.
FS_ERR_DEV_NONE_AVAIL
No devices available.
FS_ERR_DEV_NOT_PRESENT
Device is not present.
FS_ERR_DEV_TIMEOUT
Device timeout error.
FS_ERR_DEV_UNKNOWN
Unknown device error.
FS_ERR_NAME_NULL
Argument name_dev
passed a NULL pointer
Returned Value
None.
Notes/Warnings
- The return error code from the function SHOULD always be checked by the calling application to determine whether the device was successfully opened. Repeated calls to
FSDev_Open()
resulting in errors that do not indicate failure to open (such asFS_ERR_DEV_LOW_FMT_INVALID
) without matchingFSDev_Close()
calls may exhaust the supply of device structures.- If
FS_ERR_NONE
is returned, then the device has been added to the file system and is immediately accessible. - If
FS_DEV_INVALID_LOW_FMT
is returned, then the device has been added to the file system, but needs to be low-level formatted, though it is present. - If
FS_ERR_DEV_NOT_PRESENT
,FS_ERR_DEV_IO
orFS_ERR_DEV_TIMEOUT
is returned, then the device has been added to the file system, though it is probably not present. The device will need to be either closed and re-added, or refreshed. - If any of the follwing is returned:
- FS_ERR_DEV_INVALID_NAME
- FS_ERR_DEV_INVALID_SEC_SIZE
- FS_ERR_DEV_INVALID_SIZE
- FS_ERR_DEV_INVALID_UNIT_NBR
- FS_ERR_DEV_NONE_AVAIL
...then the device has not been added to the file system.
- If
FS_ERR_DEV_UNKNOWN
is returned, then the device driver is in an indeterminate state. The system MAY need to be restarted and the device driver should be examined for errors. The device has not been added to the file system.
- If