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: UsbHostMAX3421E_Hello
hexdump.h
00001 /* Copyright (C) 2011 Circuits At Home, LTD. All rights reserved. 00002 00003 This program is free software; you can redistribute it and/or modify 00004 it under the terms of the GNU General Public License as published by 00005 the Free Software Foundation; either version 2 of the License, or 00006 (at your option) any later version. 00007 00008 This program is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00011 GNU General Public License for more details. 00012 00013 You should have received a copy of the GNU General Public License 00014 along with this program; if not, write to the Free Software 00015 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00016 00017 Contact information 00018 ------------------- 00019 00020 Circuits At Home, LTD 00021 Web : http://www.circuitsathome.com 00022 e-mail : support@circuitsathome.com 00023 */ 00024 00025 #if !defined(_usb_h_) || defined(__HEXDUMP_H__) 00026 #error "Never include hexdump.h directly; include Usb.h instead" 00027 #else 00028 #define __HEXDUMP_H__ 00029 00030 extern int UsbDEBUGlvl; 00031 00032 template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE> 00033 class HexDumper : public BASE_CLASS { 00034 uint8_t byteCount; 00035 OFFSET_TYPE byteTotal; 00036 00037 public: 00038 00039 HexDumper() : byteCount(0), byteTotal(0) { 00040 }; 00041 00042 void Initialize() { 00043 byteCount = 0; 00044 byteTotal = 0; 00045 }; 00046 00047 void Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset); 00048 }; 00049 00050 template <class BASE_CLASS, class LEN_TYPE, class OFFSET_TYPE> 00051 void HexDumper<BASE_CLASS, LEN_TYPE, OFFSET_TYPE>::Parse(const LEN_TYPE len, const uint8_t *pbuf, const OFFSET_TYPE &offset __attribute__((unused))) { 00052 if(UsbDEBUGlvl >= 0x80) { // Fully bypass this block of code if we do not debug. 00053 for(LEN_TYPE j = 0; j < len; j++, byteCount++, byteTotal++) { 00054 if(!byteCount) { 00055 PrintHex<OFFSET_TYPE > (byteTotal, 0x80); 00056 E_Notify(PSTR(": "), 0x80); 00057 } 00058 PrintHex<uint8_t > (pbuf[j], 0x80); 00059 E_Notify(PSTR(" "), 0x80); 00060 00061 if(byteCount == 15) { 00062 E_Notify(PSTR("\r\n"), 0x80); 00063 byteCount = 0xFF; 00064 } 00065 } 00066 } 00067 } 00068 00069 #endif // __HEXDUMP_H__
Generated on Tue Jul 12 2022 18:12:04 by
1.7.2