嵌入式爱好者

查看: 4835|回复: 4

OK6410 Wince 6修改调试串口问题

[复制链接]

0

主题

0

帖子

71

积分

XX18通行证

扫一扫,手机访问本帖
发表于 2010-8-6 16:16:59 | 显示全部楼层 |阅读模式
请教各位大大,要修改ok6410的com1做普通串口应该要怎么改?
在smdk6410.bat里面发现
  1. set BSP_NOSERIAL=
  2. set BSP_NOUART0=1
  3. set BSP_NOUART1=
  4. set BSP_NOUART2=
  5. set BSP_NOUART3=
  6. set BSP_NOIRDA2=1
  7. set BSP_NOIRDA3=1

  8. set BSP_NOI2C=
  9. set BSP_NOSPI=1

  10. set BSP_NOUSBHCD=

  11. @REM If you want to exclude USB Function driver in BSP. Set this variable
  12. set BSP_NOUSBFN=
  13. @REM This select default function driver
  14. set BSP_USBFNCLASS=SERIAL
  15. @REM set BSP_USBFNCLASS=MASS_STORAGE
  16. @REM DVFS is not yet implemented.
  17. set BSP_USEDVS=1

  18. set BSP_DEBUGPORT=SERIAL_UART0
  19. @REM set BSP_DEBUGPORT=SERIAL_UART1
  20. @REM set BSP_DEBUGPORT=SERIAL_UART2
  21. @REM set BSP_DEBUGPORT=SERIAL_UART3
复制代码
据说还要修改debug.c,在src\oal\oallib里面发现debug.c,内容如下:
  1. //
  2. // Copyright (c) Microsoft Corporation.  All rights reserved.
  3. //
  4. //
  5. // Use of this source code is subject to the terms of the Microsoft end-user
  6. // license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
  7. // If you did not accept the terms of the EULA, you are not authorized to use
  8. // this source code. For a copy of the EULA, please see the LICENSE.RTF on your
  9. // install media.
  10. //
  11. //------------------------------------------------------------------------------
  12. //
  13. //  File:  debug.c
  14. //
  15. //  This module is provides the interface to the serial port.
  16. //
  17. #include <bsp.h>
  18. #include <nkintr.h>

  19. //------------------------------------------------------------------------------
  20. // Defines

  21. //------------------------------------------------------------------------------
  22. // Externs

  23. //------------------------------------------------------------------------------
  24. // Global Variables

  25. //------------------------------------------------------------------------------
  26. // Local Variables

  27. static volatile S3C6410_UART_REG *g_pUARTReg = NULL;
  28. static volatile S3C6410_GPIO_REG *g_pGPIOReg = NULL;
  29. static volatile S3C6410_SYSCON_REG *g_pSysConReg = NULL;

  30. static const UINT32 aSlotTable[16] =
  31. {
  32.     0x0000, 0x0080, 0x0808, 0x0888,
  33.     0x2222, 0x4924, 0x4a52, 0x54aa,
  34.     0x5555, 0xd555, 0xd5d5, 0xddd5,
  35.     0xdddd, 0xdfdd, 0xdfdf, 0xffdf
  36. };

  37. //------------------------------------------------------------------------------
  38. // Local Functions

  39. //------------------------------------------------------------------------------
  40. //
  41. //  Function: OEMInitDebugSerial
  42. //
  43. //  Initializes the debug serial port
  44. //
  45. VOID OEMInitDebugSerial()
  46. {
  47.     UINT32 logMask;
  48.     UINT32 DivSlot;
  49.     float Div;

  50.     //OALMSG(TRUE, (TEXT("[OAL] ++OEMInitDebugSerial()\n\r")));

  51.     // At this moment we must suppress logging.
  52.     //
  53.     logMask = dpCurSettings.ulZoneMask;
  54.     dpCurSettings.ulZoneMask = 0;

  55.     // Map SFR Address
  56.     //
  57.     if (g_pUARTReg == NULL)
  58.     {
  59. #if    (DEBUG_PORT == DEBUG_UART0)
  60.         // UART0
  61.         g_pUARTReg = (S3C6410_UART_REG *)OALPAtoVA(S3C6410_BASE_REG_PA_UART0, FALSE);
  62. #elif (DEBUG_PORT == DEBUG_UART1)
  63.         // UART1
  64.         g_pUARTReg = (S3C6410_UART_REG *)OALPAtoVA(S3C6410_BASE_REG_PA_UART1, FALSE);
  65. #elif (DEBUG_PORT == DEBUG_UART2)
  66.         // UART2
  67.         g_pUARTReg = (S3C6410_UART_REG *)OALPAtoVA(S3C6410_BASE_REG_PA_UART2, FALSE);
  68. #elif (DEBUG_PORT == DEBUG_UART3)
  69.         // UART3
  70.         g_pUARTReg = (S3C6410_UART_REG *)OALPAtoVA(S3C6410_BASE_REG_PA_UART3, FALSE);
  71. #else
  72.         INVALID_DEBUG_PORT        // Error
  73. #endif
  74.     }

  75.     if (g_pGPIOReg == NULL)
  76.     {
  77.         g_pGPIOReg = (S3C6410_GPIO_REG *)OALPAtoVA(S3C6410_BASE_REG_PA_GPIO, FALSE);
  78.     }

  79.     if (g_pSysConReg == NULL)
  80.     {
  81.         g_pSysConReg = (S3C6410_SYSCON_REG *)OALPAtoVA(S3C6410_BASE_REG_PA_SYSCON, FALSE);
  82.     }

  83.     // UART I/O port initialize
  84. #if    (DEBUG_PORT == DEBUG_UART0)
  85.     // UART0 Clock Enable
  86.     g_pSysConReg->PCLK_GATE |= (1<<1);        // UART0
  87.     g_pSysConReg->SCLK_GATE |= (1<<5);        // UART0~3
  88.     // UART0 Port Initialize (RXD0 : GPA0, TXD0: GPA1)
  89.     g_pGPIOReg->GPACON = (g_pGPIOReg->GPACON & ~(0xff<<0)) | (0x22<<0);        // GPA0->RXD0, GPA1->TXD0
  90.     g_pGPIOReg->GPAPUD = (g_pGPIOReg->GPAPUD & ~(0xf<<0)) | (0x1<<0);            // RXD0: Pull-down, TXD0: pull up/down disable
  91. #elif (DEBUG_PORT == DEBUG_UART1)
  92.     // UART1 Clock Enable
  93.     g_pSysConReg->PCLK_GATE |= (1<<2);        // UART1
  94.     g_pSysConReg->SCLK_GATE |= (1<<5);        // UART0~3
  95.     // UART1 Port Initialize (RXD1 : GPA4, TXD1: GPA5)
  96.     g_pGPIOReg->GPACON = (g_pGPIOReg->GPACON & ~(0xff<<16)) | (0x22<<16);    // GPA4->RXD1, GPA5->TXD1
  97.     g_pGPIOReg->GPAPUD = (g_pGPIOReg->GPAPUD & ~(0xf<<8)) | (0x1<<8);            // RXD1: Pull-down, TXD1: pull up/down disable
  98. #elif (DEBUG_PORT == DEBUG_UART2)
  99.     // UART2 Clock Enable
  100.     g_pSysConReg->PCLK_GATE |= (1<<3);        // UART2
  101.     g_pSysConReg->SCLK_GATE |= (1<<5);        // UART0~3
  102.     // UART2 Port Initialize (RXD2 : GPAB0, TXD2: GPB1)
  103.     g_pGPIOReg->GPBCON = (g_pGPIOReg->GPBCON & ~(0xff<<0)) | (0x22<<0);        // GPB0->RXD2, GPB1->TXD2
  104.     g_pGPIOReg->GPBPUD = (g_pGPIOReg->GPBPUD & ~(0xf<<0)) | (0x1<<0);            // RXD2: Pull-down, TXD2: pull up/down disable
  105. #elif (DEBUG_PORT == DEBUG_UART3)
  106.     // UART3 Clock Enable
  107.     g_pSysConReg->PCLK_GATE |= (1<<4);        // UART3
  108.     g_pSysConReg->SCLK_GATE |= (1<<5);        // UART0~3
  109.     // UART3 Port Initialize (RXD3 : GPB2, TXD3: GPB3)
  110.     g_pGPIOReg->GPBCON = (g_pGPIOReg->GPBCON & ~(0xff<<8)) | (0x22<<8);        // GPB2->RXD3, GPB3->TXD3
  111.     g_pGPIOReg->GPBPUD = (g_pGPIOReg->GPBPUD & ~(0xf<<4)) | (0x1<<4);            // RXD3: Pull-down, TXD3: pull up/down disable
  112. #endif

  113.     // Initialize UART
  114.     //
  115.     g_pUARTReg->ULCON = (0<<6)|(0<<3)|(0<<2)|(3<<0);                    // Normal Mode, No Parity, 1 Stop Bit, 8 Bit Data
  116.     g_pUARTReg->UCON = (0<<10)|(1<<9)|(1<<8)|(0<<7)|(0<<6)|(0<<5)|(0<<4)|(1<<2)|(1<<0);    // PCLK divide, Polling Mode
  117.     g_pUARTReg->UFCON = (0<<6)|(0<<4)|(0<<2)|(0<<1)|(0<<0);            // Disable FIFO
  118.     g_pUARTReg->UMCON = (0<<5)|(0<<4)|(0<<0);                        // Disable Auto Flow Control

  119.     Div = (float)((float)S3C6410_PCLK/(16.0*(float)DEBUG_BAUDRATE)) - 1;
  120.     DivSlot = (UINT32)((Div-(int)Div)*16);

  121.     g_pUARTReg->UBRDIV = (UINT32)Div;                                    // Baud rate
  122.     g_pUARTReg->UDIVSLOT = aSlotTable[DivSlot];

  123.     //OALMSG(TRUE, (TEXT("[OAL] OEMInitDebugSerial() : UBRDIV0 = %d, DivSlot = %d, UDIVSLOT0 = 0x%08x\n\r"), (int)Div, DivSlot, aSlotTable[DivSlot]));

  124.     // Restore the logging mask.
  125.     //
  126.     dpCurSettings.ulZoneMask = logMask;

  127.     //OALMSG(TRUE, (TEXT("[OAL] --OEMInitDebugSerial()\n\r")));
  128. }

  129. //------------------------------------------------------------------------------
  130. //
  131. //  Function: OEMWriteDebugByte
  132. //
  133. //  Transmits a character out the debug serial port.
  134. //
  135. VOID OEMWriteDebugByte(UINT8 ch)
  136. {
  137.     // Wait for TX Buffer Empty
  138.     //
  139.     while (!(g_pUARTReg->UTRSTAT & 0x2));

  140.     // TX Character
  141.     //
  142.     g_pUARTReg->UTXH = ch;
  143. }


  144. //------------------------------------------------------------------------------
  145. //
  146. //  Function: OEMReadDebugByte
  147. //
  148. //  Reads a byte from the debug serial port. Does not wait for a character.
  149. //  If a character is not available function returns "OEM_DEBUG_READ_NODATA".
  150. //

  151. int OEMReadDebugByte()
  152. {
  153.     int ch;

  154.     if (g_pUARTReg->UTRSTAT & 0x1)        // There is received data
  155.     {
  156.         ch = (int)(g_pUARTReg->URXH);
  157.     }
  158.     else        // There no data in RX Buffer;
  159.     {
  160.         ch = OEM_DEBUG_READ_NODATA;
  161.     }

  162.     return ch;
  163. }

  164. void OEMWriteDebugLED(UINT16 Index, DWORD Pattern)
  165. {
  166.     if (g_pGPIOReg == NULL)
  167.     {
  168.         // It is first time. Initialize SFR and GPIO set to output
  169.         g_pGPIOReg = (S3C6410_GPIO_REG *)OALPAtoVA(S3C6410_BASE_REG_PA_GPIO, FALSE);
  170. //        g_pGPIOReg->GPNPUD &= ~(0xff<<24);    // Pull Up/Down Disable
  171. //        g_pGPIOReg->GPNCON = (g_pGPIOReg->GPNCON & ~(0xff<<24)) | (0x55<<24);    // GPN[15:12] set to output
  172.     }

  173.     // The SMDK6410 Evaluation Platform supports 4 LEDs
  174. //    g_pGPIOReg->GPNDAT = (g_pGPIOReg->GPNDAT & ~(0xf<<12)) | ((Pattern&0xf)<<12);
  175. }

  176. //------------------------------------------------------------------------------
复制代码
就是不知道应该改哪,跪求各位大侠赐教
回复

使用道具 举报

0

主题

905

帖子

743

积分

i.MX6Q通行证i.MX6UL通行证TCU通行证AM335x通行证

发表于 2010-8-11 21:50:22 | 显示全部楼层
set BSP_NOUART0=1将这句的值去掉
set BSP_DEBUGPORT=SERIAL_UART0将这句屏蔽掉

0

主题

0

帖子

71

积分

XX18通行证

 楼主| 发表于 2010-8-12 11:41:42 | 显示全部楼层
谢谢seventeen
请问src\oal\oallib\debug.c里面还需不需要改动呢?
cincker 该用户已被删除
发表于 2011-7-11 18:00:14 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽

29

主题

9048

帖子

5593

积分

发表于 2011-7-12 08:30:37 | 显示全部楼层
该会员没有填写今日想说内容.
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋| 飞凌嵌入式 ( 冀ICP备12004394号-1 )

GMT+8, 2025-1-11 16:48

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表