#include "legato.h"
Go to the source code of this file.
Macros | |
#define | LE_SPI_MAX_WRITE_SIZE 1024 |
#define | LE_SPI_MAX_READ_SIZE 1024 |
Typedefs | |
typedef struct le_spi_DeviceHandle * | le_spi_DeviceHandleRef_t |
Functions | |
void | le_spi_ConnectService (void) |
le_result_t | le_spi_TryConnectService (void) |
void | le_spi_DisconnectService (void) |
le_result_t | le_spi_Open (const char *deviceName, le_spi_DeviceHandleRef_t *handlePtr) |
void | le_spi_Close (le_spi_DeviceHandleRef_t handle) |
void | le_spi_Configure (le_spi_DeviceHandleRef_t handle, int32_t mode, uint8_t bits, uint32_t speed, int32_t msb) |
le_result_t | le_spi_WriteReadHD (le_spi_DeviceHandleRef_t handle, const uint8_t *writeDataPtr, size_t writeDataNumElements, uint8_t *readDataPtr, size_t *readDataNumElementsPtr) |
le_result_t | le_spi_WriteHD (le_spi_DeviceHandleRef_t handle, const uint8_t *writeDataPtr, size_t writeDataNumElements) |
le_result_t | le_spi_ReadHD (le_spi_DeviceHandleRef_t handle, uint8_t *readDataPtr, size_t *readDataNumElementsPtr) |
le_result_t | le_spi_WriteReadFD (le_spi_DeviceHandleRef_t handle, const uint8_t *writeDataPtr, size_t writeDataNumElements, uint8_t *readDataPtr, size_t *readDataNumElementsPtr) |
Detailed Description
Legato c_le_spi include file.
Copyright (C) Sierra Wireless Inc. Use of this work is subject to license.
Macro Definition Documentation
#define LE_SPI_MAX_READ_SIZE 1024 |
Max byte storage size for read buffer
#define LE_SPI_MAX_WRITE_SIZE 1024 |
Max byte storage size for write buffer
Typedef Documentation
typedef struct le_spi_DeviceHandle* le_spi_DeviceHandleRef_t |
Handle for passing to related functions to access the SPI device
Function Documentation
void le_spi_Close | ( | le_spi_DeviceHandleRef_t | handle | ) |
Closes the device associated with the given handle and frees the associated resources.
- Note
- Once a handle is closed, it's not permitted to use it for future SPI access without first calling Open.
- Parameters
-
[in] handle Handle for the SPI master to close
void le_spi_Configure | ( | le_spi_DeviceHandleRef_t | handle, |
int32_t | mode, | ||
uint8_t | bits, | ||
uint32_t | speed, | ||
int32_t | msb | ||
) |
Configures an SPI device's data sample settings. The required values should be included in your target's datasheet. Most common Mode
values are 0
and 3
.
These are the SPI Mode options:
Mode | Clock Polarity | Clock Phase | Clock Edge |
---|---|---|---|
0 | 0 | 0 | 1 |
1 | 0 | 1 | 0 |
2 | 1 | 0 | 1 |
3 | 1 | 1 | 0 |
- Note
- This function should be called before any of the Read/Write functions to ensure the SPI bus configuration is in a known state.
- Parameters
-
[in] handle Handle for the SPI master to configure [in] mode Choose mode options for the bus per above table [in] bits bits per word, typically 8 bits per word [in] speed max speed (Hz), this is slave dependant [in] msb set as 0 for MSB as first bit or 1 for LSB as first bit
void le_spi_ConnectService | ( | void | ) |
Connect the current client thread to the service providing this API. Block until the service is available.
For each thread that wants to use this API, either ConnectService or TryConnectService must be called before any other functions in this API. Normally, ConnectService is automatically called for the main thread, but not for any other thread. For details, see Client-specific Functions.
This function is created automatically.
void le_spi_DisconnectService | ( | void | ) |
Disconnect the current client thread from the service providing this API.
Normally, this function doesn't need to be called. After this function is called, there's no longer a connection to the service, and the functions in this API can't be used. For details, see Client-specific Functions.
This function is created automatically.
le_result_t le_spi_Open | ( | const char * | deviceName, |
le_spi_DeviceHandleRef_t * | handlePtr | ||
) |
Opens an SPI device so that the attached device may be accessed.
- Returns
- LE_OK on success
- LE_BAD_PARAMETER if the device name string is bad
- LE_NOT_FOUND if the SPI device file could not be found
- LE_NOT_PERMITTED if the SPI device file can't be opened for read/write
- LE_DUPLICATE if the given device file is already opened by another spiService client
- LE_FAULT for non-specific failures
- Parameters
-
[in] deviceName Handle for the SPI master to open [out] handlePtr Handle for passing to related functions in order to
le_result_t le_spi_ReadHD | ( | le_spi_DeviceHandleRef_t | handle, |
uint8_t * | readDataPtr, | ||
size_t * | readDataNumElementsPtr | ||
) |
SPI Read for Half Duplex Communication
- Returns
- LE_OK on success or LE_FAULT on failure.
- Parameters
-
[in] handle Handle for the SPI master to perform the read from [out] readDataPtr RX response from slave with number of bytes reserved [in,out] readDataNumElementsPtr
le_result_t le_spi_TryConnectService | ( | void | ) |
Try to connect the current client thread to the service providing this API. Return with an error if the service is not available.
For each thread that wants to use this API, either ConnectService or TryConnectService must be called before any other functions in this API. Normally, ConnectService is automatically called for the main thread, but not for any other thread. For details, see Client-specific Functions.
This function is created automatically.
- Returns
- LE_OK if the client connected successfully to the service.
- LE_UNAVAILABLE if the server is not currently offering the service to which the client is bound.
- LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
- LE_COMM_ERROR if the Service Directory cannot be reached.
le_result_t le_spi_WriteHD | ( | le_spi_DeviceHandleRef_t | handle, |
const uint8_t * | writeDataPtr, | ||
size_t | writeDataNumElements | ||
) |
SPI Write for Half Duplex Communication
- Returns
- LE_OK on success or LE_FAULT on failure.
- Parameters
-
[in] handle Handle for the SPI master to perform the write on [in] writeDataPtr TX command/address being sent to slave with size [in] writeDataNumElements
le_result_t le_spi_WriteReadFD | ( | le_spi_DeviceHandleRef_t | handle, |
const uint8_t * | writeDataPtr, | ||
size_t | writeDataNumElements, | ||
uint8_t * | readDataPtr, | ||
size_t * | readDataNumElementsPtr | ||
) |
Simultaneous SPI Write and Read for full duplex communication
- Returns
- LE_OK on success or LE_FAULT on failure.
- Parameters
-
[in] handle Handle for the SPI master to perform full duplex write-read on [in] writeDataPtr TX command/address being sent to slave with size [in] writeDataNumElements [out] readDataPtr RX response from slave with same buffer size as TX [in,out] readDataNumElementsPtr
le_result_t le_spi_WriteReadHD | ( | le_spi_DeviceHandleRef_t | handle, |
const uint8_t * | writeDataPtr, | ||
size_t | writeDataNumElements, | ||
uint8_t * | readDataPtr, | ||
size_t * | readDataNumElementsPtr | ||
) |
Performs SPI WriteRead Half Duplex. You can send send Read command/ address of data to read.
- Returns
- LE_OK on success or LE_FAULT on failure.
- Parameters
-
[in] handle Handle for the SPI master to perform the write-read on [in] writeDataPtr TX command/address being sent to slave with size [in] writeDataNumElements [out] readDataPtr RX response from slave with number of bytes reserved [in,out] readDataNumElementsPtr