TI中文支持网
TI专业的中文技术问题搜集分享网站

SYS/BIOS 使用GIO模块来实现串口驱动 GIO_create() 失败;

1、代码:

UserUartHandle_t*  UserDebugUartHandle()
{
    int32_t ret = 0;
    Error_Block eb;
    GIO_Params     ioParams;
    Uart_ChanParams  chanParams;
    UserUartHandle_t *pUserDebugUartHandle = NULL;

    GIO_Params_init(&ioParams);
    if(pGlobalLogUartInstance == NULL)
    {
        pGlobalLogUartInstance = (UserUartInstance_t*)malloc(sizeof(UserUartInstance_t));
        memset(pGlobalLogUartInstance, 0, sizeof(UserUartInstance_t));

        pGlobalLogUartInstance->deviceId = USER_LOG_UART;
        UartEdmaInit(pGlobalLogUartInstance);
        chanParams.hEdma = pGlobalLogUartInstance->hEdma;
           ioParams.chanParams = (Ptr)&chanParams;
#if 1
        ret = GIO_addDevice("/uart1",                            &Uart_IOMFXNS,                            UserLogUartInit,                            USER_LOG_UART,                            &pGlobalLogUartInstance->uartParams);
        if(ret < 0)
        {            System_printf("\r\n GIO_addDevice add log uart1 fail");
            free(pGlobalLogUartInstance);
            pGlobalLogUartInstance = NULL;
            
            return NULL;
        }
#endif
        
        pGlobalLogUartInstance->uartTxHandle = GIO_create("/uart1", GIO_OUTPUT, &ioParams, &eb);
        pGlobalLogUartInstance->uartRxHandle = GIO_create("/uart1", GIO_INPUT,  &ioParams, &eb);
        if ((NULL == pGlobalLogUartInstance->uartTxHandle) || (NULL == pGlobalLogUartInstance->uartRxHandle))
        {
            System_printf("\nStream creation failed\n");
            free(pGlobalLogUartInstance);
            pGlobalLogUartInstance = NULL;
            
            return NULL;
        }
    }
    
    pUserDebugUartHandle = (UserUartHandle_t*)malloc(sizeof(UserUartHandle_t));
    if(pUserDebugUartHandle == NULL)
    {
        free(pGlobalLogUartInstance);
        pGlobalLogUartInstance = NULL;
        
        return NULL;
    }
    memset(pUserDebugUartHandle, 0, sizeof(UserUartHandle_t));

    pUserDebugUartHandle->deviceId  = USER_LOG_UART;
    pUserDebugUartHandle->uartRead  = UserLogUartRead;
    pUserDebugUartHandle->uartWrite = UserLogUartWrite;
    pUserDebugUartHandle->pInstance = pGlobalLogUartInstance;
    
    if(pUserDebugUartHandle->pInstance == NULL)
    {
        free(pUserDebugUartHandle);
        free(pGlobalLogUartInstance);
        pGlobalLogUartInstance = NULL;
        
        return NULL;
    }

    return  pUserDebugUartHandle;
}

结果是:pGlobalLogUartInstance->uartTxHandle和pGlobalLogUartInstance->uartRxHandle 是空,GIO_create失败;

2、对应的cfg文件如下:

var Defaults = xdc.useModule('xdc.runtime.Defaults');
var Diags = xdc.useModule('xdc.runtime.Diags');
var Error = xdc.useModule('xdc.runtime.Error');
var Log = xdc.useModule('xdc.runtime.Log');
var LoggerBuf = xdc.useModule('xdc.runtime.LoggerBuf');
var Main = xdc.useModule('xdc.runtime.Main');
var Memory = xdc.useModule('xdc.runtime.Memory')
var SysMin = xdc.useModule('xdc.runtime.SysMin');
var System = xdc.useModule('xdc.runtime.System');
var SysStd = xdc.useModule('xdc.runtime.SysStd');
var Assert = xdc.useModule('xdc.runtime.Assert');

var GIO  = xdc.useModule('ti.sysbios.io.GIO');
var BIOS = xdc.useModule('ti.sysbios.BIOS');
var Clock = xdc.useModule('ti.sysbios.knl.Clock');
var Queue = xdc.useModule('ti.sysbios.knl.Queue');
var Event = xdc.useModule('ti.sysbios.knl.Event');
var Semaphore = xdc.useModule('ti.sysbios.knl.Semaphore');
var Hwi = xdc.useModule('ti.sysbios.hal.Hwi');
var Timer = xdc.useModule('ti.sysbios.hal.Timer');
var ti_sysbios_timers_timer64_Timer = xdc.useModule('ti.sysbios.timers.timer64.Timer');
var ti_sysbios_family_c64p_Hwi = xdc.useModule('ti.sysbios.family.c64p.Hwi');
var HeapMem = xdc.useModule('ti.sysbios.heaps.HeapMem');
var Task = xdc.useModule('ti.sysbios.knl.Task');
var ti_sysbios_family_c64p_Exception = xdc.useModule('ti.sysbios.family.c64p.Exception');
var DRV = xdc.useModule('ti.sdo.edma3.drv.DRV');
var RM  = xdc.useModule('ti.sdo.edma3.rm.RM');
var ECM = xdc.useModule ("ti.sysbios.family.c64p.EventCombiner");
var Cache = xdc.useModule ("ti.sysbios.hal.Cache");
var timestamp = xdc.useModule ("xdc.runtime.Timestamp");
var RmSample = xdc.useModule('ti.sdo.edma3.rm.sample.RmSample');
var DrvSample = xdc.useModule('ti.sdo.edma3.drv.sample.DrvSample');
var Swi       = xdc.useModule ("ti.sysbios.knl.Swi");
var HeapBuf = xdc.useModule('ti.sysbios.heaps.HeapBuf');
var HeapMultiBuf = xdc.useModule('ti.sysbios.heaps.HeapMultiBuf');

