ecg2  2.0.0.0
Main Page

ECG 2 click

ECG 2 click contains ADS1194 16-bit delta-sigma analog-to-digital converters from Texas Instruments, a built-in programmable gain amplifier (PGA), an internal reference, and an onboard oscillator.

click Product page


Click library

  • Author : Stefan Ilic
  • Date : Nov 2021.
  • Type : SPI type

Software Support

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

Standard key functions :

Example key functions :

Example Description

This is an example that demonstrates the use of the ECG 2 Click board.

The demo application is composed of two sections :

Application Init

Initializes SPI and UART communication, configures INT pin as INPUT, RST pin as OUTPUT, CS pin as OUTPUT and PWM pin as OUTPUT. Initializes SPI driver, initializes ECG2 click, sends START and RDATAC opcodes.

void application_init ( void )
{
log_cfg_t log_cfg;
ecg2_cfg_t ecg2_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
ecg2_cfg_setup( &ecg2_cfg );
ECG2_MAP_MIKROBUS( ecg2_cfg, MIKROBUS_1 );
if ( SPI_MASTER_ERROR == ecg2_init( &ecg2, &ecg2_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
if ( ECG2_ERROR == ecg2_default_cfg ( &ecg2 ) )
{
log_error( &logger, " Default configuration." );
for ( ; ; );
}
Delay_ms( 100 );
Delay_ms( 100 );
Delay_ms( 100 );
log_info( &logger, " Application Task " );
Delay_ms( 100 );
}

Application Task

Captures readings from channel and plots data to serial plotter.

void application_task ( void )
{
uint16_t ecg_an = 0;
ecg2_read_channel_data( &ecg2, 5, &ecg_an );
log_printf( &logger, " %.6u, %.8lu \r\n", ecg_an, time );
time += 5;
Delay_ms( 5 );
}

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

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.


ecg2_init
err_t ecg2_init(ecg2_t *ctx, ecg2_cfg_t *cfg)
ECG 2 initialization function.
ecg2_t
ECG 2 Click context object.
Definition: ecg2.h:343
ECG2_MAP_MIKROBUS
#define ECG2_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: ecg2.h:325
application_task
void application_task(void)
Definition: main.c:73
ecg2_cfg_t
ECG 2 Click configuration object.
Definition: ecg2.h:365
SET_SPI_DATA_SAMPLE_EDGE
#define SET_SPI_DATA_SAMPLE_EDGE
Definition: spi_specifics.h:113
ecg2_cfg_setup
void ecg2_cfg_setup(ecg2_cfg_t *cfg)
ECG 2 configuration object setup function.
ECG2_START_CONVERSION
#define ECG2_START_CONVERSION
Definition: ecg2.h:111
ecg2_read_an_pin_value
err_t ecg2_read_an_pin_value(ecg2_t *ctx, uint16_t *data_out)
ECG 2 read AN pin value function.
ecg2_send_command
err_t ecg2_send_command(ecg2_t *ctx, uint8_t command)
ECG 2 send command function.
ecg2_default_cfg
err_t ecg2_default_cfg(ecg2_t *ctx)
ECG 2 default configuration function.
application_init
void application_init(void)
Definition: main.c:30
ecg2_read_channel_data
err_t ecg2_read_channel_data(ecg2_t *ctx, uint8_t channel, uint16_t *data_out)
ECG 2 read data channel function.
ECG2_ERROR
@ ECG2_ERROR
Definition: ecg2.h:395
time
uint32_t time
Definition: main.c:28
ECG2_ENABLE_READ_DATA_CONT_MODE
#define ECG2_ENABLE_READ_DATA_CONT_MODE
Definition: ecg2.h:113