Program Listing for File uart_terminal_device.hpp

Return to documentation for file (src/tap/communication/serial/uart_terminal_device.hpp)

/*
 * Copyright (c) 2020-2021 Advanced Robotics at the University of Washington <robomstr@uw.edu>
 *
 * This file is part of Taproot.
 *
 * Taproot is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Taproot is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Taproot.  If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef TAPROOT_UART_TERMINAL_DEVICE_HPP_
#define TAPROOT_UART_TERMINAL_DEVICE_HPP_

#include "tap/communication/serial/uart.hpp"

#include "modm/io/iodevice.hpp"

#include "uart_terminal_device_constants.hpp"

namespace tap
{
class Drivers;
}

namespace tap::communication::serial
{
class UartTerminalDevice : public ::modm::IODevice
{
public:
    UartTerminalDevice(Drivers *drivers);
    DISALLOW_COPY_AND_ASSIGN(UartTerminalDevice);
    virtual ~UartTerminalDevice() = default;

    void initialize();

    bool read(char &c) override;

    using IODevice::write;
    void write(char c) override;

    void flush() override;

private:
    static constexpr uint32_t UART_BAUDE_RATE = 115200;

    Drivers *drivers;

    static constexpr Uart::UartPort TERMINAL_UART_PORT = bound_ports::TERMINAL_SERIAL_UART_PORT;
};  // class UartTerminalDevice
}  // namespace tap::communication::serial

#endif  // TAPROOT_UART_TERMINAL_DEVICE_HPP_