cleanup
This commit is contained in:
10
README
10
README
@@ -10,11 +10,13 @@ External source
|
||||
Taken from http://chibios.sourceforge.net/
|
||||
Note that CRLF is converted to LF in this repository.
|
||||
|
||||
* STM32_USB-FS-Device_Driver
|
||||
Taken from http://github.com/robots/STM32.git
|
||||
* PolarSSS 0.14.0
|
||||
Taken from http://polarssl.org/
|
||||
|
||||
* USBCDC
|
||||
Taken from http://github.com/robots/STM32.git
|
||||
* STM32F10x USB Full Speed Device Library (USB-FS-Device_Lib)
|
||||
I took Libraries/STM32_USB-FS-Device_Driver and a part of
|
||||
Project/Virtual_COM_Port in STM32_USB-FS-Device_Lib distribution.
|
||||
See http://www.st.com for detail.
|
||||
|
||||
|
||||
HOWTO RUN
|
||||
|
||||
12
src/Makefile
12
src/Makefile
@@ -1,3 +1,6 @@
|
||||
# Makefile for Gnuk
|
||||
|
||||
|
||||
##############################################################################
|
||||
# Build global options
|
||||
# NOTE: Can be overridden externally.
|
||||
@@ -62,7 +65,7 @@ include $(CHIBIOS)/os/hal/hal.mk
|
||||
include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F10x/port.mk
|
||||
include $(CHIBIOS)/os/kernel/kernel.mk
|
||||
include stmusb.mk
|
||||
include usbcdc.mk
|
||||
include vcomport.mk
|
||||
include rsa.mk
|
||||
include ../boards/OLIMEX_STM32_H103/board.mk
|
||||
|
||||
@@ -76,15 +79,16 @@ CSRC = $(PORTSRC) \
|
||||
$(CHIBIOS)/os/various/evtimer.c \
|
||||
$(CHIBIOS)/os/various/syscalls.c \
|
||||
$(STMUSBSRC) \
|
||||
$(USBCDCSRC) \
|
||||
$(VCOMSRC) \
|
||||
$(RSASRC) \
|
||||
main.c hw_config.c usb_lld.c usb_desc.c usb_prop.c usb-icc.c gpg.c ac.c gpg-do.c
|
||||
main.c hw_config.c usb_lld.c usb_desc.c usb_prop.c \
|
||||
usb-icc.c gpg.c ac.c openpgp-do.c flash.c
|
||||
|
||||
# List ASM source files here
|
||||
ASMSRC = $(PORTASM) \
|
||||
$(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F10x/vectors.s gpg-data.s
|
||||
|
||||
INCDIR = $(RSAINCDIR) $(STMUSBINCDIR) $(USBCDCDIR) \
|
||||
INCDIR = $(RSAINCDIR) $(STMUSBINCDIR) $(VCOMDIR) \
|
||||
$(PORTINC) $(KERNINC) $(TESTINC) \
|
||||
$(HALINC) $(PLATFORMINC) $(BOARDINC) \
|
||||
$(CHIBIOS)/os/various
|
||||
|
||||
458
src/chconf.h
458
src/chconf.h
@@ -1,494 +1,56 @@
|
||||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
ChibiOS/RT 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
---
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes ChibiOS/RT, without being obliged to provide
|
||||
the source code for any proprietary components. See the file exception.txt
|
||||
for full details of how and when the exception can be applied.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file templates/chconf.h
|
||||
* @brief Configuration file template.
|
||||
* @details A copy of this file must be placed in each project directory, it
|
||||
* contains the application specific kernel settings.
|
||||
*
|
||||
* @addtogroup config
|
||||
* @details Kernel related settings and hooks.
|
||||
* @{
|
||||
*/
|
||||
/* ChibiOS/RT configuration file */
|
||||
|
||||
#ifndef _CHCONF_H_
|
||||
#define _CHCONF_H_
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Kernel parameters. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief System tick frequency.
|
||||
* @details Frequency of the system timer that drives the system ticks. This
|
||||
* setting also defines the system tick time unit.
|
||||
*/
|
||||
#if !defined(CH_FREQUENCY) || defined(__DOXYGEN__)
|
||||
#define CH_FREQUENCY 1000
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Round robin interval.
|
||||
* @details This constant is the number of system ticks allowed for the
|
||||
* threads before preemption occurs. Setting this value to zero
|
||||
* disables the preemption for threads with equal priority and the
|
||||
* round robin becomes cooperative. Note that higher priority
|
||||
* threads can still preempt, the kernel is always preemptive.
|
||||
*
|
||||
* @note Disabling the round robin preemption makes the kernel more compact
|
||||
* and generally faster.
|
||||
*/
|
||||
#if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__)
|
||||
#define CH_TIME_QUANTUM 20
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Nested locks.
|
||||
* @details If enabled then the use of nested @p chSysLock() / @p chSysUnlock()
|
||||
* operations is allowed.<br>
|
||||
* For performance and code size reasons the recommended setting
|
||||
* is to leave this option disabled.<br>
|
||||
* You may use this option if you need to merge ChibiOS/RT with
|
||||
* external libraries that require nested lock/unlock operations.
|
||||
*
|
||||
* @note T he default is @p FALSE.
|
||||
*/
|
||||
#if !defined(CH_USE_NESTED_LOCKS) || defined(__DOXYGEN__)
|
||||
#define CH_USE_NESTED_LOCKS FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Managed RAM size.
|
||||
* @details Size of the RAM area to be managed by the OS. If set to zero
|
||||
* then the whole available RAM is used. The core memory is made
|
||||
* available to the heap allocator and/or can be used directly through
|
||||
* the simplified core memory allocator.
|
||||
*
|
||||
* @note In order to let the OS manage the whole RAM the linker script must
|
||||
* provide the @p __heap_base__ and @p __heap_end__ symbols.
|
||||
* @note Requires @p CH_USE_COREMEM.
|
||||
*/
|
||||
#if !defined(CH_MEMCORE_SIZE) || defined(__DOXYGEN__)
|
||||
#define CH_MEMCORE_SIZE 0
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Performance options. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief OS optimization.
|
||||
* @details If enabled then time efficient rather than space efficient code
|
||||
* is used when two possible implementations exist.
|
||||
*
|
||||
* @note This is not related to the compiler optimization options.
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__)
|
||||
#define CH_MEMCORE_SIZE 0 /* Whole RAM */
|
||||
#define CH_OPTIMIZE_SPEED TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Exotic optimization.
|
||||
* @details If defined then a CPU register is used as storage for the global
|
||||
* @p currp variable. Caching this variable in a register greatly
|
||||
* improves both space and time OS efficiency. A side effect is that
|
||||
* one less register has to be saved during the context switch
|
||||
* resulting in lower RAM usage and faster context switch.
|
||||
*
|
||||
* @note This option is only usable with the GCC compiler and is only useful
|
||||
* on processors with many registers like ARM cores.
|
||||
* @note If this option is enabled then ALL the libraries linked to the
|
||||
* ChibiOS/RT code <b>must</b> be recompiled with the GCC option @p
|
||||
* -ffixed-@<reg@>.
|
||||
* @note This option must be enabled in the Makefile, it is listed here for
|
||||
* documentation only.
|
||||
*/
|
||||
#if defined(__DOXYGEN__)
|
||||
#define CH_CURRP_REGISTER_CACHE "reg"
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Subsystem options. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Threads registry APIs.
|
||||
* @details If enabled then the registry APIs are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(CH_USE_REGISTRY) || defined(__DOXYGEN__)
|
||||
#define CH_USE_REGISTRY TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Threads synchronization APIs.
|
||||
* @details If enabled then the @p chThdWait() function is included in
|
||||
* the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__)
|
||||
#define CH_USE_WAITEXIT TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Semaphores APIs.
|
||||
* @details If enabled then the Semaphores APIs are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__)
|
||||
#define CH_USE_SEMAPHORES TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Semaphores queuing mode.
|
||||
* @details If enabled then the threads are enqueued on semaphores by
|
||||
* priority rather than in FIFO order.
|
||||
*
|
||||
* @note The default is @p FALSE. Enable this if you have special requirements.
|
||||
* @note Requires @p CH_USE_SEMAPHORES.
|
||||
*/
|
||||
#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__)
|
||||
#define CH_USE_SEMAPHORES FALSE
|
||||
#define CH_USE_SEMAPHORES_PRIORITY FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Atomic semaphore API.
|
||||
* @details If enabled then the semaphores the @p chSemSignalWait() API
|
||||
* is included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_USE_SEMAPHORES.
|
||||
*/
|
||||
#if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__)
|
||||
#define CH_USE_SEMSW TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Mutexes APIs.
|
||||
* @details If enabled then the mutexes APIs are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__)
|
||||
#define CH_USE_SEMSW FALSE
|
||||
#define CH_USE_MUTEXES TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Conditional Variables APIs.
|
||||
* @details If enabled then the conditional variables APIs are included
|
||||
* in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_USE_MUTEXES.
|
||||
*/
|
||||
#if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__)
|
||||
#define CH_USE_CONDVARS TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Conditional Variables APIs with timeout.
|
||||
* @details If enabled then the conditional variables APIs with timeout
|
||||
* specification are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_USE_CONDVARS.
|
||||
*/
|
||||
#if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__)
|
||||
#define CH_USE_CONDVARS_TIMEOUT TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Events Flags APIs.
|
||||
* @details If enabled then the event flags APIs are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__)
|
||||
#define CH_USE_EVENTS TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Events Flags APIs with timeout.
|
||||
* @details If enabled then the events APIs with timeout specification
|
||||
* are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_USE_EVENTS.
|
||||
*/
|
||||
#if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__)
|
||||
#define CH_USE_EVENTS_TIMEOUT TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Synchronous Messages APIs.
|
||||
* @details If enabled then the synchronous messages APIs are included
|
||||
* in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__)
|
||||
#define CH_USE_EVENTS TRUE /* We use this! */
|
||||
#define CH_USE_EVENTS_TIMEOUT TRUE /* We use this! */
|
||||
#define CH_USE_MESSAGES TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Synchronous Messages queuing mode.
|
||||
* @details If enabled then messages are served by priority rather than in
|
||||
* FIFO order.
|
||||
*
|
||||
* @note The default is @p FALSE. Enable this if you have special requirements.
|
||||
* @note Requires @p CH_USE_MESSAGES.
|
||||
*/
|
||||
#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__)
|
||||
#define CH_USE_MESSAGES_PRIORITY FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Mailboxes APIs.
|
||||
* @details If enabled then the asynchronous messages (mailboxes) APIs are
|
||||
* included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_USE_SEMAPHORES.
|
||||
*/
|
||||
#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
|
||||
#define CH_USE_MAILBOXES TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief I/O Queues APIs.
|
||||
* @details If enabled then the I/O queues APIs are included in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_USE_SEMAPHORES.
|
||||
*/
|
||||
#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__)
|
||||
#define CH_USE_QUEUES TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Core Memory Manager APIs.
|
||||
* @details If enabled then the core memory manager APIs are included
|
||||
* in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(CH_USE_MEMCORE) || defined(__DOXYGEN__)
|
||||
#define CH_USE_MAILBOXES FALSE
|
||||
#define CH_USE_QUEUES FALSE
|
||||
#define CH_USE_MEMCORE TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Heap Allocator APIs.
|
||||
* @details If enabled then the memory heap allocator APIs are included
|
||||
* in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_USE_COREMEM and either @p CH_USE_MUTEXES or
|
||||
* @p CH_USE_SEMAPHORES.
|
||||
* @note Mutexes are recommended.
|
||||
*/
|
||||
#if !defined(CH_USE_HEAP) || defined(__DOXYGEN__)
|
||||
#define CH_USE_HEAP TRUE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief C-runtime allocator.
|
||||
* @details If enabled the the heap allocator APIs just wrap the C-runtime
|
||||
* @p malloc() and @p free() functions.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
* @note Requires @p CH_USE_HEAP.
|
||||
* @note The C-runtime may or may not require @p CH_USE_COREMEM, see the
|
||||
* appropriate documentation.
|
||||
*/
|
||||
#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
|
||||
#define CH_USE_MALLOC_HEAP FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Memory Pools Allocator APIs.
|
||||
* @details If enabled then the memory pools allocator APIs are included
|
||||
* in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
*/
|
||||
#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__)
|
||||
#define CH_USE_MEMPOOLS TRUE
|
||||
#endif
|
||||
#define CH_USE_DYNAMIC FALSE
|
||||
|
||||
/**
|
||||
* @brief Dynamic Threads APIs.
|
||||
* @details If enabled then the dynamic threads creation APIs are included
|
||||
* in the kernel.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note Requires @p CH_USE_WAITEXIT.
|
||||
* @note Requires @p CH_USE_HEAP and/or @p CH_USE_MEMPOOLS.
|
||||
*/
|
||||
#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__)
|
||||
#define CH_USE_DYNAMIC TRUE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Debug options. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Debug option, parameters checks.
|
||||
* @details If enabled then the checks on the API functions input
|
||||
* parameters are activated.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
*/
|
||||
#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
|
||||
/* Debug options */
|
||||
#define CH_DBG_ENABLE_CHECKS FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Debug option, consistency checks.
|
||||
* @details If enabled then all the assertions in the kernel code are
|
||||
* activated. This includes consistency checks inside the kernel,
|
||||
* runtime anomalies and port-defined checks.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
*/
|
||||
#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
|
||||
#define CH_DBG_ENABLE_ASSERTS FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Debug option, trace buffer.
|
||||
* @details If enabled then the context switch circular trace buffer is
|
||||
* activated.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
*/
|
||||
#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
|
||||
#define CH_DBG_ENABLE_TRACE FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Debug option, stack checks.
|
||||
* @details If enabled then a runtime stack check is performed.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
* @note The stack check is performed in a architecture/port dependent way.
|
||||
* It may not be implemented or some ports.
|
||||
* @note The default failure mode is to halt the system with the global
|
||||
* @p panic_msg variable set to @p NULL.
|
||||
*/
|
||||
#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
|
||||
#define CH_DBG_ENABLE_STACK_CHECK FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Debug option, stacks initialization.
|
||||
* @details If enabled then the threads working area is filled with a byte
|
||||
* value when a thread is created. This can be useful for the
|
||||
* runtime measurement of the used stack.
|
||||
*
|
||||
* @note The default is @p FALSE.
|
||||
*/
|
||||
#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
|
||||
#define CH_DBG_FILL_THREADS FALSE
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Debug option, threads profiling.
|
||||
* @details If enabled then a field is added to the @p Thread structure that
|
||||
* counts the system ticks occurred while executing the thread.
|
||||
*
|
||||
* @note The default is @p TRUE.
|
||||
* @note This debug option is defaulted to TRUE because it is required by
|
||||
* some test cases into the test suite.
|
||||
*/
|
||||
#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
|
||||
#define CH_DBG_THREADS_PROFILING TRUE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Kernel hooks. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Threads descriptor structure hook.
|
||||
* @details User fields added to the end of the @p Thread structure.
|
||||
*/
|
||||
#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
|
||||
#define THREAD_EXT_FIELDS \
|
||||
struct { \
|
||||
/* Add threads custom fields here.*/ \
|
||||
};
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Threads initialization hook.
|
||||
* @details User initialization code added to the @p chThdInit() API.
|
||||
*
|
||||
* @note It is invoked from within @p chThdInit() and implicitily from all
|
||||
* the threads creation APIs.
|
||||
*/
|
||||
#if !defined(THREAD_EXT_INIT) || defined(__DOXYGEN__)
|
||||
#define THREAD_EXT_INIT(tp) { \
|
||||
/* Add threads initialization code here.*/ \
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Threads finalization hook.
|
||||
* @details User finalization code added to the @p chThdExit() API.
|
||||
*
|
||||
* @note It is inserted into lock zone.
|
||||
* @note It is also invoked when the threads simply return in order to
|
||||
* terminate.
|
||||
*/
|
||||
#if !defined(THREAD_EXT_EXIT) || defined(__DOXYGEN__)
|
||||
#define THREAD_EXT_EXIT(tp) { \
|
||||
/* Add threads finalization code here.*/ \
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Idle Loop hook.
|
||||
* @details This hook is continuously invoked by the idle thread loop.
|
||||
*/
|
||||
#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__)
|
||||
#define IDLE_LOOP_HOOK() { \
|
||||
/* Idle loop code here.*/ \
|
||||
}
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* Port-specific settings (override port settings defaulted in chcore.h). */
|
||||
/*===========================================================================*/
|
||||
|
||||
#endif /* _CHCONF_H_ */
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -44,8 +44,9 @@ extern int verify_pso_admin (uint8_t *pw, int pw_len);
|
||||
|
||||
extern void write_res_apdu (const uint8_t *p, int len,
|
||||
uint8_t sw1, uint8_t sw2);
|
||||
#define DEBUG 1
|
||||
|
||||
extern int gpg_do_table_init (void);
|
||||
extern void gpg_do_get_data (uint16_t tag);
|
||||
extern void gpg_do_put_data (uint16_t tag, uint8_t *data, int len);
|
||||
|
||||
extern uint8_t * flash_do_write (uint16_t tag, uint8_t *data, int len);
|
||||
|
||||
146
src/halconf.h
146
src/halconf.h
@@ -1,159 +1,17 @@
|
||||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
ChibiOS/RT 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
---
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes ChibiOS/RT, without being obliged to provide
|
||||
the source code for any proprietary components. See the file exception.txt
|
||||
for full details of how and when the exception can be applied.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file templates/halconf.h
|
||||
* @brief HAL configuration header.
|
||||
* @addtogroup HAL_CONF
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*
|
||||
* HAL configuration file, this file allows to enable or disable the various
|
||||
* device drivers from your application. You may also use this file in order
|
||||
* to override the device drivers default settings.
|
||||
*/
|
||||
/* HAL configuration file for ChibiOS/RT */
|
||||
|
||||
#ifndef _HALCONF_H_
|
||||
#define _HALCONF_H_
|
||||
|
||||
/*
|
||||
* Uncomment the following line in order to include a mcu-related
|
||||
* settings file. This file can be used to include platform specific
|
||||
* header files or to override the low level drivers settings.
|
||||
*/
|
||||
#include "mcuconf.h"
|
||||
|
||||
/*===========================================================================*/
|
||||
/* PAL driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables the PAL subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_PAL) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_PAL TRUE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* ADC driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables the ADC subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_ADC) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_ADC FALSE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* CAN driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables the CAN subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_CAN) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_CAN FALSE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* MAC driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables the MAC subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_MAC) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_MAC FALSE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* PWM driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables the PWM subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_PWM) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_PWM FALSE
|
||||
#endif
|
||||
|
||||
/*===========================================================================*/
|
||||
/* SERIAL driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables the SERIAL subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_SERIAL) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_SERIAL TRUE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default SERIAL settings overrides (uncomment to override).
|
||||
*/
|
||||
/*#define SERIAL_DEFAULT_BITRATE 38400*/
|
||||
/*#define SERIAL_BUFFERS_SIZE 64*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* SPI driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables the SPI subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_SPI) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_SERIAL FALSE
|
||||
#define CH_HAL_USE_SPI FALSE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default SPI settings overrides (uncomment to override).
|
||||
*/
|
||||
/*#define SPI_USE_MUTUAL_EXCLUSION TRUE*/
|
||||
|
||||
/*===========================================================================*/
|
||||
/* MMC_SPI driver related settings. */
|
||||
/*===========================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Enables the MMC_SPI subsystem.
|
||||
*/
|
||||
#if !defined(CH_HAL_USE_MMC_SPI) || defined(__DOXYGEN__)
|
||||
#define CH_HAL_USE_MMC_SPI FALSE
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Default MMC_SPI settings overrides (uncomment to override).
|
||||
*/
|
||||
/*#define MMC_SECTOR_SIZE 512*/
|
||||
/*#define MMC_NICE_WAITING TRUE*/
|
||||
/*#define MMC_POLLING_INTERVAL 10*/
|
||||
/*#define MMC_POLLING_DELAY 10*/
|
||||
|
||||
#endif /* _HALCONF_H_ */
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
/* Hardware specific USB functions */
|
||||
/*
|
||||
* For detail, please see the documentation of
|
||||
* STM32F10x USB Full Speed Device Library (USB-FS-Device_Lib)
|
||||
* by STMicroelectronics' MCD Application Team
|
||||
*/
|
||||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
|
||||
|
||||
48
src/main.c
48
src/main.c
@@ -1,28 +1,25 @@
|
||||
/*
|
||||
ChibiOS/RT - Copyright (C) 2006,2007,2008,2009,2010 Giovanni Di Sirio.
|
||||
|
||||
This file is part of ChibiOS/RT.
|
||||
|
||||
ChibiOS/RT 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.
|
||||
|
||||
ChibiOS/RT 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
---
|
||||
|
||||
A special exception to the GPL can be applied should you wish to distribute
|
||||
a combined work that includes ChibiOS/RT, without being obliged to provide
|
||||
the source code for any proprietary components. See the file exception.txt
|
||||
for full details of how and when the exception can be applied.
|
||||
*/
|
||||
* main.c - main routine of Gnuk
|
||||
*
|
||||
* Copyright (C) 2010 Free Software Initiative of Japan
|
||||
* Author: NIIBE Yutaka <gniibe@fsij.org>
|
||||
*
|
||||
* This file is a part of Gnuk, a GnuPG USB Token implementation.
|
||||
*
|
||||
* Gnuk 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.
|
||||
*
|
||||
* Gnuk 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
@@ -174,7 +171,8 @@ extern msg_t GPGthread (void *arg);
|
||||
* Entry point, note, the main() function is already a thread in the system
|
||||
* on entry.
|
||||
*/
|
||||
int main(int argc, char **argv)
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
int count = 0;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* gpg-do.c -- OpenPGP card Data Objects (DO) handling
|
||||
* openpgp-do.c -- OpenPGP card Data Objects (DO) handling
|
||||
*
|
||||
* Copyright (C) 2010 Free Software Initiative of Japan
|
||||
* Author: NIIBE Yutaka <gniibe@fsij.org>
|
||||
@@ -21,6 +21,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "ch.h"
|
||||
#include "gnuk.h"
|
||||
|
||||
@@ -619,37 +621,6 @@ gpg_do_get_data (uint16_t tag)
|
||||
write_res_apdu (NULL, 0, 0x6a, 0x88);
|
||||
}
|
||||
|
||||
uint8_t *
|
||||
flash_do_write (uint16_t tag, uint8_t *data, int len)
|
||||
{
|
||||
static uint8_t do_pool[1024];
|
||||
static uint8_t *last_p = do_pool;
|
||||
uint8_t *p = last_p;
|
||||
|
||||
if (last_p - do_pool + len + 2 + 3 > 1024)
|
||||
return NULL;
|
||||
|
||||
*last_p++ = (tag >> 8);
|
||||
*last_p++ = (tag & 0xff);
|
||||
if (len < 128)
|
||||
*last_p++ = len;
|
||||
else if (len < 256)
|
||||
{
|
||||
*last_p++ = 0x81;
|
||||
*last_p++ = len;
|
||||
}
|
||||
else
|
||||
{
|
||||
*last_p++ = 0x82;
|
||||
*last_p++ = (len >> 8);
|
||||
*last_p++ = (len & 0xff);
|
||||
}
|
||||
memcpy (last_p, data, len);
|
||||
last_p += len;
|
||||
|
||||
return p + 2;
|
||||
}
|
||||
|
||||
void
|
||||
gpg_do_put_data (uint16_t tag, uint8_t *data, int len)
|
||||
{
|
||||
@@ -74,7 +74,7 @@ rsa_sign (unsigned char *raw_message)
|
||||
len = (cmd_APDU[5]<<8) | cmd_APDU[6]; /* cmd_APDU_size - 6 */
|
||||
|
||||
mpi_init( &P1, &Q1, &H, NULL );
|
||||
rsa_init( &ctx, RSA_PKCS_V15, 0, NULL, NULL );
|
||||
rsa_init( &ctx, RSA_PKCS_V15, 0 );
|
||||
|
||||
#if 0
|
||||
ctx.len = 2048 / 8;
|
||||
@@ -1,4 +1,4 @@
|
||||
RSADIR = ../../polarssl-0.13.1
|
||||
RSADIR = ../polarssl-0.14.0
|
||||
RSASRCDIR = $(RSADIR)/library
|
||||
RSAINCDIR = $(RSADIR)/include
|
||||
RSASRC = $(RSASRCDIR)/bignum.c $(RSASRCDIR)/rsa.c rsa_sign.c
|
||||
RSASRC = $(RSASRCDIR)/bignum.c $(RSASRCDIR)/rsa.c rsa-sign.c
|
||||
|
||||
@@ -1,36 +1,26 @@
|
||||
/* USB configuration file for USB-FS-Device_Lib */
|
||||
/*
|
||||
(C) COPYRIGHT 2010 STMicroelectronics
|
||||
usb_conf.h
|
||||
MCD Application Team
|
||||
V3.1.1
|
||||
04/07/2010
|
||||
Virtual COM Port Demo configuration header
|
||||
*/
|
||||
* For detail, please see the documentation of
|
||||
* STM32F10x USB Full Speed Device Library (USB-FS-Device_Lib)
|
||||
* by STMicroelectronics
|
||||
*/
|
||||
|
||||
#ifndef __USB_CONF_H
|
||||
#define __USB_CONF_H
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/* EP_NUM */
|
||||
/* defines how many endpoints are used by the device */
|
||||
/*-------------------------------------------------------------*/
|
||||
|
||||
#ifdef ENABLE_VIRTUAL_COM_PORT
|
||||
#define EP_NUM (6)
|
||||
#else
|
||||
#define EP_NUM (3)
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/* -------------- Buffer Description Table -----------------*/
|
||||
/*-------------------------------------------------------------*/
|
||||
/* buffer table base address */
|
||||
/* buffer table base address */
|
||||
#define BTABLE_ADDRESS (0x00)
|
||||
|
||||
/* EP0 */
|
||||
/* rx/tx buffer base address */
|
||||
#define ENDP0_RXADDR (0x40)
|
||||
#define ENDP0_TXADDR (0x80)
|
||||
|
||||
/* EP1 */
|
||||
/* tx buffer base address */
|
||||
#define ENDP1_TXADDR (0xC0)
|
||||
/* EP2 */
|
||||
#define ENDP2_TXADDR (0x100)
|
||||
@@ -43,39 +33,6 @@ Virtual COM Port Demo configuration header
|
||||
/* EP5 */
|
||||
#define ENDP5_RXADDR (0x1C0)
|
||||
|
||||
/*-------------------------------------------------------------*/
|
||||
/* ------------------- ISTR events -------------------------*/
|
||||
/*-------------------------------------------------------------*/
|
||||
/* IMR_MSK */
|
||||
/* mask defining which events has to be handled */
|
||||
/* by the device application software */
|
||||
#define IMR_MSK (CNTR_CTRM | CNTR_SOFM | CNTR_RESETM )
|
||||
|
||||
/*#define CTR_CALLBACK*/
|
||||
/*#define DOVR_CALLBACK*/
|
||||
/*#define ERR_CALLBACK*/
|
||||
/*#define WKUP_CALLBACK*/
|
||||
/*#define SUSP_CALLBACK*/
|
||||
/*#define RESET_CALLBACK*/
|
||||
/*#define SOF_CALLBACK*/
|
||||
/*#define ESOF_CALLBACK*/
|
||||
|
||||
#if 0
|
||||
#define EP1_IN_Callback NOP_Process
|
||||
#define EP2_IN_Callback NOP_Process
|
||||
#define EP3_IN_Callback NOP_Process
|
||||
#define EP4_IN_Callback NOP_Process
|
||||
#define EP5_IN_Callback NOP_Process
|
||||
#define EP6_IN_Callback NOP_Process
|
||||
#define EP7_IN_Callback NOP_Process
|
||||
|
||||
#define EP1_OUT_Callback NOP_Process
|
||||
#define EP2_OUT_Callback NOP_Process
|
||||
#define EP3_OUT_Callback NOP_Process
|
||||
#define EP4_OUT_Callback NOP_Process
|
||||
#define EP5_OUT_Callback NOP_Process
|
||||
#define EP6_OUT_Callback NOP_Process
|
||||
#define EP7_OUT_Callback NOP_Process
|
||||
#endif
|
||||
|
||||
#endif /* __USB_CONF_H */
|
||||
|
||||
@@ -1,8 +1,2 @@
|
||||
/**
|
||||
* @brief USB interrupt priority level setting.
|
||||
*/
|
||||
#if !defined(STM32_USB_IRQ_PRIORITY) || defined(__DOXYGEN__)
|
||||
#define STM32_USB_IRQ_PRIORITY 11
|
||||
#endif
|
||||
|
||||
void usb_lld_init (void);
|
||||
|
||||
157
src/usb_prop.c
157
src/usb_prop.c
@@ -1,10 +1,27 @@
|
||||
/*
|
||||
usb_prop.c
|
||||
MCD Application Team
|
||||
V3.1.1
|
||||
04/07/2010
|
||||
All processing related to Virtual Com Port Demo
|
||||
*/
|
||||
* usb_prop.c - glue/interface code between Gnuk and USB-FS-Device_Lib
|
||||
*
|
||||
* Copyright (C) 2010 Free Software Initiative of Japan
|
||||
* Author: NIIBE Yutaka <gniibe@fsij.org>
|
||||
*
|
||||
* This file is a part of Gnuk, a GnuPG USB Token implementation.
|
||||
*
|
||||
* Gnuk 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.
|
||||
*
|
||||
* Gnuk 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "usb_lib.h"
|
||||
#include "usb_conf.h"
|
||||
@@ -13,56 +30,16 @@ All processing related to Virtual Com Port Demo
|
||||
#include "usb_pwr.h"
|
||||
#include "hw_config.h"
|
||||
|
||||
#if 0
|
||||
static uint8_t Request = 0;
|
||||
#ifdef ENABLE_VIRTUAL_COM_PORT
|
||||
#include "usb-cdc-vport.c"
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t bitrate;
|
||||
uint8_t format;
|
||||
uint8_t paritytype;
|
||||
uint8_t datatype;
|
||||
} LINE_CODING;
|
||||
|
||||
static LINE_CODING linecoding = {
|
||||
115200, /* baud rate*/
|
||||
0x00, /* stop bits-1*/
|
||||
0x00, /* parity - none*/
|
||||
0x08 /* no. of bits 8*/
|
||||
};
|
||||
|
||||
static uint8_t *Virtual_Com_Port_GetLineCoding(uint16_t Length)
|
||||
{
|
||||
if (Length == 0)
|
||||
{
|
||||
pInformation->Ctrl_Info.Usb_wLength = sizeof(linecoding);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (uint8_t *)&linecoding;
|
||||
}
|
||||
|
||||
static uint8_t *Virtual_Com_Port_SetLineCoding(uint16_t Length)
|
||||
{
|
||||
if (Length == 0)
|
||||
{
|
||||
pInformation->Ctrl_Info.Usb_wLength = sizeof(linecoding);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (uint8_t *)&linecoding;
|
||||
}
|
||||
|
||||
|
||||
#define GNUK_MAX_PACKET_SIZE 64
|
||||
|
||||
static void
|
||||
gnuk_device_init (void)
|
||||
{
|
||||
|
||||
/* Update the serial number string descriptor with the data from the unique
|
||||
ID*/
|
||||
/*
|
||||
* Update the serial number string descriptor (if needed)
|
||||
*/
|
||||
Get_SerialNum ();
|
||||
|
||||
pInformation->Current_Configuration = 0;
|
||||
@@ -79,13 +56,13 @@ gnuk_device_init (void)
|
||||
static void
|
||||
gnuk_device_reset (void)
|
||||
{
|
||||
/* Set Virtual_Com_Port DEVICE as not configured */
|
||||
/* Set DEVICE as not configured */
|
||||
pInformation->Current_Configuration = 0;
|
||||
|
||||
/* Current Feature initialization */
|
||||
pInformation->Current_Feature = Config_Descriptor.Descriptor[7];
|
||||
|
||||
/* Set Virtual_Com_Port DEVICE with the default Interface*/
|
||||
/* Set DEVICE with the default Interface*/
|
||||
pInformation->Current_Interface = 0;
|
||||
|
||||
SetBTABLE (BTABLE_ADDRESS);
|
||||
@@ -99,6 +76,7 @@ gnuk_device_reset (void)
|
||||
SetEPRxCount (ENDP0, GNUK_MAX_PACKET_SIZE);
|
||||
SetEPRxValid (ENDP0);
|
||||
|
||||
#ifdef ENABLE_VIRTUAL_COM_PORT
|
||||
/* Initialize Endpoint 1 */
|
||||
SetEPType (ENDP1, EP_BULK);
|
||||
SetEPTxAddr (ENDP1, ENDP1_TXADDR);
|
||||
@@ -117,6 +95,7 @@ gnuk_device_reset (void)
|
||||
SetEPRxCount (ENDP3, VIRTUAL_COM_PORT_DATA_SIZE);
|
||||
SetEPRxStatus (ENDP3, EP_RX_VALID);
|
||||
SetEPTxStatus (ENDP3, EP_TX_DIS);
|
||||
#endif
|
||||
|
||||
/* Initialize Endpoint 4 */
|
||||
SetEPType (ENDP4, EP_BULK);
|
||||
@@ -127,7 +106,7 @@ gnuk_device_reset (void)
|
||||
/* Initialize Endpoint 5 */
|
||||
SetEPType (ENDP5, EP_BULK);
|
||||
SetEPRxAddr (ENDP5, ENDP5_RXADDR);
|
||||
SetEPRxCount (ENDP5, VIRTUAL_COM_PORT_DATA_SIZE); /* XXX */
|
||||
SetEPRxCount (ENDP5, GNUK_MAX_PACKET_SIZE);
|
||||
SetEPRxStatus (ENDP5, EP_RX_VALID);
|
||||
SetEPTxStatus (ENDP5, EP_TX_DIS);
|
||||
|
||||
@@ -157,10 +136,6 @@ gnuk_device_SetDeviceAddress (void)
|
||||
static void
|
||||
gnuk_device_Status_In (void)
|
||||
{
|
||||
#if 0
|
||||
if (Request == SET_LINE_CODING)
|
||||
Request = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* OUT to port 0 */
|
||||
@@ -169,65 +144,6 @@ gnuk_device_Status_Out (void)
|
||||
{
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : Virtual_Com_Port_Data_Setup
|
||||
* Description : handle the data class specific requests
|
||||
* Input : Request Nb.
|
||||
* Output : None.
|
||||
* Return : USB_UNSUPPORT or USB_SUCCESS.
|
||||
*******************************************************************************/
|
||||
static RESULT
|
||||
Virtual_Com_Port_Data_Setup (uint8_t RequestNo)
|
||||
{
|
||||
uint8_t *(*CopyRoutine)(uint16_t);
|
||||
|
||||
CopyRoutine = NULL;
|
||||
|
||||
if (RequestNo == GET_LINE_CODING)
|
||||
{
|
||||
if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
|
||||
CopyRoutine = Virtual_Com_Port_GetLineCoding;
|
||||
}
|
||||
else if (RequestNo == SET_LINE_CODING)
|
||||
{
|
||||
if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
|
||||
CopyRoutine = Virtual_Com_Port_SetLineCoding;
|
||||
#if 0
|
||||
Request = SET_LINE_CODING;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (CopyRoutine == NULL)
|
||||
return USB_UNSUPPORT;
|
||||
|
||||
pInformation->Ctrl_Info.CopyData = CopyRoutine;
|
||||
pInformation->Ctrl_Info.Usb_wOffset = 0;
|
||||
(*CopyRoutine) (0);
|
||||
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
* Function Name : Virtual_Com_Port_NoData_Setup.
|
||||
* Description : handle the no data class specific requests.
|
||||
* Input : Request Nb.
|
||||
* Output : None.
|
||||
* Return : USB_UNSUPPORT or USB_SUCCESS.
|
||||
*******************************************************************************/
|
||||
static RESULT
|
||||
Virtual_Com_Port_NoData_Setup (uint8_t RequestNo)
|
||||
{
|
||||
if (Type_Recipient == (CLASS_REQUEST | INTERFACE_RECIPIENT))
|
||||
{
|
||||
if (RequestNo == SET_COMM_FEATURE)
|
||||
return USB_SUCCESS;
|
||||
else if (RequestNo == SET_CONTROL_LINE_STATE)
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
|
||||
return USB_UNSUPPORT;
|
||||
}
|
||||
|
||||
static uint8_t *
|
||||
gnuk_device_GetDeviceDescriptor (uint16_t Length)
|
||||
{
|
||||
@@ -261,7 +177,7 @@ gnuk_device_Get_Interface_Setting (uint8_t Interface, uint8_t AlternateSetting)
|
||||
|
||||
return USB_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Interface to USB core
|
||||
*/
|
||||
@@ -271,8 +187,13 @@ DEVICE_PROP Device_Property = {
|
||||
gnuk_device_reset,
|
||||
gnuk_device_Status_In,
|
||||
gnuk_device_Status_Out,
|
||||
#ifdef ENABLE_VIRTUAL_COM_PORT
|
||||
Virtual_Com_Port_Data_Setup,
|
||||
Virtual_Com_Port_NoData_Setup,
|
||||
#else
|
||||
NULL,
|
||||
NULL,
|
||||
#endif
|
||||
gnuk_device_Get_Interface_Setting,
|
||||
gnuk_device_GetDeviceDescriptor,
|
||||
gnuk_device_GetConfigDescriptor,
|
||||
|
||||
@@ -1,25 +1,6 @@
|
||||
/*
|
||||
(C) COPYRIGHT 2010 STMicroelectronics
|
||||
usb_prop.h
|
||||
MCD Application Team
|
||||
V3.1.1
|
||||
04/07/2010
|
||||
All processing related to Virtual COM Port Demo (Endpoint 0)
|
||||
*/
|
||||
|
||||
#ifndef __usb_prop_H
|
||||
#define __usb_prop_H
|
||||
|
||||
#define SEND_ENCAPSULATED_COMMAND 0x00
|
||||
#define GET_ENCAPSULATED_RESPONSE 0x01
|
||||
#define SET_COMM_FEATURE 0x02
|
||||
#define GET_COMM_FEATURE 0x03
|
||||
#define CLEAR_COMM_FEATURE 0x04
|
||||
#define SET_LINE_CODING 0x20
|
||||
#define GET_LINE_CODING 0x21
|
||||
#define SET_CONTROL_LINE_STATE 0x22
|
||||
#define SEND_BREAK 0x23
|
||||
|
||||
extern ONE_DESCRIPTOR Device_Descriptor;
|
||||
extern ONE_DESCRIPTOR Config_Descriptor;
|
||||
extern ONE_DESCRIPTOR String_Descriptor[4];
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
USBCDCDIR = ../USBCDC
|
||||
USBCDCSRC= $(USBCDCDIR)/usb_endp.c $(USBCDCDIR)/usb_istr.c \
|
||||
$(USBCDCDIR)/usb_pwr.c
|
||||
2
src/vcomport.mk
Normal file
2
src/vcomport.mk
Normal file
@@ -0,0 +1,2 @@
|
||||
VCOMDIR = ../Virtual_COM_Port
|
||||
VCOMSRC= $(VCOMDIR)/usb_endp.c $(VCOMDIR)/usb_istr.c $(VCOMDIR)/usb_pwr.c
|
||||
Reference in New Issue
Block a user