This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

From where we can get value for "uint32_t event" in the below UART driver code???

I was trying to understand the following code. We have "void myUSART_callback(uint32_t event)" this function having parameter "uint32_t event" so can anyone please exaplain from where the value of event comes??? 

link of the code - https://arm-software.github.io/CMSIS_5/Driver/html/group__usart__interface__gr.html

#include "Driver_USART.h"
#include "cmsis_os.h" /* ARM::CMSIS:RTOS:Keil RTX */
#include <stdio.h>
#include <string.h>
void myUART_Thread(void const *argument);
osThreadId tid_myUART_Thread;
/* USART Driver */
extern ARM_DRIVER_USART Driver_USART3;
void myUSART_callback(uint32_t event)
{
uint32_t mask;
if (event & mask) {
/* Success: Wakeup Thread */
osSignalSet(tid_myUART_Thread, 0x01);
}
__breakpoint(0); /* Error: Call debugger or replace with custom error handling */
}
__breakpoint(0); /* Error: Call debugger or replace with custom error handling */
}
}
/* CMSIS-RTOS Thread - UART command thread */
void myUART_Thread(const void* args)
{
static ARM_DRIVER_USART * USARTdrv = &Driver_USART3;
ARM_USART_CAPABILITIES drv_capabilities;
char cmd;
#ifdef DEBUG
version = USARTdrv->GetVersion();
if (version.api < 0x200) /* requires at minimum API version 2.00 or higher */
{ /* error handling */
return;
}
drv_capabilities = USARTdrv->GetCapabilities();
if (drv_capabilities.event_tx_complete == 0)
{ /* error handling */
return;
}
#endif
/*Initialize the USART driver */
USARTdrv->Initialize(myUSART_callback);
/*Power up the USART peripheral */
/*Configure the USART to 4800 Bits/sec */
/* Enable Receiver and Transmitter lines */
USARTdrv->Send("\nPress Enter to receive a message", 34);
osSignalWait(0x01, osWaitForever);
while (1)
{
USARTdrv->Receive(&cmd, 1); /* Get byte from UART */
osSignalWait(0x01, osWaitForever);
if (cmd == 13) /* CR, send greeting */
{
USARTdrv->Send("\nHello World!", 12);
osSignalWait(0x01, osWaitForever);
}
}
}
  • It's explained on the same page you copied the example from: the driver generates the event by calling the user-supplied callback function with the appropriate value for event. The conditions that generate each event are also explained. Which events are generated depend on the driver capabilities.