0

I'm trying to make the CMSIS UART driver example work on my Tiva launchpad: https://www.keil.com/pack/doc/CMSIS/Driver/html/group__usart__interface__gr.html

My code is the following:

#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


}

Now I don't expect it to work right away, however my builder starts complaining at the linkig phase that Driver_UART0 is undefined:

.\Objects\bl.axf: Error: L6218E: Undefined symbol Driver_UART0 (referred from blinky.o).

Any idea what I could do to fix this?

Thank you,

Botond

artless noise
  • 21,212
  • 6
  • 68
  • 105
Botond
  • 2,640
  • 6
  • 28
  • 44

1 Answers1

0

Unfortunately TI doesn't support the CMSIS Driver API at this time. I've have been working on creating this API on my own and have a working example in my GitHub repository:

This is the example: https://github.com/AllAboutEE/ARM-Programming-Examples-TM4C/blob/master/CMSIS-Driver-Examples/UART-CMSIS-Driver/main.c

You'll have to set your include path in project options to this folder: https://github.com/AllAboutEE/ARM-Programming-Examples-TM4C/tree/master/inc

Also add the files in this folder to your project: https://github.com/AllAboutEE/ARM-Programming-Examples-TM4C/tree/master/src

and also this file https://github.com/AllAboutEE/ARM-Programming-Examples-TM4C/blob/master/startup_LM4F.s

SoftwareDev
  • 674
  • 1
  • 6
  • 14
  • Thanks a lot! Let me give it a try and get back to you! – Botond Mar 13 '15 at 20:40
  • hey don't you need to add commands to enable TX and RX lines i.e. ptrUSART->Control(ARM_USART_CONTROL_TX, 1); ptrUSART->Control(ARM_USART_CONTROL_RX, 1); as shown in https://www.keil.com/pack/doc/CMSIS/Driver/html/group__usart__interface__gr.html – Maxwell Weru May 04 '15 at 14:26