move STRING & XSTRING & STATIC_ASSERT to compiler.h

disable test for a class of cdc host
temporarily disable test for test_osal_none.c
change include in some core files
remove osal.h from common.h
This commit is contained in:
hathach
2014-04-17 22:57:11 +07:00
parent 69c46b2f9a
commit 06bb9ad7a7
20 changed files with 89 additions and 78 deletions

View File

@@ -50,25 +50,13 @@ extern "C"
#endif
#include "tusb_option.h"
#include "primitive_types.h"
#include "compiler/compiler.h"
#include "hal/hal.h" // TODO find a way to break hal dependency
#define VOID_RETURN
//--------------------------------------------------------------------+
// Compile-time Assert
//--------------------------------------------------------------------+
#ifdef __ICCARM__
#define STATIC_ASSERT static_assert
#else
#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
#define _ASSERT_COUNTER __COUNTER__
#else
#define _ASSERT_COUNTER __LINE__
#endif
#define STATIC_ASSERT(const_expr, message) enum { XSTRING_CONCAT_(static_assert_, _ASSERT_COUNTER) = 1/(!!(const_expr)) }
#endif
//#if ( defined CFG_PRINTF_UART || defined CFG_PRINTF_USBCDC || defined CFG_PRINTF_DEBUG )
#if TUSB_CFG_DEBUG
#define _PRINTF(...) printf(__VA_ARGS__)

View File

