Skip to content

Commit acfa78a

Browse files
committed
Added alternate pin muxing for UART1
1 parent 97d1b04 commit acfa78a

File tree

2 files changed

+23
-7
lines changed

2 files changed

+23
-7
lines changed

hardware/lm4f/cores/lm4f/HardwareSerial.cpp

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
#include "driverlib/uart.h"
4949
#include "HardwareSerial.h"
5050

51-
5251
#define TX_BUFFER_EMPTY (txReadIndex == txWriteIndex)
5352
#define TX_BUFFER_FULL (((txWriteIndex + 1) % SERIAL_BUFFER_SIZE) == txReadIndex)
5453

@@ -87,7 +86,7 @@ static const unsigned long g_ulUARTPeriph[8] =
8786
};
8887
//*****************************************************************************
8988
//
90-
// The list of UART gpio configurations.
89+
// The list of UART GPIO configurations.
9190
//
9291
//*****************************************************************************
9392
static const unsigned long g_ulUARTConfig[8][2] =
@@ -104,11 +103,6 @@ static const unsigned long g_ulUARTPort[8] =
104103
GPIO_PORTC_BASE, GPIO_PORTE_BASE, GPIO_PORTD_BASE, GPIO_PORTE_BASE
105104
};
106105

107-
//*****************************************************************************
108-
//
109-
// The list of i2c gpio configurations.
110-
//
111-
//*****************************************************************************
112106
static const unsigned long g_ulUARTPins[8] =
113107
{
114108
GPIO_PIN_0 | GPIO_PIN_1, GPIO_PIN_4 | GPIO_PIN_5,
@@ -233,6 +227,23 @@ HardwareSerial::setModule(unsigned long module)
233227
begin(baudRate);
234228

235229
}
230+
void
231+
HardwareSerial::setPins(unsigned long pins)
232+
{
233+
if(pins == UART1_PORTB)
234+
{
235+
ROM_GPIOPinConfigure(GPIO_PB0_U1RX);
236+
ROM_GPIOPinConfigure(GPIO_PB1_U1TX);
237+
ROM_GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1);
238+
}
239+
else
240+
{
241+
//Default UART1 Pin Muxing
242+
ROM_GPIOPinConfigure(g_ulUARTConfig[1][0]);
243+
ROM_GPIOPinConfigure(g_ulUARTConfig[1][1]);
244+
ROM_GPIOPinTypeUART(g_ulUARTPort[1], g_ulUARTPins[1]);
245+
}
246+
}
236247

237248
void HardwareSerial::end()
238249
{

hardware/lm4f/cores/lm4f/HardwareSerial.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
#include "Stream.h"
3434

3535
#define SERIAL_BUFFER_SIZE 1024
36+
37+
#define UART1_PORTB 0
38+
#define UART1_PORTC 1
39+
3640
class HardwareSerial : public Stream
3741
{
3842

@@ -53,6 +57,7 @@ class HardwareSerial : public Stream
5357
HardwareSerial(unsigned long);
5458
void begin(unsigned long);
5559
void setModule(unsigned long);
60+
void setPins(unsigned long);
5661
void end(void);
5762
virtual int available(void);
5863
virtual int peek(void);

0 commit comments

Comments
 (0)