BSPACM  20150113
Board Support Package for ARM Cortex-M Microcontrollers
Macros | Functions
ioctl.h File Reference

ioctl() support for BSPACM's newlib file descriptor operations More...

#include <bspacm/newlib/fdops.h>

Go to the source code of this file.

Macros

#define BSPACM_IOCTL_FLUSH   0x100
 

Functions

int ioctl (int fd, int request,...)
 

Detailed Description

ioctl() support for BSPACM's newlib file descriptor operations

This file defines ioctl request values common to multiple BSPACM devices. More specific ioctl requests may be defined in other headers.

Applications should make no attempt to interpret ioctl values; they are to be treated as opaque integers that are constant within a given application.

Homepage
http://github.com/pabigot/bspacm

Macro Definition Documentation

#define BSPACM_IOCTL_FLUSH   0x100

Flush read and write buffers at the device layer.

This blocks, with interrupts enabled, as long as the underlying device still has data pending for transmission or reception; e.g. see iBSPACMperiphUARTfifoState() for an example device-layer utility used by this ioctl.

A common use for this would be to flush pending information written through stdout prior to entering a sleep mode that might disable the peripheral that supports the device. E.g.:

// Flush past any libc buffering
fflush(stdout);
// Flush past any device buffering
(void)ioctl(1, BSPACM_IOCTL_FLUSH, O_WRONLY);
// Now go to sleep
BSPACM_CORE_DEEP_SLEEP();
Parameters
flagsOne of the values O_RDONLY (0), O_WRONLY (1), or O_RDWR (2) as defined in <fcntl.h>. O_RDONLY and O_RDWR will block until all material received by the device has been consumed by the application. O_WRONLY and O_RDWR will block until all material submitted to the device has been written.
Returns
0 if all data could be flushed, or a negative error code.

Function Documentation

int ioctl ( int  fd,
int  request,
  ... 
)

Manipulate the underlying parameters of the device.

The semantics of this are specific to request and to the device that fd references.

Parameters
fddescriptor for an open device
requestoperation-specific request identifier
...any parameters associated with request
Returns
Usually zero on success, with errors indicated by returning -1 and setting errno.