Skip to content

Commit

Permalink
[#83] UART TX works in LMM & CMM modes; UART RX broken
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidZemon committed Apr 6, 2016
1 parent 06c7ced commit 67d5267
Show file tree
Hide file tree
Showing 15 changed files with 278 additions and 641 deletions.
13 changes: 7 additions & 6 deletions Examples/PropWare_DuplexUART/DuplexUART_Demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

#include <PropWare/utility/runnable.h>
#include <PropWare/PropWare.h>
#include <PropWare/serial/uart/halfduplexuart.h>
#include <PropWare/serial/uart/uartrx.h>
#include <PropWare/serial/uart/uarttx.h>
#include <PropWare/hmi/output/synchronousprinter.h>

// Create the test string - useful when testing with a terminal
Expand All @@ -47,8 +48,8 @@ class Listener : public PropWare::Runnable {
void init ();

private:
PropWare::HalfDuplexUART m_listener;
char m_buffer[sizeof(TEST_STRING)];
PropWare::UARTRX m_listener;
char m_buffer[sizeof(TEST_STRING)];
};

void error (const PropWare::ErrorCode err);
Expand All @@ -61,9 +62,9 @@ void error (const PropWare::ErrorCode err);
* @include PropWare_DuplexUART/CMakeLists.txt
*/
int main () {
uint32_t threadStack[256];
Listener listener(threadStack);
PropWare::SimplexUART speaker(TX_PIN);
uint32_t threadStack[256];
Listener listener(threadStack);
PropWare::UARTTX speaker(TX_PIN);

// Start our new cog and initialize the speaking UART
speaker.set_baud_rate(BAUD_RATE);
Expand Down
1 change: 0 additions & 1 deletion Examples/PropWare_L3G/L3G_Demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
// Includes
#include <PropWare/PropWare.h>
#include <PropWare/sensor/gyroscope/l3g.h>
#include <PropWare/serial/uart/simplexuart.h>

/** Pin number for MOSI (master out - slave in) */
const PropWare::Port::Mask MOSI = PropWare::Port::P0;
Expand Down
8 changes: 4 additions & 4 deletions Examples/PropWare_SimplexUART/SimplexUART_Demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

// Includes
#include <PropWare/PropWare.h>
#include <PropWare/serial/uart/simplexuart.h>
#include <PropWare/serial/uart/uarttx.h>
#include <PropWare/hmi/output/printer.h>

void error (const PropWare::ErrorCode err);
Expand All @@ -42,11 +42,11 @@ const int32_t DELAY = 200;
*/
int main () {
PropWare::ErrorCode err;
PropWare::SimplexUART uart;
PropWare::UARTTX uart;

// Create an easy-to-test number pattern - useful when testing with a logic
// analyzer
char numberPattern[] = {
uint8_t numberPattern[] = {
0x01,
0x02,
0x03,
Expand All @@ -70,7 +70,7 @@ int main () {

while (1) {
// Test the number pattern
uart.puts(numberPattern);
uart.send_array((char *) numberPattern, sizeof(numberPattern));
waitcnt(DELAY * MILLISECOND + CNT);

// Test a basic string
Expand Down
7 changes: 6 additions & 1 deletion PropWare/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ set(PROPWARE_SOURCES
${CMAKE_CURRENT_LIST_DIR}/serial/i2c/i2c.h
${CMAKE_CURRENT_LIST_DIR}/serial/i2c/i2cbase.h
${CMAKE_CURRENT_LIST_DIR}/serial/spi/spi.h
${CMAKE_CURRENT_LIST_DIR}/serial/uart/uart.cpp # FIXME
${CMAKE_CURRENT_LIST_DIR}/serial/uart/halfduplexuart.h
${CMAKE_CURRENT_LIST_DIR}/serial/uart/shareduarttx.h
${CMAKE_CURRENT_LIST_DIR}/serial/uart/uart.cpp
${CMAKE_CURRENT_LIST_DIR}/serial/uart/uart.h
${CMAKE_CURRENT_LIST_DIR}/serial/uart/uartrx.h
${CMAKE_CURRENT_LIST_DIR}/serial/uart/uarttx.h
${CMAKE_CURRENT_LIST_DIR}/string/staticstringbuilder.h
${CMAKE_CURRENT_LIST_DIR}/string/stringbuilder.h
${CMAKE_CURRENT_LIST_DIR}/utility/comparator.cpp
Expand Down
6 changes: 3 additions & 3 deletions PropWare/hmi/input/scanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
*/

#include <PropWare/hmi/input/scanner.h>
#include <PropWare/serial/uart/halfduplexuart.h>
#include <PropWare/serial/uart/uartrx.h>

PropWare::HalfDuplexUART _g_halfDuplexUart;
PropWare::Scanner pwIn(_g_halfDuplexUart, &pwOut);
PropWare::UARTRX _g_uartrx;
PropWare::Scanner pwIn(_g_uartrx, &pwOut);
6 changes: 3 additions & 3 deletions PropWare/hmi/output/printer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
*/

#include <PropWare/hmi/output/printer.h>
#include <PropWare/serial/uart/simplexuart.h>
#include <PropWare/serial/uart/uarttx.h>

const PropWare::Printer::Format PropWare::Printer::DEFAULT_FORMAT;
PropWare::SimplexUART _g_simplexUart;
const PropWare::Printer pwOut(_g_simplexUart);
PropWare::UARTTX _g_uarttx;
const PropWare::Printer pwOut(_g_uarttx);
4 changes: 2 additions & 2 deletions PropWare/hmi/output/synchronousprinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
*/

#include <PropWare/hmi/output/synchronousprinter.h>
#include <PropWare/serial/uart/sharedsimplexuart.h>
#include <PropWare/serial/uart/shareduarttx.h>

PropWare::SharedSimplexUART _g_sharedSimplexUart;
PropWare::SharedUARTTX _g_sharedSimplexUart;
const PropWare::Printer _g_printer(_g_sharedSimplexUart);
const PropWare::SynchronousPrinter pwSyncOut(_g_printer);
110 changes: 0 additions & 110 deletions PropWare/serial/uart/duplexuart.h

This file was deleted.

62 changes: 0 additions & 62 deletions PropWare/serial/uart/fullduplexuart.h

This file was deleted.

30 changes: 7 additions & 23 deletions PropWare/serial/uart/halfduplexuart.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@

#pragma once

#include <PropWare/serial/uart/abstractduplexuart.h>
#include <PropWare/serial/uart/shareduarttx.h>
#include <PropWare/serial/uart/uartrx.h>

namespace PropWare {

Expand All @@ -35,32 +36,15 @@ namespace PropWare {
* It is important to note that, just like PropWare::FullDuplexUART, receiving
* data is an indefinitely blocking call
*/
class HalfDuplexUART : public AbstractDuplexUART {
class HalfDuplexUART : public SharedUARTTX,
public UARTRX {
public:
/**
* @see PropWare::SimplexUART::SimplexUART()
*/
HalfDuplexUART () :
AbstractDuplexUART() {
}

/**
* @see PropWare::FullDuplexUART::FullDuplexUART()
*/
HalfDuplexUART (const Port::Mask pinMask) :
AbstractDuplexUART(pinMask, pinMask) {
}

virtual void send (uint16_t originalData) const {
AbstractDuplexUART::send(originalData);

this->m_tx.set_dir_in();
}

virtual void send_array (char const array[], uint32_t words) const {
AbstractDuplexUART::send_array(array, words);

this->m_tx.set_dir_in();
HalfDuplexUART (const Pin::Mask pinMask)
: UARTTX(pinMask),
UARTRX(pinMask) {
}
};

Expand Down
Loading

0 comments on commit 67d5267

Please sign in to comment.