/* * Program.argSize sets the size of the .args section. * The examples don't use command line args so argSize is setto 0.
 */
Program.argSize = 0x0;

/*
 * Uncomment this line to globally disable Asserts.
 * All modules inherit the default from the 'Defaults' module.  You
 * can override these defaults on a per-module basis using Module.common$. * Disabling Asserts will save code space and improve runtime performance.
Defaults.common$.diags_ASSERT = Diags.ALWAYS_OFF;
 */

/*
 * Uncomment this line to keep module names from being loaded on the target.
 * The module name strings are placed in the .const section. Setting this
 * parameter to false will save space in the .const section.  Error and
 * Assert messages will contain an "unknown module" prefix instead
 * of the actual module name.
Defaults.common$.namedModule = false;
 */

/*
 * Minimize exit handler array in System.  The System module includes
 * an array of functions that are registered with System_atexit() to be
 * called by System_exit().
 */
System.maxAtexitHandlers = 4;       

/* * Uncomment this line to disable the Error print function.  
 * We lose error information when this is disabled since the errors are
 * not printed.  Disabling the raiseHook will save some code space if
 * your app is not using System_printf() since the Error_print() function
 * calls System_printf().
Error.raiseHook = null;
 */

/* * Uncomment this line to keep Error, Assert, and Log strings from being
 * loaded on the target.  These strings are placed in the .const section.
 * Setting this parameter to false will save space in the .const section.
 * Error, Assert and Log message will print raw ids and args instead of
 * a formatted message.
Text.isLoaded = false;
 */

/*
 * Uncomment this line to disable the output of characters by SysMin
 * when the program exits.  SysMin writes characters to a circular buffer.
 * This buffer can be viewed using the SysMin Output view in ROV.
SysMin.flushAtExit = false;
 */

/*
 * The BIOS module will create the default heap for the system.
 * Specify the size of this default heap.
 */
BIOS.heapSize = 0x80000;
BIOS.taskEnabled = true;

/* System stack size (used by ISRs and Swis) */
Program.stack = 0x4000;

/* Circular buffer size for System_printf() */
SysMin.bufSize = 0x200;

/* * Create and install logger for the whole system
 */
var loggerBufParams = new LoggerBuf.Params();
loggerBufParams.numEntries = 16;
var logger0 = LoggerBuf.create(loggerBufParams);
Defaults.common$.logger = logger0;
Main.common$.diags_INFO = Diags.ALWAYS_ON;

System.SupportProxy = SysStd;

Clock.timerId = 0;
ti_sysbios_timers_timer64_Timer.intFreqs[0].lo = 19200000;
ti_sysbios_timers_timer64_Timer.intFreqs[1].lo = 19200000;
ti_sysbios_timers_timer64_Timer.intFreqs[2].lo = 9600000;
ti_sysbios_timers_timer64_Timer.intFreqs[3].lo = 9600000;
Memory.defaultHeapSize = 0x80000;

Program.sectMap[".text:_c_int00"] = new Program.SectionSpec();
Program.sectMap[".text:_c_int00"] = "CINIT_IRAM";

Program.sectMap[".MIPStext"] = "DDR";
Program.sectMap[".MIPStable"] = "DDR";
Program.sectMap[".MIPStable1"] = "DDR";
Program.sectMap[".MIPStable2"] = "DDR";
Program.sectMap[".MIPStable3"] = "DDR";
Program.sectMap[".MIPStable4"] = "DDR";
Program.sectMap[".ambeconst"] = "DDR";
Program.sectMap[".ambetext"] = "DDR";
Program.sectMap[".DARamData"] = "DDR";
Program.sectMap[".ddrdata"] = "DDR";
Program.sectMap[".fardata"] = "IRAM";

var iomFxns = "Uart_IOMFXNS";
var initFxn = "UserLogUartInit";
var deviceParams = "uartParams";
var deviceId = 1;
GIO.addDeviceMeta("/uart1", iomFxns, initFxn, deviceId, deviceParams);

BIOS.heapTrackEnabled = true;
ti_sysbios_family_c64p_Exception.enablePrint = true;
RM.edma3_max_rm_instances = 8;

还请各位给予帮助,谢谢!!

Nancy Wang:

请问是要在RTOS下使用UART吗?
直接用最新的sdk中断的uart例程就可以了。
software-dl.ti.com/…/index_device_drv.html

min zhang1:

回复 Nancy Wang:

1、你好,之前最新的PDK用过是可以的。只是现在我们有几个核心算法库是用V7.41的编译编的(目前没有源码),所以用不了最新。
还请帮忙看下这个问题。谢谢!!
2、我用仿真器跟了感觉好像是 Memory_calloc(od->objHeap, od->objSize, od->objAlign, eb)好像是这个分配内存有点问题;(但是不太确认,因为仿真用的库和源码有点对不上);

Nancy Wang:

回复 min zhang1:

抱歉对GIO模块的使用不熟悉,建议去E2E论坛咨询,看能否获取帮助。https://e2e.ti.com/support/processors/f/791    

TI 诚邀您参加全新设计的产品页面测试,参加测试即可享有 TI 购物 9 折优惠码,点击加入 EP产品页面测试报名,名额有限。感谢您的参与!

赞(0)
未经允许不得转载:TI中文支持网 » SYS/BIOS 使用GIO模块来实现串口驱动 GIO_create() 失败;
分享到: 更多 (0)