歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> 嵌入式Linux 下 通用 console(控制台)的實現

嵌入式Linux 下 通用 console(控制台)的實現

日期:2017/3/1 11:16:53   编辑:Linux編程

前言:

當我們使用嵌入式linux 進行開發時,kernel 跑起來之後,我們希望能通過串口(標准輸入、輸出),在應用程序正在運行的過程中,進行一些調試工作,例如,對CPU一些寄存進行調整,以觀測調整以後的結果,並且,當我們無法把我們的應用程序放在後台運行,那麼我們就需要實現一個基礎的控制台。

下文中的控制台,雖然簡單,但完備的支持 上 下 左 右 backspace del 常用控制台操作,使用 上 下 鍵可以浏覽已經輸入過的命令(類似 doskey 這樣的功能),支持 光標 左右移動 修改命令

一般我們在 main 函數最後 都會做 while(TRUE) sleep(1000) 這樣 阻塞住主線程,用這個控制台的實現,替換這個過程,則應用程序可增加控制台應用功能,各部分的具體實現如下:

調用代碼(main.c):

  1. #include <stdio.h>
  2. #include "app_console.h"
  3. int main(int argc, char *argv[])
  4. {
  5. // 之前的應用代碼
  6. ....
  7. ....
  8. ....
  9. App_Console_Start();
  10. return 0;
  11. }

控制台頭文件(app_console.h)

  1. #ifndef __APP_CONSOLE_H__
  2. #define __APP_CONSOLE_H__
  3. #ifdef __cplusplus
  4. extern "C"
  5. {
  6. #endif
  7. #include "type_def.h"
  8. void App_Console_Start();
  9. #ifdef __cplusplus
  10. }
  11. #endif
  12. #endif

