Command 4 ultra-bright RGB LEDs to vividly showcase your information
A
A
Hardware Overview
How does it work?
2x2 RGB Click is based on the KTD2052A, a 12-channel RGB LED driver from Kinetic Technologies. It can be powered from mikroBUS™ socket supply rails, both with 3.3V and 5V selected over the VCC SEL. A 4-wire bus is multiplexed to reduce the pin count, as each pin on the bus integrates a switch to the input voltage and a programmable low-dropout current sink regulator. The driver is capable of 14 million colors with a controllable LED current from 125μA to 24mA in 125μA steps. There is also a night mode (8μA to
1.5mA in 8μA steps). There are 12 independent exponential fade engines with ultra-smooth 3072-step fade resolution and a 3-bit programmable fade rate. 2x2 RGB Click uses a standard 2-Wire I2C interface to communicate with the host MCU, supporting clock frequency of up to 1MHz. The I2C interface allows you to set the ON/OFF status and individual LED current, as well as adjust the fade rate. An internal flexible pattern generator with a watchdog counter enables set-and-forget pattern executions, while more complex patterns may be
executed from system firmware via the I2C interface. This Click board™ can operate with either 3.3V or 5V logic voltage levels selected via the VIO SEL jumper. This way, both 3.3V and 5V capable MCUs can use the communication lines properly. Also, this Click board™ comes equipped with a library containing easy-to-use functions and an example code that can be used as a reference for further development.
Features overview
Development board
Fusion for TIVA v8 is a development board specially designed for the needs of rapid development of embedded applications. It supports a wide range of microcontrollers, such as different 32-bit ARM® Cortex®-M based MCUs from Texas Instruments, regardless of their number of pins, and a broad set of unique functions, such as the first-ever embedded debugger/programmer over a WiFi network. The development board is well organized and designed so that the end-user has all the necessary elements, such as switches, buttons, indicators, connectors, and others, in one place. Thanks to innovative manufacturing technology, Fusion for TIVA v8 provides a fluid and immersive working experience, allowing access
anywhere and under any circumstances at any time. Each part of the Fusion for TIVA v8 development board contains the components necessary for the most efficient operation of the same board. An advanced integrated CODEGRIP programmer/debugger module offers many valuable programming/debugging options, including support for JTAG, SWD, and SWO Trace (Single Wire Output)), and seamless integration with the Mikroe software environment. Besides, it also includes a clean and regulated power supply module for the development board. It can use a wide range of external power sources, including a battery, an external 12V power supply, and a power source via the USB Type-C (USB-C) connector.
Communication options such as USB-UART, USB HOST/DEVICE, CAN (on the MCU card, if supported), and Ethernet is also included. In addition, it also has the well-established mikroBUS™ standard, a standardized socket for the MCU card (SiBRAIN standard), and two display options for the TFT board line of products and character-based LCD. Fusion for TIVA v8 is an integral part of the Mikroe ecosystem for rapid development. Natively supported by Mikroe software tools, it covers many aspects of prototyping and development thanks to a considerable number of different Click boards™ (over a thousand boards), the number of which is growing every day.
Microcontroller Overview
MCU Card / MCU

Type
8th Generation
Architecture
ARM Cortex-M4
MCU Memory (KB)
1024
Silicon Vendor
Texas Instruments
Pin count
128
RAM (Bytes)
262144
Used MCU Pins
mikroBUS™ mapper
Take a closer look
Click board™ Schematic

