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

📄 fmc.h

📁 <B>SMSC USB2.0 Flash硬盘驱动源码</B>
💻 H
📖 第 1 页 / 共 2 页
字号:
}

//+-----------------------------------------------------------------------------
// Name:
//   _fmc_set_options
//
// Declaration:
//   void _fmc_set_options(uint8 options);
//
// Purpose:
//   Set the options for an fmc transfer.
//
// Arguments:
//   options - a uint8 containing bitmask:
//     kbm_fmc_disable_auto_xfer       - don't turn on the autoxfer bit
//     kbm_fmc_end_burst_on_count_down - end burst when count hits zero, instead of on irq
//     kbm_fmc_xfer_512_byte_pkt       - Set this to receive a 512 byte pkt in 1.1 speed
//
// Return:
//   None.
//
// Notes:
//   None.
//
// Since:
//   fmc-1.0
//------------------------------------------------------------------------------
#define _fmc_set_options(__options)                                            \
{                                                                              \
  g_fmc_options = (uint8)(__options);                                          \
}

//+-----------------------------------------------------------------------------
// Name:
//   _fmc_set_callback
//
// Declaration:
//   void _fmc_set_callback(t_fmc_callback begin_xfer, t_fmc_callback end_xfer,
//                          t_fmc_callback begin_split, t_fmc_callback end_split,
//                          t_fmc_callback begin_burst, t_fmc_callback intra_burst,
//                          t_fmc_callback end_burst);
//
// Purpose:
//   Set the callback functions for an fmc transfer.
//
// Arguments:
//   begin_xfer  - a t_fmc_callback at the beginning of the transfer.
//   end_xfer    - a t_fmc_callback at the end of the transfer.
//   begin_split - a t_fmc_callback that issues a command to the drive.
//   end_split   - a t_fmc_callback that cleans up after a split, if necessary.
//   begin_burst - a t_fmc_callback that waits for the drive to be ready for a burst.
//   intra_burst - a t_fmc_callback as soon as the transfer has started.
//   end_burst   - a t_fmc_callback that cleans up after a burst, if necessary.
//
// Return:
//   None.
//
// Notes:
//   The callback functions must return a t_result.
//   Any return value other that k_success from a callback aborts the fmc transfer.
//
// Since:
//   fmc-1.0
//------------------------------------------------------------------------------
#define _fmc_set_callback(__begin_xfer, __end_xfer, __begin_split, __end_split, __begin_burst, __intra_burst, __end_burst) \
{                                                                              \
  g_fmc_begin_xfer_callback = (t_fmc_callback)(__begin_xfer);                  \
  g_fmc_end_xfer_callback = (t_fmc_callback)(__end_xfer);                      \
  g_fmc_begin_split_callback = (t_fmc_callback)(__begin_split);                \
  g_fmc_end_split_callback = (t_fmc_callback)(__end_split);                    \
  g_fmc_begin_burst_callback = (t_fmc_callback)(__begin_burst);                \
  g_fmc_intra_burst_callback = (t_fmc_callback)(__intra_burst);                \
  g_fmc_end_burst_callback = (t_fmc_callback)(__end_burst);                    \
}

//+-----------------------------------------------------------------------------
// Name:
//   _fmc_set_start_lb_32
//
// Declaration:
//   void _fmc_set_start_lb_32(uint32 val);
//
// Purpose:
//   Set the starting logical block for an fmc transfer
//   as a 32 bit number.
//
// Arguments:
//   val - a uint32 representing the starting logical block.
//
// Return:
//   None.
//
// Notes:
//   None.
//
// Since:
//   fmc-1.0
//------------------------------------------------------------------------------
#define _fmc_set_start_lb_32(__val)                                            \
{                                                                              \
  g_start_lb_this_xfer.u32 = (uint32)(__val);                                  \
}

