0

我正在尝试使 CMSIS UART 驱动程序示例在我的 Tiva 启动板上工作:https ://www.keil.com/pack/doc/CMSIS/Driver/html/group__usart__interface__gr.html

我的代码如下:

#include "Driver_USART.h"
#include <cmsis_os.h> /* ARM::CMSIS:RTOS:Keil RTX */
#include <stdio.h>
#include <string.h>


/* USART Driver */
extern ARM_DRIVER_USART Driver_UART0;

void myUART_Thread(void const *argument);
osThreadId tid_myUART_Thread;



void myUSART_callback(uint32_t event)
{
switch (event)
{
case ARM_USART_EVENT_RECEIVE_COMPLETE: 
case ARM_USART_EVENT_TRANSFER_COMPLETE:
case ARM_USART_EVENT_SEND_COMPLETE:
case ARM_USART_EVENT_TX_COMPLETE:
/* Success: Wakeup Thread */
osSignalSet(tid_myUART_Thread, 0x01);
break;

case ARM_USART_EVENT_RX_TIMEOUT:
__breakpoint(0); /* Error: Call debugger or replace with custom error     handling */
break;

case ARM_USART_EVENT_RX_OVERFLOW:
case ARM_USART_EVENT_TX_UNDERFLOW:
__breakpoint(0); /* Error: Call debugger or replace with custom error handling */
break;
}
}

/* CMSIS-RTOS Thread - UART command thread */
void myUART_Thread(const void* args)
{ // static ARM_DRIVER_USART * USARTdrv = &Driver_UART0;
ARM_DRIVER_VERSION version;
ARM_USART_CAPABILITIES drv_capabilities;
char cmd;


/*Initialize the USART driver */
Driver_UART0.Initialize(myUSART_callback);
/*Power up the USART peripheral */
Driver_UART0.PowerControl(ARM_POWER_FULL);
/*Configure the USART to 4800 Bits/sec */
Driver_UART0.Control(ARM_USART_MODE_ASYNCHRONOUS |
ARM_USART_DATA_BITS_8 |
ARM_USART_PARITY_NONE |
ARM_USART_STOP_BITS_1 |
ARM_USART_FLOW_CONTROL_NONE, 4800);

/* Enable Receiver and Transmitter lines */
Driver_UART0.Control (ARM_USART_CONTROL_TX, 1);
Driver_UART0.Control (ARM_USART_CONTROL_RX, 1);

Driver_UART0.Send("\nPress Enter to receive a message", 34);
osSignalWait(0x01, osWaitForever);

while (1)
{
Driver_UART0.Receive(&cmd, 1); /* Get byte from UART */
osSignalWait(0x01, osWaitForever);
if (cmd == 13) /* CR, send greeting */
{
Driver_UART0.Send("\nHello World!", 12);
osSignalWait(0x01, osWaitForever);
}

}
}

int main(void){
osKernelInitialize (); // initialize CMSIS-RTOS
osKernelStart (); // start thread execution


}

现在我不希望它立即工作,但是我的构建器开始在链接阶段抱怨 Driver_UART0 未定义:

.\Objects\bl.axf:错误:L6218E:未定义符号 Driver_UART0(来自 blinky.o)。

知道我能做些什么来解决这个问题吗?

谢谢,

博通

4

1 回答 1

0

不幸的是,TI 目前不支持 CMSIS 驱动程序 API。我一直在自己创建这个 API,并且在我的 GitHub 存储库中有一个工作示例:

这是示例: https ://github.com/AllAboutEE/ARM-Programming-Examples-TM4C/blob/master/CMSIS-Driver-Examples/UART-CMSIS-Driver/main.c

您必须在此文件夹的项目选项中设置包含路径: https ://github.com/AllAboutEE/ARM-Programming-Examples-TM4C/tree/master/inc

还将此文件夹中的文件添加到您的项目中: https ://github.com/AllAboutEE/ARM-Programming-Examples-TM4C/tree/master/src

还有这个文件 https://github.com/AllAboutEE/ARM-Programming-Examples-TM4C/blob/master/startup_LM4F.s

于 2015-03-07T22:21:30.590 回答