uwb  2.0.0.0
Main Page

UWB click

UWB Click is an Ultra-Wideband transceiver Click boardâ„¢ that can be used in 2-way ranging or TDOA location systems to locate assets to a precision of 10 cm and supports data rates of up to 6.8 Mbps. This Click boardâ„¢ features the DWM1000 module based on Decawave's DW1000 Ultra-Wideband (UWB) transceiver from Decawave Limited.

click Product page


Click library

  • Author : MikroE Team
  • Date : jul 2020.
  • Type : SPI type

Software Support

We provide a library for the Uwb 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 form compilers IDE(recommended way), or downloaded from our LibStock, or found on mikroE github account.

Library Description

This library contains API for Uwb Click driver.

Standard key functions :

  • Config Object Initialization function.

    void uwb_cfg_setup ( uwb_cfg_t *cfg );

  • Initialization function.

    UWB_RETVAL uwb_init ( uwb_t *ctx, uwb_cfg_t *cfg );

Example key functions :

  • This function set device working mode.

    void uwb_set_mode ( uwb_t *ctx, uint8_t mode );

  • This function get transmit status.

    uint8_t uwb_get_transmit_status ( uwb_t *ctx );

  • This function start communication of device.

    void uwb_start_transceiver ( uwb_t *ctx );

Examples Description

UWB Click sends and receive data, depending on the selected device mode.

The demo application is composed of two sections :

Application Init

Initializes the driver and configures the click board for the selected mode.

void application_init ( void )
{
log_cfg_t log_cfg;
uwb_cfg_t cfg;
uint16_t tag_data;
uint8_t id_raw[ 4 ];
LOG_MAP_USB_UART( log_cfg );
log_init( &logger, &log_cfg );
log_info( &logger, "---- Application Init ----" );
// Click initialization.
uwb_cfg_setup( &cfg );
UWB_MAP_MIKROBUS( cfg, MIKROBUS_1 );
uwb_init( &uwb, &cfg );
Delay_ms( 100 );
uwb_enable ( &uwb );
Delay_ms( 100 );
uwb.offset = UWB_SUB_NO;
uwb_generic_read( &uwb, UWB_REG_DEV_ID, &id_raw[ 0 ], 4 );
tag_data = ( id_raw[ 3 ] << 8 ) | id_raw[ 2 ];
if ( UWB_TAG != tag_data )
{
log_printf( &logger, " ***** ERROR ***** \r\n" );
for ( ; ; );
}
//-----------------------------------------------------
// Setting device mode and interrupt for that mode as well as clearing dev_status reg.
uwb_set_mode( &uwb, dev_mode );
// Setting device address and network ID
log_printf( &logger, " ******************** \r\n" );
if ( UWB_MODE_RX == dev_mode )
{
log_printf( &logger, " ***** RECEIVER ***** \r\n" );
}
else if ( UWB_MODE_TX == dev_mode )
{
log_printf( &logger, " **** TRANSMITER **** \r\n" );
}
log_printf( &logger, " ******************** \r\n" );
Delay_ms( 100 );
// Setting default configuartion and tuning device for that configuration
uwb_tune_config( &uwb );
Delay_ms( 100 );
if ( UWB_MODE_RX == dev_mode )
{
// Setup for first receive
}
else if ( UWB_MODE_TX == dev_mode )
{
// Setup for first transmit
uwb_set_transmit( &uwb, &data_tx[ 0 ], 6 );
}
log_printf( &logger, " ***** APP TASK ***** \r\n" );
Delay_ms( 500 );
}

Application Task

Depending on the selected mode, it reads all the received data or sends the desired message every 2 seconds.

void application_task ( void )
{
dev_status = uwb_get_qint_pin_status( &uwb );
if ( UWB_MODE_RX == dev_mode )
{
if ( dev_status )
{
// Reading transtimed data logs it and reseting to receive mode
temp_len = uwb_get_transmit_len( &uwb );
uwb_get_transmit( &uwb, &transmit_data[ 0 ], temp_len );
log_printf( &logger, "Received data: %s\r\n", transmit_data );
log_printf( &logger, " - Receive done - \r\n" );
}
}
else if ( UWB_MODE_TX == dev_mode )
{
if ( dev_status )
{
// Transmits data reseting to transmit mode and setts 2sec delay
log_printf( &logger, " - Transmit done - \r\n" );
uwb_set_transmit( &uwb, &data_tx[ 0 ], 6 );
Delay_ms( 2000 );
}
}
}

