Manchester
Revision 6:7454ad91f714, committed 2017-05-22
- Comitter:
- hudakz
- Date:
- Mon May 22 09:35:26 2017 +0000
- Parent:
- 5:3b2c7e9fda3f
- Child:
- 7:afd0ee36dcd1
- Commit message:
- Updated.
Changed in this revision
--- a/Manchester.cpp Sun May 21 19:17:28 2017 +0000
+++ b/Manchester.cpp Mon May 22 09:35:26 2017 +0000
@@ -3,7 +3,7 @@
* @file Manchester.cpp
* @author Zoltan Hudak
* @version
- * @date 16-May-2017
+ * @date 2017-May-16
* @brief Manchester code for mbed
******************************************************************************
* @attention
@@ -28,10 +28,10 @@
/*
This library implements Manchester code according to both IEEE 802.3
- and G.E. Thomas' convention.
+ and G.E. Thomas' conventions.
• A '0' is expressed by a high-to-low transition, a '1' by low-to-high transition
in the IEEE 802.3 convention. The reverse is true in the G.E. Thomas' convention.
- • The transitions which signify 0 or 1 occur at the midpoint of a period.
+ • The transitions which signify '0' or '1' occur at the midpoint of a period.
• Transitions at the start of a period are overhead and don't signify data.
• Least significant bit is sent first
• There is one synchronization pulse at the begin of transmission
@@ -55,10 +55,10 @@
*/
Manchester::Manchester
(
- PinName txPin,
- PinName rxPin,
- uint32_t speed, /* = 1200 bps */
- uint8_t tol /* = (+/-)25% */
+ PinName txPin,
+ PinName rxPin,
+ uint32_t speed, /* = 1200 bps */
+ uint8_t tol /* = (+/-)25% */
) :
_tx(txPin),
_rx(rxPin) {
@@ -83,19 +83,18 @@
* @retval
*/
void Manchester::transmit(ManchesterMsg& msg) {
- bool txComplete;
+ bool txFinished;
_data = msg.data;
_len = msg.len;
_state = SYNCH_START;
_txTicker.attach_us(callback(this, &Manchester::transmission), _midBitTime);
- do
- {
+ do {
core_util_critical_section_enter();
- txComplete = (_state == IDLE);
+ txFinished = (_state == IDLE);
core_util_critical_section_exit();
- } while(!txComplete);
+ } while(!txFinished);
_txTicker.detach();
}
@@ -206,7 +205,6 @@
*/
bool Manchester::receive(ManchesterMsg& msg) {
bool rxFinished;
- uint32_t now = us_ticker_read();
_data = msg.data;
_maxLen = msg.maxLen();
@@ -216,8 +214,7 @@
_rx.enable_irq();
core_util_critical_section_exit();
- do
- {
+ do {
core_util_critical_section_enter();
rxFinished = ((_state == IDLE) || (_state == ERROR));
core_util_critical_section_exit();
@@ -337,3 +334,4 @@
_state = ERROR; // Incomplete transmission
}
+
--- a/Manchester.h Sun May 21 19:17:28 2017 +0000
+++ b/Manchester.h Mon May 22 09:35:26 2017 +0000
@@ -3,7 +3,7 @@
* @file Manchester.h
* @author Zoltan Hudak
* @version
- * @date 16-May-2017
+ * @date 2017-May-16
* @brief Manchester code for mbed
******************************************************************************
* @attention
@@ -28,10 +28,10 @@
/*
This library implements Manchester code according to both IEEE 802.3
- and G.E. Thomas' convention.
+ and G.E. Thomas' conventions.
• A '0' is expressed by a high-to-low transition, a '1' by low-to-high transition
in the IEEE 802.3 convention. The reverse is true in the G.E. Thomas' convention.
- • The transitions which signify 0 or 1 occur at the midpoint of a period.
+ • The transitions which signify '0' or '1' occur at the midpoint of a period.
• Transitions at the start of a period are overhead and don't signify data.
• Least significant bit is sent first
• There is one synchronization pulse at the begin of transmission
@@ -73,7 +73,7 @@
PinName txPin, /* transmitter pin name */
PinName rxPin, /* receiver pin name */
uint32_t speed = 1200, /* speed in bits per second */
- uint8_t tol = 25 /* pulse width tolerance (+/-) in % */
+ uint8_t tol = 25 /* pulse width tolerance (+/-) in % */
);
~Manchester(void) { }
void transmit(ManchesterMsg& msg);
--- a/ManchesterMsg.h Sun May 21 19:17:28 2017 +0000
+++ b/ManchesterMsg.h Mon May 22 09:35:26 2017 +0000
@@ -3,7 +3,7 @@
* @file ManchesterMsg.h
* @author Zoltan Hudak
* @version
- * @date 16-May-2017
+ * @date 2017-May-16
* @brief Message container
******************************************************************************
* @attention
@@ -75,7 +75,7 @@
return *this;
}
- /** Inserter operator: Appends string of char to message
+ /** Inserter operator: Appends array of char to message
*/
ManchesterMsg &operator<<(const char* str) {
size_t strLen = strlen(str);
@@ -111,7 +111,7 @@
return *this;
}
- /** Extractor operator: Extracts string of char from message
+ /** Extractor operator: Extracts array of char from message
*/
ManchesterMsg &operator>>(char* str) {
size_t strLen = strlen(data);