thyonei 2.1.0.0
Main Page

Thyone-I click

PRVIH_PAR_RECENICA_SA_PRODUCT_PAGE_DA_ISPRATE_CELINU

[click Product page](CLICK_PRODUCT_PAGE_LINK)


Click library

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

Software Support

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

Standard key functions :

Example key functions :

  • thyonei_get_req This command can be used to set individual setting parameters in flash of Thyone-I click board.
    err_t thyonei_get_req ( thyonei_t *ctx, uint8_t settings_index, uint8_t *param_len, uint8_t *parameter );
    err_t thyonei_get_req(thyonei_t *ctx, uint8_t settings_index, uint8_t *param_len, uint8_t *parameter)
    Thyone-I get individual parameters function.
  • thyonei_multicast_data_req This command provides the multicast data transmission to a group of modules configured with the same MAC GROUP ADDRESS of Thyone-I click board.
    err_t thyonei_multicast_data_req ( thyonei_t *ctx, uint8_t message_len, uint8_t *message );
    err_t thyonei_multicast_data_req(thyonei_t *ctx, uint8_t message_len, uint8_t *message)
    Thyone-I multicast data function.
  • thyonei_unicast_data_req This command provides the unicast data transmission to the configured MAC DESTINATION ADDRESS of Thyone-I click board.
    err_t thyonei_unicast_data_req ( thyonei_t *ctx, uint8_t message_len, uint8_t *message );
    err_t thyonei_unicast_data_req(thyonei_t *ctx, uint8_t message_len, uint8_t *message)
    Thyone-I unicast data function.

Example Description

This example demonstrates the use of the Thyone-I click board by sending and receiving data and displaying them on the USB UART.

The demo application is composed of two sections :

Application Init

Initializes the driver and performs the click default configuration and setting the MAC addresses and mode.

void application_init ( void )
{
log_cfg_t log_cfg;
thyonei_cfg_t thyonei_cfg;
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, " Application Init " );
// Click initialization.
thyonei_cfg_setup( &thyonei_cfg );
THYONEI_MAP_MIKROBUS( thyonei_cfg, MIKROBUS_1 );
if ( UART_ERROR == thyonei_init( &thyonei, &thyonei_cfg ) )
{
log_error( &logger, " Communication init." );
for ( ; ; );
}
thyonei_default_cfg ( &thyonei );
uint8_t tmp_data [ 4 ] = { 0 };
uint8_t len = 0;
thyonei_get_req( &thyonei, THYONEI_INDEX_SERIAL_NUMBER, &len, tmp_data );
log_printf( &logger, " Thyone-I serial number: 0x" );
for( uint8_t cnt = 0; cnt < len; cnt++ )
{
log_printf( &logger, "%.2X", ( uint16_t ) tmp_data[ cnt ] );
}
log_printf( &logger, "\r\n" );
log_printf( &logger, "= = = = = = = = = = = = = = =\r\n" );
log_printf( &logger, " Thyone-I factory reset request: \r\n" );
thyonei_get_resp ( &thyonei, THYONEI_CMD_FACTORY_RESET_REQ );
log_printf( &logger, " Thyone-I Set Mode to normal mode: \r\n" );
tmp_data[ 0 ] = 0;
thyonei_set_req( &thyonei, THYONEI_INDEX_MODULE_MODE, 1, tmp_data );
thyonei_get_resp ( &thyonei, THYONEI_CMD_SET_REQ );
log_printf( &logger, " Thyone-I Set RF-Profile to 0: \r\n" );
tmp_data[ 0 ] = 0;
thyonei_set_req( &thyonei, THYONEI_INDEX_RF_PROFILE, 1, tmp_data );
thyonei_get_resp ( &thyonei, THYONEI_CMD_SET_REQ );
log_printf( &logger, " Thyone-I Set MAC Group ID to 0xAA: \r\n" );
tmp_data[ 0 ] = MAC_GROUP_ADDRESS;
thyonei_set_req( &thyonei, THYONEI_INDEX_MAC_GROUP_ID, 1, tmp_data );
thyonei_get_resp ( &thyonei, THYONEI_CMD_SET_REQ );
log_printf( &logger, " Thyone-I Set Source MAC address: \r\n" );
tmp_data[ 0 ] = ( uint8_t ) SOURCE_ADDRESS;
tmp_data[ 1 ] = ( uint8_t ) ( SOURCE_ADDRESS >> 8 );
tmp_data[ 2 ] = ( uint8_t ) ( SOURCE_ADDRESS >> 16 );
tmp_data[ 3 ] = ( uint8_t ) ( SOURCE_ADDRESS >> 24 );
thyonei_get_resp ( &thyonei, THYONEI_CMD_SET_REQ );
log_printf( &logger, " Thyone-I Set Destination MAC address: \r\n" );
tmp_data[ 0 ] = ( uint8_t ) DESTINATION_ADDRESS;
tmp_data[ 1 ] = ( uint8_t ) ( DESTINATION_ADDRESS >> 8 );
tmp_data[ 2 ] = ( uint8_t ) ( DESTINATION_ADDRESS >> 16 );
tmp_data[ 3 ] = ( uint8_t ) ( DESTINATION_ADDRESS >> 24 );
thyonei_get_resp ( &thyonei, THYONEI_CMD_SET_REQ );
log_info( &logger, " Application Task " );
}
#define THYONEI_INDEX_MAC_GROUP_ID
Definition: thyonei.h:119
#define THYONEI_CMD_FACTORY_RESET_REQ
Definition: thyonei.h:84
#define THYONEI_INDEX_MAC_DEST_ADDRESS
Definition: thyonei.h:118
#define THYONEI_CMD_SET_REQ
Definition: thyonei.h:78
#define THYONEI_INDEX_RF_PROFILE
Definition: thyonei.h:113
#define THYONEI_INDEX_MODULE_MODE
Definition: thyonei.h:131
#define THYONEI_INDEX_MAC_SOURCE_ADDRESS
Definition: thyonei.h:117
#define THYONEI_INDEX_SERIAL_NUMBER
Thyone-I settings indexes.
Definition: thyonei.h:106
#define THYONEI_MAP_MIKROBUS(cfg, mikrobus)
MikroBUS pin mapping.
Definition: thyonei.h:171
err_t thyonei_set_req(thyonei_t *ctx, uint8_t settings_index, uint8_t parameters_length, uint8_t *parameters)
Thyone-I set individual parameters function.
err_t thyonei_send_command(thyonei_t *ctx, uint8_t command, uint16_t payload_length, uint8_t *payload)
Thyone-I send command function.
err_t thyonei_generic_read(thyonei_t *ctx, uint8_t *data_out, uint16_t len)
Thyone-I data reading function.
void application_init(void)
Definition: main.c:73
#define SOURCE_ADDRESS
Definition: main.c:41
#define MAC_GROUP_ADDRESS
Definition: main.c:39
#define DESTINATION_ADDRESS
Definition: main.c:43
#define PROCESS_BUFFER_SIZE
Definition: main.c:31

