• BIOS MCSDK 2.0 学习笔记(二)————使用Platform Library创建工程


    Platform Library提供了一组适用于开发板的API函数。我们可以使用它来快速入手开发板。

    1、启动CCS,建立一个空的工程

    2、添加include路径

    "C:Program FilesTexas Instrumentspdk_C####_1_0_0_xxpackages"

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

    "C: ipdk_c667x_2_0_3packages iplatformevmc6678lplatform_liblibdebug i.platform.evm6678l.ae66"
    "C: ipdk_c667x_2_0_3packages icsllibc6678c66 elease i.csl.ae66"
    "C: ipdk_c667x_2_0_3packages icsllibc6678c66 elease i.csl.intc.ae66"

    4、指定库的查找路径

    "C: ipdk_c667x_2_0_3packages icsllibc6678c66 elease"
    "C: ipdk_c667x_2_0_3packages iplatformevmc6678lplatform_liblibdebug"

    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 "tiplatformplatform.h"
    #include "tiplatform
    esource_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[] = "
    Hello World.....
    ";
        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、编译。。。

  • 相关阅读:
    第04组 Beta冲刺 (2/5)
    第04组 Beta冲刺 (1/6)
    第04组 Alpha冲刺 总结
    二叉树的递归与非递归
    各类典例模板
    选择题合辑2
    运算符重载
    链表题目
    集合的模拟实现(类模板)
    2018Final静态成员(黑名单)
  • 原文地址:https://www.cnblogs.com/liqi120150/p/6212967.html
Copyright © 2020-2023  润新知