From cc9da9cc9c8098c2afd8e776217651e7762f5344 Mon Sep 17 00:00:00 2001 From: Gwenhael Goavec-Merou Date: Thu, 5 Mar 2020 19:53:35 +0100 Subject: [PATCH] jtagInterface: introduce abstraction between jtag implementation and hardware --- src/jtagInterface.hpp | 89 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 src/jtagInterface.hpp diff --git a/src/jtagInterface.hpp b/src/jtagInterface.hpp new file mode 100644 index 0000000..6438528 --- /dev/null +++ b/src/jtagInterface.hpp @@ -0,0 +1,89 @@ +/* + * Copyright (C) 2020 Gwenhael Goavec-Merou + * + * This program 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. + * + * This program 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 this program. If not, see . + */ + +#ifndef _JTAGINTERFACE_H_ +#define _JTAGINTERFACE_H_ + +#include +#include + +/*! + * \file JtagInterface.hpp + * \class JtagInterface + * \brief abstract class between jtag implementation and converters + * \author Gwenhael Goavec-Merou + */ + +class JtagInterface { + public: + virtual ~JtagInterface() {} + + virtual int setClkFreq(uint32_t clkHZ) = 0; + virtual int setClkFreq(uint32_t clkHZ, char use_divide_by_5) = 0; + + /*! + * \brief store TMS states in internal buffer. Not limited to 8 states + * \param tms: array of TMS values + * \param nb_bit: number of TMS states to store + * \param tdi: state of TDI for all TMS to store + * \return number of states stored + */ + virtual int storeTMS(uint8_t *tms, int nb_bit, uint8_t tdi = 1, + bool read = false) = 0; + /*! + * \brief flush TMS internal buffer (ie. transmit to converter) + * \param tdo: pointer for read operation. May be NULL + * \param len: number of bit to send + * \return number of bit send/received + */ + virtual int writeTMS(uint8_t *tdo, int len = 0) = 0; + /*! + * \brief store up to 8 TDI state(s) in internal buffer + * \param tdi: TDI value(s) + * \param tms: state of TMS for all TDI to store + * \param nb_bit: number of TMS states to store + * \return number of states stored + */ + virtual int storeTDI(uint8_t tdi, int nb_bit, bool read) = 0; + /*! + * \brief store TDI multiple of 8 states in internal buffer. + * \param tdi: array of TDI values + * \param tms: state of TMS for all TDI to store + * \param nb_byte: number of TDI states to store + * \return number of states stored + */ + virtual int storeTDI(uint8_t *tdi, int nb_byte, bool read) = 0; + /*! + * \brief flush TDI internal buffer (ie. transmit to converter) + * \param tdo: pointer for read operation. May be NULL + * \return number of bit send/received + */ + virtual int writeTDI(uint8_t *tdo, int nb_bit) = 0; + + /*! + * \brief return internal buffer size (in byte) + * \return internal buffer size + */ + virtual int get_buffer_size() = 0; + + /*! + * \brief return status of internal buffer + * \return true when internal buffer is full + */ + virtual bool isFull() = 0; +}; +#endif // _JTAGINTERFACE_H_