@@ -47,14 +47,6 @@
extern "C" {
#endif
//--------------------------------------------------------------------+
// MACROS
//--------------------------------------------------------------------+
#define STRING_(x) #x // stringify without expand
#define XSTRING_(x) STRING_(x) // expand then stringify
#define STRING_CONCAT_(a, b) a##b // concat without expand
#define XSTRING_CONCAT_(a, b) STRING_CONCAT_(a, b) // expand then concat
//--------------------------------------------------------------------+
// INCLUDES
//--------------------------------------------------------------------+
@@ -79,16 +71,9 @@
#include "std_descriptors.h"
#include "std_request.h"
#include "osal/osal.h"
//--------------------------------------------------------------------+
// MACROS
//--------------------------------------------------------------------+
#define STRING_(x) #x ///< stringify without expand
#define XSTRING_(x) STRING_(x) ///< expand then stringify
#define STRING_CONCAT_(a, b) a##b ///< concat without expand
#define XSTRING_CONCAT_(a, b) STRING_CONCAT_(a, b) ///< expand then concat
#define MAX_OF(a, b) ( (a) > (b) ? (a) : (b) )
#define MIN_OF(a, b) ( (a) < (b) ? (a) : (b) )

View File

@@ -44,6 +44,26 @@
#ifndef _TUSB_COMPILER_H_
#define _TUSB_COMPILER_H_
#define STRING_(x) #x ///< stringify without expand
#define XSTRING_(x) STRING_(x) ///< expand then stringify
#define STRING_CONCAT_(a, b) a##b ///< concat without expand
#define XSTRING_CONCAT_(a, b) STRING_CONCAT_(a, b) ///< expand then concat
//--------------------------------------------------------------------+
// Compile-time Assert
//--------------------------------------------------------------------+
#ifdef __ICCARM__
#define STATIC_ASSERT static_assert
#else
#if defined __COUNTER__ && __COUNTER__ != __COUNTER__
#define _ASSERT_COUNTER __COUNTER__
#else
#define _ASSERT_COUNTER __LINE__
#endif
#define STATIC_ASSERT(const_expr, message) enum { XSTRING_CONCAT_(static_assert_, _ASSERT_COUNTER) = 1/(!!(const_expr)) }
#endif
#ifndef _TEST_
// TODO move some to tusb_option.h
#define STATIC_ static

View File

@@ -36,14 +36,9 @@
*/
/**************************************************************************/
/** \file
* \brief GCC Header
*/
/** \ingroup Group_Compiler
* \defgroup Group_GCC GNU GCC
* @{
*/
* @{ */
#ifndef _TUSB_COMPILER_GCC_H_
#define _TUSB_COMPILER_GCC_H_
@@ -63,10 +58,8 @@
/// If this attribute is used on a function declaration and a call to such a function is not eliminated through dead code elimination or other optimizations, a warning that includes message is diagnosed. This is useful for compile-time checking
#define ATTR_WARNING(Message) __attribute__ ((warning(Message)))
/**
* \defgroup Group_VariableAttr Variable Attributes
* @{
*/
/** \defgroup Group_VariableAttr Variable Attributes
* @{ */
/// This attribute specifies a minimum alignment for the variable or structure field, measured in bytes
#define ATTR_ALIGNED(Bytes) __attribute__ ((aligned(Bytes)))
@@ -79,10 +72,8 @@
#define ATTR_PACKED_STRUCT(x) x __attribute__ ((packed))
/** @} */
/**
* \defgroup Group_FuncAttr Function Attributes
* @{
*/
/** \defgroup Group_FuncAttr Function Attributes
* @{ */
#ifndef ATTR_ALWAYS_INLINE
/// Generally, functions are not inlined unless optimization is specified. For functions declared inline, this attribute inlines the function even if no optimization level is specified
@@ -125,10 +116,8 @@
/** @} */
/**
* \defgroup Group_BuiltinFunc Built-in Functions
* @{
*/
/** \defgroup Group_BuiltinFunc Built-in Functions
* @{ */
// TODO mcu specific
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__

View File

@@ -49,6 +49,10 @@
extern "C" {
#endif
#include "tusb_option.h"
#include "primitive_types.h"
#include "compiler/compiler.h"
//--------------------------------------------------------------------+
// STANDARD DESCRIPTORS
//--------------------------------------------------------------------+

View File

@@ -46,6 +46,10 @@
extern "C" {
#endif
#include "tusb_option.h"
#include "primitive_types.h"
#include "compiler/compiler.h"
typedef ATTR_PACKED_STRUCT(struct){
union {
ATTR_PACKED_STRUCT(struct) {

View File

@@ -50,6 +50,7 @@
// INCLUDE
//--------------------------------------------------------------------+
#include "common/common.h"
#include "osal/osal.h"
#include "dcd.h"
//--------------------------------------------------------------------+

View File

@@ -40,13 +40,13 @@
* @{
* \defgroup EHCI
* \brief EHCI driver. All documents sources mentioned here (eg section 3.5) is referring to EHCI Specs unless state otherwise
* @{
*/
* @{ */
#ifndef _TUSB_EHCI_H_
#define _TUSB_EHCI_H_
#include "common/common.h"
#include "../hcd.h"
/* Abbreviation
* HC: Host Controller

View File

@@ -50,10 +50,10 @@
// INCLUDE
//--------------------------------------------------------------------+
#include "common/common.h"
#include "osal/osal.h"
#ifdef _TEST_
#include "hcd.h"
#include "osal.h"
#endif
//--------------------------------------------------------------------+

View File

@@ -75,8 +75,8 @@
#define OSAL_TASK_LOOP_END }
//------------- Sub Task -------------//
#define OSAL_SUBTASK_BEGIN // TODO refractor move
#define OSAL_SUBTASK_END return TUSB_ERROR_NONE;
#define OSAL_SUBTASK_BEGIN
#define OSAL_SUBTASK_END return TUSB_ERROR_NONE;
#define SUBTASK_EXIT(error) return error;
#define OSAL_SUBTASK_INVOKED_AND_WAIT(subtask, status) status = subtask
@@ -111,10 +111,8 @@ typedef uint32_t osal_task_t;
tusb_error_t osal_task_create(osal_task_t *task);
#define OSAL_TASK_DEF(code, stack_depth, prio) osal_task_t variable
#define OSAL_TASK_REF(name) (&name)
#define OSAL_TASK_FUNCTION(task_name) void task_name
#define OSAL_TASK_FUNCTION(task_func, p_para) void task_func(void * p_para)
void osal_task_delay(uint32_t msec);

View File

@@ -133,8 +133,7 @@ static inline void osal_semaphore_reset(osal_semaphore_handle_t const sem_hdl)
#define OSAL_MUTEX_DEF OSAL_SEM_DEF
typedef xSemaphoreHandle osal_mutex_handle_t;
#define osal_mutex_create(x) \
xSemaphoreCreateMutex()
#define osal_mutex_create(x) xSemaphoreCreateMutex()
static inline tusb_error_t osal_mutex_release(osal_mutex_handle_t const mutex_hdl) ATTR_ALWAYS_INLINE;
static inline tusb_error_t osal_mutex_release(osal_mutex_handle_t const mutex_hdl)
@@ -172,8 +171,7 @@ typedef xQueueHandle osal_queue_handle_t;
#define OSAL_QUEUE_REF(name) (&name)
#define osal_queue_create(p_queue) \
xQueueCreate((p_queue)->depth, (p_queue)->item_size)
#define osal_queue_create(p_queue) xQueueCreate((p_queue)->depth, (p_queue)->item_size)
static inline void osal_queue_receive (osal_queue_handle_t const queue_hdl, void *p_data, uint32_t msec, tusb_error_t *p_error) ATTR_ALWAYS_INLINE;
static inline void osal_queue_receive (osal_queue_handle_t const queue_hdl, void *p_data, uint32_t msec, tusb_error_t *p_error)