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: Nucleo_modbus_protocol_test
Diff: SerialPortHandler.cpp
- Revision:
- 0:f66dd1c93477
- Child:
- 1:a891da6966b7
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/SerialPortHandler.cpp Mon Jan 19 03:40:33 2015 +0000
@@ -0,0 +1,33 @@
+#include "SerialPortHandler.h"
+
+SerialPortHandler::SerialPortHandler(Serial* ps, MessageQueue<uint8_t>* txQueue, MessageQueue<uint8_t>* rxQueue)
+{
+ m_ps = ps;
+ m_txQueue = txQueue;
+ m_rxQueue = rxQueue;
+}
+
+SerialPortHandler::~SerialPortHandler()
+{
+ delete m_ps;
+ delete m_txQueue;
+ delete m_rxQueue;
+}
+
+void SerialPortHandler::transmitPacket()
+{
+ uint32_t count = m_txQueue->getWriteIndex();
+ uint8_t data;
+
+ for (uint32_t i = 0; i < count; i++) {
+ data = m_txQueue->read();
+
+ m_ps->putc(data);
+ }
+}
+
+void SerialPortHandler::receivePacket()
+{
+ uint8_t rxreg = m_ps->getc();
+ m_rxQueue->write(rxreg);
+}