Linduino  1.3.0
Linear Technology Arduino-Compatible Demonstration Board
platform_drivers.h File Reference

Header file of Generic Platform Drivers. More...

Detailed Description

Header file of Generic Platform Drivers.

Author
DBogdan (drago.nosp@m.s.bo.nosp@m.gdan@.nosp@m.anal.nosp@m.og.co.nosp@m.m)

Copyright 2017(c) Analog Devices, Inc.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of Analog Devices, Inc. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
  • The use of this software may or may not infringe the patent rights of one or more patent holders. This license does not release you from the requirement that you obtain separate licenses from these patent holders to use this software.
  • Use of the software either in source or binary form, must be run on or directly connected to an Analog Devices Inc. component.

THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file platform_drivers.h.

Go to the source code of this file.

Data Structures

struct  i2c_init_param
 
struct  i2c_desc
 
struct  spi_init_param
 
struct  spi_desc
 
struct  gpio_desc
 

Functions

int32_t i2c_init (i2c_desc **desc, const struct i2c_init_param *param)
 Initialize the I2C communication peripheral. More...
 
int32_t i2c_remove (i2c_desc *desc)
 Free the resources allocated by i2c_init(). More...
 
int32_t i2c_write (i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
 Write data to a slave device. More...
 
int32_t i2c_read (i2c_desc *desc, uint8_t *data, uint8_t bytes_number, uint8_t stop_bit)
 Read data from a slave device. More...
 
int32_t spi_init (spi_desc **desc, const struct spi_init_param *param)
 Initialize the SPI communication peripheral. More...
 
int32_t spi_remove (spi_desc *desc)
 Free the resources allocated by spi_init(). More...
 
int32_t spi_write_and_read (spi_desc *desc, uint8_t *data, uint8_t bytes_number)
 Write and read data to/from SPI. More...
 
int32_t gpio_get (gpio_desc **desc, uint8_t gpio_number)
 Obtain the GPIO decriptor. More...
 
int32_t gpio_remove (gpio_desc *desc)
 Free the resources allocated by gpio_get(). More...
 
int32_t gpio_direction_input (gpio_desc *desc)
 Enable the input direction of the specified GPIO. More...
 
int32_t gpio_direction_output (gpio_desc *desc, uint8_t value)
 Enable the output direction of the specified GPIO. More...
 
int32_t gpio_get_direction (gpio_desc *desc, uint8_t *direction)
 Get the direction of the specified GPIO. More...
 
int32_t gpio_set_value (gpio_desc *desc, uint8_t value)
 Set the value of the specified GPIO. More...
 
int32_t gpio_get_value (gpio_desc *desc, uint8_t *value)
 Get the value of the specified GPIO. More...
 
void mdelay (uint32_t msecs)
 Generate miliseconds delay. More...
 
void quikeval_set_mux (uint8_t mux)
 Sets the Linduino MUX that selects SPI or I2C for the quikeval port. More...
 
void Wire_Connect ()
 Connects and initializes I2C. More...
 
uint8_t Wire_Write (unsigned char address, unsigned char *data, unsigned char length, unsigned char stop)
 Write I2C. More...
 
uint8_t Wire_Read (unsigned char address, unsigned char *data, unsigned char length, unsigned char stop)
 Read I2C. More...
 
void uartTX (char *buf)
 Enable SPI, matches spi_enable. More...
 

Macros

#define SUCCESS   0
 
#define FAILURE   -1
 
#define SPI_CPHA   0x01
 
#define SPI_CPOL   0x02
 
#define GPIO_OUT   0x01
 
#define GPIO_IN   0x00
 
#define GPIO_HIGH   0x01
 
#define GPIO_LOW   0x00
 
#define MUX_I2C   0
 
#define MUX_SPI   1
 

Typedefs

typedef enum i2c_type i2c_type
 
typedef struct i2c_init_param i2c_init_param
 
typedef struct i2c_desc i2c_desc
 
typedef enum spi_type spi_type
 
typedef struct spi_init_param spi_init_param
 

Enumerations

enum  i2c_type { GENERIC_I2C }
 
enum  spi_type { GENERIC_SPI }
 
enum  gpio_type { GENERIC_GPIO }
 

Function Documentation

◆ gpio_direction_input()

int32_t gpio_direction_input ( gpio_desc desc)

Enable the input direction of the specified GPIO.

Parameters
desc- The GPIO descriptor.
Returns
SUCCESS in case of success, FAILURE otherwise.

Definition at line 290 of file platform_drivers.cpp.

◆ gpio_direction_output()

int32_t gpio_direction_output ( gpio_desc desc,
uint8_t  value 
)

Enable the output direction of the specified GPIO.

Parameters
desc- The GPIO descriptor.
value- The value. Example: GPIO_HIGH GPIO_LOW
Returns
SUCCESS in case of success, FAILURE otherwise.

Definition at line 305 of file platform_drivers.cpp.

◆ gpio_get()

int32_t gpio_get ( gpio_desc **  desc,
uint8_t  gpio_number 
)

Obtain the GPIO decriptor.

Parameters
desc- The GPIO descriptor.
gpio_number- The number of the GPIO.
Returns
SUCCESS in case of success, FAILURE otherwise.

Definition at line 258 of file platform_drivers.cpp.

◆ gpio_get_direction()

int32_t gpio_get_direction ( gpio_desc desc,
uint8_t *  direction 
)

Get the direction of the specified GPIO.

Parameters
desc- The GPIO descriptor.
direction- The direction. Example: GPIO_OUT GPIO_IN
Returns
SUCCESS in case of success, FAILURE otherwise.

Definition at line 322 of file platform_drivers.cpp.

◆ gpio_get_value()

int32_t gpio_get_value ( gpio_desc desc,
uint8_t *  value 
)

Get the value of the specified GPIO.

Parameters
desc- The GPIO descriptor.
value- The value. Example: GPIO_HIGH GPIO_LOW
Returns
SUCCESS in case of success, FAILURE otherwise.

Definition at line 360 of file platform_drivers.cpp.

◆ gpio_remove()

int32_t gpio_remove ( gpio_desc desc)

Free the resources allocated by gpio_get().

Parameters
desc- The SPI descriptor.
Returns
SUCCESS in case of success, FAILURE otherwise.

Definition at line 276 of file platform_drivers.cpp.

◆ gpio_set_value()

int32_t gpio_set_value ( gpio_desc desc,
uint8_t  value 
)

Set the value of the specified GPIO.

Parameters
desc- The GPIO descriptor.
value- The value. Example: GPIO_HIGH GPIO_LOW
Returns
SUCCESS in case of success, FAILURE otherwise.

Definition at line 344 of file platform_drivers.cpp.

◆ i2c_init()

int32_t i2c_init ( i2c_desc **  desc,
const struct i2c_init_param param 
)

Initialize the I2C communication peripheral.

Parameters
desc- The I2C descriptor.
init_param- The structure that contains the I2C parameters.
Returns
SUCCESS in case of success, FAILURE otherwise.

Definition at line 60 of file platform_drivers.cpp.

◆ i2c_read()

int32_t i2c_read ( i2c_desc desc,
uint8_t *  data,
uint8_t  bytes_number,
uint8_t  stop_bit 
)

Read data from a slave device.

Parameters
desc- The I2C descriptor.
data- Buffer that will store the received data.
bytes_number- Number of bytes to read.
stop_bit- Stop condition control. Example: 0 - A stop condition will not be generated; 1 - A stop condition will be generated.
Returns
SUCCESS in case of success, FAILURE otherwise.

Definition at line 122 of file platform_drivers.cpp.

◆ i2c_remove()

int32_t i2c_remove ( i2c_desc desc)

Free the resources allocated by i2c_init().

Parameters
desc- The I2C descriptor.
Returns
SUCCESS in case of success, FAILURE otherwise.

Definition at line 89 of file platform_drivers.cpp.

◆ i2c_write()

int32_t i2c_write ( i2c_desc desc,
uint8_t *  data,
uint8_t  bytes_number,
uint8_t  stop_bit 
)

Write data to a slave device.

Parameters
desc- The I2C descriptor.
data- Buffer that stores the transmission data.
bytes_number- Number of bytes to write.
stop_bit- Stop condition control. Example: 0 - A stop condition will not be generated; 1 - A stop condition will be generated.
Returns
SUCCESS in case of success, FAILURE otherwise.

Definition at line 104 of file platform_drivers.cpp.

◆ mdelay()

void mdelay ( uint32_t  msecs)

Generate miliseconds delay.

Parameters
msecs- Delay in miliseconds.
Returns
None.

Definition at line 374 of file platform_drivers.cpp.

◆ quikeval_set_mux()

void quikeval_set_mux ( uint8_t  mux)

Sets the Linduino MUX that selects SPI or I2C for the quikeval port.

Parameters
mux- New mux selection Example: MUX_I2C - Enable I2C MUX_SPI - Enable SPI

Definition at line 465 of file platform_drivers.cpp.

◆ spi_init()

int32_t spi_init ( spi_desc **  desc,
const struct spi_init_param param 
)

Initialize the SPI communication peripheral.

Parameters
desc- The SPI descriptor.
init_param- The structure that contains the SPI parameters.
Returns
SUCCESS in case of success, FAILURE otherwise.

Definition at line 147 of file platform_drivers.cpp.

◆ spi_remove()

int32_t spi_remove ( spi_desc desc)

Free the resources allocated by spi_init().

Parameters
desc- The SPI descriptor.
Returns
SUCCESS in case of success, FAILURE otherwise.

Definition at line 186 of file platform_drivers.cpp.

◆ spi_write_and_read()

int32_t spi_write_and_read ( spi_desc desc,
uint8_t *  data,
uint8_t  bytes_number 
)

Write and read data to/from SPI.

Parameters
desc- The SPI descriptor.
data- The buffer with the transmitted/received data.
bytes_number- Number of bytes to write/read.
Returns
SUCCESS in case of success, FAILURE otherwise.

Definition at line 200 of file platform_drivers.cpp.

◆ uartTX()

void uartTX ( char *  buf)

Enable SPI, matches spi_enable.

Initialize SPI, matches spi_init

Connect to SPI, matches quikeval_spi_connect

Definition at line 483 of file platform_drivers.cpp.

◆ Wire_Connect()

void Wire_Connect ( )

Connects and initializes I2C.

Connects and initializes I2C.

Definition at line 390 of file platform_drivers.cpp.

◆ Wire_Read()

uint8_t Wire_Read ( unsigned char  address,
unsigned char *  data,
unsigned char  length,
unsigned char  stop 
)

Read I2C.

Read I2C.

Parameters
address- Address of device
data- Data read back
length- Length of data byte array to read
stop- Stop bit
Returns
Number of read bytes

Definition at line 436 of file platform_drivers.cpp.

◆ Wire_Write()

uint8_t Wire_Write ( unsigned char  address,
unsigned char *  data,
unsigned char  length,
unsigned char  stop 
)

Write I2C.

Write I2C.

Parameters
address- Address of device
data- Data to write, includes command
length- Length of data byte array
stop- Stop bit
Returns
Transmission acknowledged by device

Definition at line 406 of file platform_drivers.cpp.

Macro Definition Documentation

◆ FAILURE

#define FAILURE   -1

Definition at line 55 of file platform_drivers.h.

◆ GPIO_HIGH

#define GPIO_HIGH   0x01

Definition at line 63 of file platform_drivers.h.

◆ GPIO_IN

#define GPIO_IN   0x00

Definition at line 61 of file platform_drivers.h.

◆ GPIO_LOW

#define GPIO_LOW   0x00

Definition at line 64 of file platform_drivers.h.

◆ GPIO_OUT

#define GPIO_OUT   0x01

Definition at line 60 of file platform_drivers.h.

◆ MUX_I2C

#define MUX_I2C   0

Definition at line 66 of file platform_drivers.h.

◆ MUX_SPI

#define MUX_SPI   1

Definition at line 67 of file platform_drivers.h.

◆ SPI_CPHA

#define SPI_CPHA   0x01

Definition at line 57 of file platform_drivers.h.

◆ SPI_CPOL

#define SPI_CPOL   0x02

Definition at line 58 of file platform_drivers.h.

◆ SUCCESS

#define SUCCESS   0

Definition at line 54 of file platform_drivers.h.

Typedef Documentation

◆ i2c_desc

typedef struct i2c_desc i2c_desc

◆ i2c_init_param

◆ i2c_type

typedef enum i2c_type i2c_type

◆ spi_init_param

◆ spi_type

typedef enum spi_type spi_type

Enumeration Type Documentation

◆ gpio_type

enum gpio_type
Enumerator
GENERIC_GPIO 

Definition at line 120 of file platform_drivers.h.

◆ i2c_type

enum i2c_type
Enumerator
GENERIC_I2C 

Definition at line 73 of file platform_drivers.h.

◆ spi_type

enum spi_type
Enumerator
GENERIC_SPI 

Definition at line 91 of file platform_drivers.h.