CMSIS-Driver_DVRT  
Peripheral Library (PLIB) Documentation
 
Loading...
Searching...
No Matches
DVRT Interface

Driver API for DVRT (dvrt.h) More...

Data Structures

struct  DVRT_TMR_PLIB_INTERFACE
 Timer peripheral library interface structure. More...
 
struct  DVRT_USART_INTERFACE
 USART peripheral library interface structure. More...
 
struct  DVRT_StreamUpdates_t
 Stream updates message structure. More...
 
struct  DVRT_StreamIntervalUpdate_t
 Stream interval update message structure. More...
 
struct  DVRT_CommandTemplate_t
 Generic command template structure. More...
 
struct  DVPMT_t
 Dynamic Variable Pointer Map Table entry structure. More...
 

Macros

#define DYNAMIC_VAR_PTR_COUNT   8U
 Maximum number of variable pointers that can be monitored.
 
#define DV_STREAM_TIME   20U
 Default streaming interval in milliseconds.
 
#define DV_RX_CMD_TIMEOUT   200U
 Timeout for receiving commands in milliseconds.
 
#define DV_FW_CODE   261U
 Firmware identification code for ping response.
 
#define DV_START_OF_FRAME   0x03U
 Start of frame marker for DVRT protocol.
 
#define DV_END_OF_FRAME   0xFCU
 End of frame marker for DVRT protocol.
 
#define DV_RX_CMD_MIN_SIZE   3U
 Minimum size of a valid received command frame.
 

Typedefs

typedef void(* DVRT_TMR_PLIB_START) (void)
 Function pointer type for timer start operation.
 
typedef void(* DVRT_TMR_PLIB_STOP) (void)
 Function pointer type for timer stop operation.
 
typedef void(* DVRT_TMR_PLIB_CALLBACK) (uint32_t status, uintptr_t context)
 Function pointer type for timer callback.
 
typedef void(* DVRT_TMR_PLIB_CALLBACK_REGISTER) (DVRT_TMR_PLIB_CALLBACK callback, uintptr_t context)
 Function pointer type for timer callback registration.
 
typedef void(* DVRT_TMR_PLIB_PERIOD_SET) (uint32_t period)
 Function pointer type for timer period setting.
 
typedef void(* DVRT_USART_CALLBACK) (uint32_t event)
 Function pointer type for USART callback.
 
typedef size_t DVRT_error_t
 DVRT error type definition.
 

Enumerations

enum  DVRT_commands {
  UPDATE_VARIABLE_POINTER_TABLE =0U , UPDATE_VARIABLE_VALUE =1U , UPDATE_STREAMING_TICK =2U , TURN_STREAMING_OFF =3U ,
  TURN_STREAMING_ON =4U , ONE_SHOT_READ =5U , PING =6U
}
 DVRT command identifiers. More...
 

Functions

void DVRT_Initialize (void)
 Initializes the DVRT middleware.
 
void DVRT_Process (void)
 Main DVRT processing function.
 
void DVRT_USART_RxHandler (uint32_t event)
 USART event callback for DVRT reception.
 
int32_t DVRT_USART_StartReceive (void)
 Start continuous USART reception into the DVRT ring buffer.
 
uint32_t usart_rx_available (void)
 Gets the number of bytes available in the receive buffer.
 
bool usart_rx_get (uint8_t *byte)
 Gets a single byte from the receive buffer.
 
struct __attribute__ ((packed))
 Variable pointer table entry structure.
 
void DVRT_HandleCommand (void)
 Handles received DVRT commands.
 
size_t DVRT_WritePacket (void)
 Writes a data packet to the USART.
 

Variables

DVRT_TMR_PLIB_START DVRT_TMR_PLIB_INTERFACE::timerStart
 
DVRT_TMR_PLIB_STOP DVRT_TMR_PLIB_INTERFACE::timerStop
 
DVRT_TMR_PLIB_PERIOD_SET DVRT_TMR_PLIB_INTERFACE::timerPeriodSet
 
DVRT_TMR_PLIB_CALLBACK_REGISTER DVRT_TMR_PLIB_INTERFACE::timerCallbackRegister
 
const DVRT_TMR_PLIB_INTERFACE dvrt_TMRPlibAPI
 
ARM_DRIVER_USART *const dvrt_USART_API
 External CMSIS USART driver API pointer.
 
void(* DVRT_USART_INTERFACE::readCallbackRegister )(DVRT_USART_CALLBACK callback, uintptr_t context)
 
