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、编译。。。

上一篇:关于android sensor架构


下一篇:Kubernetes & Docker 容器网络终极之战(十四)