Application Task

Transmitter mode - Sending data to the devices within range ( thyonei_broadcast_data_req ), with same MAC group ( thyonei_multicast_data_req )

and with the selected MAC destination address ( thyonei_unicast_data_req ).

Receiver mode - Reads and processes all incoming data and displays them on the USB UART.

void application_task ( void )
{
#if ( TRANSMITTER_MAC_ADDRESS == SOURCE_ADDRESS )
uint8_t message_data[ PROCESS_BUFFER_SIZE ] = { 0 };
#define BRODCAST_MESSAGE "Brodcast"
strcpy( message_data, MESSAGE );
strcat( message_data, BRODCAST_MESSAGE );
log_printf( &logger, " Thyone-I sending broadcast message: \r\n" );
thyonei_broadcast_data_req( &thyonei, strlen( message_data ), message_data );
thyonei_get_resp ( &thyonei, THYONEI_CMD_DATA_CNF );
Delay_ms( 5000 );
#define MULTICAST_MESSAGE "Multicast"
strcpy( message_data, MESSAGE );
strcat( message_data, MULTICAST_MESSAGE );
log_printf( &logger, " Thyone-I sending multicast message: \r\n" );
thyonei_multicast_data_req( &thyonei, strlen( message_data ), message_data );
thyonei_get_resp ( &thyonei, THYONEI_CMD_DATA_CNF );
Delay_ms( 5000 );
#define UNICAST_MESSAGE "Unicast"
strcpy( message_data, MESSAGE );
strcat( message_data, UNICAST_MESSAGE );
log_printf( &logger, " Thyone-I sending unicast message: \r\n" );
thyonei_unicast_data_req( &thyonei, strlen( message_data ), message_data );
thyonei_get_resp ( &thyonei, THYONEI_CMD_DATA_CNF );
Delay_ms( 5000 );
#else
thyonei_get_resp ( &thyonei, THYONEI_CMD_DATA_IND );
#endif
}
#define THYONEI_CMD_DATA_CNF
Definition: thyonei.h:74
#define THYONEI_CMD_DATA_IND
Definition: thyonei.h:76
err_t thyonei_broadcast_data_req(thyonei_t *ctx, uint8_t message_len, uint8_t *message)
Thyone-I brodcast data function.
#define UNICAST_MESSAGE
void application_task(void)
Definition: main.c:154
#define BRODCAST_MESSAGE
#define MULTICAST_MESSAGE
#define MESSAGE
Thyone-I Message.
Definition: main.c:52

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

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.