Program Listing for File hsu.hpp

Return to documentation for file (libspookyaction/include/pn532/esp32/hsu.hpp)

//
// Created by Pietro Saccardi on 21/12/2020.
//

#ifndef PN532_ESP32_HSU_HPP
#define PN532_ESP32_HSU_HPP

#include <driver/gpio.h>
#include <driver/uart.h>
#include <pn532/channel.hpp>

namespace pn532::esp32 {

    class hsu_channel final : public channel {
        uart_port_t _port;

    protected:
        result<> raw_send(mlab::range<bin_data::const_iterator> buffer, ms timeout) override;

        result<> raw_receive(mlab::range<bin_data::iterator> buffer, ms timeout) override;

        [[nodiscard]] inline comm_rx_mode raw_receive_mode() const override;

        bool on_send_prepare(ms timeout) override;

    public:
        bool wake() override;

        hsu_channel(uart_port_t port, uart_config_t config, gpio_num_t to_device_tx, gpio_num_t to_device_rx);

        ~hsu_channel() override;
    };
}// namespace pn532::esp32

namespace pn532::esp32 {
    comm_rx_mode hsu_channel::raw_receive_mode() const {
        return comm_rx_mode::stream;
    }
}// namespace pn532::esp32

#endif//PN532_ESP32_HSU_HPP