scd.c source file for Smart Card Detective More...
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/sleep.h>
#include <avr/power.h>
#include <avr/eeprom.h>
#include <string.h>
#include <util/delay.h>
#include <util/delay_basic.h>
#include <stdlib.h>
#include <avr/wdt.h>
#include "apps.h"
#include "emv.h"
#include "scd_hal.h"
#include "scd_io.h"
#include "scd.h"
#include "scd_logger.h"
#include "utils.h"
#include "emv_values.h"
#include "scd_values.h"
#include "VirtualSerial.h"
#include "serial.h"
Go to the source code of this file.
Defines | |
#define | LCD_ENABLED 1 |
Set this to 1 to enable LCD functionality. | |
#define | DEBUG 0 |
Set this to 1 to enable debug mode. | |
#define | ICC_PRES_INT_ENABLE 1 |
Set this to 1 to enable card presence interrupt. | |
Functions | |
int | main (void) |
Main function. | |
uint8_t | SelectApplication () |
Show menu and select application. | |
void | InitSCD () |
Initializes the SCD. | |
ISR (INT0_vect) | |
ISR (INT1_vect) | |
ISR (WDT_vect) | |
ISR (TIMER3_COMPA_vect, ISR_NAKED) | |
void | BootloaderJumpCheck () |
void | TestHardware () |
Tests the hardware (LEDs, LCD and buttons). | |
void | TestSCDTerminal () |
Tests the SCD-Terminal communication. | |
void | TestSCDICC (log_struct_t *logger) |
void | SwitchLeds () |
Simple application to switch some LEDs on and off. | |
Variables | |
log_struct_t | scd_logger |
uint8_t | warmResetByte |
uint8_t | lcdAvailable |
uint8_t | nCounter |
uint8_t | selected |
uint8_t | bootkey |
uint16_t | revision = 0x24 |
FILE | lcd_str = FDEV_SETUP_STREAM(LcdPutchar, NULL, _FDEV_SETUP_WRITE) |
scd.c source file for Smart Card Detective
This file implements the main application of the Smart Card Detective
It uses the functions defined in scd_hal.h and emv.h to communicate with the ICC and Terminal and the functions from scd_io.h to communicate with the LCD, buttons and LEDs
Copyright (C) 2012 Omar Choudary (omar.choudary@cl.cam.ac.uk)
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Definition in file scd.c.
#define ICC_PRES_INT_ENABLE 1 |
#define LCD_ENABLED 1 |
void BootloaderJumpCheck | ( | void | ) |
Interrupt routine for Timer2 Compare Match A overflow. This interrupt can fire when the Timer2 matches the OCR2A value and the corresponding interrupt is enabled. We could put the IncrementCounter() code directly into the subroutine to save some clock cycles but we must take care to save all used registers since they are probably used by other functions.
Uncomment the code below to combine avr-gcc handling of register with the IncrementCounter assembler routine. Else the interrupt handler is entirely in assembler without calling the extra function.
Code taken from: http://www.fourwalledcubicle.com/files/LUFA/Doc/100807/html/_page__software_bootloader_start.html
void InitSCD | ( | ) |
ISR | ( | TIMER3_COMPA_vect | , | |
ISR_NAKED | ||||
) |
ISR | ( | INT1_vect | ) |
ISR | ( | INT0_vect | ) |
uint8_t SelectApplication | ( | ) |
Show menu and select application.
This function shows a menu with the existing applications and allows the user to select one of them.
The different applications are shown on the LCD and the user can use the buttons to scroll between the list and to select the desired application.
void SwitchLeds | ( | ) |
void TestHardware | ( | ) |
void TestSCDICC | ( | log_struct_t * | logger | ) |
void TestSCDTerminal | ( | ) |
Tests the SCD-Terminal communication.
This function implements an infinite communication loop between the SCD and my terminal emulator, by continuously replying to the SELECT command for "1PAY.SYS.DDF01"
The main role of this function is to test the correct transfer of bytes between the terminal and the SCD
FILE lcd_str = FDEV_SETUP_STREAM(LcdPutchar, NULL, _FDEV_SETUP_WRITE) |
uint8_t lcdAvailable |
uint8_t warmResetByte |