FTDI APIs. More...
#include <stdio.h>
#include <stdlib.h>
#include "ftd2xx.h"
#include "libMPSSE_spi.h"
Go to the source code of this file.
Functions | |
int | ftdi_init (uint32 clock_rate, uint8 latency, int spi_mode, int cs_pin, int ss_default) |
FTDI interface initialisation. More... | |
int | ftdi_kill () |
FTDI destructor. More... | |
int | ftdi_print_channel_info () |
Prints FTDI channel information. More... | |
int | ftdi_open_channel (int channel_id) |
FTDI open channel. More... | |
int | ftdi_init_channel () |
Initialise opened channel. More... | |
int | ftdi_close_channel () |
Closes FTDI channel. More... | |
int | ftdi_read_stream (uint8 *buffer, int bytes) |
Read data stream from FTDI. More... | |
int | ftdi_write_stream (uint8 *buffer, int bytes) |
Write data stream to FTDI. More... | |
int | ftdi_readwrite (uint8 *inbuffer, uint8 *outbuffer, int bytes) |
Write and read data stream simultaneously. More... | |
Variables | |
int | gp_debug |
FTDI APIs.
int ftdi_close_channel | ( | ) |
Closes FTDI channel.
This function closes the channel previously opened by ftdi_open_channel() Should always be uses in pairs with ftdi_open_channel() to release unused resources
none |
int ftdi_init | ( | uint32 | clock_rate, |
uint8 | latency, | ||
int | spi_mode, | ||
int | cs_pin, | ||
int | ss_default | ||
) |
FTDI interface initialisation.
This function initialises FTDI interface with the following parameters
[in] | clock_rate | Clock rate of SPI interface |
[in] | latency | Latency in ms, typically 1ms for FT232H/FT2232H |
[in] | spi_mode | SPI mode 0 to 3. SPI mode defined by (CPOL,CPHA) |
[in] | cs_pin | SS pin on DBUSx |
[in] | ss_default | SS default value |
int ftdi_init_channel | ( | ) |
Initialise opened channel.
This function initialises the channel opened by ftdi_open_channel() This function should be called immediately after ftdi_open_channel() and before any other channel operation takes place
none |
int ftdi_kill | ( | ) |
FTDI destructor.
This function is the destructor of ftdi_init()
none |
int ftdi_open_channel | ( | int | channel_id | ) |
FTDI open channel.
This function opens a channel for communications Only one channel should be opened at a time with this library
[in] | channel_id | The ID of the channel to open |
int ftdi_print_channel_info | ( | ) |
Prints FTDI channel information.
This function prints FTDI channel information to screen for user to select the correct channel to communicate with
none |
int ftdi_read_stream | ( | uint8 * | buffer, |
int | bytes | ||
) |
Read data stream from FTDI.
This function reads a data stream from FTDI
[out] | *buffer | Buffer to store received data |
[in] | bytes | Number of bytes to be read |
int ftdi_readwrite | ( | uint8 * | inbuffer, |
uint8 * | outbuffer, | ||
int | bytes | ||
) |
Write and read data stream simultaneously.
This function writes a data stream to FTDI and reads from it simultaneously
[in] | *inbuffer | Buffer from which data will be read |
[out] | *outbuffer | Buffer to store data to write |
[in] | bytes | Number of bytes |
int ftdi_write_stream | ( | uint8 * | buffer, |
int | bytes | ||
) |
Write data stream to FTDI.
This function writes a data stream to FTDI
[in] | *buffer | Buffer from which data will be read |
[in] | bytes | Number of bytes to be read |