Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: 4dofRoboticArmAX12 2014-Mx64 2014-ax12-test 2014-mx64-test
Fork of SerialHalfDuplex by
Revision 2:5ecc72a47df0, committed 2014-04-01
- Comitter:
- aimen
- Date:
- Tue Apr 01 06:50:02 2014 +0000
- Parent:
- 1:8fd1fa67565e
- Commit message:
- no change
Changed in this revision
| SerialHalfDuplex.cpp | Show annotated file Show diff for this revision Revisions of this file |
| SerialHalfDuplex.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/SerialHalfDuplex.cpp Wed Apr 03 16:42:49 2013 +0000
+++ b/SerialHalfDuplex.cpp Tue Apr 01 06:50:02 2014 +0000
@@ -1,4 +1,4 @@
-/* mbed Microcontroller Library
+ /* mbed Microcontroller Library
* Copyright (c) 2006-2012 ARM Limited
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -22,25 +22,25 @@
* NOTE: This is an unsupported legacy untested library.
*/
#include "SerialHalfDuplex.h"
-
+
#if DEVICE_SERIAL
-
+
#include "pinmap.h"
#include "serial_api.h"
#include "gpio_api.h"
-
+
namespace mbed {
-
+
SerialHalfDuplex::SerialHalfDuplex(PinName tx, PinName rx, const char *name)
: Serial(tx, rx, name) {
_txpin = tx;
- //gpio_input(_txpin); // set as input
+ // set as input
gpio_set(_txpin);
pin_mode(_txpin, PullNone); // no pull
pin_function(_txpin, 0); // set as gpio
}
-
+
// To transmit a byte in half duplex mode:
// 1. Disable interrupts, so we don't trigger on loopback byte
// 2. Set tx pin to UART out
@@ -49,7 +49,7 @@
// transmit has occurred, and also clears the byte from the buffer.
// 5. Return pin to input mode
// 6. Re-enable interrupts
-
+
int SerialHalfDuplex::_putc(int c) {
int retc;
@@ -67,11 +67,11 @@
return retc;
}
-
+
int SerialHalfDuplex::_getc(void) {
return Serial::_getc();
}
-
+
} // End namespace
-
-#endif
+
+#endif
\ No newline at end of file
--- a/SerialHalfDuplex.h Wed Apr 03 16:42:49 2013 +0000
+++ b/SerialHalfDuplex.h Tue Apr 01 06:50:02 2014 +0000
@@ -25,15 +25,15 @@
#define MBED_SERIALHALFDUPLEX_H
#include "device.h"
-
+
#if DEVICE_SERIAL
-
+
#include "Serial.h"
#include "PinNames.h"
#include "PeripheralNames.h"
-
+
namespace mbed {
-
+
/* Class: SerialHalfDuplex
* A serial port (UART) for communication with other devices using
* Half-Duplex, allowing transmit and receive on a single
@@ -75,7 +75,7 @@
* For Simplex and Full-Duplex Serial communication, see <Serial>
*/
class SerialHalfDuplex : public Serial {
-
+
public:
/* Constructor: SerialHalfDuplex
* Create a half-duplex serial port, connected to the specified transmit
@@ -88,7 +88,7 @@
* rx - Receive pin
*/
SerialHalfDuplex(PinName tx, PinName rx, const char *name = NULL);
-
+
#if 0 // Inherited from Serial class, for documentation
/* Function: baud
* Set the baud rate of the serial port
@@ -97,7 +97,7 @@
* baudrate - The baudrate of the serial port (default = 9600).
*/
void baud(int baudrate);
-
+
enum Parity {
None = 0
, Odd
@@ -105,7 +105,7 @@
, Forced1
, Forced0
};
-
+
/* Function: format
* Set the transmission format used by the Serial port
*
@@ -117,7 +117,7 @@
*/
void format(int bits = 8, Parity parity = Serial::None, int stop_bits
= 1);
-
+
/* Function: putc
* Write a character
*
@@ -125,7 +125,7 @@
* c - The character to write to the serial port
*/
int putc(int c);
-
+
/* Function: getc
* Read a character
*
@@ -137,7 +137,7 @@
* returns - The character read from the serial port
*/
int getc();
-
+
/* Function: printf
* Write a formated string
*
@@ -146,7 +146,7 @@
* variables to use in formating the string.
*/
int printf(const char* format, ...);
-
+
/* Function: scanf
* Read a formated string
*
@@ -155,7 +155,7 @@
* followed by the pointers to variables to store the results.
*/
int scanf(const char* format, ...);
-
+
/* Function: readable
* Determine if there is a character available to read
*
@@ -163,7 +163,7 @@
* returns - 1 if there is a character available to read, else 0
*/
int readable();
-
+
/* Function: writeable
* Determine if there is space available to write a character
*
@@ -171,7 +171,7 @@
* returns - 1 if there is space to write a character, else 0
*/
int writeable();
-
+
/* Function: attach
* Attach a function to call whenever a serial interrupt is generated
*
@@ -179,7 +179,7 @@
* fptr - A pointer to a void function, or 0 to set as none
*/
void attach(void (*fptr)(void));
-
+
/* Function: attach
* Attach a member function to call whenever a serial interrupt is generated
*
@@ -189,19 +189,19 @@
*/
template<typename T>
void attach(T* tptr, void (T::*mptr)(void));
-
+
#endif
-
+
protected:
PinName _txpin;
-
+
virtual int _putc(int c);
virtual int _getc(void);
-
+
}; // End class SerialHalfDuplex
-
+
} // End namespace
-
+
#endif
-
-#endif
+
+#endif
\ No newline at end of file
