SPI Extend click
SPI Extend Click is a compact add-on board for applications that require extending the SPI communication bus over a long distance. This board features the LTC4332, an SPI slave extender device, from Analog Devices. Using a ±60V fault protected differential transceiver, the LTC4332 can transmit SPI data, including an interrupt signal, up to 2MHz over two twisted-pair cables.
click Product page
Click library
- Author : Jelena Milosavljevic
- Date : Jul 2021.
- Type : SPI type
Software Support
We provide a library for the SPIExtend Click as well as a demo application (example), developed using MikroElektronika compilers. The demo can run on all the main MikroElektronika development boards.
Package can be downloaded/installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Library Description
This library contains API for SPIExtend Click driver.
Standard key functions :
spiextend_cfg_setup
Config Object Initialization function.
void spiextend_cfg_setup(spiextend_cfg_t *cfg)
SPI Extend configuration object setup function.
SPI Extend Click configuration object.
Definition spiextend.h:232
spiextend_init
Initialization function.
err_t spiextend_init(spiextend_t *ctx, spiextend_cfg_t *cfg)
SPI Extend initialization function.
SPI Extend Click context object.
Definition spiextend.h:211
spiextend_default_cfg
Click Default Configuration function.
err_t spiextend_default_cfg(spiextend_t *ctx)
SPI Extend default configuration function.
Example key functions :
spiextend_get_config
Function get configuration of the LTC4332 SPI Extender Over Rugged Differential Link on the SPI Extend click board.
void spiextend_get_config(spiextend_t *ctx, spiextend_config_data_t *config_data)
SPI Extend get the configuration function.
SPI Extend Click configuration data.
Definition spiextend.h:257
spiextend_set_config
Function set configuration of the LTC4332 SPI Extender Over Rugged Differential Link on the SPI Extend click board.
void spiextend_set_config(spiextend_t *ctx, spiextend_config_data_t config_data)
SPI Extend set the configuration function.
spiextend_get_status
Function set configuration of the LTC4332 SPI Extender Over Rugged Differential Link on the SPI Extend click board.
void spiextend_get_status(spiextend_t *ctx, spiextend_status_data_t *status_data)
SPI Extend get the status function.
SPI Extend Click status data.
Definition spiextend.h:272
Example Description
In this example, if the connection is established, we read Accel axis of the connected Accel 14 Click boards to the SPI Extend Click ( Remote Mode ) which is connected by a LAN cable to
SPI Extend Click ( Local Mode ) placed in the mikroBUS 1. Results are being sent to the Usart Terminal where you can track their changes. All data logs write on USB uart changes for every 1 sec.
The demo application is composed of two sections :
Application Init
Initializes SPI, sets INT pin as input and AN, RST, CS nad PWM pins as outputs and begins to write log. Also, initialization driver enables - SPI, set default configuration of the Accel 14 Click
connected to the SPI Extend Click ( Remote Mode ).
log_cfg_t log_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init \r\n" );
if ( SPI_MASTER_ERROR == init_flag ) {
log_error( &logger, " Application Init Error. \r\n" );
log_info( &logger, " Please, run program again... \r\n" );
for ( ; ; );
}
log_printf( &logger, "---------------------\r\n" );
log_printf( &logger, " SPI Extend Click \r\n" );
log_printf( &logger, "---------------------\r\n" );
Delay_ms ( 100 );
log_printf( &logger, " LINK : " );
log_printf( &logger, " INT : " );
log_printf( &logger, " Remote INT : " );
log_printf( &logger, "---------------------\r\n" );
Delay_ms ( 100 );
log_printf( &logger, " >>> Accel 14 <<< \r\n" );
log_printf( &logger, " Set default config. \r\n" );
Delay_ms ( 100 );
Delay_ms ( 100 );
log_printf( &logger, "---------------------\r\n" );
log_printf( &logger, " Acceleration data: \r\n" );
log_printf( &logger, "---------------------\r\n" );
Delay_ms ( 100 );
log_info( &logger, " Application Task \r\n" );
}
#define SPIEXTEND_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition spiextend.h:193
#define SPIEXTEND_ACCEL14_REG_CTRL1_XL
Definition spiextend.h:87
#define SPIEXTEND_ACCEL14_REG_CTRL3_C
Definition spiextend.h:88
#define SPIEXTEND_ACCEL14_CTRL3_C_INT_ACTIVE_HIGH
Definition spiextend.h:125
#define SPIEXTEND_ACCEL14_CTRL3_C_IF_INC_ENABLE
Definition spiextend.h:128
#define SPIEXTEND_ACCEL14_CTRL1_XL_HIGH_RES_FS
Definition spiextend.h:121
#define SPIEXTEND_SLAVE_SELECT_SS1
SPI Extend slave select.
Definition spiextend.h:148
#define SPIEXTEND_ACCEL14_CTRL3_C_SW_RESET_DIS
Definition spiextend.h:129
#define SPIEXTEND_ACCEL14_CTRL1_XL_POWER_UP
SPI Extend description setting for Accel 14 config.
Definition spiextend.h:120
#define SPIEXTEND_ACCEL14_SPI_WRITE
SPI Extend Accel 14 communication.
Definition spiextend.h:135
#define SPIEXTEND_ACCEL14_CTRL1_XL_GSEL_4G
Definition spiextend.h:122
#define SPIEXTEND_ACCEL14_CTRL3_C_BOOT_NORMAL
Definition spiextend.h:123
#define SPIEXTEND_ACCEL14_CTRL3_C_BDU_READ_UPDATE
Definition spiextend.h:124
#define SPIEXTEND_ACCEL14_CTRL3_C_PP_OD_PUSH_PULL
Definition spiextend.h:126
#define SPIEXTEND_ACCEL14_CTRL3_C_SIM_SPI_4_WIRE
Definition spiextend.h:127
void spiextend_rmt_write(spiextend_t *ctx, uint8_t reg, uint8_t tx_data, uint8_t sel_slave)
SPI Extend generic write data in Remote Mode function.
void spiextend_display_status(uint8_t check_status)
SPI Extend check display status function.
Definition main.c:202
void application_init(void)
Definition main.c:57
spiextend_status_data_t spiextend_status
Definition main.c:39
uint8_t speed_idx
Definition spiextend.h:276
uint8_t nlink
Definition spiextend.h:273
uint8_t nint
Definition spiextend.h:274
uint8_t rmt_nint
Definition spiextend.h:275
Application Task
If the click is connected properly then the status becomes active and the X-axis coordinate is printed first on the UART terminal, then Y and finally Z. After 1s the process is repeated.
In case an error has occurred, printed "LINK is not established" on UART Terminal.
Delay_ms ( 10 );
log_printf( &logger, " Accel X : %d \r\n", axis );
Delay_ms ( 10 );
log_printf( &logger, " Accel Y : %d \r\n", axis );
Delay_ms ( 10 );
log_printf( &logger, " Accel Z : %d \r\n", axis );
log_printf( &logger, "---------------------\r\n" );
Delay_ms ( 1000 );
}
else {
log_printf( &logger, " LINK not established\r\n" );
log_printf( &logger, "---------------------\r\n" );
Delay_ms ( 1000 );
}
}
#define SPIEXTEND_ACCEL14_REG_OUTY_L_A
Definition spiextend.h:93
#define SPIEXTEND_ACCEL14_REG_OUTZ_L_A
Definition spiextend.h:95
#define SPIEXTEND_ACCEL14_REG_OUTX_L_A
Definition spiextend.h:91
#define SPIEXTEND_STATUS_ACTIVE
SPI Extend status.
Definition spiextend.h:113
void application_task(void)
Definition main.c:135
void spiextend_accel14_get_axis(uint8_t axis_out_reg)
SPI Extend reading axis function.
Definition main.c:183
The full application code, and ready to use projects can be installed directly from NECTO Studio Package Manager(recommended way), downloaded from our LibStock™ or found on Mikroe github account.
Other Mikroe Libraries used in the example:
- MikroSDK.Board
- MikroSDK.Log
- Click.SPIExtend
Additional notes and informations
Depending on the development board you are using, you may need USB UART click, USB UART 2 Click or RS232 Click to connect to your PC, for development systems with no UART to USB interface available on the board. The terminal available in all MikroElektronika compilers, or any other terminal application of your choice, can be used to read the message.