TOP Contributors

  1. MIKROE (2762 codes)
  2. Alcides Ramos (374 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (118 codes)
  5. Bugz Bensce (90 codes)
  6. S P (73 codes)
  7. dany (71 codes)
  8. MikroBUS.NET Team (35 codes)
  9. NART SCHINACKOW (34 codes)
  10. Armstrong Subero (27 codes)

Most Downloaded

  1. Timer Calculator (139242 times)
  2. FAT32 Library (71742 times)
  3. Network Ethernet Library (57115 times)
  4. USB Device Library (47428 times)
  5. Network WiFi Library (43082 times)
  6. FT800 Library (42403 times)
  7. GSM click (29835 times)
  8. mikroSDK (28072 times)
  9. PID Library (26885 times)
  10. microSD click (26198 times)
Libstock prefers package manager

Package Manager

We strongly encourage users to use Package manager for sharing their code on Libstock website, because it boosts your efficiency and leaves the end user with no room for error. [more info]

< Back
mikroSDK Library

Expand 17 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.2

mikroSDK Library: 2.0.0.0

Category: Port expander

Downloaded: 9 times

Not followed.

License: MIT license  

Expand 17 Click is a compact add-on board designed to expand the number of input/output pins in your system. This board features the TCAL6408, an 8-bit I/O expander from Texas Instruments, which communicates via the I2C protocol. The TCAL6408 features programmable output drive strength, latchable inputs, pull-up/pull-down resistors, and configurable open-drain or push-pull outputs, offering flexible and enhanced I/O performance with minimal power consumption and reduced EMI.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Expand 17 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Expand 17 Click" changes.

Do you want to report abuse regarding "Expand 17 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


Expand 17 Click

Expand 17 Click is a compact add-on board designed to expand the number of input/output pins in your system. This board features the TCAL6408, an 8-bit I/O expander from Texas Instruments, which communicates via the I2C protocol. The TCAL6408 features programmable output drive strength, latchable inputs, pull-up/pull-down resistors, and configurable open-drain or push-pull outputs, offering flexible and enhanced I/O performance with minimal power consumption and reduced EMI.

expand17_click.png

Click Product page


Click library

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

Software Support

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

Standard key functions :

  • expand17_cfg_setup Config Object Initialization function.

    void expand17_cfg_setup ( expand17_cfg_t *cfg );
  • expand17_init Initialization function.

    err_t expand17_init ( expand17_t *ctx, expand17_cfg_t *cfg );
  • expand17_default_cfg Click Default Configuration function.

    err_t expand17_default_cfg ( expand17_t *ctx );

Example key functions :

  • expand17_set_io_dir This function is used to set input or output direction of pins.

    err_t expand17_set_io_dir ( expand17_t *ctx, uint8_t input_pins, uint8_t output_pins );
  • expand17_set_output_state This function is used to set output state of the pins.

    err_t expand17_set_output_state ( expand17_t *ctx, uint8_t clr_mask, uint8_t set_mask );
  • expand17_get_input_state This function is used to get state of the input pins.

    err_t expand17_get_input_state ( expand17_t *ctx, uint8_t *input_state );

Example Description

This example demonstrates the use of Expand 17 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 pins as output ( IO5, IO6, IO7 and IO8 ) and the half of the pins as inputs ( IO1, IO2, IO3 and IO4 ).


void application_init ( void ) 
{
    log_cfg_t log_cfg;  /**< Logger config object. */
    expand17_cfg_t expand17_cfg;  /**< Click config object. */

    /** 
     * Logger initialization.
     * Default baud rate: 115200
     * Default log level: LOG_LEVEL_DEBUG
     * @note If USB_UART_RX and USB_UART_TX 
     * are defined as HAL_PIN_NC, you will 
     * need to define them manually for log to work. 
     * See @b LOG_MAP_USB_UART macro definition for detailed explanation.
     */
    LOG_MAP_USB_UART( log_cfg );
    log_init( &logger, &log_cfg );
    log_info( &logger, " Application Init " );

    // Click initialization.
    expand17_cfg_setup( &expand17_cfg );
    EXPAND17_MAP_MIKROBUS( expand17_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == expand17_init( &expand17, &expand17_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    if ( EXPAND17_ERROR == expand17_default_cfg ( &expand17 ) )
    {
        log_error( &logger, " Default configuration." );
        for ( ; ; );
    }

    log_info( &logger, " Application Task " );
}

Application Task

Sets the state of the output pins and then reads the status of the input pins and displays the results on the USB UART approximately every 2 seconds.

void application_task ( void ) 
{
    uint8_t input_state = 0;

    log_printf( &logger, " Setting output pins state: HIGH \r\n" );
    log_printf( &logger, " = = = = = = = = = = = = = = = = = \r\n" );
    expand17_set_output_state( &expand17, EXPAND17_NO_IO_PIN_MASK, EXPAND17_IO_5_PIN_MASK | 
                                          EXPAND17_IO_6_PIN_MASK | EXPAND17_IO_7_PIN_MASK | 
                                          EXPAND17_IO_8_PIN_MASK );

    log_printf( &logger, " State of input pins: \r\n" );
    log_printf( &logger, " = = = = = = = = = = = = = = = = = \r\n" );
    expand17_get_input_state( &expand17, &input_state );
    if ( input_state & EXPAND17_IO_1_PIN_MASK )
    {
        log_printf( &logger, " IO1 - HIGH \r\n" );
    }
    else
    {
        log_printf( &logger, " IO1 - LOW \r\n" );
    }
    if ( input_state & EXPAND17_IO_2_PIN_MASK )
    {
        log_printf( &logger, " IO2 - HIGH \r\n" );
    }
    else
    {
        log_printf( &logger, " IO2 - LOW \r\n" );
    }
    if ( input_state & EXPAND17_IO_3_PIN_MASK )
    {
        log_printf( &logger, " IO3 - HIGH \r\n" );
    }
    else
    {
        log_printf( &logger, " IO3 - LOW \r\n" );
    }
    if ( input_state & EXPAND17_IO_4_PIN_MASK )
    {
        log_printf( &logger, " IO4 - HIGH \r\n" );
    }
    else
    {
        log_printf( &logger, " IO4 - LOW \r\n" );
    }
    log_printf( &logger, " = = = = = = = = = = = = = = = = = \r\n" );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );

    log_printf( &logger, " Setting output pins state: LOW \r\n" );
    log_printf( &logger, " = = = = = = = = = = = = = = = = = \r\n" );
    expand17_set_output_state( &expand17, EXPAND17_IO_5_PIN_MASK | EXPAND17_IO_6_PIN_MASK | 
                                          EXPAND17_IO_7_PIN_MASK | EXPAND17_IO_8_PIN_MASK, 
                                          EXPAND17_NO_IO_PIN_MASK );

    log_printf( &logger, " State of input pins: \r\n" );
    log_printf( &logger, " = = = = = = = = = = = = = = = = = \r\n" );
    expand17_get_input_state( &expand17, &input_state );
    if ( input_state & EXPAND17_IO_1_PIN_MASK )
    {
        log_printf( &logger, " IO1 - HIGH \r\n" );
    }
    else
    {
        log_printf( &logger, " IO1 - LOW \r\n" );
    }
    if ( input_state & EXPAND17_IO_2_PIN_MASK )
    {
        log_printf( &logger, " IO2 - HIGH \r\n" );
    }
    else
    {
        log_printf( &logger, " IO2 - LOW \r\n" );
    }
    if ( input_state & EXPAND17_IO_3_PIN_MASK )
    {
        log_printf( &logger, " IO3 - HIGH \r\n" );
    }
    else
    {
        log_printf( &logger, " IO3 - LOW \r\n" );
    }
    if ( input_state & EXPAND17_IO_4_PIN_MASK )
    {
        log_printf( &logger, " IO4 - HIGH \r\n" );
    }
    else
    {
        log_printf( &logger, " IO4 - LOW \r\n" );
    }
    log_printf( &logger, " = = = = = = = = = = = = = = = = = \r\n" );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );
}

Note

In order for this example to work as intended it is necessary to connect the input and output pins eg. IO1 and IO5, IO2 and IO6 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.Expand17

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.


ALSO FROM THIS AUTHOR

GNSS MAX Click

0

GNSS MAX Click is a compact add-on board that provides fast positioning capability. This board features the MAX-M10S, an ultra-low-power GNSS receiver for high-performance asset-tracking from u-blox. The MAX-M10S supports the concurrent reception of four GNSS (GPS, GLONASS, Galileo, and BeiDou), which maximizes the position availability, particularly under challenging conditions such as in deep urban canyons. It is built on the u-blox M10 GNSS platform, which provides exceptional sensitivity and acquisition times for all L1 GNSS systems. It also comes with a configurable host interface, and advanced jamming and spoofing detection.

[Learn More]

Stepper 23 Click

0

Stepper 23 Click is a compact add-on board designed to drive small stepping motors in consumer electronics and industrial equipment applications. This board features the TB67S569FTG, a BiCD constant-current 2-phase bipolar stepping motor driver IC from Toshiba Semiconductor. Key features include a PWM chopper-type 2-phase bipolar drive system, high withstand voltage of up to 34V operating, and a maximum operating current of 1.8A per phase. The board also integrates safety mechanisms such as over-temperature, over-current, and low-supply voltage detection. Additional control is provided by the PCA9555A port expander via I2C, enabling functions like decay and torque modes, step resolution settings, and many more.

[Learn More]

IoT ExpressLink 2 Click

0

IoT ExpressLink 2 Click is a compact add-on board that allows users to connect to IoT ExpressLink services easily and securely interact with cloud applications and other services. This board features the SARA-R510AWS, an LTE-M AWS IoT EsxpressLink module from u-blox. It supports a comprehensive set of 3GPP Rel. 14 features that are relevant for IoT applications, like improvements to power consumption, coverage, data rate, mobility, and positioning. They are 5G-ready, meaning customers will be able to (software) upgrade their deployed devices once 5G LTE has been fully rolled out by mobile operators, greatly improving end-product scalability and lifetime.

[Learn More]