EE445M RTOS
Taken at the University of Texas Spring 2015
uartpp.cpp File Reference
#include "uartpp.hpp"
#include "inc/hw_memmap.h"
#include "driverlib/pin_map.h"
#include "driverlib/interrupt.h"
#include "driverlib/sysctl.h"
#include "driverlib/rom_map.h"
#include "driverlib/gpio.h"
#include "driverlib/uart.h"
Include dependency graph for uartpp.cpp:

Go to the source code of this file.

Functions

uint32_t ustrlen (const char *s)
 
int UARTwrite (memory_address_t channel, const char *pcBuf, uint32_t ui32Len)
 

Variables

static uint32_t g_ui32Base = UART0_BASE
 
static const char *const g_pcHex = "0123456789abcdef"
 

Function Documentation

int UARTwrite ( memory_address_t  channel,
const char *  pcBuf,
uint32_t  ui32Len 
)

Definition at line 64 of file uartpp.cpp.

References g_ui32Base.

Referenced by uart::vprintf().

65 {
66 #ifdef UART_BUFFERED
67  unsigned int uIdx;
68 
69  // Send the characters
70  for(uIdx = 0; uIdx < ui32Len; uIdx++) {
71  // If the character to the UART is \n, then add a \r before it so that
72  // \n is translated to \n\r in the output.
73  if(pcBuf[uIdx] == '\n') {
74  if(!TX_BUFFER_FULL) {
75  g_pcUARTTxBuffer[g_ui32UARTTxWriteIndex] = '\r';
76  ADVANCE_TX_BUFFER_INDEX(g_ui32UARTTxWriteIndex);
77  } else {
78  // Buffer is full - discard remaining characters and return.
79  break;
80  }
81  }
82 
83  // Send the character to the UART output.
84  if(!TX_BUFFER_FULL) {
85  g_pcUARTTxBuffer[g_ui32UARTTxWriteIndex] = pcBuf[uIdx];
86  ADVANCE_TX_BUFFER_INDEX(g_ui32UARTTxWriteIndex);
87  } else {
88  // Buffer is full - discard remaining characters and return.
89  break;
90  }
91  }
92 
93  // If we have anything in the buffer, make sure that the UART is set
94  // up to transmit it.
95  if(!TX_BUFFER_EMPTY) {
96  UARTPrimeTransmit(g_ui32Base);
97  UARTIntEnable(channel, UART_INT_TX);
98  }
99 
100  // Return the number of characters written.
101  return(uIdx);
102 #else
103  unsigned int uIdx;
104 
105  // Send the characters
106  for(uIdx = 0; uIdx < ui32Len; uIdx++) {
107  // If the character to the UART is \n, then add a \r before it so that
108  // \n is translated to \n\r in the output.
109  if(pcBuf[uIdx] == '\n') {
110  UARTCharPut(channel, '\r');
111  }
112 
113  // Send the character to the UART output.
114  UARTCharPut(channel, pcBuf[uIdx]);
115  }
116 
117  // Return the number of characters written.
118  return(uIdx);
119 #endif
120 }
static uint32_t g_ui32Base
Definition: uartpp.cpp:60

Here is the caller graph for this function:

uint32_t ustrlen ( const char *  s)

Definition at line 14 of file uartpp.cpp.

Referenced by uart::send_string().

14  {
15 
16  uint32_t len = 0;
17  while(s[len]) { ++len; }
18  return len;
19 }

Here is the caller graph for this function:

Variable Documentation

const char* const g_pcHex = "0123456789abcdef"
static

Definition at line 61 of file uartpp.cpp.

Referenced by uart::vprintf().

uint32_t g_ui32Base = UART0_BASE
static

Definition at line 60 of file uartpp.cpp.

Referenced by UARTwrite().