⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 endpoint.h

📁 U盘控制器USB97C223的固件代码,对2kPAGE NAND FLASH 有很好的支持.
💻 H
📖 第 1 页 / 共 2 页
字号:
}

//------------------------------------------------------------------------------
// Name:
//   _endpoint_rd_rx_toggle_100
//
// Declaration:
//   void _endpoint_rd_rx_toggle_100(uint8 ndp);
//
// Purpose:
//   10x:
//     Reads the rx toggle bit of the specified endpoint.
//
// Arguments:
//   10x:
//     ndp - a number 1..15 indicating the target endpoint.
//     (Note: current implementation is limited to 8 endpoints...)
//
// Return:
//   0 or 1, whatever is in the rx toggle bit.
//   (Always retuens 0 for the 20x)
//
// Notes:
//   This is an internal API used only by the USB engine.
//   Applications should not use this API.
//
// Since:
//   MinimOS-2.1
//------------------------------------------------------------------------------
#define _endpoint_rd_rx_toggle_100(__ndp) ((g_ndp_rx_toggle & (1 << (__ndp))) ? 1 : 0)

//------------------------------------------------------------------------------
// Name:
//   _endpoint_rd_rx_pnr_10x
//
// Declaration:
//   uint8 _endpoint_rd_rx_pnr_10x(uint8 ndp);
//
// Purpose:
//   10x:
//     Returns the packet number of the packet most recently received by the
//     specified endpoint.
//
// Arguments:
//   10x:
//     ndp - a number 1..15 indicating the target endpoint.
//
// Return:
//   10x:
//     ndp - a number 0..31 indicating the packet.
//
// 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_rd_rx_pnr_10x(__ndp) _gpfifo_rd(__ndp)

//------------------------------------------------------------------------------
// Name:
//   _endpoint_flip_rx_toggle_100
//
// Declaration:
//   void _endpoint_flip_rx_toggle_100(uint8 ndp);
//
// Purpose:
//   10x:
//     Flips the toggle from 0->1 or 1->0.
//
// Arguments:
//   10x:
//     ndp - a number 1..15 indicating the target endpoint.
//     (Note: current implementation is limited to 8 endpoints...)
//
// Return:
//   None.
//
// Notes:
//   This is an internal API used only by the USB engine.
//   Applications should not use this API.
//
// Since:
//   MinimOS-2.1
//------------------------------------------------------------------------------
#define _endpoint_flip_rx_toggle_100(__ndp) { g_ndp_rx_toggle ^= (1 << (__ndp)); }

