2013-10-24 10:32:54 +02:00
|
|
|
/**************************************************************************/
|
|
|
|
/*!
|
|
|
|
@file osal.h
|
|
|
|
@author hathach (tinyusb.org)
|
|
|
|
|
|
|
|
@section LICENSE
|
|
|
|
|
|
|
|
Software License Agreement (BSD License)
|
|
|
|
|
|
|
|
Copyright (c) 2013, hathach (tinyusb.org)
|
|
|
|
All rights reserved.
|
|
|
|
|
|
|
|
Redistribution and use in source and binary forms, with or without
|
|
|
|
modification, are permitted provided that the following conditions are met:
|
|
|
|
1. Redistributions of source code must retain the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer.
|
|
|
|
2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
notice, this list of conditions and the following disclaimer in the
|
|
|
|
documentation and/or other materials provided with the distribution.
|
|
|
|
3. Neither the name of the copyright holders nor the
|
|
|
|
names of its contributors may be used to endorse or promote products
|
|
|
|
derived from this software without specific prior written permission.
|
|
|
|
|
|
|
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''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 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.
|
|
|
|
|
|
|
|
This file is part of the tinyusb stack.
|
|
|
|
*/
|
|
|
|
/**************************************************************************/
|
|
|
|
|
|
|
|
#ifndef _TUSB_OSAL_H_
|
|
|
|
#define _TUSB_OSAL_H_
|
|
|
|
|
2014-03-25 07:00:37 +01:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2014-03-25 07:11:22 +01:00
|
|
|
/** \addtogroup group_osal
|
2014-03-25 07:00:37 +01:00
|
|
|
* @{ */
|
|
|
|
|
|
|
|
/** \defgroup group_supported_os Supported RTOS
|
|
|
|
* \brief \ref TUSB_CFG_OS must be defined to one of these
|
2013-10-24 10:32:54 +02:00
|
|
|
* @{ */
|
|
|
|
#define TUSB_OS_NONE 1 ///< No RTOS is used
|
|
|
|
#define TUSB_OS_FREERTOS 2 ///< FreeRTOS is used
|
|
|
|
/** @} */
|
|
|
|
|
2013-10-25 08:45:57 +02:00
|
|
|
#include "tusb_option.h"
|
2018-03-12 16:45:35 +01:00
|
|
|
#include "common/tusb_common.h"
|
2013-10-25 08:45:57 +02:00
|
|
|
|
2018-02-28 10:45:54 +01:00
|
|
|
|
2013-10-24 10:32:54 +02:00
|
|
|
#if TUSB_CFG_OS == TUSB_OS_NONE
|
|
|
|
#include "osal_none.h"
|
2014-03-16 16:20:33 +01:00
|
|
|
|
2013-10-24 10:32:54 +02:00
|
|
|
#else
|
2014-03-19 10:50:49 +01:00
|
|
|
#if TUSB_CFG_OS == TUSB_OS_FREERTOS
|
|
|
|
#include "osal_freeRTOS.h"
|
|
|
|
#else
|
|
|
|
#error TUSB_CFG_OS is not defined or OS is not supported yet
|
|
|
|
#endif
|
|
|
|
|
2018-03-01 06:14:44 +01:00
|
|
|
#define OSAL_TASK_BEGIN while(1) {
|
|
|
|
#define OSAL_TASK_END }
|
2014-02-28 09:50:04 +01:00
|
|
|
|
|
|
|
//------------- Sub Task -------------//
|
2014-04-17 17:57:11 +02:00
|
|
|
#define OSAL_SUBTASK_BEGIN
|
2018-03-22 08:15:16 +01:00
|
|
|
#define OSAL_SUBTASK_END return TUSB_ERROR_NONE;
|
2014-02-28 09:50:04 +01:00
|
|
|
|
2018-03-22 08:15:16 +01:00
|
|
|
#define SUBTASK_RETURN(_error) return _error;
|
|
|
|
#define SUBTASK_INVOKE(_subtask, _status) (_status) = _subtask
|
2014-02-28 09:50:04 +01:00
|
|
|
|
|
|
|
//------------- Sub Task Assert -------------//
|
2018-03-05 07:31:17 +01:00
|
|
|
#define SUBTASK_ASSERT_STATUS(sts) VERIFY_STATUS(sts)
|
|
|
|
#define SUBTASK_ASSERT(condition) VERIFY(condition, TUSB_ERROR_OSAL_TASK_FAILED)
|
2014-02-28 09:50:04 +01:00
|
|
|
|
2018-03-21 14:42:23 +01:00
|
|
|
#define SUBTASK_ASSERT_STATUS_HDLR(sts, func_call) VERIFY_STATUS_HDLR(sts, func_call)
|
|
|
|
#define SUBTASK_ASSERT_HDLR(condition, func_call) VERIFY_HDLR(condition, func_call)
|
2013-10-24 10:32:54 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-10-25 08:45:57 +02:00
|
|
|
/** @} */
|
|
|
|
|
|
|
|
#endif /* _TUSB_OSAL_H_ */
|