适用于Tiva启动板的CMSIS UART驱动程序

时间:2015-02-15 01:57:47

标签: cortex-m3 keil texas-instruments cmsis

我正在尝试使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


}

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

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

知道我可以做些什么来解决这个问题?

谢谢,

Botond

1 个答案:

答案 0 :(得分: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