expand8  2.0.0.0
Main Page

Expand 8 click

Expand 8 Click is a compact add-on board that contains a multi-port I/O expander with bi-directional input/outputs. This board features the MAX7317, 10-Port SPI-interfaced I/O expander with overvoltage and hot-insertion protection from Maxim Integrated.

click Product page


Click library

  • Author : Stefan Ilic
  • Date : Oct 2021.
  • Type : SPI type

Software Support

We provide a library for the Expand8 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 Expand8 Click driver.

Standard key functions :

Example key functions :

Example Description

This is an example that demonstrates the use of the Expand 8 click board.

The demo application is composed of two sections :

Application Init

Initialization driver enables - SPI, also write log.

void application_init ( void )
{
log_cfg_t log_cfg;
expand8_cfg_t expand8_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
expand8_cfg_setup( &expand8_cfg );
EXPAND8_MAP_MIKROBUS( expand8_cfg, MIKROBUS_1 );
err_t init_flag = expand8_init( &expand8, &expand8_cfg );
if ( SPI_MASTER_ERROR == init_flag ) {
log_error( &logger, " Application Init Error. " );
log_info( &logger, " Please, run program again... " );
for ( ; ; );
}
log_info( &logger, " Application Task " );
Delay_ms( 100 );
}

Application Task

This example is working by toggling each of 10 available ports every 1 second. Results are being sent to the Uart Terminal where you can track their changes.

void application_task ( void )
{
log_printf( &logger, " Port P%d - ON\r\n", ( uint16_t ) select_port );
log_printf( &logger, "- - - - - - - - - - -\r\n" );
Delay_ms( 1000 );
log_printf( &logger, " Port P%d - OFF\r\n", ( uint16_t ) select_port );
log_printf( &logger, "---------------------\r\n" );
Delay_ms( 1000 );
}
}

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.Expand8

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.


expand8_cfg_t
Expand 8 Click configuration object.
Definition: expand8.h:146
expand8_set_port
err_t expand8_set_port(expand8_t *ctx, uint8_t sel_port, uint8_t sel_imped)
Set port function.
expand8_t
Expand 8 Click context object.
Definition: expand8.h:133
EXPAND8_SET_HIGH_IMPEDANCE
#define EXPAND8_SET_HIGH_IMPEDANCE
Definition: expand8.h:84
application_task
void application_task(void)
Definition: main.c:64
EXPAND8_ADDR_OUT_LVL_PORT_P0
#define EXPAND8_ADDR_OUT_LVL_PORT_P0
Expand 8 port adresses.
Definition: expand8.h:60
EXPAND8_MAP_MIKROBUS
#define EXPAND8_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: expand8.h:120
select_port
uint8_t select_port
Definition: main.c:27
expand8_read_data
uint8_t expand8_read_data(expand8_t *ctx, uint8_t addr)
Generic read data function.
expand8_init
err_t expand8_init(expand8_t *ctx, expand8_cfg_t *cfg)
Expand 8 initialization function.
application_init
void application_init(void)
Definition: main.c:29
expand8_cfg_setup
void expand8_cfg_setup(expand8_cfg_t *cfg)
Expand 8 configuration object setup function.
EXPAND8_SET_LOW_IMPEDANCE
#define EXPAND8_SET_LOW_IMPEDANCE
Expand 8 impedance set values.
Definition: expand8.h:83
expand8_write_data
void expand8_write_data(expand8_t *ctx, uint8_t addr, uint8_t tx_data)
Generic write data function.
EXPAND8_ADDR_OUT_LVL_PORT_P9
#define EXPAND8_ADDR_OUT_LVL_PORT_P9
Definition: expand8.h:69