Common IO - basic v1.0.0
Common IO - basic v1.0.0 Library
 
Loading...
Searching...
No Matches
iot_spi.h
Go to the documentation of this file.
1/*
2 * Common IO - basic V1.0.0
3 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * http://aws.amazon.com/freertos
23 * http://www.FreeRTOS.org
24 */
25
30#ifndef _IOT_SPI_H_
31#define _IOT_SPI_H_
32
33/* Standard includes. */
34#include <stdint.h>
35#include <stddef.h>
36
45#define IOT_SPI_SUCCESS ( 0 )
46#define IOT_SPI_INVALID_VALUE ( 1 )
47#define IOT_SPI_WRITE_FAILED ( 2 )
48#define IOT_SPI_READ_FAILED ( 3 )
49#define IOT_SPI_TRANSFER_ERROR ( 4 )
50#define IOT_SPI_BUS_BUSY ( 5 )
51#define IOT_SPI_NOTHING_TO_CANCEL ( 6 )
52#define IOT_SPI_FUNCTION_NOT_SUPPORTED ( 7 )
58typedef enum
59{
65
70typedef enum
71{
77
81typedef enum
82{
86
90typedef enum
91{
97
104typedef struct IotSPIMasterConfig
105{
106 uint32_t ulFreq;
109 uint8_t ucDummyValue;
111
115struct IotSPIDescriptor;
116
122typedef struct IotSPIDescriptor * IotSPIHandle_t;
123
128 void * pvSPIparam );
129
143IotSPIHandle_t iot_spi_open( int32_t lSPIInstance );
144
160void iot_spi_set_callback( IotSPIHandle_t const pxSPIPeripheral,
161 IotSPICallback_t xCallback,
162 void * pvUserContext );
163
205int32_t iot_spi_ioctl( IotSPIHandle_t const pxSPIPeripheral,
206 IotSPIIoctlRequest_t xSPIRequest,
207 void * const pvBuffer );
208
234int32_t iot_spi_read_sync( IotSPIHandle_t const pxSPIPeripheral,
235 uint8_t * const pvBuffer,
236 size_t xBytes );
237
269int32_t iot_spi_read_async( IotSPIHandle_t const pxSPIPeripheral,
270 uint8_t * const pvBuffer,
271 size_t xBytes );
272
297int32_t iot_spi_write_sync( IotSPIHandle_t const pxSPIPeripheral,
298 uint8_t * const pvBuffer,
299 size_t xBytes );
300
331int32_t iot_spi_write_async( IotSPIHandle_t const pxSPIPeripheral,
332 uint8_t * const pvBuffer,
333 size_t xBytes );
334
357int32_t iot_spi_transfer_sync( IotSPIHandle_t const pxSPIPeripheral,
358 uint8_t * const pvTxBuffer,
359 uint8_t * const pvRxBuffer,
360 size_t xBytes );
361
387int32_t iot_spi_transfer_async( IotSPIHandle_t const pxSPIPeripheral,
388 uint8_t * const pvTxBuffer,
389 uint8_t * const pvRxBuffer,
390 size_t xBytes );
391
403int32_t iot_spi_close( IotSPIHandle_t const pxSPIPeripheral );
404
419int32_t iot_spi_cancel( IotSPIHandle_t const pxSPIPeripheral );
420
432int32_t iot_spi_select_slave( int32_t lSPIInstance,
433 int32_t lSPISlave );
434
438/* end of group iot_spi */
439
440#endif /* _IOT_SPI_H_ */
int32_t iot_spi_cancel(IotSPIHandle_t const pxSPIPeripheral)
This function is used to cancel the current operation in progress, if the underlying driver allows th...
int32_t iot_spi_select_slave(int32_t lSPIInstance, int32_t lSPISlave)
This function is used to select spi slave.
IotSPIMode_t
The SPI Modes denoting the clock polarity and clock phase.
Definition: iot_spi.h:71
#define IOT_SPI_READ_FAILED
Definition: iot_spi.h:48
IotSPITransactionStatus_t
The SPI return status from Async operations.
Definition: iot_spi.h:59
int32_t iot_spi_transfer_async(IotSPIHandle_t const pxSPIPeripheral, uint8_t *const pvTxBuffer, uint8_t *const pvRxBuffer, size_t xBytes)
The SPI master starts a asynchronous transfer between master and the slave.
int32_t iot_spi_transfer_sync(IotSPIHandle_t const pxSPIPeripheral, uint8_t *const pvTxBuffer, uint8_t *const pvRxBuffer, size_t xBytes)
The SPI master starts a synchronous transfer between master and the slave.
struct IotSPIDescriptor * IotSPIHandle_t
IotSPIHandle_t is the handle type returned by calling iot_spi_open(). This is initialized in open and...
Definition: iot_spi.h:122
void(* IotSPICallback_t)(IotSPITransactionStatus_t xStatus, void *pvSPIparam)
The callback function for completion of SPI operation.
Definition: iot_spi.h:127
void iot_spi_set_callback(IotSPIHandle_t const pxSPIPeripheral, IotSPICallback_t xCallback, void *pvUserContext)
Sets the application callback to be called on completion of an operation.
int32_t iot_spi_read_sync(IotSPIHandle_t const pxSPIPeripheral, uint8_t *const pvBuffer, size_t xBytes)
The SPI master starts reading from the slave synchronously.
int32_t iot_spi_read_async(IotSPIHandle_t const pxSPIPeripheral, uint8_t *const pvBuffer, size_t xBytes)
The SPI master starts reading from the slave asynchronously.
#define IOT_SPI_WRITE_FAILED
Definition: iot_spi.h:47
IotSPIHandle_t iot_spi_open(int32_t lSPIInstance)
Initializes SPI peripheral with default configuration.
int32_t iot_spi_write_sync(IotSPIHandle_t const pxSPIPeripheral, uint8_t *const pvBuffer, size_t xBytes)
The SPI master starts transmission of data to the slave synchronously.
int32_t iot_spi_write_async(IotSPIHandle_t const pxSPIPeripheral, uint8_t *const pvBuffer, size_t xBytes)
The SPI master starts transmission of data to the slave asynchronously.
int32_t iot_spi_ioctl(IotSPIHandle_t const pxSPIPeripheral, IotSPIIoctlRequest_t xSPIRequest, void *const pvBuffer)
Configures the SPI port with user configuration.
int32_t iot_spi_close(IotSPIHandle_t const pxSPIPeripheral)
Stops the ongoing operation on SPI bus and de-initializes the SPI peripheral.
IotSPIBitOrder_t
The bit order of the data transmission.
Definition: iot_spi.h:82
#define IOT_SPI_TRANSFER_ERROR
Definition: iot_spi.h:49
IotSPIIoctlRequest_t
Ioctl request for SPI HAL.
Definition: iot_spi.h:91
#define IOT_SPI_SUCCESS
The return codes for the methods in SPI.
Definition: iot_spi.h:45
@ eSPIMode1
Definition: iot_spi.h:73
@ eSPIMode2
Definition: iot_spi.h:74
@ eSPIMode0
Definition: iot_spi.h:72
@ eSPIMode3
Definition: iot_spi.h:75
@ eSPIReadError
Definition: iot_spi.h:62
@ eSPITransferError
Definition: iot_spi.h:63
@ eSPISuccess
Definition: iot_spi.h:60
@ eSPIWriteError
Definition: iot_spi.h:61
@ eSPIMSBFirst
Definition: iot_spi.h:83
@ eSPILSBFirst
Definition: iot_spi.h:84
@ eSPISetMasterConfig
Definition: iot_spi.h:92
@ eSPIGetRxNoOfbytes
Definition: iot_spi.h:95
@ eSPIGetTxNoOfbytes
Definition: iot_spi.h:94
@ eSPIGetMasterConfig
Definition: iot_spi.h:93
The configuration parameters for SPI Master.
Definition: iot_spi.h:105
IotSPIMode_t eMode
Definition: iot_spi.h:107
IotSPIBitOrder_t eSetBitOrder
Definition: iot_spi.h:108
uint32_t ulFreq
Definition: iot_spi.h:106
uint8_t ucDummyValue
Definition: iot_spi.h:109