size_t(* DVRT_USART_INTERFACE::read_t )(void *buffer, size_t size)
 
size_t(* DVRT_USART_INTERFACE::readCountGet )(void)
 
size_t(* DVRT_USART_INTERFACE::write_t )(const void *buffer, size_t size)
 
uint32_t(* DVRT_USART_INTERFACE::errorGet )(void)
 
void(* DVRT_USART_INTERFACE::readThresholdSet )(uint32_t nBytesThreshold)
 
void(* DVRT_USART_INTERFACE::readNotificationEnable )(bool isEnabled, bool isPersistent)
 
const DVRT_USART_INTERFACE dvrt_USARTPlibAPI
 External USART peripheral library API instance.
 
 DVRT_VariablePointerTableEntry_t
 
uint8_t DVRT_StreamUpdates_t::startOfFrame
 
uint8_t DVRT_StreamUpdates_t::command
 
uint8_t DVRT_StreamUpdates_t::size
 
DVRT_VariablePointerTableEntry_t DVRT_StreamUpdates_t::DVPMT [8U]
 
uint8_t DVRT_StreamUpdates_t::endOfFrame
 
 DVRT_VariableUpdate_t
 
uint8_t DVRT_StreamIntervalUpdate_t::startOfFrame
 
uint8_t DVRT_StreamIntervalUpdate_t::command
 
uint16_t DVRT_StreamIntervalUpdate_t::period
 
uint8_t DVRT_StreamIntervalUpdate_t::endOfFrame
 
uint8_t DVRT_CommandTemplate_t::startOfFrame
 
uint8_t DVRT_CommandTemplate_t::command
 
uint8_t DVRT_CommandTemplate_t::data
 
uint8_t DVRT_CommandTemplate_t::endOfFrame
 
uint8_t * DVPMT_t::address
 
uint8_t DVPMT_t::size
 
ARM_DRIVER_USART Driver_USART1
 External declaration for CMSIS USART driver instance 1.
 

Description

Driver API for DVRT (dvrt.h)

Usage Example

The following example demonstrates typical usage of the DVRT peripheral:

/********************************************************************************
* Copyright © 2026 Microchip Technology Inc. and its subsidiaries.
*
* Subject to your compliance with these terms, you may use Microchip software
* and any derivatives exclusively with Microchip products. It is your
* responsibility to comply with third party license terms applicable to your
* use of third party software (including open source software) that may
* accompany Microchip software.
*
* THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER
* EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY IMPLIED
* WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE,
* INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND
* WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP HAS
* BEEN ADVISED OF THE POSSIBILITY OF THE DAMAGES ARE FORESEEABLE. TO THE
* FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL CLAIMS IN
* ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT OF FEES, IF ANY,
* THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS SOFTWARE.
*******************************************************************************/
#include "Driver_USART.h"
#if defined(ARM_USART_MODE_ASYNCHRONOUS)
#include "dvrt.h"
static ARM_DRIVER_USART *dvrt_usart_drv;
void DVRT_Init(ARM_DRIVER_USART *usart_drv, uint32_t baud_rate)
{
dvrt_usart_drv = usart_drv;
/* Initialize USART with DVRT receive event callback */
dvrt_usart_drv->Initialize(DVRT_USART_RxHandler);
dvrt_usart_drv->PowerControl(ARM_POWER_FULL);
/* Configure 8N1 asynchronous mode at specified baud rate */
dvrt_usart_drv->Control(
ARM_USART_MODE_ASYNCHRONOUS |
ARM_USART_DATA_BITS_8 |
ARM_USART_PARITY_NONE |
ARM_USART_STOP_BITS_1,
baud_rate);
/* Enable transmitter and receiver */
dvrt_usart_drv->Control(ARM_USART_CONTROL_TX, 1);
dvrt_usart_drv->Control(ARM_USART_CONTROL_RX, 1);
/* Start DVRT ring buffer reception */
/* Initialize DVRT middleware */
}
#endif /* ARM_USART_MODE_ASYNCHRONOUS */
Data Visualizer Run-Time (DVRT) Public Interface.
int32_t DVRT_USART_StartReceive(void)
Start continuous USART reception into the DVRT ring buffer.
void DVRT_USART_RxHandler(uint32_t event)
USART event callback for DVRT reception.
void DVRT_Initialize(void)
Initializes the DVRT middleware.

Macro Definition Documentation

