BIOS MCSDK 2.0 學習筆記(二)————使用Platform Library創建工程


Platform Library提供了一組適用於開發板的API函數。我們可以使用它來快速入手開發板。

1、啟動CCS,建立一個空的工程

2、添加include路徑

"C:\Program Files\Texas Instruments\pdk_C####_1_0_0_xx\packages"

3、添加下列鏈接庫到C6000 Linker section中的File Search Path

"C:\ti\pdk_c667x_2_0_3\packages\ti\platform\evmc6678l\platform_lib\lib\debug\ti.platform.evm6678l.ae66"
"C:\ti\pdk_c667x_2_0_3\packages\ti\csl\lib\c6678\c66\release\ti.csl.ae66"
"C:\ti\pdk_c667x_2_0_3\packages\ti\csl\lib\c6678\c66\release\ti.csl.intc.ae66"

4、指定庫的查找路徑

"C:\ti\pdk_c667x_2_0_3\packages\ti\csl\lib\c6678\c66\release"
"C:\ti\pdk_c667x_2_0_3\packages\ti\platform\evmc6678l\platform_lib\lib\debug"

5

打開Project->Properties,在Build->C6000 Compiler->Advanced Options->Predefined Symbol中添加SOC_C6678

6、編寫代碼

這里給MCSDK中的led_play.c的代碼

Note:代碼中的OSAL functions for Platform Library不要注釋掉!(Osal_platformMalloc等這些函數在platform_lib中的platform.c 中有使用,但是lib工程中沒有其實現,所以可以在工程中實現。否則在linker的時候會提示函數未定義,也可以將實現與聲明均放在lib中編譯生成lib。)

#include <cerrno>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "ti\platform\platform.h"
#include "ti\platform\resource_mgr.h"
 
/* OSAL functions for Platform Library */
uint8_t *Osal_platformMalloc (uint32_t num_bytes, uint32_t alignment)
{
    return malloc(num_bytes);
}
 
void Osal_platformFree (uint8_t *dataPtr, uint32_t num_bytes)
{
    /* Free up the memory */
    if (dataPtr)
    {
        free(dataPtr);
    }
}
 
void Osal_platformSpiCsEnter(void)
{
    /* Get the hardware semaphore.
     *
     * Acquire Multi core CPPI synchronization lock
     */
    while ((CSL_semAcquireDirect (PLATFORM_SPI_HW_SEM)) == 0);
 
    return;
}
 
void Osal_platformSpiCsExit (void)
{
    /* Release the hardware semaphore
     *
     * Release multi-core lock.
     */
    CSL_semReleaseSemaphore (PLATFORM_SPI_HW_SEM);
 
    return;
}
 
void main(void) {
    platform_init_flags init_flags;
    platform_init_config init_config;
    platform_info p_info;
    uint32_t led_no = 0;
    char message[] = "\r\nHello World.....\r\n";
    uint32_t length = strlen((char *)message);
    uint32_t i;
 
    /* Initialize platform with default values */
    memset(&init_flags, 0x01, sizeof(platform_init_flags));
    memset(&init_config, 0, sizeof(platform_init_config));
    if (platform_init(&init_flags, &init_config) != Platform_EOK) {
        return;
    }
 
    platform_uart_init();
    platform_uart_set_baudrate(115200);
 
    platform_get_info(&p_info);
 
    /* Write to the UART */
    for (i = 0; i < length; i++) {
        if (platform_uart_write(message[i]) != Platform_EOK) {
            return;
        }
    }
 
    /* Play forever */
    while(1) {
        platform_led(led_no, PLATFORM_LED_ON, PLATFORM_USER_LED_CLASS);
        platform_delay(30000);
        platform_led(led_no, PLATFORM_LED_OFF, PLATFORM_USER_LED_CLASS);
        led_no = (++led_no) % p_info.led[PLATFORM_USER_LED_CLASS].count;
    }
}

7、添加linker command script

The linker command script defines the memory map for the platform (where internal, shared and external memory start, etc.) and where we want our code and data sections to be placed. We are going to put them in the shared memory region on the processor.

  • Select File->New->File from Template, enter File Name as XXXX.cmd and hit Finish.

  • paste following linker command file in the editor


-c
-heap  0x41000
-stack 0xa000
 
/* Memory Map */
MEMORY
{
    L1PSRAM (RWX)  : org = 0x0E00000, len = 0x7FFF
    L1DSRAM (RWX)  : org = 0x0F00000, len = 0x7FFF
    L2SRAM (RWX)   : org = 0x0800000, len = 0x080000
    MSMCSRAM (RWX) : org = 0xc000000, len = 0x200000
    DDR3 (RWX)     : org = 0x80000000,len = 0x10000000
}
 
SECTIONS
{
    .csl_vect    >       MSMCSRAM
    .text        >       MSMCSRAM
    GROUP (NEAR_DP)
    {
        .neardata
        .rodata
        .bss
    } load       >      MSMCSRAM
    .stack       >      MSMCSRAM
    .cinit       >      MSMCSRAM
    .cio         >      MSMCSRAM
    .const       >      MSMCSRAM
    .data        >      MSMCSRAM
    .switch      >      MSMCSRAM
    .sysmem      >      MSMCSRAM
    .far         >      MSMCSRAM
    .testMem     >      MSMCSRAM
    .fardata     >      MSMCSRAM
    platform_lib > 	MSMCSRAM
}

8、編譯。。。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM