This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS/TI-RTOS-MCU: TI-RTOS + Source code

Part Number: TI-RTOS-MCU
Other Parts Discussed in Thread: SYSBIOS, CC2650

Tool/software: TI-RTOS

Hello , I have a question that is how to find out the source code:

just check the docs of BIOS,
C:\ti\tirtos_cc13xx_cc26xx_2_21_00_06\products\bios_6_46_01_37\docs\cdoc\index.html


Clock_Handle Clock_create(Clock_FuncPtr clockFxn, UInt timeout, const Clock_Params *params, Error_Block*eb);
// Allocate and initialize a new instance object and return its handle 
Void Clock_construct(Clock_Struct *structP, Clock_FuncPtr clockFxn, UInt timeout, const Clock_Params *params);
// Initialize a new instance object inside the provided structure
I like to know what difference between these two functions, so I want to check the source code, but only found declarations:



/* construct */ xdc__CODESECT(ti_sysbios_knl_Clock_construct, "ti_sysbios_knl_Clock_construct") __extern void ti_sysbios_knl_Clock_construct( ti_sysbios_knl_Clock_Struct *__obj, ti_sysbios_knl_Clock_FuncPtr clockFxn, xdc_UInt timeout, const ti_sysbios_knl_Clock_Params *__prms );
  • Hi,

    I am not sure whether the source code for TI-RTOS is available, but I can explain the differences between the two.

    The only difference between the two functions is where the memory for the clock comes from.

    Clock_create is used when you need to allocate memory to hold the clock information. The memory is allocated from the heap.
    Clock_create returns a Clock_Handle which is a pointer to where the data has been allocated.

    Clock_construct is used when you reserve the space in your code (through a variable of type Clock_Struct) and you tell TI-RTOS to use that memory space to instantiate a clock.

    So in one case, you allocate memory from the heap, and in the other, you assign the memory yourself by creating a variable to hold the data.

    Most clock functions use a Clock_Handle, so if you used Clock_construct, you can obtain that by using the following function:
    Clock_Handle Clock_handle(Clock_Struct *yourVariable)

    Both clocks will behave exactly the same way.

    I hope this helps.

    Regards,
    Michel
  • WH HUANG said:
    I like to know what difference between these two functions, so I want to check the source code, but only found declarations:

    ti_sysbios_knl_Clock_create and ti_sysbios_knl_Clock_construct appear in the auto-generated <project_name>_pem4f.c source file. E.g. in the SYS/BIOS auto-generated Debug/configPkg/cfg/<project_name>_pem4f.c file for a CC2650 found:

    /* create */
    ti_sysbios_knl_Clock_Handle ti_sysbios_knl_Clock_create( ti_sysbios_knl_Clock_FuncPtr clockFxn, xdc_UInt timeout, const ti_sysbios_knl_Clock_Params *__paramsPtr, xdc_runtime_Error_Block *__eb )
    {
        ti_sysbios_knl_Clock_Params __prms;
        ti_sysbios_knl_Clock_Object *__newobj;
    
        /* common instance initialization */
        __newobj = xdc_runtime_Core_createObject__I(&ti_sysbios_knl_Clock_Object__DESC__C, 0, &__prms, (xdc_Ptr)__paramsPtr, sizeof(ti_sysbios_knl_Clock_Params), __eb);
        if (__newobj == NULL) {
            return NULL;
        }
    
        /* module-specific initialization */
        ti_sysbios_knl_Clock_Instance_init__E(__newobj, clockFxn, timeout, &__prms);
        return __newobj;
    }
    
    /* construct */
    void ti_sysbios_knl_Clock_construct(ti_sysbios_knl_Clock_Struct *__obj, ti_sysbios_knl_Clock_FuncPtr clockFxn, xdc_UInt timeout, const ti_sysbios_knl_Clock_Params *__paramsPtr )
    {
        ti_sysbios_knl_Clock_Params __prms;
    
        /* common instance initialization */
        xdc_runtime_Core_constructObject__I(&ti_sysbios_knl_Clock_Object__DESC__C, __obj, &__prms, (xdc_Ptr)__paramsPtr, sizeof(ti_sysbios_knl_Clock_Params), NULL);
        /* module-specific initialization */
        ti_sysbios_knl_Clock_Instance_init__E((xdc_Ptr)__obj, clockFxn, timeout, &__prms);
    }

  • Hello,

    If you would like to view the original source files, navigate to the following directory:

    C:\ti\tirtos_cc13xx_cc26xx_2_21_00_06\products\bios_6_46_01_37\packages\ti\sysbios\knl

    Derrick
  • many thanks.

  • xdc_runtime_Core_createObject__I      So  how to find out this function ?  
  • WH HUAHG,
    that function comes from XDCtools. Look into xdctools/packages/xdc/runtime/Core-mem.c.