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

📄 control.h

📁 U盘控制器USB97C223的固件代码,对2kPAGE NAND FLASH 有很好的支持.
💻 H
📖 第 1 页 / 共 2 页
字号:
    uint8 typ:2;
    uint8 dir:1;
  } bmRqstType;
  uint8 bRqst;
  uint8 wValueLo;
  uint8 wValueHi;
  uint8 wIndexLo;
  uint8 wIndexHi;
  uint8 wLengthLo;
  uint8 wLengthHi;
} t_usb_rqst, *t_usb_rqst_ref;
//------------------------------------------------------------------------------
// control pipe extension
typedef t_result (code *t_cpex)(t_message_ref) reentrant;
//------------------------------------------------------------------------------
typedef struct s_endpoint
{
  uint8 tid;    // index of thread that receives synchs about this ndp
  uint8 rxpnr;  // pnr of most recently received packet
  t_cpex cpex;  // control pipe extension                                !!! cannot have any of these on the 200?
} t_endpoint;
//------------------------------------------------------------------------------
typedef struct s_interface
{
  t_cpex cpex;  // control pipe extension
} t_interface;
//------------------------------------------------------------------------------
// global variables
//------------------------------------------------------------------------------
extern uint8 g_ix_ctl_thread;
extern t_endpoint seg_knl_manager g_endpoint[k_dev_max_endpoint];
extern t_interface seg_knl_manager g_interface[k_dev_max_interface];
extern seg_knl_manager uint8 *g_source_addr;
#define g_sink_addr g_source_addr
extern seg_knl_manager uint16 g_data_len;
extern seg_knl_manager uint16 g_wtmp;
extern seg_knl_manager uint8 g_tmp;
extern bit g_usbrst;
extern bit g_port_suspend;
extern bit g_hub_suspend;
extern bit g_port_resume;
extern bit g_hub_resume;
extern bit g_vbus_removed;
extern bit g_app_suspended;
#ifdef k_20x_family
extern bit g_new_config;
#endif
// there are just never enough syncs, are there?
#define kbm_sync_usbrst kbm_sync_rsrvd0
#ifdef k_20x_family
#define kbm_sync_setup kbm_sync_rsrvd1
#endif
//------------------------------------------------------------------------------
// prototypes
//------------------------------------------------------------------------------
void ctl_bind_interface(uint8 ifc, t_cpex cpex) reentrant;
void ctl_bind_endpoint(uint8 ndp, uint8 tid, t_cpex cpex) reentrant;
uint8 ctl_mngr(t_message_ref msgp) reentrant;
void ctl_thread_wait_create(void) reentrant;
void ctl_poll(void) reentrant;
uint8 ctl_cpex(t_message_ref msgp) reentrant;
//+-----------------------------------------------------------------------------
// Name:
//   _payload_source
//
// Declaration:
//   void _payload_source(uint8 *addr, uint8 len);
//
// Purpose:
//   The protocol engine delivers a message to a cpex.  That message requires
//   a data payload to be sent over the USB to the host via the control pipe.
//   The cpex receiving the message must either prepare to source the data into
//   a packet buffer (that will be provided in a subsequent k_msg_source_payload)
//   and return k_success, or it must return k_error to cause the protol engine
//   to stall the control transaction.  In the case where the cpex is prepared to
//   source a packet, this macro sets up the global variables used for moving
//   the data.  (They are globals not because the protocol engine uses them,
//   (it doesn't) but because every cpex must access them.
//   Each cpex could have its own private copy, but they would need to be
//   module globals, or statics, since they must persist accross calls to the
//   cpex.  Ram is scarce, and only one control transaction can run at a time
//   (in the current system where ndp0 is the only control pipe) so globals
//   are used to hold the data transfer information.)
//
// Arguments:
//   addr - the address in memory of the payload to source
//   len  - the number of bytes remaining to be sourced
//
// Return:
//   None.
//
// Notes:
//   The source buffer may reside in any 8051 address space.
//   The source address cannot be a non static automatic variable (on the
//   parameter stack) because it won't persist until the k_msg_source_payload
//   arrives.  Therefore this macro manipulates a pair of global variables,
//   g_source_addr and g_data_len.  These are global so that they can be used
//   by all control pipe extensions without having to allocate additional
//   memory unique variables for each cpex.
//
// Since:
//   Minimos-2.0
//------------------------------------------------------------------------------
#define _payload_source(_mcr_addr, _mcr_len)                                   \
{                                                                              \
  g_source_addr = (uint8 *)(_mcr_addr);                                        \
  g_data_len = (_mcr_len);                                                     \
}
//+-----------------------------------------------------------------------------
// Name:
//   _payload_sink
//
// Declaration:
//   void _payload_sink(uint8 *addr, uint8 len);
//
// Purpose:
//   The protocol engine delivers a message to a cpex.  That message requires
//   a data payload to be received over the USB from the host via the control pipe.
//   The cpex receiving the message must either prepare to sinkthe data from
//   a packet buffer (that will be provided in a subsequent k_msg_sink_payload)
//   and return k_success, or it must return k_error to cause the protol engine
//   to stall the control transaction.  In the case where the cpex is prepared to
//   sink a packet, this macro sets up the global variables used for moving
//   the data.  (They are globals not because the protocol engine uses them,
//   (it doesn't) but because every cpex must access them.
//   Yes, each cpex could have its own private copy, but they would need to be
//   module globals, or statics, since they must persist accross calls to the
//   cpex.  Ram is scarce, and only one control transaction can run at a time
//   (in the current system where ndp0 is the only control pipe) so globals
//   are used to hold the data transfer information.)
//
// Arguments:
//   addr - the address in memory where the payload is to be sunk
//   len  - the number of bytes remaining to be sunk
//
// Return:
//   None.
//
// Notes:
//   The target buffer may reside in any 8051 address space (code space can't be
//   written normally.  Something like DFU is needsd to rewrite code space).
//   The sink address cannot be a non static automatic variable (on the
//   parameter stack) because it won't persist until the k_msg_sink_payload
//   arrives.  Therefore this macro manipulates a pair of global variables,
//   g_source_addr and g_data_len.  These are global so that they can be used
//   by all control pipe extensions without having to allocate additional
//   memory unique variables for each cpex.
//
// Since:
//   Minimos-2.0
//------------------------------------------------------------------------------
#define _payload_sink(_mcr_addr, _mcr_len)                                     \
{                                                                              \
  g_sink_addr = (uint8 *)(_mcr_addr);                                          \
  g_data_len = (_mcr_len);                                                     \
}

//---eof------------------------------------------------------------------------

⌨️ 快捷键说明

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