控制台C文件(app_console.c)

  1. #include "app_console.h"
  2. #include "ctype.h"
  3. #include "unistd.h"
  4. #include "app_test.h"
  5. // 說明
  6. // read write 使用的是 POSIX 的標准文件讀寫函數
  7. // unistd.h 包含了 STDIN_FILENO 等文件描述符的定義
  8. // ctype.h 包含了 isprint 函數的聲明
  9. // 經過仔細考慮,決定不支持 ESC 鍵,因為ESC 鍵的鍵值為 0x1b 與 上下左右的鍵值重復
  10. // 但可以考慮按2下ESC清除本行輸入
  11. // 對不可打印字符的處理僅限於以下已經列出的宏定義
  12. // change:
  13. // 放棄對 double ESC 的支持,因為可能出現按了 ESC 又按了 方向鍵 的情況
  14. // 則用戶輸入編碼為 '/x1b' '/x1b' '[' 'A' (按了ESC 又按了上鍵)
  15. // change:
  16. // 為了將應用與控制台應用剝離,則將 #define MAX_CMD_LEN 512 房到 app_test.h 中定義
  17. // 二維數組作為參數進行傳遞時,需要明確第二個維度的大小,否則編譯器無法正確定位地址
  18. #define KEY_BACKSPACE '/x08' // back space
  19. #define KEY_DEL '/x7F' // del
  20. #define KEY_ENTER '/x0A' // 回車
  21. // 以下為 0x1b 開頭的鍵值
  22. //#define KEY_DOUBLEESC "/x1B/x1B"// ESC
  23. //#define KEY_ARROW_UP "/x1B[A" // 上
  24. //#define KEY_ARROW_DOWN "/x1B[B" // 下
  25. //#define KEY_ARROW_LEFT "/x1B[D" // 左
  26. //#define KEY_ARROW_RIGHT "/x1B[C" // 右
  27. typedef enum
  28. {
  29. WKS_WAIT,
  30. WKS_RECV1B,
  31. WKS_UDLR,
  32. }T_WaitKeyState;
  33. #define MAX_CMD_HISTORY 32
  34. #define MAX_PAR_COUNT 16
  35. static char szPrompt[] = {"TR_Console> "};
  36. static T_WaitKeyState waitKeyState = WKS_WAIT;
  37. static char szCmdHistory[MAX_CMD_HISTORY][MAX_CMD_LEN];
  38. static char szCmdNow[MAX_CMD_LEN] = {0};
  39. static UINT32 nCmdIndex = 0;
  40. static UINT32 nCmdCursor = 0;
  41. static UINT32 nCmdInputCount = 0;
  42. static UINT32 nCmdInputCursor = 0;
  43. static void App_Console_ParseCmd(const char* pCmd);
  44. static UINT32 App_Console_ReadInput(char *input)
  45. {
  46. U32 nRead=0;
  47. struct pollfd p;
  48. struct termio term,term_old;
  49. /* Get control of the terminal */
  50. ioctl(STDIN_FILENO,TCGETA,(void *)&term);
  51. term_old = term;
  52. term.c_lflag &= ~ICANON;
  53. term.c_lflag &= ~ECHO;
  54. ioctl(STDIN_FILENO,TCSETAW,(void *)&term);
  55. /* Get event we want to know */
  56. p.fd = STDIN_FILENO;
  57. p.events = POLLIN;
  58. /* If we receive one thing, get the byte now */
  59. if (poll(&p,1,-1)>0)
  60. {
  61. if (p.revents==POLLIN)
  62. {
  63. nRead=read(STDIN_FILENO,input,1);
  64. }
  65. }
  66. /* Purge the byte */
  67. /* tcflush(0,TCIOFLUSH); */
  68. /* Leave control */
  69. ioctl(STDIN_FILENO,TCSETAW,(void *)&term_old);
  70. return(nRead);
  71. }
  72. static void App_Console_BSChar()
  73. {
  74. char szTemp[3];
  75. szTemp[0] = '/b';
  76. szTemp[1] = ' ';
  77. szTemp[2] = '/b';
  78. write(STDOUT_FILENO,szTemp,3);
  79. }
  80. static void App_Console_OnPrintChar(char input)
  81. {
  82. if(nCmdInputCount == MAX_CMD_LEN) return;
  83. if(nCmdInputCursor < nCmdInputCount) // 光標不在末尾
  84. {
  85. char szTemp[MAX_CMD_LEN] = {0};
  86. char* pCmd = szCmdNow;
  87. int nBackCount = nCmdInputCount-nCmdInputCursor;
  88. szTemp[0] = input;
  89. memcpy(&szTemp[1],&pCmd[nCmdInputCursor],nBackCount);
  90. write(STDOUT_FILENO,szTemp,nBackCount+1);
  91. memcpy(&pCmd[nCmdInputCursor],&szTemp,nBackCount+1);
  92. memset(szTemp,'/b',nBackCount);
  93. write(STDOUT_FILENO,szTemp,nBackCount);
  94. }
  95. else
  96. {
  97. write(STDOUT_FILENO,&input,1);
  98. szCmdNow[nCmdInputCount] = input;
  99. }
  100. nCmdInputCursor++;
  101. nCmdInputCount++;
  102. }
  103. static void App_Console_OnBackspace()
  104. {
  105. if(nCmdInputCursor > 0)
  106. {
  107. if(nCmdInputCursor == nCmdInputCount) // 光標在末尾
  108. App_Console_BSChar();
  109. else// 光標不在末尾
  110. {
  111. char szTemp[MAX_CMD_LEN] = {0};
  112. char* pCmd = szCmdNow;
  113. int nBackCount = nCmdInputCount-nCmdInputCursor;
  114. szTemp[0] = '/b';
  115. memcpy(&szTemp[1],&pCmd[nCmdInputCursor],nBackCount);
  116. szTemp[nBackCount+1] = ' ';
  117. write(STDOUT_FILENO,szTemp,nBackCount+2);
  118. memcpy(&pCmd[nCmdInputCursor-1],&szTemp[1],nBackCount);
  119. memset(szTemp,'/b',nBackCount+1);
  120. write(STDOUT_FILENO,szTemp,nBackCount+1);
  121. }
  122. nCmdInputCount --;
  123. nCmdInputCursor--;
  124. }
  125. }
  126. static void App_Console_OnDel()
  127. {
  128. if(nCmdInputCursor < nCmdInputCount) // 光標不在末尾
  129. {
  130. char szTemp[MAX_CMD_LEN] = {0};
  131. char* pCmd = szCmdNow;
  132. int nBackCount = nCmdInputCount-nCmdInputCursor-1;
  133. memcpy(szTemp,&pCmd[nCmdInputCursor+1],nBackCount);
  134. szTemp[nBackCount] = ' ';
  135. write(STDOUT_FILENO,szTemp,nBackCount+1);
  136. memcpy(&pCmd[nCmdInputCursor],szTemp,nBackCount);
  137. memset(szTemp,'/b',nBackCount+1);
  138. write(STDOUT_FILENO,szTemp,nBackCount+1);
  139. nCmdInputCount--;
  140. }
  141. }
  142. static void App_Console_OnDoubleEsc()
  143. {
  144. if(nCmdInputCount > 0)
  145. {
  146. char* pCmd = szCmdNow;
  147. // 將光標移動到最末尾
  148. while(nCmdInputCursor < nCmdInputCount)
  149. {
  150. write(STDOUT_FILENO,&pCmd[nCmdInputCursor],1);
  151. nCmdInputCursor++;
  152. }
  153. // 清除所有輸入的數據
  154. int i=0;
  155. for(i=0;i<nCmdInputCount;i++) App_Console_BSChar();
  156. nCmdInputCount = 0;
  157. nCmdInputCursor = 0;
  158. }
  159. }
  160. static void App_Console_OnUp()
  161. {
  162. if(nCmdCursor == 0) return;
  163. nCmdCursor --;
  164. // 清除掉現在所有的輸入
  165. App_Console_OnDoubleEsc();
  166. char* pCmdHistory = &szCmdHistory[nCmdCursor][0];
  167. memcpy(szCmdNow,pCmdHistory,MAX_CMD_LEN);
  168. nCmdInputCount = strlen(szCmdNow);
  169. nCmdInputCursor= nCmdInputCount;
  170. write(STDOUT_FILENO,szCmdNow,nCmdInputCount);
  171. }
  172. static void App_Console_OnDown()
  173. {
  174. if(nCmdCursor >= (nCmdIndex-1)) return;
  175. nCmdCursor ++;
  176. // 清除掉現在所有的輸入
  177. App_Console_OnDoubleEsc();
  178. char* pCmdHistory = &szCmdHistory[nCmdCursor][0];
  179. memcpy(szCmdNow,pCmdHistory,MAX_CMD_LEN);
  180. nCmdInputCount = strlen(szCmdNow);
  181. nCmdInputCursor= nCmdInputCount;
  182. write(STDOUT_FILENO,szCmdNow,nCmdInputCount);
  183. }
  184. static void App_Console_OnLeft()
  185. {
  186. if(nCmdInputCursor > 0)
  187. {
  188. char c = '/b';
  189. write(STDOUT_FILENO,&c,1);
  190. nCmdInputCursor--;
  191. }
  192. }
  193. static void App_Console_OnRight()
  194. {
  195. if(nCmdInputCursor < nCmdInputCount)
  196. {
  197. char* pCmd = szCmdNow;
  198. char c = pCmd[nCmdInputCursor];
  199. write(STDOUT_FILENO,&c,1);
  200. nCmdInputCursor++;
  201. }
  202. }
  203. static void App_Console_OnEnter()
  204. {
  205. szCmdNow[nCmdInputCount] = '/0';
  206. char szTemp[] = {"/r/n"};
  207. write(STDOUT_FILENO,szTemp,strlen(szTemp));
  208. nCmdInputCount = 0;
  209. nCmdInputCursor = 0;
  210. if(strlen(szCmdNow) == 0) return;
  211. if(nCmdIndex == MAX_CMD_HISTORY) // 命令隊列滿了,移動
  212. {
  213. char szTempCmd[MAX_CMD_HISTORY][MAX_CMD_LEN];
  214. memcpy(szTempCmd,&szCmdHistory[1][0],MAX_CMD_LEN*(MAX_CMD_HISTORY-1));
  215. memcpy(szCmdHistory,szTempCmd,MAX_CMD_LEN*(MAX_CMD_HISTORY-1));
  216. nCmdIndex = MAX_CMD_HISTORY-1;
  217. nCmdCursor = nCmdIndex;
  218. }
  219. memcpy(szCmdHistory[nCmdIndex],szCmdNow,MAX_CMD_LEN);
  220. nCmdIndex++;
  221. nCmdCursor = nCmdIndex;
  222. // 解析命令
  223. App_Console_ParseCmd(szCmdNow);
  224. }
  225. static void App_Console_CmdLoop()
  226. {
  227. BOOL bGetEnter = FALSE;
  228. while(TRUE)
  229. {
  230. // 讀取一個console輸入
  231. UINT32 nReturn = 0;
  232. char input;
  233. nReturn = App_Console_ReadInput (&input);
  234. if(nReturn > 0)
  235. {
  236. switch(waitKeyState)
  237. {
  238. case WKS_WAIT :
  239. if(isprint(input))// 可打印字符
  240. App_Console_OnPrintChar(input);
  241. else
  242. {
  243. if(input == KEY_BACKSPACE)
  244. App_Console_OnBackspace();
  245. else if(input == KEY_DEL)
  246. App_Console_OnDel();
  247. else if(input == KEY_ENTER)
  248. {
  249. App_Console_OnEnter();
  250. bGetEnter = TRUE;
  251. }
  252. else if(input == '/x1b')
  253. waitKeyState = WKS_RECV1B;
  254. else
  255. waitKeyState = WKS_WAIT;
  256. }
  257. break;
  258. case WKS_RECV1B:
  259. if(input == '/x1b') // 按了ESC 又按了方向鍵,或者是 ESC
  260. {
  261. //App_Console_OnDoubleEsc();
  262. waitKeyState = WKS_RECV1B;
  263. }
  264. else
  265. if(input == '[') //可能為 上下左右 4個鍵
  266. waitKeyState = WKS_UDLR;
  267. else//下面的情況為 按了 ESC 鍵之後,按了其他的鍵的處理
  268. {
  269. if(isprint(input)) App_Console_OnPrintChar(input);
  270. waitKeyState = WKS_WAIT;
  271. }
  272. break;
  273. case WKS_UDLR:
  274. if(input == 'A')// 上
  275. App_Console_OnUp();
  276. else if(input == 'B')// 下
  277. App_Console_OnDown();
  278. else if(input == 'D')// 左
  279. App_Console_OnLeft();
  280. else if(input == 'C')// 右
  281. App_Console_OnRight();
  282. else
  283. {
  284. if(isprint(input)) App_Console_OnPrintChar(input);
  285. }
  286. waitKeyState = WKS_WAIT;
  287. break;
  288. default:
  289. break;
  290. }
  291. }
  292. if(bGetEnter)
  293. {
  294. break;
  295. }
  296. }
  297. }
  298. void App_Console_Start()
  299. {
  300. // 清空 sdtout 緩沖
  301. fflush(stdout);
  302. fflush(stdin);
  303. char szTemp[] = {"/r/nStart TR Console.../r/n/r/n"};
  304. write(STDOUT_FILENO,szTemp,strlen(szTemp));
  305. while(TRUE)
  306. {
  307. write(STDOUT_FILENO,szPrompt,strlen(szPrompt));
  308. App_Console_CmdLoop();
  309. }
  310. }
  311. // 解析命令
  312. static void App_Console_ParseCmd(const char* pCmd)
  313. {
  314. int length = strlen(pCmd);
  315. // 全部轉小寫
  316. int i=0;
  317. char szTempCmd[MAX_CMD_LEN];
  318. for (i=0; i < length; i++) szTempCmd[i] = tolower(pCmd[i]);
  319. // 將輸入的命令各個 part 分開
  320. char szPart[MAX_PAR_COUNT][MAX_CMD_LEN];
  321. int nPartCount = 0;
  322. int nPartCursor = 0;
  323. int nCmdCursor = 0;
  324. memset(szPart,0,sizeof(szPart));
  325. while(TRUE)
  326. {
  327. if(nCmdCursor == length)
  328. {
  329. if(nPartCursor > 0)
  330. {
  331. nPartCount++;
  332. nPartCursor = 0;
  333. }
  334. break;
  335. }
  336. if( (szTempCmd[nCmdCursor] == ',') || (szTempCmd[nCmdCursor] == ' ') ) // part 分割符
  337. {
  338. szPart[nPartCount][nPartCursor] = '/0';
  339. nPartCount++;
  340. nPartCursor = 0;
  341. }
  342. else
  343. {
  344. szPart[nPartCount][nPartCursor] = szTempCmd[nCmdCursor];
  345. nPartCursor++;
  346. }
  347. nCmdCursor++;
  348. }
  349. App_Test_OnCmd(szPart,nPartCount);
  350. }