Step by step
Project assembly
Software Support
Library Description
This library contains API for 2x2 RGB Click driver.
Key functions:
c2x2rgb_set_rgb_led- 2x2 RGB set RGB LED function.c2x2rgb_set_control- 2x2 RGB set control function.
Open Source
Code example
The complete application code and a ready-to-use project are available through the NECTO Studio Package Manager for direct installation in the NECTO Studio. The application code can also be found on the MIKROE GitHub account.
/*!
* @file main.c
* @brief 2x2 RGB Click example
*
* # Description
* This example demonstrates the use of the 2x2 RGB Click board™
* by controlling the color of the LEDs [1-4].
*
* The demo application is composed of two sections :
*
* ## Application Init
* Initialization of SPI module and log UART.
* After driver initialization, the app executes a default configuration.
*
* ## Application Task
* This simple example shows all LEDs in different colors.
* These LEDs actually consist of three single-colored LEDs (Red, Green and Blue) in a single package.
* Various colors can be reproduced by mixing the intensity of each LED.
*
* @author Mikroe Team
*
*/
#include "board.h"
#include "log.h"
#include "c2x2rgb.h"
#define DEMO_LED_CURRENT 600
static c2x2rgb_t c2x2rgb;
static log_t logger;
void application_init ( void )
{
log_cfg_t log_cfg; /**< Logger config object. */
c2x2rgb_cfg_t c2x2rgb_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.
c2x2rgb_cfg_setup( &c2x2rgb_cfg );
C2X2RGB_MAP_MIKROBUS( c2x2rgb_cfg, MIKROBUS_1 );
if ( I2C_MASTER_ERROR == c2x2rgb_init( &c2x2rgb, &c2x2rgb_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( C2X2RGB_ERROR == c2x2rgb_default_cfg ( &c2x2rgb ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
log_info( &logger, " Application Task " );
log_printf( &logger, "----------------" );
Delay_ms ( 100 );
}
void application_task ( void )
{
log_printf( &logger, "\r\nRED: " );
for ( uint8_t led_pos = C2X2RGB_SET_LD1; led_pos <= C2X2RGB_SET_LD4; led_pos++ )
{
if ( C2X2RGB_OK == c2x2rgb_set_rgb_led( &c2x2rgb, led_pos, DEMO_LED_CURRENT,
C2X2RGB_LED_CURRENT_OFF,
C2X2RGB_LED_CURRENT_OFF ) )
{
log_printf( &logger, "LD%d ", ( uint16_t ) led_pos );
}
Delay_ms ( 200 );
}
log_printf( &logger, "\r\nGREEN: " );
for ( uint8_t led_pos = C2X2RGB_SET_LD1; led_pos <= C2X2RGB_SET_LD4; led_pos++ )
{
if ( C2X2RGB_OK == c2x2rgb_set_rgb_led( &c2x2rgb, led_pos, C2X2RGB_LED_CURRENT_OFF,
DEMO_LED_CURRENT,
C2X2RGB_LED_CURRENT_OFF ) )
{
log_printf( &logger, "LD%d ", ( uint16_t ) led_pos );
}
Delay_ms ( 200 );
}
log_printf( &logger, "\r\nBLUE: " );
for ( uint8_t led_pos = C2X2RGB_SET_LD1; led_pos <= C2X2RGB_SET_LD4; led_pos++ )
{
if ( C2X2RGB_OK == c2x2rgb_set_rgb_led( &c2x2rgb, led_pos, C2X2RGB_LED_CURRENT_OFF,
C2X2RGB_LED_CURRENT_OFF,
DEMO_LED_CURRENT ) )
{
log_printf( &logger, "LD%d ", ( uint16_t ) led_pos );
}
Delay_ms ( 200 );
}
log_printf( &logger, "\r\nWHITE: " );
for ( uint8_t led_pos = C2X2RGB_SET_LD1; led_pos <= C2X2RGB_SET_LD4; led_pos++ )
{
if ( C2X2RGB_OK == c2x2rgb_set_rgb_led( &c2x2rgb, led_pos, DEMO_LED_CURRENT,
DEMO_LED_CURRENT,
DEMO_LED_CURRENT ) )
{
log_printf( &logger, "LD%d ", ( uint16_t ) led_pos );
}
Delay_ms ( 200 );
}
log_printf( &logger, "\r\n----------------" );
}
int main ( void )
{
/* Do not remove this line or clock might not be set correctly. */
#ifdef PREINIT_SUPPORTED
preinit();
#endif
application_init( );
for ( ; ; )
{
application_task( );
}
return 0;
}
// ------------------------------------------------------------------------ END

































