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
SerialPortHandler.cpp
- Committer:
- gabrielrivas
- Date:
- 2015-01-19
- Revision:
- 1:a891da6966b7
- Parent:
- 0:f66dd1c93477
- Child:
- 2:aa72cb66762f
File content as of revision 1:a891da6966b7:
/** Serial port handler.
* Copyright (c) 2015 Gabriel Rivas
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#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);
}