命令實現頭文件(app_test.h)

view plaincopy to clipboardprint?

  1. #ifndef __APP_TEST_H__
  2. #define __APP_TEST_H__
  3. #ifdef __cplusplus
  4. extern "C"
  5. {
  6. #endif
  7. #include "type_def.h"
  8. #define MAX_CMD_LEN 512
  9. void App_Test_OnCmd(char szPart[][MAX_CMD_LEN],int nPartCount);
  10. #ifdef __cplusplus
  11. }
  12. #endif
  13. #endif

命令實現c文件(app_test.c)

view plaincopy to clipboardprint?

  1. #include "app_test.h"
  2. #include "stapp_main.h"
  3. #include "app_qam.h"
  4. #include "api_av.h"
  5. #include "api_video.h"
  6. #include "api_audio.h"
  7. #include "api_pcr.h"
  8. static void App_Test_OnHelp();
  9. static void App_Test_OnWriteReg8(char szPart[][MAX_CMD_LEN],int nPartCount);
  10. static void App_Test_OnReadReg8(char szPart[][MAX_CMD_LEN],int nPartCount);
  11. static void App_Test_OnQamConnect(char szPart[][MAX_CMD_LEN],int nPartCount);
  12. static void App_Test_OnAVPlayMpeg(char szPart[][MAX_CMD_LEN],int nPartCount);
  13. static void App_Test_OnAVStop();
  14. static void App_Test_OnVolumeSet(char szPart[][MAX_CMD_LEN],int nPartCount);
  15. static void App_Test_OnMute();
  16. static void App_Test_OnUnmute();
  17. static void App_Test_OnDENCRegDum();
  18. static void App_Test_OnDENCRegSet(char szPart[][MAX_CMD_LEN],int nPartCount);
  19. void App_Test_OnCmd(char szPart[][MAX_CMD_LEN],int nPartCount)
  20. {
  21. // 這裡處理私有的命令
  22. if(nPartCount == 0) return;
  23. if( strcmp(szPart[0],"help") == 0)
  24. {
  25. App_Test_OnHelp();
  26. }
  27. else if( strcmp(szPart[0],"writereg8") == 0)
  28. {
  29. if(nPartCount > 2) App_Test_OnWriteReg8(szPart,nPartCount);
  30. }
  31. else if( strcmp(szPart[0],"readreg8") == 0)
  32. {
  33. if(nPartCount > 1) App_Test_OnReadReg8(szPart,nPartCount);
  34. }
  35. else if( strcmp(szPart[0],"qamconnect") == 0)
  36. {
  37. if(nPartCount > 1) App_Test_OnQamConnect(szPart,nPartCount);
  38. }
  39. else if( strcmp(szPart[0],"avplaympeg") == 0)
  40. {
  41. if(nPartCount > 1) App_Test_OnAVPlayMpeg(szPart,nPartCount);
  42. }
  43. else if( strcmp(szPart[0],"avstop") == 0)
  44. {
  45. App_Test_OnAVStop();
  46. }
  47. else if( strcmp(szPart[0],"volumeset") == 0)
  48. {
  49. if(nPartCount > 1) App_Test_OnVolumeSet(szPart,nPartCount);
  50. }
  51. else if( strcmp(szPart[0],"mute") == 0)
  52. {
  53. App_Test_OnMute();
  54. }
  55. else if( strcmp(szPart[0],"unmute") == 0)
  56. {
  57. App_Test_OnUnmute();
  58. }
  59. else if( strcmp(szPart[0],"dencregdump") == 0)
  60. {
  61. App_Test_OnDENCRegDum();
  62. }
  63. else if( strcmp(szPart[0],"dencregset") == 0)
  64. {
  65. if(nPartCount > 1) App_Test_OnDENCRegSet(szPart,nPartCount);
  66. }
  67. }
  68. static void App_Test_OnHelp()
  69. {
  70. printf("**************************************************************/n");
  71. printf("* Help PARAM MUST 0 MAX 0 Eg. help/n");
  72. printf("* WriteReg8 PARAM MUST 2 MAX 2 Eg. WriteReg8 0x1920C114 128/n");
  73. printf("* ReadReg8 PARAM MUST 1 MAX 1 Eg. ReadReg8 0x1920C114/n");
  74. printf("* QamConnect PARAM MUST 1 MAX 3 Eg. QamConnect 546000/n");
  75. printf("* AVPlayMpeg PARAM MUST 1 MAX 3 Eg. AVPlayMpeg 64 63 32/n");
  76. printf("* AVStop PARAM MUST 0 MAX 0 Eg. AVStop/n");
  77. printf("* VolumeSet PARAM MUST 1 MAX 1 Eg. VolumeSet 63/n");
  78. printf("* Mute PARAM MUST 0 MAX 0 Eg. Mute/n");
  79. printf("* Unmute PARAM MUST 0 MAX 0 Eg. Unmute/n");
  80. printf("* DENCRegDump PARAM MUST 0 MAX 0 Eg. DENCRegDump/n");
  81. printf("* DENCRegSet PARAM MUST 1 MAX 1 Eg. DENCRegSet 1/n");
  82. printf("*************************************************************/n");
  83. }
  84. static void App_Test_OnWriteReg8(char szPart[][MAX_CMD_LEN],int nPartCount)
  85. {
  86. char* pAddress = &szPart[1][0];
  87. char* pValue = &szPart[2][0];
  88. DWORD dwAddress = 0;
  89. UINT8 nValue = atoi(pValue);
  90. sscanf(pAddress,"0x%08x",&dwAddress);
  91. SYS_WriteRegDev8(dwAddress,nValue);
  92. }
  93. static void App_Test_OnQamConnect(char szPart[][MAX_CMD_LEN],int nPartCount)
  94. {
  95. char* pFreq = &szPart[1][0];
  96. UINT32 nFreq = atoi(pFreq);
  97. UINT32 nSymbolRate = 6875;
  98. T_DMD_Modulation nQAMMode = QAM_64;
  99. if(nPartCount > 2)
  100. {
  101. char* pSymbolRate = &szPart[2][0];
  102. nSymbolRate = atoi(pSymbolRate);
  103. }
  104. if(nPartCount > 3)
  105. {
  106. char* pQAMMode = &szPart[3][0];
  107. nQAMMode = atoi(pQAMMode);
  108. }
  109. App_Qam_Locking(TRUE,nFreq,nSymbolRate,nQAMMode);
  110. }
  111. static void App_Test_OnAVPlayMpeg(char szPart[][MAX_CMD_LEN],int nPartCount)
  112. {
  113. UINT16 nVideoPid = 0xFFFF;
  114. UINT16 nAudioPid = 0xFFFF;
  115. UINT16 nPcrPid = 0xFFFF;
  116. char* pAudioPid = &szPart[1][0];
  117. nAudioPid = atoi(pAudioPid);
  118. if(nPartCount > 2)
  119. {
  120. char* pVideoPid = &szPart[2][0];
  121. nVideoPid = atoi(pVideoPid);
  122. }
  123. if(nPartCount > 3)
  124. {
  125. char* pPcr = &szPart[3][0];
  126. nPcrPid = atoi(pPcr);
  127. }
  128. Api_Av_Stop();
  129. Api_Av_Start(nAudioPid,STREAMTYPE_MP2A,nVideoPid,STREAMTYPE_MP2V,nPcrPid);
  130. }
  131. static void App_Test_OnVolumeSet(char szPart[][MAX_CMD_LEN],int nPartCount)
  132. {
  133. UINT16 nVolume = 0;
  134. char* pVolume = &szPart[1][0];
  135. nVolume = atoi(pVolume);
  136. Api_Audio_Volume_Set(nVolume);
  137. }
  138. static void App_Test_OnMute()
  139. {
  140. Api_Audio_Mute();
  141. }
  142. static void App_Test_OnUnmute()
  143. {
  144. Api_Audio_Unmute();
  145. }
  146. static void App_Test_OnAVStop()
  147. {
  148. Api_Av_Stop();
  149. }
  150. static void App_Test_OnDENCRegDum()
  151. {
  152. printf("* Brightness 0x1920C114 value is 0x%02x/n",SYS_ReadRegDev8(0x1920C114));
  153. printf("* Contrast 0x1920C118 value is 0x%02x/n",SYS_ReadRegDev8(0x1920C118));
  154. printf("* Saturation 0x1920C11c value is 0x%02x/n",SYS_ReadRegDev8(0x1920C11c));
  155. printf("* CHROMA_COEF0 0x1920C120 value is 0x%02x/n",SYS_ReadRegDev8(0x1920C120));
  156. printf("* CHROMA_COEF1 0x1920C124 value is 0x%02x/n",SYS_ReadRegDev8(0x1920C124));
  157. printf("* CHROMA_COEF2 0x1920C128 value is 0x%02x/n",SYS_ReadRegDev8(0x1920C128));
  158. printf("* CHROMA_COEF3 0x1920C12c value is 0x%02x/n",SYS_ReadRegDev8(0x1920C12c));
  159. printf("* CHROMA_COEF4 0x1920C130 value is 0x%02x/n",SYS_ReadRegDev8(0x1920C130));
  160. printf("* CHROMA_COEF5 0x1920C134 value is 0x%02x/n",SYS_ReadRegDev8(0x1920C134));
  161. printf("* CHROMA_COEF6 0x1920C138 value is 0x%02x/n",SYS_ReadRegDev8(0x1920C138));
  162. printf("* CHROMA_COEF7 0x1920C13c value is 0x%02x/n",SYS_ReadRegDev8(0x1920C13c));
  163. printf("* CHROMA_COEF8 0x1920C140 value is 0x%02x/n",SYS_ReadRegDev8(0x1920C140));
  164. printf("* LUM_COEF0 0x1920C148 value is 0x%02x/n",SYS_ReadRegDev8(0x1920C148));
  165. printf("* LUM_COEF1 0x1920C14c value is 0x%02x/n",SYS_ReadRegDev8(0x1920C14c));
  166. printf("* LUM_COEF2 0x1920C150 value is 0x%02x/n",SYS_ReadRegDev8(0x1920C150));
  167. printf("* LUM_COEF3 0x1920C154 value is 0x%02x/n",SYS_ReadRegDev8(0x1920C154));
  168. printf("* LUM_COEF4 0x1920C158 value is 0x%02x/n",SYS_ReadRegDev8(0x1920C158));
  169. printf("* LUM_COEF5 0x1920C15c value is 0x%02x/n",SYS_ReadRegDev8(0x1920C15c));
  170. printf("* LUM_COEF6 0x1920C160 value is 0x%02x/n",SYS_ReadRegDev8(0x1920C160));
  171. printf("* LUM_COEF7 0x1920C164 value is 0x%02x/n",SYS_ReadRegDev8(0x1920C164));
  172. printf("* LUM_COEF8 0x1920C168 value is 0x%02x/n",SYS_ReadRegDev8(0x1920C168));
  173. printf("* LUM_COEF9 0x1920C16c value is 0x%02x/n",SYS_ReadRegDev8(0x1920C16c));
  174. printf("* CFG9 0x1920C144 value is 0x%02x/n",SYS_ReadRegDev8(0x1920C144));
  175. }
  176. static void App_Test_OnDENCRegSet(char szPart[][MAX_CMD_LEN],int nPartCount)
  177. {
  178. UINT16 nScheme = 1;
  179. char* pScheme = &szPart[1][0];
  180. nScheme = atoi(pScheme);
  181. switch(nScheme)
  182. {
  183. case 1:
  184. break;
  185. case 2:
  186. break;
  187. case 3:
  188. break;
  189. case 4:
  190. break;
  191. default:
  192. break;
  193. }
  194. }
  195. static void App_Test_OnReadReg8(char szPart[][MAX_CMD_LEN],int nPartCount)
  196. {
  197. char* pAddress = &szPart[1][0];
  198. DWORD dwAddress = 0;
  199. sscanf(pAddress,"0x%08x",&dwAddress);
  200. printf("* 0x%08x value is 0x%02x/n",dwAddress,SYS_ReadRegDev8(dwAddress));
  201. }
Copyright © Linux教程網 All Rights Reserved