TOP Contributors

  1. MIKROE (2653 codes)
  2. Alcides Ramos (352 codes)
  3. Shawon Shahryiar (307 codes)
  4. jm_palomino (112 codes)
  5. Chisanga Mumba (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 (136736 times)
  2. FAT32 Library (69950 times)
  3. Network Ethernet Library (55941 times)
  4. USB Device Library (46266 times)
  5. Network WiFi Library (41886 times)
  6. FT800 Library (41170 times)
  7. GSM click (28983 times)
  8. PID Library (26413 times)
  9. mikroSDK (26360 times)
  10. microSD click (25376 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 16 click

Rating:

0

Author: MIKROE

Last Updated: 2024-04-03

Package Version: 2.1.0.4

mikroSDK Library: 2.0.0.0

Category: Port expander

Downloaded: 9 times

Not followed.

License: MIT license  

Expand 16 Click is a compact add-on board with a multi-port I/O expander. This board features the FLX6408, a fully configurable 8-bit GPIO expander from ON Semiconductor. It brings eight independently configurable input/output ports, with a 6mA output drive, when configured in the output mode.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Expand 16 click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Expand 16 click" changes.

Do you want to report abuse regarding "Expand 16 click".

  • Information
  • Comments (0)

mikroSDK Library Blog


Expand 16 click

Expand 16 Click is a compact add-on board with a multi-port I/O expander. This board features the FLX6408, a fully configurable 8-bit GPIO expander from ON Semiconductor. It brings eight independently configurable input/output ports, with a 6mA output drive, when configured in the output mode.

expand16_click.png

click Product page


Click library

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

Software Support

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

Standard key functions :

  • expand16_cfg_setup Config Object Initialization function.

    void expand16_cfg_setup ( expand16_cfg_t *cfg );
  • expand16_init Initialization function.

    err_t expand16_init ( expand16_t *ctx, expand16_cfg_t *cfg );
  • expand16_default_cfg Click Default Configuration function.

    err_t expand16_default_cfg ( expand16_t *ctx );

Example key functions :

  • expand16_write_reg Expand 16 register write function.

    err_t expand16_write_reg ( expand16_t *ctx, uint8_t reg, uint8_t data_in );
  • expand16_set_io_dir Expand 16 set pin input or output direction function.

    err_t expand16_set_io_dir ( expand16_t *ctx, uint8_t input_pins, uint8_t output_pins );
  • expand16_set_output_state Expand 16 set output pins state function.

    err_t expand16_set_output_state ( expand16_t *ctx, uint8_t clr_mask, uint8_t set_mask );

Example Description

This example demonstrates the use of Expand 16 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 pins as output ( GPIO4, GPIO5, GPIO6 and GPIO7 ) and the other half of the pins as inputs ( GPIO0, GPIO1, GPIO2 and GPIO3 ).


void application_init ( void ) 
{
    log_cfg_t log_cfg;              /**< Logger config object. */
    expand16_cfg_t expand16_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.
    expand16_cfg_setup( &expand16_cfg );
    EXPAND16_MAP_MIKROBUS( expand16_cfg, MIKROBUS_1 );
    if ( I2C_MASTER_ERROR == expand16_init( &expand16, &expand16_cfg ) ) 
    {
        log_error( &logger, " Communication init." );
        for ( ; ; );
    }

    uint8_t dev_id = 0;
    expand16_read_reg( &expand16, EXPAND16_REG_DEV_ID_AND_CTRL, &dev_id ); 
    if ( EXPAND16_DEVICE_ID != ( dev_id & EXPAND16_DEVICE_ID_MASK ) )
    {
        log_error( &logger, " Communication error." );
        for ( ; ; );
    }

    if ( EXPAND16_ERROR == expand16_default_cfg ( &expand16 ) )
    {
        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 input pins and displays the results on the USB UART approximately 2 seconds.

void application_task ( void ) 
{
    uint8_t tmp_data = 0;

    log_printf( &logger, "Output pins state: HIGH \r\n" );
    log_printf( &logger, "- - - - - - - - - - - - -\r\n" );
    expand16_set_output_state( &expand16, EXPAND16_PIN_MASK_NONE, EXPAND16_PIN_MASK_GPIO_4 | 
                                          EXPAND16_PIN_MASK_GPIO_5 | EXPAND16_PIN_MASK_GPIO_6 | 
                                          EXPAND16_PIN_MASK_GPIO_7 );
    expand16_read_reg( &expand16, EXPAND16_REG_INPUT_STATE, &tmp_data ); 
    show_input_pin_state( tmp_data );
    Delay_ms ( 1000 );
    Delay_ms ( 1000 );

    log_printf( &logger, "Output pins state: LOW \r\n" );
    log_printf( &logger, "- - - - - - - - - - - - -\r\n" );
    expand16_set_output_state( &expand16, EXPAND16_PIN_MASK_GPIO_4 | EXPAND16_PIN_MASK_GPIO_5 | 
                                          EXPAND16_PIN_MASK_GPIO_6 | EXPAND16_PIN_MASK_GPIO_7, 
                                          EXPAND16_PIN_MASK_NONE );
    expand16_read_reg( &expand16, EXPAND16_REG_INPUT_STATE, &tmp_data ); 
    show_input_pin_state( tmp_data );
    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. GPIO0 and GPIO4, GPIO1 and GPIO5 etc. Floating input pins will be shown as a low 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.Expand16

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

BLE TX click

0

BLE TX Click is a compact add-on board that contains a low-energy Bluetooth transmitter. This board features the AK1595, a Bluetooth 5.2 transmitter with incorporated proprietary algorithm software from AKM Semiconductor. The AK1595 transmitter simplifies wireless connectivity to a system with no need to develop complicated, proprietary microcontroller code. Bluetooth Low Energy compliant advertising transmission can be achieved by simply configuring the transmission power, data, and transmission start-trigger via the UART or I2C interface.

[Learn More]

Remote Relay Control Example (BeagleBone Black)

0

Control two relays remotely through simple web interface controller by NODE.js server. Using BeagleBone (Black), BeagleBone click SHIELD (http://www.mikroe.com/click/beaglebone-shield/) and Relay click (http://www.mikroe.com/click/relay/) board.

[Learn More]

nRF S click - Example

6

This is a sample program which demonstrates the use of nRF S click. Programmer uses RF module for communication between two development systems. Each module can be used as transmitter and receiver.

[Learn More]