From fc371d0d0e3a60b06dec862e37612375860c41d5 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sun, 17 Jun 2018 14:21:45 +1000 Subject: Add CCID class driver and associated demos. --- Demos/Device/ClassDriver/CCID/Lib/Iso7816.c | 47 +++++++++++++++++++++++++++++ Demos/Device/ClassDriver/CCID/Lib/Iso7816.h | 42 ++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 Demos/Device/ClassDriver/CCID/Lib/Iso7816.c create mode 100644 Demos/Device/ClassDriver/CCID/Lib/Iso7816.h (limited to 'Demos/Device/ClassDriver/CCID/Lib') diff --git a/Demos/Device/ClassDriver/CCID/Lib/Iso7816.c b/Demos/Device/ClassDriver/CCID/Lib/Iso7816.c new file mode 100644 index 000000000..1f9391d72 --- /dev/null +++ b/Demos/Device/ClassDriver/CCID/Lib/Iso7816.c @@ -0,0 +1,47 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2018. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2018 Filipe Rodrigues (filipepazrodrigues [at] gmail [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaims all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "Iso7816.h" + +void Iso7816_CreateSimpleAtr(uint8_t* attr, uint8_t* attrLength) +{ + attr[0] = 0x3B; //TS: direct convention + + uint8_t interfaceBytesPresence = 0; + + uint8_t historicalBytes[14] = "LUFA CCID Demo"; // Must be equal or less than 15 + uint8_t historicalBytesLength = sizeof(historicalBytes); + + attr[1] = (interfaceBytesPresence << 4) + historicalBytesLength; + memcpy(attr + 2, historicalBytes, historicalBytesLength); + + *attrLength = historicalBytesLength + 2; +} diff --git a/Demos/Device/ClassDriver/CCID/Lib/Iso7816.h b/Demos/Device/ClassDriver/CCID/Lib/Iso7816.h new file mode 100644 index 000000000..f5fc1d70a --- /dev/null +++ b/Demos/Device/ClassDriver/CCID/Lib/Iso7816.h @@ -0,0 +1,42 @@ +/* + LUFA Library + Copyright (C) Dean Camera, 2018. + + dean [at] fourwalledcubicle [dot] com + www.lufa-lib.org +*/ + +/* + Copyright 2018 Dean Camera (dean [at] fourwalledcubicle [dot] com) + Copyright 2018 Filipe Rodrigues (filipepazrodrigues [at] gmail [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the + software without specific, written prior permission. + + The author disclaims all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ +#ifndef _ISO7816_H_ +#define _ISO7816_H_ + /* Includes: */ + #include + #include + #include + #include + #include + + /* Function Prototypes: */ + void Iso7816_CreateSimpleAtr(uint8_t* attr, uint8_t* attrLength); +#endif -- cgit v1.2.3