本文整理汇总了C++中UART_PRINT函数的典型用法代码示例。如果您正苦于以下问题:C++ UART_PRINT函数的具体用法?C++ UART_PRINT怎么用?C++ UART_PRINT使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UART_PRINT函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SimpleLinkNetAppEventHandler
//*****************************************************************************
//
//! \brief This function handles network events such as IP acquisition, IP
//! leased, IP released etc.
//!
//! \param[in] pNetAppEvent - Pointer to NetApp Event Info
//!
//! \return None
//!
//*****************************************************************************
void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *pNetAppEvent)
{
switch(pNetAppEvent->Event)
{
case SL_NETAPP_IPV4_ACQUIRED:
case SL_NETAPP_IPV6_ACQUIRED:
{
SET_STATUS_BIT(g_ulStatus, STATUS_BIT_IP_AQUIRED);
}
break;
case SL_NETAPP_IP_LEASED:
{
SET_STATUS_BIT(g_ulStatus, STATUS_BIT_IP_LEASED);
g_ulStaIp = (pNetAppEvent)->EventData.ipLeased.ip_address;
UART_PRINT("[NETAPP EVENT] IP Leased to Client: IP=%d.%d.%d.%d , ",
SL_IPV4_BYTE(g_ulStaIp,3), SL_IPV4_BYTE(g_ulStaIp,2),
SL_IPV4_BYTE(g_ulStaIp,1), SL_IPV4_BYTE(g_ulStaIp,0));
}
break;
default:
{
UART_PRINT("[NETAPP EVENT] Unexpected event [0x%x] \n\r",
pNetAppEvent->Event);
}
break;
}
}
示例2: ConfigureMode
//****************************************************************************
//
//! Confgiures the mode in which the device will work
//!
//! \param iMode is the current mode of the device
//!
//! This function
//! 1. prompt user for desired configuration and accordingly configure the
//! networking mode(STA or AP).
//! 2. also give the user the option to configure the ssid name in case of
//! AP mode.
//!
//! \return sl_start return value(int).
//
//****************************************************************************
static int ConfigureMode(int iMode)
{
char pcSsidName[33];
long retVal = -1;
UART_PRINT("Enter the AP SSID name: ");
GetSsidName(pcSsidName,33);
retVal = sl_WlanSetMode(ROLE_AP);
ASSERT_ON_ERROR(__LINE__, retVal);
retVal = sl_WlanSet(SL_WLAN_CFG_AP_ID, WLAN_AP_OPT_SSID, strlen(pcSsidName),
(unsigned char*)pcSsidName);
ASSERT_ON_ERROR(__LINE__, retVal);
UART_PRINT("Device is configured in AP mode\n\r");
/* Restart Network processor */
retVal = sl_Stop(SL_STOP_TIMEOUT);
ASSERT_ON_ERROR(__LINE__, retVal);
// reset status bits
CLR_STATUS_BIT_ALL(g_ulStatus);
return sl_Start(NULL,NULL,NULL);
}
示例3: StartDeviceInP2P
//*****************************************************************************
//
//! Check the device mode and switch to P2P mode
//! restart the NWP to activate P2P mode
//!
//! \param None
//!
//! \return status code - Success:0, Failure:-ve
//
//*****************************************************************************
long StartDeviceInP2P()
{
long lRetVal = -1;
// Reset CC3200 Network State Machine
InitializeAppVariables();
//
// Following function configure the device to default state by cleaning
// the persistent settings stored in NVMEM (viz. connection profiles &
// policies, power policy etc)
//
// Applications may choose to skip this step if the developer is sure
// that the device is in its default state at start of application
//
// Note that all profiles and persistent settings that were done on the
// device will be lost
//
lRetVal = ConfigureSimpleLinkToDefaultState();
if(lRetVal < 0)
{
if (DEVICE_NOT_IN_STATION_MODE == lRetVal)
UART_PRINT("Failed to configure the device in its default state \n\r");
LOOP_FOREVER();
}
UART_PRINT("Device is configured in default state \n\r");
//
// Assumption is that the device is configured in station mode already
// and it is in its default state
//
lRetVal = sl_Start(NULL,NULL,NULL);
ASSERT_ON_ERROR(lRetVal);
if(lRetVal != ROLE_P2P)
{
lRetVal = sl_WlanSetMode(ROLE_P2P);
ASSERT_ON_ERROR(lRetVal);
lRetVal = sl_Stop(0xFF);
// reset the Status bits
CLR_STATUS_BIT_ALL(g_ulStatus);
lRetVal = sl_Start(NULL,NULL,NULL);
if(lRetVal < 0 || lRetVal != ROLE_P2P)
{
ASSERT_ON_ERROR(P2P_MODE_START_FAILED);
}
else
{
UART_PRINT("Started SimpleLink Device: P2P Mode\n\r");
return SUCCESS;
}
}
return SUCCESS;
}
示例4: sl_NetAppEvtHdlr
//****************************************************************************
//
//! \brief This function handles events for IP address acquisition via DHCP
//! indication
//!
//! \param[in] pNetAppEvent is the event passed to the handler
//!
//! \return None
//
//****************************************************************************
void sl_NetAppEvtHdlr(SlNetAppEvent_t *pNetAppEvent)
{
unsigned char ucQueueMsg = 0;
switch(pNetAppEvent->Event)
{
case SL_NETAPP_IPV4_IPACQUIRED_EVENT:
case SL_NETAPP_IPV6_IPACQUIRED_EVENT:
g_ulIpAddr = pNetAppEvent->EventData.ipAcquiredV4.ip;
ucQueueMsg = (unsigned char)EVENT_IP_ACQUIRED;
if(g_tConnection != 0)
{
osi_MsgQWrite(&g_tConnection, &ucQueueMsg, OSI_WAIT_FOREVER);
}
else
{
UART_PRINT("Error: sl_NetAppEvtHdlr: Queue does not exist\n\r");
while(FOREVER);
}
UART_PRINT("IP: ");
PrintIPAddr(g_ulIpAddr);
UART_PRINT("\n\r");
break;
default:
break;
}
}
示例5: sl_WlanEvtHdlr
//****************************************************************************
//
//! \brief This function handles WLAN events
//!
//! \param[in] pSlWlanEvent is the event passed to the handler
//!
//! \return None
//
//****************************************************************************
void sl_WlanEvtHdlr(SlWlanEvent_t *pSlWlanEvent)
{
unsigned char ucQueueMsg = 0;
switch(pSlWlanEvent->Event)
{
case SL_WLAN_CONNECT_EVENT:
ucQueueMsg = (unsigned char)EVENT_CONNECTION;
if(g_tConnection != 0)
{
osi_MsgQWrite(&g_tConnection, &ucQueueMsg, OSI_WAIT_FOREVER);
}
else
{
UART_PRINT("Error: sl_WlanEvtHdlr: Queue does not exist\n\r");
while(FOREVER);
}
UART_PRINT("C\n\r");
break;
case SL_WLAN_DISCONNECT_EVENT:
ucQueueMsg = (unsigned char)EVENT_DISCONNECTION;
if(g_tConnection != 0)
{
osi_MsgQWrite(&g_tConnection, &ucQueueMsg, OSI_WAIT_FOREVER);
}
else
{
UART_PRINT("Error: sl_WlanEvtHdlr: Queue does not exist\n\r");
while(FOREVER);
}
UART_PRINT("D\n\r");
break;
default:
break;
}
}
示例6: PingTest
//****************************************************************************
//
//! \brief device will try to ping the machine that has just connected to the
//! device.
//!
//! \param ulIpAddr is the ip address of the station which has connected to
//! device
//!
//! \return 0 if ping is successful, -1 for error
//
//****************************************************************************
static int PingTest(unsigned long ulIpAddr)
{
signed long retVal = -1;
SlPingStartCommand_t PingParams;
SlPingReport_t PingReport;
PingParams.PingIntervalTime = PING_INTERVAL;
PingParams.PingSize = PING_PKT_SIZE;
PingParams.PingRequestTimeout = PING_TIMEOUT;
PingParams.TotalNumberOfAttempts = NO_OF_ATTEMPTS;
PingParams.Flags = PING_FLAG;
PingParams.Ip = ulIpAddr; /* Cleint's ip address */
UART_PRINT("Running Ping Test...\n\r");
/* Check for LAN connection */
retVal = sl_NetAppPingStart((SlPingStartCommand_t*)&PingParams, SL_AF_INET,
(SlPingReport_t*)&PingReport, SimpleLinkPingReport);
ASSERT_ON_ERROR(__LINE__, retVal);
while(!IS_PING_DONE(g_ulStatus))
{
// Wait for Ping Event
}
if (g_ulPingPacketsRecv)
{
// LAN connection is successful
UART_PRINT("Ping Test successful\n\r");
return SUCCESS;
}
else
{
// Problem with LAN connection
return LAN_CONNECTION_FAILED;
}
}
示例7: Init
static void Init()
{
long lRetVal = -1;
BoardInit();
UDMAInit();
PinMuxConfig();
InitTerm();
InitializeAppVariables();
//
// Following function configure the device to default state by cleaning
// the persistent settings stored in NVMEM (viz. connection profiles &
// policies, power policy etc)
//
// Applications may choose to skip this step if the developer is sure
// that the device is in its default state at start of applicaton
//
// Note that all profiles and persistent settings that were done on the
// device will be lost
//
lRetVal = ConfigureSimpleLinkToDefaultState();
if (lRetVal < 0) {
if (DEVICE_NOT_IN_STATION_MODE == lRetVal)
UART_PRINT(
"Failed to configure the device in its default state \n\r");
LOOP_FOREVER()
;
}
//
// Asumption is that the device is configured in station mode already
// and it is in its default state
//
lRetVal = sl_Start(0, 0, 0);
if (lRetVal < 0) {
UART_PRINT("Failed to start the device \n\r");
LOOP_FOREVER()
;
}
UART_PRINT("Connecting to AP: '%s'...\r\n", SSID_NAME);
// Connecting to WLAN AP - Set with static parameters defined at common.h
// After this call we will be connected and have IP address
lRetVal = WlanConnect();
if (lRetVal < 0) {
UART_PRINT("Connection to AP failed \n\r");
LOOP_FOREVER()
;
}
UART_PRINT("Connected to AP: '%s' \n\r", SSID_NAME);
#ifdef NEW_ID
iobeam_Reset();
#endif
}
示例8: main
int main()
{
/*
* Preparation
*/
// Board Initialization
BoardInit();
// Configuring UART
InitTerm();
// Connect to AP
// Put your SSID and password in common.h
long lRetVal = ConnectToAP();
if(lRetVal < 0)
{
UART_PRINT("Connection to AP failed\n\r");
LOOP_FOREVER();
}
UART_PRINT("Connected to AP\n\r");
if(lRetVal < 0)
{
LOOP_FOREVER();
}
// Declare thing
Thing_Struct thing;
// Connect to thethingsiO server
lRetVal = ConnectTo_thethingsiO(&thing.thing_client);
if(lRetVal < 0)
{
LOOP_FOREVER();
}
UART_PRINT("Thing client connected\n\r");
// In order to initialize the thing correctly you have to use one of
// following two methods:
// 1. If you have already activated your thing you should set the token
thing.token = "YOUR TOKEN HERE";
// 2. Or if not copy the provided activation code here
// and uncomment the following line
// char *act_code = "YOUR ACTIVATION CODE HERE";
// and activate the thing (uncomment the following line)
// char *token = thing_activate(&thing, act_code);
/* Intializes random number generator */
// time_t t;
// srand((unsigned) time(&t));
while(1)
{
char *sub = thing_subscribe(&thing);
if (strlen(sub) > 0)
{
UART_PRINT(sub);
UART_PRINT("\n\r");
}
// Free memory
free(sub);
}
}
示例9: net_ping
void net_ping(const char *host)
{
SlPingStartCommand_t pingParams = {0};
SlPingReport_t pingReport = {0};
unsigned long ulIpAddr = 0;
CLR_STATUS_BIT(g_ulStatus, STATUS_BIT_PING_DONE);
// Set the ping parameters
pingParams.PingIntervalTime = 1000;
pingParams.PingSize = 20;
pingParams.PingRequestTimeout = 3000;
pingParams.TotalNumberOfAttempts = 3;
pingParams.Flags = 0;
pingParams.Ip = g_ulGatewayIP;
UART_PRINT("ping host: %s\r\n", host);
sl_NetAppDnsGetHostByName((signed char*)host, strlen(host), &ulIpAddr, SL_AF_INET);
UART_PRINT("host ip: 0x%08X\r\n", host);
pingParams.Ip = ulIpAddr;
sl_NetAppPingStart((SlPingStartCommand_t*)&pingParams, SL_AF_INET, (SlPingReport_t*)&pingReport, SimpleLinkPingReport);
while(!IS_PING_DONE(g_ulStatus))
_SlNonOsMainLoopTask();
}
示例10: DSPCeateInstance
tDSPInstance* DSPCeateInstance(uint32_t signalSize, uint32_t Fs) {
tDSPInstance* tempInstance;
tempInstance = (tDSPInstance*)malloc(sizeof(tDSPInstance));
if (tempInstance == NULL){
UART_PRINT("DSPCreate malloc error!");
LOOP_FOREVER(); //malloc error. heap too small?
return NULL;
}
tempInstance->signalSize = signalSize;
tempInstance->Fs = Fs;
tempInstance->ucpSignal = (unsigned char*)malloc(sizeof(unsigned char)*signalSize);
tempInstance->fpSignal = (float32_t*)malloc(sizeof(float32_t)*signalSize/2);
tempInstance->fftSize = signalSize / 4;
tempInstance->FFTResults = (float32_t*)malloc(sizeof(float32_t)*tempInstance->fftSize);
if (tempInstance->ucpSignal==NULL || \
tempInstance->fpSignal==NULL || \
tempInstance->FFTResults==NULL) {
UART_PRINT("DSPCreate malloc error!");
LOOP_FOREVER(); //malloc error. heap too small?
return NULL;
}
tempInstance->maxEnergyBinIndex = 0;
tempInstance->maxEnergyBinValue = 0;
return tempInstance;
}
示例11: SimpleLinkSockEventHandler
//*****************************************************************************
//
//! This function handles socket events indication
//!
//! \param[in] pSock - Pointer to Socket Event Info
//!
//! \return None
//!
//*****************************************************************************
void SimpleLinkSockEventHandler(SlSockEvent_t *pSock)
{
//
// This application doesn't work w/ socket - Events are not expected
//
switch( pSock->Event )
{
case SL_SOCKET_TX_FAILED_EVENT:
switch( pSock->EventData.status )
{
case SL_ECLOSE:
UART_PRINT("[SOCK ERROR] - close socket (%d) operation "
"failed to transmit all queued packets\n\n",
pSock->EventData.sd);
break;
default:
UART_PRINT("[SOCK ERROR] - TX FAILED : socket %d , reason"
"(%d) \n\n",
pSock->EventData.sd, pSock->EventData.status);
}
break;
default:
UART_PRINT("[SOCK EVENT] - Unexpected Event [%x0x]\n\n",pSock->Event);
}
}
示例12: LoadDefaultValues
//*****************************************************************************
//
//! Function - Read Predefined Values. Populate Key,PlainText,Mode etc from
//! pre-defined Vectors
//!
//! \param ui32Config - Configuration Value (Direction | Mode |KeySize)
//! \out uiConfig - Configuration value
//! \out uiKeySize - Key Size used
//! \out uiIV - Initialization Vector
//! \out puiKey1 - Key Used
//! \out uiDataLength - DataLength Used
//! \out puiResult - Result
//!
//! \return Returns /\e true on success or \e false on failure.
//
//*****************************************************************************
unsigned int *
LoadDefaultValues(unsigned int ui32Config,unsigned int *uiConfig,
unsigned int *uiKeySize,
unsigned int **uiIV,unsigned int **puiKey1,
unsigned int *uiDataLength,unsigned int **puiResult)
{
unsigned int *uiData;
//
// Populate all the out parameters from pre-defined vector
//
*uiConfig=ui32Config;
//
// Read Key and Key size
//
*puiKey1=psAESCBCTestVectors.pui32Key1;
*uiKeySize=psAESCBCTestVectors.ui32KeySize;
//
// Read Initialization Vector
//
*uiIV=&psAESCBCTestVectors.pui32IV[0];
//
// Read Data Length and allocate Result and Data variables accordingly
//
*uiDataLength=psAESCBCTestVectors.ui32DataLength;
*puiResult=(unsigned int*)malloc(*uiDataLength);
if(*puiResult != NULL)
{
memset(*puiResult,0,*uiDataLength);
}
else
{
//Failed to allocate memory
UART_PRINT("Failed to allocate memory");
return 0;
}
uiData=(unsigned int*)malloc(*uiDataLength);
if(uiData != NULL)
{
memset(uiData,0,*uiDataLength);
}
else
{
//Failed to allocate memory
UART_PRINT("Failed to allocate memory");
return 0;
}
//
// Copy Plain Text or Cipher Text into the variable Data
//
if(ui32Config & AES_CFG_DIR_ENCRYPT)
memcpy(uiData,psAESCBCTestVectors.pui32PlainText,*uiDataLength);
else
memcpy(uiData,psAESCBCTestVectors.pui32CipherText,*uiDataLength);
return uiData;
}
示例13: startApplication
void startApplication(void *pvParameters) {
// TODO: Change to your SSID and password
signed char ssid[] = "<wifi ssid>";
signed char key[] = "<wifi password>";
SlSecParams_t keyParams;
keyParams.Type = SL_SEC_TYPE_WPA;
keyParams.Key = key;
keyParams.KeyLen = strlen((char *)key);
initNetwork(ssid, &keyParams);
// TODO: Set to current date/time (within an hour precision)
SlDateTime_t dateTime;
memset(&dateTime, 0, sizeof(dateTime));
dateTime.sl_tm_year = 2015;
dateTime.sl_tm_mon = 3;
dateTime.sl_tm_day = 20;
dateTime.sl_tm_hour = 12;
sl_DevSet(SL_DEVICE_GENERAL_CONFIGURATION, SL_DEVICE_GENERAL_CONFIGURATION_DATE_TIME, sizeof(SlDateTime_t), (unsigned char *)&dateTime);
UART_PRINT("\r\n");
UART_PRINT("[QuickStart] Start application\r\n");
UART_PRINT("\r\n");
// TODO: Add Parse code here
}
示例14: SimpleLinkNetAppEventHandler
void SimpleLinkNetAppEventHandler(SlNetAppEvent_t *pNetAppEvent) {
switch (pNetAppEvent->Event) {
case SL_NETAPP_IPV4_IPACQUIRED_EVENT:
{
UART_PRINT("[QuickStart] IP address : %d.%d.%d.%d\r\n",
SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip, 3),
SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip, 2),
SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip, 1),
SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.ip, 0));
UART_PRINT("[QuickStart] Gateway : %d.%d.%d.%d\r\n",
SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway, 3),
SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway, 2),
SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway, 1),
SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.gateway, 0));
UART_PRINT("[QuickStart] DNS server : %d.%d.%d.%d\r\n",
SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.dns, 3),
SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.dns, 2),
SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.dns, 1),
SL_IPV4_BYTE(pNetAppEvent->EventData.ipAcquiredV4.dns, 0));
SET_STATUS_BIT(g_Status, STATUS_BIT_IP_AQUIRED);
}
break;
default:
break;
}
}
示例15: main
int main(void) {
// init the hardware
initBoard();
UART_PRINT("[Blink] Start application\r\n");
// create the main application message queue
// this call properly enables the OSI scheduler to function
short status = osi_MsgQCreate(&g_ApplicationMessageQueue, "ApplicationMessageQueue", sizeof(ApplicationMessage), 1);
if (status < 0) {
UART_PRINT("[Blink] Create application message queue error\r\n");
ERR_PRINT(status);
LOOP_FOREVER();
}
// start the main application task
// this is necessary because SimpleLink host driver is started by sl_Start(),
// which cannot be called on before the OSI scheduler is started
status = osi_TaskCreate(startApplication, (signed char *)"Blink", OSI_STACK_SIZE, NULL, OOB_TASK_PRIORITY, NULL);
if (status < 0) {
UART_PRINT("[Blink] Start application error\r\n");
ERR_PRINT(status);
LOOP_FOREVER();
}
// start the OSI scheduler
osi_start();
return 0;
}