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 :

  • uwb_cfg_setup Config Object Initialization function.
    void uwb_cfg_setup ( uwb_cfg_t *cfg );
    void uwb_cfg_setup(uwb_cfg_t *cfg)
    Config Object Initialization function.
    Click configuration structure definition.
    Definition uwb.h:382
  • uwb_init Initialization function.
    err_t uwb_init ( uwb_t *ctx, uwb_cfg_t *cfg );
    err_t uwb_init(uwb_t *ctx, uwb_cfg_t *cfg)
    Initialization function.
    Click ctx object definition.
    Definition uwb.h:357

Example key functions :

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;
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 );
uint8_t id_raw[ 4 ] = { 0 };
uwb.offset = UWB_SUB_NO;
uwb_generic_read( &uwb, UWB_REG_DEV_ID, &id_raw[ 0 ], 4 );
uint16_t tag_data = ( ( uint16_t ) 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_1[ 0 ], 6 );
log_printf( &logger, " - Transmit 1 done - \r\n" );
}
log_printf( &logger, " ***** APP TASK ***** \r\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
#define UWB_CHANNEL_5
Definition uwb.h:200
#define UWB_LOW
Definition uwb.h:247
#define UWB_HIGH
Definition uwb.h:246
const uint8_t UWB_TMODE_LONGDATA_RANGE_LOWPOWER[3]
#define UWB_TAG
Definition uwb.h:271
#define UWB_MAP_MIKROBUS(cfg, mikrobus)
Definition uwb.h:68
#define UWB_SUB_NO
Definition uwb.h:89
#define UWB_MODE_TX
Definition uwb.h:264
#define UWB_MODE_IDLE
Definition uwb.h:262
#define UWB_MODE_RX
Definition uwb.h:263
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.
void uwb_set_transmit(uwb_t *ctx, uint8_t *tx_buf, uint16_t len_buf)
Function for setting transmit data.
void uwb_frame_check(uint8_t fc_val)
Function for setting frame check option.
void uwb_enable(uwb_t *ctx)
Function for enabling device.
void uwb_int_mask_set(uwb_t *ctx)
Function for setting interrupt mask.
void uwb_clear_status(uwb_t *ctx)
Function for clearing status.
void uwb_set_transmit_type(uwb_t *ctx, const uint8_t *t_t)
Function for setting transmit type mode.
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.
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.
void uwb_frame_filter(uwb_t *ctx, uint8_t ff_val)
Function for setting frame filter option.
void uwb_tune_config(uwb_t *ctx)
Function for tuneing configuration for set values.
void uwb_use_smart_power(uwb_t *ctx, uint8_t smart_power)
Function for setting smart power option.
void uwb_set_channel(uwb_t *ctx, uint8_t channel)
Function for setting channel.
#define UWB_REG_SYS_CFG
Definition uwb.h:99
#define UWB_REG_DEV_ID
Definition uwb.h:96
void application_init(void)
Definition main.c:49

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 transmitted data, logs it and resetting 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, resetting to transmit mode and sets 2sec delay
uwb_set_transmit( &uwb, &data_tx_2[ 0 ], 9 );
log_printf( &logger, " - Transmit 2 done - \r\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
uwb_set_transmit( &uwb, &data_tx_1[ 0 ], 6 );
log_printf( &logger, " - Transmit 1 done - \r\n" );
Delay_ms ( 1000 );
Delay_ms ( 1000 );
}
}
}
void uwb_get_transmit(uwb_t *ctx, uint8_t *rx_buf, uint16_t len_buf)
Function for getting transmit data.
uint8_t uwb_get_transmit_len(uwb_t *ctx)
Function for getting transmit length.
uint8_t uwb_get_qint_pin_status(uwb_t *ctx)
Function for getting irq pin status.
void application_task(void)
Definition main.c:150

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.