◆ DV_END_OF_FRAME

#define DV_END_OF_FRAME   0xFCU

End of frame marker for DVRT protocol.

◆ DV_FW_CODE

#define DV_FW_CODE   261U

Firmware identification code for ping response.

◆ DV_RX_CMD_MIN_SIZE

#define DV_RX_CMD_MIN_SIZE   3U

Minimum size of a valid received command frame.

◆ DV_RX_CMD_TIMEOUT

#define DV_RX_CMD_TIMEOUT   200U

Timeout for receiving commands in milliseconds.

◆ DV_START_OF_FRAME

#define DV_START_OF_FRAME   0x03U

Start of frame marker for DVRT protocol.

◆ DV_STREAM_TIME

#define DV_STREAM_TIME   20U

Default streaming interval in milliseconds.

◆ DYNAMIC_VAR_PTR_COUNT

#define DYNAMIC_VAR_PTR_COUNT   8U

Maximum number of variable pointers that can be monitored.

Typedef Documentation

◆ DVRT_error_t

typedef size_t DVRT_error_t

DVRT error type definition.

◆ DVRT_TMR_PLIB_CALLBACK

typedef void(* DVRT_TMR_PLIB_CALLBACK) (uint32_t status, uintptr_t context)

Function pointer type for timer callback.

Parameters
status- Timer status value.
context- User-defined context pointer.

◆ DVRT_TMR_PLIB_CALLBACK_REGISTER

typedef void(* DVRT_TMR_PLIB_CALLBACK_REGISTER) (DVRT_TMR_PLIB_CALLBACK callback, uintptr_t context)

Function pointer type for timer callback registration.

Parameters
callback- Callback function to register.
context- User-defined context pointer.

◆ DVRT_TMR_PLIB_PERIOD_SET

typedef void(* DVRT_TMR_PLIB_PERIOD_SET) (uint32_t period)

Function pointer type for timer period setting.

Parameters
period- Timer period value.

◆ DVRT_TMR_PLIB_START

typedef void(* DVRT_TMR_PLIB_START) (void)

Function pointer type for timer start operation.

◆ DVRT_TMR_PLIB_STOP

typedef void(* DVRT_TMR_PLIB_STOP) (void)

Function pointer type for timer stop operation.

◆ DVRT_USART_CALLBACK

typedef void(* DVRT_USART_CALLBACK) (uint32_t event)

Function pointer type for USART callback.

Parameters
event- USART event identifier.

Enumeration Type Documentation

◆ DVRT_commands

DVRT command identifiers.

This enumeration defines the command codes used in the DVRT protocol for communication between the target device and Data Visualizer.

Enumerator
UPDATE_VARIABLE_POINTER_TABLE 
UPDATE_VARIABLE_VALUE 
UPDATE_STREAMING_TICK 
TURN_STREAMING_OFF 
TURN_STREAMING_ON 
ONE_SHOT_READ 
PING 

Function Documentation

◆ __attribute__()

struct __attribute__ ( (packed) )

Variable pointer table entry structure.

Variable update message structure.

This structure defines an entry in the variable pointer table, containing the size and address of a monitored variable.

This structure defines the format of a variable update message for modifying variable values.

◆ DVRT_HandleCommand()

void DVRT_HandleCommand ( void )

Handles received DVRT commands.

Parameters
None.
Returns
None.
Note
This function parses and executes commands received from Data Visualizer.

◆ DVRT_Initialize()

void DVRT_Initialize ( void )

Initializes the DVRT middleware.

Parameters
None.
Returns
None.
Note
This function must be called before using any other DVRT functions. It initializes the variable pointer table and sets default streaming parameters.

◆ DVRT_Process()

void DVRT_Process ( void )

Main DVRT processing function.

Parameters
None.
Returns
None.
Note
Call this periodically (every 1 ms recommended) from your main loop or SysTick handler to process commands and send streaming data.

◆ DVRT_USART_RxHandler()

void DVRT_USART_RxHandler ( uint32_t event)

USART event callback for DVRT reception.

Parameters
event- USART event flags from CMSIS-Driver.
Note
Pass this callback to the CMSIS USART Initialize() function:
ARM_DRIVER_USART Driver_USART1
External declaration for CMSIS USART driver instance 1.

◆ DVRT_USART_StartReceive()

int32_t DVRT_USART_StartReceive ( void )

Start continuous USART reception into the DVRT ring buffer.

