📄 endpoint.h
字号:
/*============================================================================
____________________________________________________________________________
______________________________________________
SSSS M M CCCC Standard Microsystems Corporation
S MM MM SSSS C Austin Design Center
SSS M M M S C 11000 N. Mopac Expressway
S M M SSS C Stonelake Bldg. 6, Suite 500
SSSS M M S CCCC Austin, Texas 78759
SSSS ______________________________________________
____________________________________________________________________________
Copyright(C) 1999, Standard Microsystems Corporation
All Rights Reserved.
This program code listing is proprietary to SMSC and may not be copied,
distributed, or used without a license to do so. Such license may have
Limited or Restricted Rights. Please refer to the license for further
clarification.
____________________________________________________________________________
Notice: The program contained in this listing is a proprietary trade
secret of SMSC, Hauppauge, New York, and is copyrighted
under the United States Copyright Act of 1976 as an unpublished work,
pursuant to Section 104 and Section 408 of Title XVII of the United
States code. Unauthorized copying, adaption, distribution, use, or
display is prohibited by this law.
____________________________________________________________________________
Use, duplication, or disclosure by the Government is subject to
restrictions as set forth in subparagraph(c)(1)(ii) of the Rights
in Technical Data and Computer Software clause at DFARS 52.227-7013.
Contractor/Manufacturer is Standard Microsystems Corporation,
80 Arkay Drive, Hauppauge, New York, 1178-8847.
____________________________________________________________________________
____________________________________________________________________________
<module name> - <module description>
____________________________________________________________________________
comments tbd
____________________________________________________________________________
Revision History
Date Who Comment
________ ___ _____________________________________________________________
07/16/99 tbh -initial version
01/02/01 tbh -back port for the '100
03/15/01 tbh -merged 10x and 20x versions for improved maintainability
-converted api macros into functions to facilitate
implementation, and facilitate debugging with an ice
07/27/01 tbh -tweak port for 20x family
01/28/03 ds Removed function prototypes that are not relevant for 242 and 211 to reclaim code space.
These functions are protected by the #if !defined(k_mcu_97242) && !defined(k_mcu_97211)
01/28/03 ds Correction in previous check in- left out 2 fn prototypes.
02/28/03 ds Further expanded the code reduction to the whole 20x family.
06/11/03 ds Moved some endpoint specific macros, from the app to here.
============================================================================*/
#ifdef k_10x_family
// globals from endpoint.c
extern uint8 g_ndp_rx_toggle;
#endif
//!!!this is just hacked enough to support 2 rx endpoints for u2dp
// each endpoint has a gpfifo associated with it for an rxque.
// these globals track the count.
extern uint8 g_ndp0npkt;
extern uint8 g_ndp2npkt;
//------------------------------------------------------------------------------
// the macro versions of the functions are faster, but trickier to use properly.
// they exist only to improve the performance of the kernel.
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// Name:
// _endpoint_rd_thread
//
// Declaration:
// uint8 _endpoint_rd_thread(uint8 ndp);
//
// Purpose:
// Returns the id of the thread that owns the specified endpoint. This macro
// is used by the kernel to associate endpoints with threads.
//
// Arguments:
// 10x:
// ndp - a number 1..15 indicating the target endpoint.
// 20x:
// ndp - a number 0..2 indicating the target endpoint.
//
// Return:
// The id of the thread owning the specified endpoint.
//
// Notes:
// It is not recommended for use by applications. The kernel uses it.
//
// This is the macro version of endpoint_rd_thread().
// It is faster than the function. Used where performance is critical.
//
// Since:
// MinimOS-1.0
//------------------------------------------------------------------------------
#define _endpoint_rd_thread(__ndp) (g_endpoint[(__ndp)].tid)
//------------------------------------------------------------------------------
// Name:
// endpoint_is_rx_stalled_10x
//
// Declaration:
// t_bool endpoint_is_rx_stalled_10x(uint8 ndp);
//
// Purpose:
// Checks to see if the specified endpoint is receive stalled.
//
// Arguments:
// 10x:
// ndp - a number 1..15 indicating the target endpoint.
//
// Return:
// k_false - not stalled.
// k_true - stalled.
//
// Notes:
// This macro only works on for the 10x family of MCUs. It is used in the
// kernel's isrs to a slight speed improvement over the corresponding
// function. This was necessary because the 100 has to flow control its bulk
// pipes in software. It is not recommended to use this macro for anything else.
//
// Since:
// MinimOS-2.1
//------------------------------------------------------------------------------
#define _endpoint_is_rx_stalled_10x(__ndp) \
((_mcu_register_rd(XBYTE[x_ep_ctrl + (__ndp)]) & kbm_epctrl_rx_cont_msk) == kbm_epctrl_rx_stall)
//------------------------------------------------------------------------------
// Name:
// _endpoint_rx_busy_100
//
// Declaration:
// void _endpoint_rx_busy_100(uint8 ndp);
//
// Purpose:
// 10x:
// Configures the specified endpoint for receive busy operation.
// The endpoint will NAK in response to OUT tokens.
//
// Arguments:
// 10x:
// ndp - a number 1..15 indicating the target endpoint.
//
// Return:
// None.
//
// Notes:
// This macro only works on for the 100 MCU. It is used in the
// kernel's isrs to a slight speed improvement over the corresponding
// function. This was necessary because the 100 has to flow control its bulk
// pipes in software. It is not recommended to use this macro for anything else.
//
// Since:
// MinimOS-2.1
//------------------------------------------------------------------------------
#define _endpoint_rx_busy_100(__ndp) \
{ \
uint8 tmp; \
tmp = _mcu_register_rd(XBYTE[x_ep_ctrl + (__ndp)]); \
tmp &= ~kbm_epctrl_rx_cont_msk; \
tmp |= kbm_epctrl_rx_busy; \
_mcu_register_wr(XBYTE[x_ep_ctrl + (__ndp)], tmp); \
}
//------------------------------------------------------------------------------
// Name:
// _endpoint_rx_enable_100
//
// Declaration:
// void _endpoint_rx_enable_100(uint8 ndp);
//
// Purpose:
// 10x:
// Configures the specified endpoint for receive enabled operation.
// The endpoint will ACK in response to OUT tokens.
//
// Arguments:
// 10x:
// ndp - a number 1..15 indicating the target endpoint.
//
// Return:
// None.
//
// Notes:
// This macro only works on for the 100 MCU. It is used in the
// kernel's isrs to a slight speed improvement over the corresponding
// function. This was necessary because the 100 has to flow control its bulk
// pipes in software. It is not recommended to use this macro for anything else.
//
// Since:
// MinimOS-2.1
//------------------------------------------------------------------------------
#define _endpoint_rx_enable_100(__ndp) \
{ \
uint8 tmp; \
tmp = _mcu_register_rd(XBYTE[x_ep_ctrl + (__ndp)]); \
tmp &= ~kbm_epctrl_rx_cont_msk; \
tmp |= kbm_epctrl_rx_enable; \
_mcu_register_wr(XBYTE[x_ep_ctrl + (__ndp)], tmp); \
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -