Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Typedefs | Functions
AIO

Analog I/O API for Soletta. More...

Typedefs

typedef struct sol_aio sol_aio
 AIO handle structure. More...
 
typedef struct sol_aio_pending sol_aio_pending
 AIO pending operation handle structure. More...
 

Functions

void sol_aio_close (struct sol_aio *aio)
 Close the given AIO handle. More...
 
struct sol_aio_pendingsol_aio_get_value (struct sol_aio *aio, void(*read_cb)(void *cb_data, struct sol_aio *aio, int32_t ret), const void *cb_data)
 Request an (asynchronous) read operation to take place on AIO handle aio. More...
 
struct sol_aiosol_aio_open (int device, int pin, unsigned int precision)
 Open the given Analog I/O pin on device to be used. More...
 
struct sol_aiosol_aio_open_by_label (const char *label, unsigned int precision)
 Open the given board pin by its label to be used as Analog I/O. More...
 
struct sol_aiosol_aio_open_raw (int device, int pin, unsigned int precision)
 Open the given Analog I/O pin on device to be used. More...
 
void sol_aio_pending_cancel (struct sol_aio *aio, struct sol_aio_pending *pending)
 Cancel a pending operation. More...
 

Detailed Description

Analog I/O API for Soletta.

Typedef Documentation

AIO pending operation handle structure.

See Also
sol_aio_get_value()
sol_aio_pending_cancel()

Function Documentation

void sol_aio_close ( struct sol_aio aio)

Close the given AIO handle.

Parameters
aioAIO handle to be closed.
struct sol_aio_pending* sol_aio_get_value ( struct sol_aio aio,
void(*)(void *cb_data, struct sol_aio *aio, int32_t ret)  read_cb,
const void *  cb_data 
)

Request an (asynchronous) read operation to take place on AIO handle aio.

Parameters
aioA valid AIO handle for the desired 'device/pin' pair.
read_cbThe callback to be issued when the operation finishes. The ret parameter will contain the given digital reading (non-negative value) on success or a negative error code, on failure.
cb_dataThe data pointer to be passed to read_cb.
Returns
pending An AIO pending operation handle on success and errno is set to 0, otherwise NULL. It's only valid before read_cb is called. It may be used before that to cancel the read operation. If NULL is returned, the errno variable will be set with the correct error value. In case that the AIO device is in use, the errno variable is set to EBUSY.
struct sol_aio* sol_aio_open ( int  device,
int  pin,
unsigned int  precision 
)

Open the given Analog I/O pin on device to be used.

This function also applies any pin multiplexer rules needed if a multiplexer for the current board was previously loaded.

Parameters
deviceThe AIO device number.
pinThe AIO pin on device.
precisionThe number of valid bits on the data received from the analog to digital converter. Some simpler operating systems might have that hardcoded for analog-to-digital converters, in which case this value will be ignored.
Returns
A new AIO handle
See Also
sol_aio_open_raw
struct sol_aio* sol_aio_open_by_label ( const char *  label,
unsigned int  precision 
)

Open the given board pin by its label to be used as Analog I/O.

This function only works when the board was successfully detected by Soletta and a corresponding pin multiplexer module was found.

This function also applies any pin multiplexer rules needed if a multiplexer for the current board was previously loaded.

Parameters
labelLabel of the pin on the board.
precisionThe number of valid bits on the data received from the analog to digital converter. Some simpler operating systems might have that hardcoded for analog-to-digital converters, in which case this value will be ignored.
Returns
A new AIO handle
See Also
sol_aio_open_raw
struct sol_aio* sol_aio_open_raw ( int  device,
int  pin,
unsigned int  precision 
)

Open the given Analog I/O pin on device to be used.

precision is used to filter the valid bits from the data received from hardware (which is manufacturer-dependent), therefore it should not be used as a way to change intended device's output range, because it will be applied to the least significant bits of the read data.

Parameters
deviceThe AIO device number
pinThe AIO pin on device
precisionThe number of valid bits on the data received from the analog to digital converter.
Returns
A new AIO handle
void sol_aio_pending_cancel ( struct sol_aio aio,
struct sol_aio_pending pending 
)

Cancel a pending operation.

Parameters
aiothe AIO handle
pendingthe operation handle