Returns
ARM_DRIVER_OK on success, or error code.
Note
Call this after USART is initialized and configured, before entering the main loop.

◆ DVRT_WritePacket()

size_t DVRT_WritePacket ( void )

Writes a data packet to the USART.

Parameters
None.
Returns
Number of bytes written.
Note
This function constructs and sends a streaming data packet containing the current values of all monitored variables.

◆ usart_rx_available()

uint32_t usart_rx_available ( void )

Gets the number of bytes available in the receive buffer.

Returns
Number of bytes available to read.

◆ usart_rx_get()

bool usart_rx_get ( uint8_t * byte)

Gets a single byte from the receive buffer.

Parameters
byte- Pointer to store the received byte.
Returns
true if a byte was successfully retrieved, false otherwise.

Variable Documentation

◆ address

uint8_t* DVPMT_t::address

◆ command [1/3]

uint8_t DVRT_StreamUpdates_t::command

◆ command [2/3]

uint8_t DVRT_StreamIntervalUpdate_t::command

◆ command [3/3]

uint8_t DVRT_CommandTemplate_t::command

◆ data

uint8_t DVRT_CommandTemplate_t::data

◆ Driver_USART1

ARM_DRIVER_USART Driver_USART1
extern

External declaration for CMSIS USART driver instance 1.

Note
This driver is defined in the CMSIS-Driver pack and provides the USART communication interface used by the DVRT middleware.

◆ DVPMT

DVRT_VariablePointerTableEntry_t DVRT_StreamUpdates_t::DVPMT[8U]

◆ dvrt_TMRPlibAPI

const DVRT_TMR_PLIB_INTERFACE dvrt_TMRPlibAPI
extern

◆ dvrt_USART_API

ARM_DRIVER_USART* const dvrt_USART_API
extern

External CMSIS USART driver API pointer.

◆ dvrt_USARTPlibAPI

const DVRT_USART_INTERFACE dvrt_USARTPlibAPI
extern

External USART peripheral library API instance.

◆ DVRT_VariablePointerTableEntry_t

DVRT_VariablePointerTableEntry_t

◆ DVRT_VariableUpdate_t

DVRT_VariableUpdate_t

◆ endOfFrame [1/3]

uint8_t DVRT_StreamUpdates_t::endOfFrame

◆ endOfFrame [2/3]

uint8_t DVRT_StreamIntervalUpdate_t::endOfFrame

◆ endOfFrame [3/3]

uint8_t DVRT_CommandTemplate_t::endOfFrame

◆ errorGet

uint32_t(* DVRT_USART_INTERFACE::errorGet) (void)

◆ period

uint16_t DVRT_StreamIntervalUpdate_t::period

◆ read_t

size_t(* DVRT_USART_INTERFACE::read_t) (void *buffer, size_t size)

◆ readCallbackRegister

void(* DVRT_USART_INTERFACE::readCallbackRegister) (DVRT_USART_CALLBACK callback, uintptr_t context)

◆ readCountGet

size_t(* DVRT_USART_INTERFACE::readCountGet) (void)

◆ readNotificationEnable

void(* DVRT_USART_INTERFACE::readNotificationEnable) (bool isEnabled, bool isPersistent)

◆ readThresholdSet

void(* DVRT_USART_INTERFACE::readThresholdSet) (uint32_t nBytesThreshold)

◆ size [1/2]

uint8_t DVRT_StreamUpdates_t::size

◆ size [2/2]

uint8_t DVPMT_t::size

◆ startOfFrame [1/3]

uint8_t DVRT_StreamUpdates_t::startOfFrame

◆ startOfFrame [2/3]

uint8_t DVRT_StreamIntervalUpdate_t::startOfFrame

◆ startOfFrame [3/3]

uint8_t DVRT_CommandTemplate_t::startOfFrame

◆ timerCallbackRegister

DVRT_TMR_PLIB_CALLBACK_REGISTER DVRT_TMR_PLIB_INTERFACE::timerCallbackRegister

◆ timerPeriodSet

DVRT_TMR_PLIB_PERIOD_SET DVRT_TMR_PLIB_INTERFACE::timerPeriodSet

◆ timerStart

DVRT_TMR_PLIB_START DVRT_TMR_PLIB_INTERFACE::timerStart

◆ timerStop

DVRT_TMR_PLIB_STOP DVRT_TMR_PLIB_INTERFACE::timerStop

◆ write_t

size_t(* DVRT_USART_INTERFACE::write_t) (const void *buffer, size_t size)