📄 tmdap.c
字号:
/*
///////////////////////////////////////////////////////////////////////////////
// //
// Copyright (C) 2006-2008 Beijing, pengzhen (pengzhenxp@yahoo.com.cn) //
// //
///////////////////////////////////////////////////////////////////////////////
*/
#include <stdio.h>
#include <tmStdLib.h>
#include <tmNxTypes.h>
#include <tmDbg.h>
#include <tmosal.h>
#include <tmMain.h>
#include <tmbslCore.h>
#include <custom_ops.h>
#include <tmml.h>
/*static*/ tmmlMmspHandle_t m_pMemHandle = 0 ; /* peng zhen */
#define ERROR_REPORT(x) tmError = (x); if (tmError != TM_OK) { \
printf("error 0x%08x: file %s, line %d.\n", tmError, __FILE__, __LINE__); }
#define T_ERROR_REPORT(x) if ((x) != 0) { fprintf(stderr, "Error\n"); }
#include "source\dap_demo.c"
#if 0
void Print_SystemInfo() // expands to right framework for all OS with init. See tmMain.h
{
ptmbslCoreSystemInfo_t pSystemInfo;
UInt32 cpu_frequency ;
UInt32 cpu_frequency_5_percent ;
UInt32 cpu_frequency_plus_5_percent ;
UInt32 cpu_frequency_minus_5_percent ;
UInt32 onesec_start ;
UInt32 onesec_end ;
UInt32 os_frequency ;
UInt32 usleep_frequency ;
UInt err;
int index;
int errors ;
printf("\n") ;
printf("tstClock start\n") ;
printf("\n") ;
err = tmbslCoreGetSystemInfo (&pSystemInfo);
if (err) {
printf("tmbslCoreGetSystemInfo error %08x\n", err) ;
tmMain_EXIT (1);
}
index = pSystemInfo->cpuId;
cpu_frequency = pSystemInfo->pCpuInfo[index].cpuClockFreq ;
cpu_frequency_5_percent = (cpu_frequency * 5) / 100 ;
cpu_frequency_plus_5_percent = cpu_frequency + cpu_frequency_5_percent ;
cpu_frequency_minus_5_percent = cpu_frequency - cpu_frequency_5_percent ;
printf("testing tmosalTaskSleep\n") ;
onesec_start = cycles() ;
tmosalTaskSleep(1000) ;
onesec_end = cycles() ;
os_frequency = onesec_end - onesec_start ;
printf("testing microsleep\n") ;
onesec_start = cycles() ;
microsleep(1000000) ;
onesec_end = cycles() ;
usleep_frequency = onesec_end - onesec_start ;
printf("cpu frequency: %10d\n", cpu_frequency) ;
printf("tmosalTaskSleep frequency: %10d\n", os_frequency) ;
printf("microsleep frequency: %10d\n", usleep_frequency) ;
printf("\n") ;
errors = 0 ;
if ((os_frequency < cpu_frequency_minus_5_percent) ||
(os_frequency > cpu_frequency_plus_5_percent)) {
printf("tmosalTaskSleep frequency is not +-5%% of cpu frequency\n") ;
errors++ ;
}
if ((usleep_frequency < cpu_frequency_minus_5_percent) ||
(usleep_frequency > cpu_frequency_plus_5_percent)) {
printf("microsleep frequency is not +-5%% of cpu frequency\n") ;
errors++ ;
}
}
#endif /* 0 */
tmMain() // expands to right framework for all OS with init. See tmMain.h
{
tmErrorCode_t tmError=TM_OK;
//Print_SystemInfo();
#define tmmlMmspCreateFlags1 \
(tmmlMmspCreateFlags_t)( tmmlMmspMpCached /* | tmmlMmspContiguous | tmmlMmspExtendible */ )
#define tmmlMmspCreateFlags2 (tmmlMmspNormal)
/*------------- Create memspace for this application --------------------*/
//tmError = tmmlCreate (&m_pMemHandle, 32 * 1024 * 1024, tmmlMmspCreateFlags1 );
tmError = tmmlCreate (&m_pMemHandle, 24 * 1024 * 1024, tmmlMmspCreateFlags1 );
//tmError = tmmlCreate (&m_pMemHandle, 20 * 1024 * 1024, tmmlMmspCreateFlags2 );
//printf( " m_pMemHandle = %lx \n", m_pMemHandle );
dap_main(__argc, __argv);
ERROR_REPORT( tmmlDelete( m_pMemHandle ) );
tmMain_EXIT (0); // clean up and legal exit.
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -