TOP Contributors

  1. MIKROE (2751 codes)
  2. Alcides Ramos (372 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 (139060 times)
  2. FAT32 Library (71592 times)
  3. Network Ethernet Library (56989 times)
  4. USB Device Library (47330 times)
  5. Network WiFi Library (43006 times)
  6. FT800 Library (42297 times)
  7. GSM click (29777 times)
  8. mikroSDK (27874 times)
  9. PID Library (26858 times)
  10. microSD click (26129 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

Volume 2 Click

Rating:

0

Author: MIKROE

Last Updated: 2024-10-31

Package Version: 2.1.0.15

mikroSDK Library: 2.0.0.0

Category: Signal processing

Downloaded: 225 times

Not followed.

License: MIT license  

Volume 2 Click is a compact add-on board that provides the user with complete digital volume control. This board features the NJU72341, a 2-channel I2C configurable electronic volume IC with external mute control from NJRC.

No Abuse Reported

Do you want to subscribe in order to receive notifications regarding "Volume 2 Click" changes.

Do you want to unsubscribe in order to stop receiving notifications regarding "Volume 2 Click" changes.

Do you want to report abuse regarding "Volume 2 Click".

  • Information
  • Comments (0)

mikroSDK Library Blog


Volume 2 Click

Volume 2 Click is a compact add-on board that provides the user with complete digital volume control. This board features the NJU72341, a 2-channel I2C configurable electronic volume IC with external mute control from NJRC.

volume2_click.png

Click Product page


Click library

  • Author : Stefan Nikolic
  • Date : feb 2021.
  • Type : I2C type

Software Support

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

Standard key functions :

  • volume2_cfg_setup Config Object Initialization function.

    void volume2_cfg_setup ( volume2_cfg_t *cfg );
  • volume2_init Initialization function.

    VOLUME2_RETVAL volume2_init ( volume2_t *ctx, volume2_cfg_t *cfg );
  • volume2_default_cfg Click Default Configuration function.

    void volume2_default_cfg ( volume2_t *ctx );

Example key functions :

  • volume2_update_vol_data This function updates the volume by using direct defined structure options.

    err_t volume2_update_vol_data ( volume2_t *ctx, volume2_vol_data_t update_data );
  • volume2_device_mute This function is used to set mute on or off by controlling the mte pin.

    err_t volume2_device_mute ( volume2_t *ctx, uint8_t mte_state );
  • volume2_generic_write This function writes a desired number of data bytes starting from the selected register by using I2C serial interface.

    err_t volume2_generic_write ( volume2_t *ctx, uint8_t reg, uint8_t *tx_buf, uint8_t tx_len );

Example Description

This example shows how Volume 2 Click board can be used for controlling the audio channels. Thanks to this, a simple audio effect is created by switching volume from right to left and vice versa.

The demo application is composed of two sections :

Application Init

UART LOG and I2C drivers are initialized, following the default configuration. By default, both channels are set to 9 dB gain with zero cross detection enabled.


void application_init ( void ) {
    log_cfg_t log_cfg;          /**< Logger config object. */
    volume2_cfg_t volume2_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.

    volume2_cfg_setup( &volume2_cfg );
    VOLUME2_MAP_MIKROBUS( volume2_cfg, MIKROBUS_1 );
    err_t init_flag = volume2_init( &volume2, &volume2_cfg );
    if ( init_flag == I2C_MASTER_ERROR ) {
        log_error( &logger, " Application Init Error. " );
        log_info( &logger, " Please, run program again... " );

        for ( ; ; );
    }

    volume2_default_cfg( &volume2 );
    Delay_ms ( 100 );
    log_info( &logger, " Application Task " );
}

Application Task

The task performs and effect of switching the volume from right to left channel and vice versa. Like playing ping-pong with the sound.


void application_task ( void ) {
    for ( rising_vol = 0 ; rising_vol < max_atten ; rising_vol++ ) {
        volume_upd_data.attenuation_ch1 = rising_vol;
        volume_upd_data.attenuation_ch2 = max_atten - rising_vol;
        volume2_update_vol_data( &volume2, volume_upd_data );
        Delay_ms ( 50 );
    }
    Delay_ms ( 1000 );
    for ( rising_vol = 0 ; rising_vol < max_atten ; rising_vol++ ) {
        volume_upd_data.attenuation_ch1 = max_atten - rising_vol;
        volume_upd_data.attenuation_ch2 = rising_vol;
        volume2_update_vol_data( &volume2, volume_upd_data );
        Delay_ms ( 50 );
    }
    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.Volume2

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

DAC 5 click

5

DAC 5 Click carries Texas Instruments DAC53608 IC, a low-power, eight-channel, 10-bit buffered Digital-to-Analog Converter.

[Learn More]

Shuttle Click

0

Shuttle Click is a mikroBUS™ socket expansion board, which provides an easy and elegant solution for stacking up to four Click boards™ on a single mikroBUS™. It is a perfect solution for expanding the capacity of the development system with additional mikroBUS™ sockets when there is a demand for using more Click boards™ than the used development system is able to support.

[Learn More]

Boost 3 click

5

Boost 3 Click is a compact add-on board that contains a boost converter with an integrated current mirror function. This board features the TPS61391, a 700-kHz pulse-width modulating (PWM) Step-Up converter with a 70V switch FET with an input voltage up to 5.5V from Texas Instruments.

[Learn More]