The full application code, and ready to use projects can be installed directly form compilers IDE(recommneded) or found on LibStock page or mikroE GitHub accaunt.

Other mikroE Libraries used in the example:

  • MikroSDK.Board
  • MikroSDK.Log
  • Click.Uwb

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. The terminal available in all Mikroelektronika compilers, or any other terminal application of your choice, can be used to read the message.


uwb_set_dev_adr_n_network_id
void uwb_set_dev_adr_n_network_id(uwb_t *ctx, uint16_t dev_adr, uint16_t net_id)
Function for setting device address and network ID.
UWB_MODE_IDLE
#define UWB_MODE_IDLE
Definition: uwb.h:250
UWB_REG_DEV_ID
#define UWB_REG_DEV_ID
Definition: uwb.h:84
uwb_enable
void uwb_enable(uwb_t *ctx)
Function for enabling device.
uwb_set_channel
void uwb_set_channel(uwb_t *ctx, uint8_t channel)
Function for setting channel.
UWB_CHANNEL_5
#define UWB_CHANNEL_5
Definition: uwb.h:188
uwb_int_mask_set
void uwb_int_mask_set(uwb_t *ctx)
Function for setting interrupt mask.
UWB_TAG
#define UWB_TAG
Definition: uwb.h:259
uwb_clear_status
void uwb_clear_status(uwb_t *ctx)
Function for clearing status.
UWB_REG_SYS_CFG
#define UWB_REG_SYS_CFG
Definition: uwb.h:87
uwb_cfg_setup
void uwb_cfg_setup(uwb_cfg_t *cfg)
Config Object Initialization function.
uwb_get_qint_pin_status
uint8_t uwb_get_qint_pin_status(uwb_t *ctx)
Function for getting irq pin status.
UWB_MAP_MIKROBUS
#define UWB_MAP_MIKROBUS(cfg, mikrobus)
Definition: uwb.h:54
application_task
void application_task(void)
Definition: main.c:151
UWB_SUB_NO
#define UWB_SUB_NO
Definition: uwb.h:77
uwb_use_smart_power
void uwb_use_smart_power(uwb_t *ctx, uint8_t smart_power)
Function for setting smart power option.
uwb_get_transmit
void uwb_get_transmit(uwb_t *ctx, uint8_t *rx_buf, uint16_t len_buf)
Function for getting transmit data.
uwb_start_transceiver
void uwb_start_transceiver(uwb_t *ctx)
Function for starting communication of device.
uwb_cfg_t
Click configuration structure definition.
Definition: uwb.h:358
uwb_frame_check
void uwb_frame_check(uint8_t fc)
Function for setting frame check option.
UWB_MODE_TX
#define UWB_MODE_TX
Definition: uwb.h:252
UWB_HIGH
#define UWB_HIGH
Definition: uwb.h:234
uwb_init
UWB_RETVAL uwb_init(uwb_t *ctx, uwb_cfg_t *cfg)
Initialization function.
uwb_set_transmit_type
void uwb_set_transmit_type(uwb_t *ctx, const uint8_t *t_t)
Function for setting transmit type mode.
UWB_LOW
#define UWB_LOW
Definition: uwb.h:235
application_init
void application_init(void)
Definition: main.c:49
uwb_generic_read
void uwb_generic_read(uwb_t *ctx, uint8_t reg_adr, uint8_t *rx_buf, uint16_t buf_len)
Function for reading data from register.
UWB_MODE_RX
#define UWB_MODE_RX
Definition: uwb.h:251
uwb_get_transmit_len
uint8_t uwb_get_transmit_len(uwb_t *ctx)
Function for getting transmit length.
uwb_tune_config
void uwb_tune_config(uwb_t *ctx)
Function for tuneing configuration for set values.
UWB_TMODE_LONGDATA_RANGE_LOWPOWER
const uint8_t UWB_TMODE_LONGDATA_RANGE_LOWPOWER[3]
uwb_frame_filter
void uwb_frame_filter(uwb_t *ctx, uint8_t ff)
Function for setting frame filter option.
uwb_set_transmit
void uwb_set_transmit(uwb_t *ctx, uint8_t *tx_buf, uint16_t len_buf)
Function for setting transmit data.
uwb_set_mode
void uwb_set_mode(uwb_t *ctx, uint8_t mode)
Function for setting device working mode.
uwb_set_bit
void uwb_set_bit(uwb_t *ctx, uint8_t reg_adr, uint16_t bit_num, uint8_t bit_state)
Function for setting single bit state.