mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-17 05:38:33 +03:00
Removed sym links, replaced them with actual folders
This commit is contained in:
@@ -1 +0,0 @@
|
||||
./atmel_softpack_libraries/libboard_sam3s-ek/include/
|
||||
108
firmware/include_board/bitbanding.h
Normal file
108
firmware/include_board/bitbanding.h
Normal file
@@ -0,0 +1,108 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifndef _BITBANDING_
|
||||
#define _BITBANDING_
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* \file bitbanding.h
|
||||
* Include Defines & macros for bit-banding.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Header files
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Global Macros
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
* \brief Check if the address is in bit banding sram region.
|
||||
*
|
||||
* \note The address should be in area of 0x2000000 ~ 0x200FFFFF
|
||||
*
|
||||
* \param x The address to check.
|
||||
*/
|
||||
#define IS_BITBAND_SRAM_ADDR(x) \
|
||||
( ((uint32_t)(x)) >= 0x20000000 && \
|
||||
((uint32_t)(x)) < (0x20000000+0x100000) )
|
||||
|
||||
/**
|
||||
* \brief Check if the address is in bit banding peripheral region
|
||||
*
|
||||
* \note The address should be in area of 0x4000000 ~ 0x400FFFFF
|
||||
* \param x The address to check
|
||||
*/
|
||||
#define IS_BITBAND_PERIPH_ADDR(x) \
|
||||
( ((uint32_t)(x)) >= 0x40000000 && \
|
||||
((uint32_t)(x)) < (0x40000000+0x100000) )
|
||||
|
||||
/**
|
||||
* \brief Calculate bit band alias address.
|
||||
*
|
||||
* Calculate the bit band alias address and return a pointer address to word.
|
||||
*
|
||||
* \param addr The byte address of bitbanding bit.
|
||||
* \param bit The bit position of bitbanding bit.
|
||||
* \callergraph
|
||||
*/
|
||||
#define BITBAND_ALIAS_ADDRESS(addr, bit) \
|
||||
((volatile uint32_t*)((((uint32_t)(addr) & 0xF0000000) + 0x02000000) \
|
||||
+((((uint32_t)(addr)&0xFFFFF)*32)\
|
||||
+( (uint32_t)(bit)*4))))
|
||||
|
||||
/**
|
||||
* \brief Bit write through bit banding.
|
||||
*
|
||||
* \param addr32 32-bit aligned byte address where the bit exists.
|
||||
* \param bit Bit position.
|
||||
* \param val The value that the bit is set to.
|
||||
* \callergraph
|
||||
*/
|
||||
#define WRITE_BITBANDING(addr32, bit, val) do {\
|
||||
*BITBAND_ALIAS_ADDRESS(addr32,bit) = (val); \
|
||||
} while (0);
|
||||
|
||||
/**
|
||||
* \brief Toggle bit through bit banding
|
||||
*
|
||||
* \param addr32 32-bit aligned byte address where the bit exists.
|
||||
* \param bit Bit position.
|
||||
*/
|
||||
#define TOGGLE_BITBANDING(addr32, bit) do {\
|
||||
volatile uint32_t * p = \
|
||||
BITBAND_ALIAS_ADDRESS(addr32,bit); \
|
||||
if (*p) *p = 0; \
|
||||
else *p = 1; \
|
||||
}while(0);
|
||||
|
||||
#endif /* #ifndef _BITBANDING_ */
|
||||
191
firmware/include_board/board.h
Normal file
191
firmware/include_board/board.h
Normal file
@@ -0,0 +1,191 @@
|
||||
#ifndef _BOARD_
|
||||
#define _BOARD_
|
||||
|
||||
/** Headers */
|
||||
#include "chip.h"
|
||||
/* We need this for a nop instruction in USB_HAL.c */
|
||||
#define __CC_ARM
|
||||
|
||||
/** Board */
|
||||
#include "board_lowlevel.h"
|
||||
#include "uart_console.h"
|
||||
#include "iso7816_4.h"
|
||||
#include "led.h"
|
||||
#include "cciddriver.h"
|
||||
#include "USBD.h"
|
||||
|
||||
#include "USBD_Config.h"
|
||||
#include "USBDDriver.h"
|
||||
|
||||
/** Highlevel */
|
||||
#include "trace.h"
|
||||
#include "stdio.h"
|
||||
#include "stdlib.h"
|
||||
#include "string.h"
|
||||
#include "inttypes.h"
|
||||
|
||||
#include "simtrace.h"
|
||||
|
||||
#define MIN(a, b) ((a < b) ? a : b)
|
||||
|
||||
#ifdef __GNUC__
|
||||
#undef __GNUC__
|
||||
#endif
|
||||
|
||||
/** Name of the board */
|
||||
#define BOARD_NAME "SAM3S-SIMTRACE"
|
||||
/** Board definition */
|
||||
#define simtrace
|
||||
/** Family definition (already defined) */
|
||||
#define sam3s
|
||||
/** Core definition */
|
||||
#define cortexm3
|
||||
|
||||
#define BOARD_MAINOSC 18432000
|
||||
#define BOARD_MCK 48000000
|
||||
|
||||
#define LED_RED PIO_PA17
|
||||
#define LED_GREEN PIO_PA18
|
||||
|
||||
#define PIN_LED_RED {LED_RED, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
|
||||
#define PIN_LED_GREEN {LED_GREEN, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
|
||||
#define PINS_LEDS PIN_LED_RED, PIN_LED_GREEN
|
||||
|
||||
#define LED_NUM_RED 0
|
||||
#define LED_NUM_GREEN 1
|
||||
|
||||
/** Phone (SIM card emulator)/CCID Reader/MITM configuration **/
|
||||
/* Normally the communication lines between phone and SIM card are disconnected */
|
||||
// Disconnect SIM card I/O, VPP line from the phone lines
|
||||
// FIXME: Per default pins are input, therefore high-impedance, therefore they don not activate the bus switch, right?
|
||||
#define PIN_SC_SW_DEFAULT {PIO_PA20, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
|
||||
// Disconnect SIM card RST, CLK line from the phone lines
|
||||
#define PIN_IO_SW_DEFAULT {PIO_PA19, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
|
||||
#define PINS_BUS_DEFAULT PIN_SC_SW_DEFAULT, PIN_IO_SW_DEFAULT
|
||||
|
||||
/** Sniffer configuration **/
|
||||
// Connect VPP, CLK and RST lines from smartcard to the phone
|
||||
#define PIN_SC_SW_SNIFF {PIO_PA20, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}
|
||||
#define PIN_IO_SW_SNIFF {PIO_PA19, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}
|
||||
#define PINS_BUS_SNIFF PIN_SC_SW_SNIFF, PIN_IO_SW_SNIFF
|
||||
|
||||
#define PINS_SIM_SNIFF_SIM PIN_PHONE_IO, PIN_PHONE_CLK
|
||||
|
||||
|
||||
|
||||
/** USART0 pin RX */
|
||||
#define PIN_USART0_RXD {PIO_PA9A_URXD0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
/** USART0 pin TX */
|
||||
#define PIN_USART0_TXD {PIO_PA10A_UTXD0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
|
||||
#define BOARD_PIN_USART_RXD PIN_USART0_RXD
|
||||
#define BOARD_PIN_USART_TXD PIN_USART0_TXD
|
||||
|
||||
#define BOARD_ID_USART ID_USART0
|
||||
#define BOARD_USART_BASE USART0
|
||||
|
||||
#define PINS_UART { PIO_PA9A_URXD0|PIO_PA10A_UTXD0, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
|
||||
/** UART0 */
|
||||
/** Console baudrate always using 115200. */
|
||||
#define CONSOLE_BAUDRATE 115200
|
||||
/** Usart Hw interface used by the console (UART0). */
|
||||
#define CONSOLE_USART UART0
|
||||
/** Usart Hw ID used by the console (UART0). */
|
||||
#define CONSOLE_ID ID_UART0
|
||||
/** Pins description corresponding to Rxd,Txd, (UART pins) */
|
||||
#define CONSOLE_PINS {PINS_UART}
|
||||
|
||||
/// Smartcard detection pin
|
||||
// FIXME: add connect pin as iso pin...should it be periph b or interrupt oder input?
|
||||
#define BOARD_ISO7816_BASE_USART USART0
|
||||
#define BOARD_ISO7816_ID_USART ID_USART0
|
||||
|
||||
#define USART_SIM USART0
|
||||
#define ID_USART_SIM ID_USART0
|
||||
#define USART_PHONE USART1
|
||||
#define ID_USART_PHONE ID_USART1
|
||||
|
||||
#define SIM_PWEN PIO_PA5
|
||||
#define VCC_FWD PIO_PA26
|
||||
|
||||
#define SIM_PWEN_PIN {PIO_PA5, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
|
||||
|
||||
#define PWR_PINS \
|
||||
/* Enable power converter 4.5-6V to 3.3V; low: off */ \
|
||||
{SIM_PWEN, PIOA, ID_PIOA, PIO_OUTPUT_0, PIO_DEFAULT}, \
|
||||
/* Enable second power converter: VCC_PHONE to VCC_SIM; high: on */ \
|
||||
{VCC_FWD, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
|
||||
|
||||
|
||||
#define SW_SIM PIO_PA8
|
||||
#define SMARTCARD_CONNECT_PIN {SW_SIM, PIOA, ID_PIOA, PIO_INPUT, PIO_PULLUP | PIO_DEBOUNCE | PIO_DEGLITCH | PIO_IT_EDGE }
|
||||
//#define SMARTCARD_CONNECT_PIN {SW_SIM, PIOB, ID_PIOB, PIO_INPUT, PIO_PULLUP | PIO_DEBOUNCE | PIO_IT_EDGE}
|
||||
|
||||
/// PIN used for resetting the smartcard
|
||||
#define RST_SIM (1 << 7)
|
||||
// FIXME: Card is resetted with pin set to 0 --> PIO_OUTPUT_1 as default is right?
|
||||
#define PIN_ISO7816_RSTMC {RST_SIM, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
|
||||
|
||||
/// Pins used for connect the smartcard
|
||||
#define PIN_SIM_IO_INPUT {PIO_PA1, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT}
|
||||
#define PIN_SIM_IO {PIO_PA6, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
#define PIN_SIM_CLK {PIO_PA2, PIOA, ID_PIOA, PIO_PERIPH_B, PIO_DEFAULT}
|
||||
#define PIN_SIM_CLK_INPUT {PIO_PA4, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT}
|
||||
//#define PINS_ISO7816 PIN_USART1_TXD, PIN_USART1_SCK, PIN_ISO7816_RSTMC
|
||||
#define PINS_ISO7816 PIN_SIM_IO, PIN_SIM_CLK, PIN_ISO7816_RSTMC // SIM_PWEN_PIN, PIN_SIM_IO2, PIN_SIM_CLK2
|
||||
|
||||
|
||||
#define VCC_PHONE {PIO_PA25, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT}
|
||||
#define PIN_ISO7816_RST_PHONE {PIO_PA24, PIOA, ID_PIOA, PIO_INPUT, PIO_IT_RISE_EDGE }
|
||||
#define PIN_PHONE_IO_INPUT {PIO_PA21, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT}
|
||||
#define PIN_PHONE_IO {PIO_PA22, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
#define PIN_PHONE_CLK {PIO_PA23A_SCK1, PIOA, ID_PIOA, PIO_PERIPH_A, PIO_DEFAULT} // External Clock Input on PA28
|
||||
//#define PIN_PHONE_CLK {PIO_PA23A_SCK1, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT} // External Clock Input on PA28
|
||||
#define PIN_PHONE_CLK_INPUT {PIO_PA29, PIOA, ID_PIOA, PIO_INPUT, PIO_DEFAULT}
|
||||
#define PINS_ISO7816_PHONE PIN_PHONE_IO, PIN_PHONE_CLK, PIN_ISO7816_RST_PHONE
|
||||
//, VCC_PHONE
|
||||
|
||||
|
||||
//** SPI interface **/
|
||||
/// SPI MISO pin definition (PA12).
|
||||
#define PIN_SPI_MISO {1 << 12, PIOA, PIOA, PIO_PERIPH_A, PIO_PULLUP}
|
||||
/// SPI MOSI pin definition (PA13).
|
||||
#define PIN_SPI_MOSI {1 << 13, PIOA, PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
/// SPI SPCK pin definition (PA14).
|
||||
#define PIN_SPI_SPCK {1 << 14, PIOA, PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
/// SPI pins definition. Contains MISO, MOSI & SPCK (PA12, PA13 & PA14).
|
||||
#define PINS_SPI PIN_SPI_MISO, PIN_SPI_MOSI, PIN_SPI_SPCK
|
||||
/// SPI chip select 0 pin definition (PA11).
|
||||
#define PIN_SPI_NPCS0 {1 << 11, PIOA, PIOA, PIO_PERIPH_A, PIO_DEFAULT}
|
||||
|
||||
//** USB **/
|
||||
// USB pull-up control pin definition (PA16).
|
||||
// Default: 1 (USB Pullup deactivated)
|
||||
#define PIN_USB_PULLUP {1 << 16, PIOA, ID_PIOA, PIO_OUTPUT_1, PIO_DEFAULT}
|
||||
|
||||
// Board has UDP controller
|
||||
#define BOARD_USB_UDP
|
||||
// D+ has external pull-up
|
||||
#define BOARD_USB_PULLUP_EXTERNAL
|
||||
|
||||
#define BOARD_USB_NUMENDPOINTS 8
|
||||
|
||||
// FIXME: in all other cases return 0?
|
||||
#define BOARD_USB_ENDPOINTS_MAXPACKETSIZE(i) (((i == 4) || (i == 5))? 512 : 64)
|
||||
#define BOARD_USB_ENDPOINTS_BANKS(i) (((i == 0) || (i == 3)) ? 1 : 2)
|
||||
|
||||
/// USB attributes configuration descriptor (bus or self powered, remote wakeup)
|
||||
//#define BOARD_USB_BMATTRIBUTES USBConfigurationDescriptor_SELFPOWERED_NORWAKEUP
|
||||
#define BOARD_USB_BMATTRIBUTES USBConfigurationDescriptor_BUSPOWERED_NORWAKEUP
|
||||
//#define BOARD_USB_BMATTRIBUTES USBConfigurationDescriptor_SELFPOWERED_RWAKEUP
|
||||
|
||||
#define ATMEL_VENDOR_ID 0x03EB
|
||||
#define SIMTRACE_PRODUCT_ID 0x6004
|
||||
//#define OPENPCD_VENDOR_ID 0x16c0
|
||||
//#define SIMTRACE_PRODUCT_ID 0x0762
|
||||
#define USB_VENDOR_ID OPENPCD_VENDOR_ID
|
||||
#define USB_PRODUCT_ID SIMTRACE_PRODUCT_ID
|
||||
|
||||
|
||||
#endif
|
||||
46
firmware/include_board/board_lowlevel.h
Normal file
46
firmware/include_board/board_lowlevel.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* Interface for the low-level initialization function.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BOARD_LOWLEVEL_H
|
||||
#define BOARD_LOWLEVEL_H
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
extern void LowLevelInit( void ) ;
|
||||
|
||||
#endif /* BOARD_LOWLEVEL_H */
|
||||
|
||||
88
firmware/include_board/iso7816_4.h
Normal file
88
firmware/include_board/iso7816_4.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
/** \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Definition of methods for ISO7816 driver.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# ISO7816_Init
|
||||
* -# ISO7816_IccPowerOff
|
||||
* -# ISO7816_XfrBlockTPDU_T0
|
||||
* -# ISO7816_Escape
|
||||
* -# ISO7816_RestartClock
|
||||
* -# ISO7816_StopClock
|
||||
* -# ISO7816_toAPDU
|
||||
* -# ISO7816_Datablock_ATR
|
||||
* -# ISO7816_SetDataRateandClockFrequency
|
||||
* -# ISO7816_StatusReset
|
||||
* -# ISO7816_cold_reset
|
||||
* -# ISO7816_warm_reset
|
||||
* -# ISO7816_Decode_ATR
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef ISO7816_4_H
|
||||
#define ISO7816_4_H
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Constants Definition
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
/** Size max of Answer To Reset */
|
||||
#define ATR_SIZE_MAX 55
|
||||
|
||||
/** NULL byte to restart byte procedure */
|
||||
#define ISO_NULL_VAL 0x60
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
extern void ISO7816_Init( const Pin *pPinIso7816RstMC );
|
||||
extern void ISO7816_IccPowerOff(void);
|
||||
extern uint32_t ISO7816_XfrBlockTPDU_T0(const uint8_t *pAPDU,
|
||||
uint8_t *pMessage,
|
||||
uint16_t wLength,
|
||||
uint16_t *retlen);
|
||||
extern void ISO7816_Escape( void );
|
||||
extern void ISO7816_RestartClock(void);
|
||||
extern void ISO7816_StopClock( void );
|
||||
extern void ISO7816_toAPDU( void );
|
||||
extern uint32_t ISO7816_Datablock_ATR( uint8_t* pAtr, uint8_t* pLength );
|
||||
extern void ISO7816_SetDataRateandClockFrequency( uint32_t dwClockFrequency, uint32_t dwDataRate );
|
||||
extern uint8_t ISO7816_StatusReset( void );
|
||||
extern void ISO7816_cold_reset( void );
|
||||
extern void ISO7816_warm_reset( void );
|
||||
extern void ISO7816_Decode_ATR( uint8_t* pAtr );
|
||||
|
||||
#endif /* ISO7816_4_H */
|
||||
|
||||
72
firmware/include_board/led.h
Normal file
72
firmware/include_board/led.h
Normal file
@@ -0,0 +1,72 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2008, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file
|
||||
*
|
||||
* \section Purpose
|
||||
*
|
||||
* Small set of functions for simple and portable LED usage.
|
||||
*
|
||||
* \section Usage
|
||||
*
|
||||
* -# Configure one or more LEDs using LED_Configure and
|
||||
* LED_ConfigureAll.
|
||||
* -# Set, clear and toggle LEDs using LED_Set, LED_Clear and
|
||||
* LED_Toggle.
|
||||
*
|
||||
* LEDs are numbered starting from 0; the number of LEDs depend on the
|
||||
* board being used. All the functions defined here will compile properly
|
||||
* regardless of whether the LED is defined or not; they will simply
|
||||
* return 0 when a LED which does not exist is given as an argument.
|
||||
* Also, these functions take into account how each LED is connected on to
|
||||
* board; thus, \ref LED_Set might change the level on the corresponding pin
|
||||
* to 0 or 1, but it will always light the LED on; same thing for the other
|
||||
* methods.
|
||||
*/
|
||||
|
||||
#ifndef _LED_
|
||||
#define _LED_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Global Functions
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
extern uint32_t LED_Configure( uint32_t dwLed ) ;
|
||||
|
||||
extern uint32_t LED_Set( uint32_t dwLed ) ;
|
||||
|
||||
extern uint32_t LED_Clear( uint32_t dwLed ) ;
|
||||
|
||||
extern uint32_t LED_Toggle( uint32_t dwLed ) ;
|
||||
|
||||
#endif /* #ifndef LED_H */
|
||||
|
||||
65
firmware/include_board/syscalls.h
Normal file
65
firmware/include_board/syscalls.h
Normal file
@@ -0,0 +1,65 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file syscalls.h
|
||||
*
|
||||
* Implementation of newlib syscall.
|
||||
*
|
||||
*/
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Headers
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
* Exported functions
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
||||
extern caddr_t _sbrk ( int incr ) ;
|
||||
|
||||
extern int link( char *old, char *new ) ;
|
||||
|
||||
extern int _close( int file ) ;
|
||||
|
||||
extern int _fstat( int file, struct stat *st ) ;
|
||||
|
||||
extern int _isatty( int file ) ;
|
||||
|
||||
extern int _lseek( int file, int ptr, int dir ) ;
|
||||
|
||||
extern int _read(int file, char *ptr, int len) ;
|
||||
|
||||
extern int _write( int file, char *ptr, int len ) ;
|
||||
48
firmware/include_board/uart_console.h
Normal file
48
firmware/include_board/uart_console.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* ----------------------------------------------------------------------------
|
||||
* ATMEL Microcontroller Software Support
|
||||
* ----------------------------------------------------------------------------
|
||||
* Copyright (c) 2009, Atmel Corporation
|
||||
*
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* - Redistributions of source code must retain the above copyright notice,
|
||||
* this list of conditions and the disclaimer below.
|
||||
*
|
||||
* Atmel's name may not be used to endorse or promote products derived from
|
||||
* this software without specific prior written permission.
|
||||
*
|
||||
* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ATMEL 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.
|
||||
* ----------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _UART_CONSOLE_
|
||||
#define _UART_CONSOLE_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
extern void UART_Configure( uint32_t dwBaudrate, uint32_t dwMasterClock ) ;
|
||||
extern void UART_PutChar( uint8_t uc ) ;
|
||||
extern uint32_t UART_GetChar( void ) ;
|
||||
extern uint32_t UART_IsRxReady( void ) ;
|
||||
|
||||
|
||||
extern void UART_DumpFrame( uint8_t* pucFrame, uint32_t dwSize ) ;
|
||||
extern void UART_DumpMemory( uint8_t* pucBuffer, uint32_t dwSize, uint32_t dwAddress ) ;
|
||||
extern uint32_t UART_GetInteger( uint32_t* pdwValue ) ;
|
||||
extern uint32_t UART_GetIntegerMinMax( uint32_t* pdwValue, uint32_t dwMin, uint32_t dwMax ) ;
|
||||
extern uint32_t UART_GetHexa32( uint32_t* pdwValue ) ;
|
||||
|
||||
#endif /* _UART_CONSOLE_ */
|
||||
Reference in New Issue
Block a user