Skip to content

Commit

Permalink
Added alternate pin muxing for UART1
Browse files Browse the repository at this point in the history
  • Loading branch information
Revisore committed Apr 17, 2013
1 parent 97d1b04 commit acfa78a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
25 changes: 18 additions & 7 deletions hardware/lm4f/cores/lm4f/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include "driverlib/uart.h"
#include "HardwareSerial.h"


#define TX_BUFFER_EMPTY (txReadIndex == txWriteIndex)
#define TX_BUFFER_FULL (((txWriteIndex + 1) % SERIAL_BUFFER_SIZE) == txReadIndex)

Expand Down Expand Up @@ -87,7 +86,7 @@ static const unsigned long g_ulUARTPeriph[8] =
};
//*****************************************************************************
//
// The list of UART gpio configurations.
// The list of UART GPIO configurations.
//
//*****************************************************************************
static const unsigned long g_ulUARTConfig[8][2] =
Expand All @@ -104,11 +103,6 @@ static const unsigned long g_ulUARTPort[8] =
GPIO_PORTC_BASE, GPIO_PORTE_BASE, GPIO_PORTD_BASE, GPIO_PORTE_BASE
};

//*****************************************************************************
//
// The list of i2c gpio configurations.
//
//*****************************************************************************
static const unsigned long g_ulUARTPins[8] =
{
GPIO_PIN_0 | GPIO_PIN_1, GPIO_PIN_4 | GPIO_PIN_5,
Expand Down Expand Up @@ -233,6 +227,23 @@ HardwareSerial::setModule(unsigned long module)
begin(baudRate);

}
void
HardwareSerial::setPins(unsigned long pins)
{
if(pins == UART1_PORTB)
{
ROM_GPIOPinConfigure(GPIO_PB0_U1RX);
ROM_GPIOPinConfigure(GPIO_PB1_U1TX);
ROM_GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
}
else
{
//Default UART1 Pin Muxing
ROM_GPIOPinConfigure(g_ulUARTConfig[1][0]);
ROM_GPIOPinConfigure(g_ulUARTConfig[1][1]);
ROM_GPIOPinTypeUART(g_ulUARTPort[1], g_ulUARTPins[1]);
}
}

void HardwareSerial::end()
{
Expand Down
5 changes: 5 additions & 0 deletions hardware/lm4f/cores/lm4f/HardwareSerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
#include "Stream.h"

#define SERIAL_BUFFER_SIZE 1024

#define UART1_PORTB 0
#define UART1_PORTC 1

class HardwareSerial : public Stream
{

Expand All @@ -53,6 +57,7 @@ class HardwareSerial : public Stream
HardwareSerial(unsigned long);
void begin(unsigned long);
void setModule(unsigned long);
void setPins(unsigned long);
void end(void);
virtual int available(void);
virtual int peek(void);
Expand Down

0 comments on commit acfa78a

Please sign in to comment.