Skip to content

Commit

Permalink
fixed UART by removing dependency on UARTstdio
Browse files Browse the repository at this point in the history
  • Loading branch information
theotherjimmy committed Oct 15, 2013
1 parent 2dacd70 commit ebbd262
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 10 deletions.
5 changes: 2 additions & 3 deletions RASDemo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,15 @@ CFLAGS += -I$(SW_DIR) -I$(INCLUDES)
LIBS += c
LIBS += RAS
LIBS += driver-cm4f
LIBS += utils-cm4f
LIBS += m
LIBS += gcc

LDFLAGS += -T $(LD_SCRIPT)
LDFLAGS += -g
LDFLAGS += -L ../RASLib/output/
LDFLAGS += -L ../RASLib/bin/

LDFLAGS += -L ${SW_DIR}/StellarisWare/driverlib/gcc-cm4f/
LDFLAGS += -L ${SW_DIR}/StellarisWare/driverlib/gcc-cm4f/
LDFLAGS += -L ${SW_DIR}/StellarisWare/utils/gcc-cm4f/

ifeq (${FPU},hard)
LDFLAGS += -L ${TOOL}/../arm-none-eabi/lib/thumb/cortex-m4/float-abi-hard/fpuv4-sp-d16/
Expand Down
48 changes: 45 additions & 3 deletions RASLib/src/uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@
#include <math.h>

#include <StellarisWare/inc/hw_types.h>
#include <StellarisWare/driverlib/gpio.h>
#include <StellarisWare/inc/hw_ints.h>
#include <StellarisWare/inc/hw_memmap.h>
#include <StellarisWare/inc/hw_types.h>
#include <StellarisWare/inc/hw_uart.h>
#include <StellarisWare/driverlib/gpio.h>
#include <StellarisWare/driverlib/debug.h>
#include <StellarisWare/driverlib/interrupt.h>
#include <StellarisWare/driverlib/rom.h>
Expand All @@ -48,6 +48,7 @@ void InitializeUART(void)
{
// Enable GPIO port A which is used for UART0 pins.
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA);
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);

// Configure the pin muxing for UART0 functions on port A0 and A1.
GPIOPinConfigure(GPIO_PA0_U0RX);
Expand All @@ -56,11 +57,30 @@ void InitializeUART(void)
// Select the alternate (UART) function for these pins.
GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1);

SysCtlPeripheralEnable(UART0_BASE);
// Initialize the UART for console I/O.
StdioInit(0);
UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 115200,
(UART_CONFIG_PAR_NONE | UART_CONFIG_STOP_ONE |
UART_CONFIG_WLEN_8));
}

// The following block of funcitons are wrappers for StellarisWare UART functions
void UARTwrite(const unsigned char *pucBuffer, unsigned long ulCount)
{
//
// Loop while there are more characters to send.
//
while(ulCount--)
{
//
// Write the next character to the UART.
//
if (*pucBuffer == '\n') {
UARTCharPut(UART0_BASE, '\r');
}
UARTCharPut(UART0_BASE, *pucBuffer++);
}
}

void StdioConfig(unsigned long ulPort, unsigned long ulBaud, unsigned long ulSrcClock)
{
Expand All @@ -77,14 +97,35 @@ void StdioInitExpClk(unsigned long ulPort, unsigned long ulBaud)
UARTStdioInitExpClk(ulPort, ulBaud);
}

int UARTgets(unsigned char *pucBuffer, unsigned long ulCount)
{
//
// Loop while there are more characters to send.
//
unsigned long ulTemp = ulCount;
while(ulTemp--)
{
//
// Write the next character to the UART.
//
*pucBuffer = UARTCharGet(UART0_BASE);
UARTCharPut(UART0_BASE, *pucBuffer);
if( *pucBuffer == '\r') {
return ulCount - ulTemp;
}
pucBuffer++;
}
return ulCount;
}

int Gets(char *pcBuf, unsigned long ulLen)
{
return UARTgets(pcBuf, ulLen);
}

unsigned char Getc(void)
{
return UARTgetc();
return UARTCharGet(UART0_BASE);
}

// Pulled out of RASDemo Code
Expand Down Expand Up @@ -520,6 +561,7 @@ void Printf(const char *pcString, ...)
}
}


void Putc(char ch)
{
UARTwrite(&ch, 1);
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,9 @@ Note: for windows 8, the drivers are unsigned, so installing them requires you t
Setup for Linux (WIP)
---------------

### Install Git, Screen
Archlinux : 'pacman -S git screen'
Ubuntu/Debian : 'apt-get install git screen'
### Install Git, Screen, OpenOCD
Archlinux : 'pacman -S git screen openocd'
Ubuntu/Debian : 'apt-get install git screen openocd'

### Install Cross Compiler, Debugger ###
Archlinux : install from you favorite AUR wrapper, for example 'pak -S arm-none-eabi-gcc arm-none-eabi-gdb
Expand All @@ -95,7 +95,7 @@ Ubuntu/Debian : I don't use either of these Distro's so I would like someone els
### Install Stellarisware
1. Go to [TI](https://myportal.ti.com/portal/dt?provider=TIPassLoginSingleContainer&lt=myti&j5=2&j3=1&goto=https://my.ti.com/cgi-bin/home.pl) and create a new account.
2. Go to [TI](http://www.ti.com/tool/sw-lm3s), and download SW-LM3S-LM4F.exe.
3. When complete, extract the "executable" with unzip. for example by runnig : 'unzip -d StellarisWare SW-LM3S-LM4F.exe'
3. When complete, extract the "executable" with unzip. for example by running : 'unzip -d StellarisWare SW-LM3S-LM4F.exe'
4. Write down the path to StellarisWare

### Install drivers for the Launchpad ###
Expand Down

0 comments on commit ebbd262

Please sign in to comment.