//------------------------------------------------------------------------------
// CONSIDER - split this into a new module.
//+-----------------------------------------------------------------------------
// Name:
//   _buffer_rx_enable
//
// Declaration:
//   void _buffer_rx_enable(uint8 pnr);
//
// Purpose:
//   20x:
//     Frees a packet buffer so the sie can receive into it.
//     It does this by aiming the ramwr_tog at the specified buffer.
//
// Arguments:
//   20x:
//     pnr - a number 4..5 indicating the target endpoint.
//
// Return:
//   None.
//
// Notes:
//   20x only.
//   Current implementation is limited to bulk pipe 2's buffers, 4 & 5.
//   This is the macro version of buffer_rx_enable().  Use for slightly
//   better performance.
//
// Since:
//   MinimOS-2.0
//------------------------------------------------------------------------------
#define _buffer_rx_enable(__pnr)                                              \
{                                                                             \
  mcu_begin_critical_section();                                               \
  trace1(0, dbg, 0, "_buffer_rx_enable(%d)", (__pnr));                        \
  if (4 == (__pnr))                                                           \
  {                                                                           \
    trace0(0, ndp, 0, "frobbing ramwrtog_a");                                 \
    _mcu_register_wr(x_ep2_ctl, (_mcu_register_rd(x_ep2_ctl) & ~kbm_ep2_ctl_ramwr_tog) |kbm_ep2_ctl_wrtog_valid); \
    _mcu_register_clr_bits(x_imr0, kbm_isr0_ramwr_a);                         \
  }                                                                           \
  if (5 == (__pnr))                                                           \
  {                                                                           \
    trace0(0, ndp, 0, "frobbing ramwrtog_b");                                 \
    _mcu_register_wr(x_ep2_ctl, (_mcu_register_rd(x_ep2_ctl) |kbm_ep2_ctl_ramwr_tog) |kbm_ep2_ctl_wrtog_valid); \
    _mcu_register_clr_bits(x_imr0, kbm_isr0_ramwr_b);                         \
  }                                                                           \
  mcu_end_critical_section();                                                 \
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
#define _endpoint_unmask_outnak(k_rx_pipe);                                    \
{                                                                              \
  _mcu_register_wr(x_isr_nak, 1 << (2 * k_rx_pipe));                           \
  _mcu_register_clrbit(x_imr_nak, 2 * k_rx_pipe);                              \
}



//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
#define _endpoint_tx_enable(k_tx_pipe);                                        \
{                                                                              \
  _mcu_register_set_bits(x_ep2_ctl, kbm_ep2_ctl_dir);                          \
}



//------------------------------------------------------------------------------
//DS: In the macro below we should also write a 1 to clear the ramrd_ a and b bits.
//These will not be set to their POR values by writing to the toggle bits.
//------------------------------------------------------------------------------
#define _endpoint_rx_enable(k_rx_pipe);                                        \
{                                                                              \
  _mcu_register_clr_bits(x_ep2_ctl, kbm_ep2_ctl_dir);                          \
  _mcu_register_set_bits(x_isr0, (kbm_isr0_ramwr_a |kbm_isr0_ramwr_b |kbm_isr0_ramrd_a |kbm_isr0_ramrd_b));\
  _mcu_register_clr_bits(x_imr0, kbm_isr0_ramwr_a |kbm_isr0_ramwr_b);          \
  g_endpoint[2].rxpnr = 0;                                                     \
}


//------------------------------------------------------------------------------
// prototypes
uint8 endpoint_rd_thread(uint8 ndp) reentrant;
t_bool endpoint_is_rx_stalled(uint8 ndp) reentrant;
t_bool endpoint_is_tx_stalled(uint8 ndp) reentrant;
void endpoint_clr_tx_toggle(uint8 ndp) reentrant;
void endpoint_rx_enable(uint8 ndp) reentrant;
void endpoint_tx_enable(uint8 ndp) reentrant;
void endpoint_rx_stall(uint8 ndp) reentrant;
void endpoint_tx_stall(uint8 ndp) reentrant;
void endpoint_unmask_innak(uint8 ndp) reentrant;
void endpoint_unmask_outnak(uint8 ndp) reentrant;
uint8 endpoint_rd_rx_pnr(uint8 ndp) reentrant;
t_bool packet_is_available(uint8 pnr) reentrant;

#ifndef k_20x_family
t_bool endpoint_is_rx_enabled(uint8 ndp) reentrant;
t_bool endpoint_is_rx_busy(uint8 ndp) reentrant;
t_bool endpoint_is_tx_enabled(uint8 ndp) reentrant;
t_bool endpoint_is_tx_busy(uint8 ndp) reentrant;
void endpoint_set_rx_toggle(uint8 ndp) reentrant;
void endpoint_clr_rx_toggle(uint8 ndp) reentrant;
uint8 endpoint_rd_rx_toggle(uint8 ndp) reentrant;
void endpoint_flip_rx_toggle(uint8 ndp) reentrant;
void endpoint_set_tx_toggle(uint8 ndp) reentrant;
void endpoint_rx_disable(uint8 ndp) reentrant;
void endpoint_tx_disable(uint8 ndp) reentrant;
void endpoint_rx_busy(uint8 ndp) reentrant;
void endpoint_tx_busy(uint8 ndp) reentrant;
t_bool endpoint_is_rx_pnr_available(uint8 ndp) reentrant;
void endpoint_mask_innak(uint8 ndp) reentrant;
void endpoint_mask_outnak(uint8 ndp) reentrant;
#endif
//---eof------------------------------------------------------------------------

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -