expand15 2.1.0.0
Main Page

Expand 15 click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

  • Author : Stefan Ilic
  • Date : Mar 2023.
  • Type : I2C type

Software Support

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

Standard key functions :

Example key functions :

Example Description

This example demonstrates the use of Expand 15 click board by setting and reading

the ports state.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the click default configuration which sets

half of the port 0 and port 1 pins as output ( P00, P02, P04, P06, P10, P12, P14 and P16) and the half of the port 0 and port 1 pins as inputs ( P01, P03, P05, P07, P11, P13, P15 and P17).

void application_init ( void )
{
log_cfg_t log_cfg;
expand15_cfg_t expand15_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
expand15_cfg_setup( &expand15_cfg );
EXPAND15_MAP_MIKROBUS( expand15_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == expand15_init( &expand15, &expand15_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( EXPAND15_ERROR == expand15_default_cfg ( &expand15 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
log_printf( &logger, "- - - - - - - - - - - - - - - - - - - - - - - - - - \r\n" );
}
@ EXPAND15_ERROR
Definition: expand15.h:210
#define EXPAND15_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: expand15.h:157
void application_init(void)
Definition: main.c:35

Application Task

Sets the state of the output pins of one port and then reads the status of input pins of that port

and displays the results on the USB UART approximately 2 seconds.

void application_task ( void )
{
uint8_t output_pin_state;
uint8_t input_pin_state;
// Setting port0 oputput pin ( P00, P02, P04 and P06 ) to high
expand15_set_output_pins_state( &expand15, EXPAND15_PORT_0, output_pin_state );
Delay_ms( 10 );
// Checking state of the input pins on port0
expand15_get_input_pins_state( &expand15, EXPAND15_PORT_0, &input_pin_state );
log_printf( &logger, "OUTPUT PINS HIGH \r\n" );
log_printf( &logger, "INPUT PINS |" );
log_printf( &logger, " P01 : %c |", ( ( input_pin_state & EXPAND15_PIN_01_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P03 : %c |", ( ( input_pin_state & EXPAND15_PIN_03_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P05 : %c |", ( ( input_pin_state & EXPAND15_PIN_05_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P07 : %c \r\n", ( ( input_pin_state & EXPAND15_PIN_07_MASK ) ? 'H' : 'L' ) );
Delay_ms( 500 );
// Setting port0 oputput pin ( P00, P02, P04 and P06 ) to low
output_pin_state = EXPAND15_ALL_PINS_OFF;
expand15_set_output_pins_state( &expand15, EXPAND15_PORT_0, output_pin_state );
Delay_ms( 10 );
// Checking state of the input pins on port0
expand15_get_input_pins_state( &expand15, EXPAND15_PORT_0, &input_pin_state );
log_printf( &logger, "OUTPUT PINS LOW \r\n" );
log_printf( &logger, "INPUT PINS |" );
log_printf( &logger, " P01 : %c |", ( ( input_pin_state & EXPAND15_PIN_01_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P03 : %c |", ( ( input_pin_state & EXPAND15_PIN_03_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P05 : %c |", ( ( input_pin_state & EXPAND15_PIN_05_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P07 : %c \r\n", ( ( input_pin_state & EXPAND15_PIN_07_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, "- - - - - - - - - - - - - - - - - - - - - - - - - - \r\n" );
Delay_ms( 2000 );
// Setting port1 oputput pin ( P10, P12, P14 and P01 ) to high
expand15_set_output_pins_state( &expand15, EXPAND15_PORT_1, output_pin_state );
Delay_ms( 10 );
// Checking state of the input pins on port1
expand15_get_input_pins_state( &expand15, EXPAND15_PORT_1, &input_pin_state );
log_printf( &logger, "OUTPUT PINS HIGH \r\n" );
log_printf( &logger, "INPUT PINS |" );
log_printf( &logger, " P11 : %c |", ( ( input_pin_state & EXPAND15_PIN_11_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P13 : %c |", ( ( input_pin_state & EXPAND15_PIN_13_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P15 : %c |", ( ( input_pin_state & EXPAND15_PIN_15_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P17 : %c \r\n", ( ( input_pin_state & EXPAND15_PIN_17_MASK ) ? 'H' : 'L' ) );
Delay_ms( 500 );
// Setting port1 oputput pin ( P10, P12, P14 and P16 ) to low
output_pin_state = EXPAND15_ALL_PINS_OFF;
expand15_set_output_pins_state( &expand15, EXPAND15_PORT_1, output_pin_state );
Delay_ms( 10 );
// Checking state of the input pins on port1
expand15_get_input_pins_state( &expand15, EXPAND15_PORT_1, &input_pin_state );
log_printf( &logger, "OUTPUT PINS LOW \r\n" );
log_printf( &logger, "INPUT PINS |" );
log_printf( &logger, " P11 : %c |", ( ( input_pin_state & EXPAND15_PIN_11_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P13 : %c |", ( ( input_pin_state & EXPAND15_PIN_13_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P15 : %c |", ( ( input_pin_state & EXPAND15_PIN_15_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, " P17 : %c \r\n", ( ( input_pin_state & EXPAND15_PIN_17_MASK ) ? 'H' : 'L' ) );
log_printf( &logger, "- - - - - - - - - - - - - - - - - - - - - - - - - - \r\n" );
Delay_ms( 2000 );
}
#define EXPAND15_PIN_17_MASK
Definition: expand15.h:117
#define EXPAND15_PIN_14_MASK
Definition: expand15.h:114
#define EXPAND15_PIN_00_MASK
Expand 15 description setting.
Definition: expand15.h:102
#define EXPAND15_PORT_1
Definition: expand15.h:120
#define EXPAND15_PIN_10_MASK
Definition: expand15.h:110
#define EXPAND15_PIN_11_MASK
Definition: expand15.h:111
#define EXPAND15_PIN_04_MASK
Definition: expand15.h:106
#define EXPAND15_PIN_15_MASK
Definition: expand15.h:115
#define EXPAND15_PORT_0
Definition: expand15.h:119
#define EXPAND15_PIN_06_MASK
Definition: expand15.h:108
#define EXPAND15_PIN_12_MASK
Definition: expand15.h:112
#define EXPAND15_PIN_05_MASK
Definition: expand15.h:107
#define EXPAND15_PIN_01_MASK
Definition: expand15.h:103
#define EXPAND15_PIN_03_MASK
Definition: expand15.h:105
#define EXPAND15_PIN_02_MASK
Definition: expand15.h:104
#define EXPAND15_PIN_16_MASK
Definition: expand15.h:116
#define EXPAND15_PIN_07_MASK
Definition: expand15.h:109
#define EXPAND15_ALL_PINS_OFF
Definition: expand15.h:131
#define EXPAND15_PIN_13_MASK
Definition: expand15.h:113
void application_task(void)
Definition: main.c:73

Note

In order for this example to work as intended it is necessary to connect the input and output pins

eg. P00 and P01, P02 and P03 etc. Floating input pins will be shown as a high state.

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

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. UART terminal is available in all MikroElektronika compilers.