//+-----------------------------------------------------------------------------
// Name:
//   _fmc_set_lb_count_32
//
// Declaration:
//   void _fmc_set_lb_count_32(uint32 val);
//
// Purpose:
//   Set the logical block count for an fmc transfer
//   as a 32 bit number.
//
// Arguments:
//   val - a uint32 representing the logical block count.
//
// Return:
//   None.
//
// Notes:
//   None.
//
// Since:
//   fmc-1.0
//------------------------------------------------------------------------------
#define _fmc_set_lb_count_32(__val)                                            \
{                                                                              \
  g_n_lb_this_split.u32 = g_n_lb_this_xfer.u32 = (uint32)(__val);              \
}

//+-----------------------------------------------------------------------------
// Name:
//   _fmc_get_start_lb_32
//
// Declaration:
//   uint32 _fmc_get_start_lb_32(void);
//
// Purpose:
//   Get the current starting logical block for the current fmc transfer
//   as a 32 bit number.
//
// Arguments:
//   None.
//
// Return:
//   A uint32.
//
// Notes:
//   None.
//
// Since:
//   fmc-1.0
//------------------------------------------------------------------------------
#define _fmc_get_start_lb_32() g_start_lb_this_xfer.u32

//+-----------------------------------------------------------------------------
// Name:
//   _fmc_get_lb_count_32
//
// Declaration:
//   uint32 _fmc_get_lb_count_32(void);
//
// Purpose:
//   Get the remaining logical block count for the current fmc transfer
//   as a 32 bit number.
//
// Arguments:
//   None.
//
// Return:
//   A uint32.
//
// Notes:
//   None.
//
// Since:
//   fmc-1.0
//------------------------------------------------------------------------------
#define _fmc_get_lb_count_32() g_n_lb_this_split.u32

//+-----------------------------------------------------------------------------
// Name:
//   _fmc_get_result
//
// Declaration:
//   t_result _fmc_get_result(void);
//
// Purpose:
//   Get result of the transfer.  Typically used by the end_xfer callback.
//
// Arguments:
//   None.
//
// Return:
//   A t_result.
//
// Notes:
//   None.
//
// Since:
//   fmc-1.0
//------------------------------------------------------------------------------
#define _fmc_get_result() g_fmc_rslt

//------------------------------------------------------------------------------
// prototypes
t_result fmc_wait_count_down_with_timeout(uint16) reentrant;
t_result fmc_wait_blk_irq_with_timeout(uint16 ticks) reentrant;
void fmc_dump_registers(void) reentrant;
void fmc_select_cfc(void) reentrant;
void fmc_select_smc(void) reentrant;
void fmc_select_msc(void) reentrant;
void fmc_select_sdc(void) reentrant;
void fmc_select_nand(void) reentrant;
t_result fmc_transfer(void) reentrant;

//------------------------------------------------------------------------------
// externs
extern xdata t_result g_fmc_rslt;
extern xdata uint16 g_fmc_timeout;
#define kbm_fmc_disable_auto_xfer       0x01
#define kbm_fmc_end_burst_on_count_down 0x02
#define kbm_fmc_xfer_512_byte_pkt       0x04

// TRENTON WAS HERE - used with the temporary MS_TEST code in fmc.c
//_fmc_set_options(0);
#define kbm_fmc_hack_me                 0x08

extern xdata uint8 g_fmc_options;
extern xdata t_udw32 g_start_lb_this_xfer;
extern xdata t_udw32 g_n_lb_this_xfer;
extern xdata t_udw32 g_n_lb_this_split;
extern xdata t_fmc_callback g_fmc_begin_xfer_callback;
extern xdata t_fmc_callback g_fmc_end_xfer_callback;
extern xdata t_fmc_callback g_fmc_begin_split_callback;
extern xdata t_fmc_callback g_fmc_end_split_callback;
extern xdata t_fmc_callback g_fmc_begin_burst_callback;
// extern xdata t_fmc_callback g_fmc_intra_burst_callback;
extern idata t_fmc_callback g_fmc_intra_burst_callback;
extern xdata t_fmc_callback g_fmc_end_burst_callback;

// prototype for a new default callback - to eliminate need to test for existence
t_result fmc_dflt_callback(void) reentrant;

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

⌨️ 快捷键说明

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