📄 fmcdev.c
字号:
k_usb_dscr_typ_interface, // descriptor type: interface
0, // interface number
0, // alternate interface
2, // number of endpoints
0x08, // usb interface class: mass storage
0x02, // usb interface subclass: SFF
0x50, // interface protocol: BOT (bulk only transport)
0x00, // interface string index
// endpoint descriptor: bulk out
k_usb_ndpdscrsz, // length of descriptor in bytes
0x05, // descriptor type: endpoint
0x02, // endpoint 2, out
0x02, // bulk
k_fs_maxpktsz, // max packet size lo
0x00, // max packet size hi
0x01, // polling interval
// endpoint descriptor: bulk in
k_usb_ndpdscrsz, // length of descriptor in bytes
0x05, // descriptor type: endpoint
0x82, // endpoint 2, in
0x02, // bulk
k_fs_maxpktsz, // max packet size lo
0x00, // max packet size hi
0x00 // polling interval
//The DFU interface
k_usb_ifcdscrsz, // length of descriptor in bytes
k_usb_dscr_typ_interface, // descriptor type: interface
1, // interface number
0, // alternate interface
0, // number of endpoints
0xFE, // usb interface class: mass storage
0x01, // usb interface subclass: SFF
0x00, // interface protocol: BOT (bulk only transport)
0x00 // interface string index
};
#else
uint8 code g_fs_cfg_dscr[] =
{
k_usb_cfgdscrsz, // length of descriptor in bytes
k_usb_dscr_typ_config, // descriptor type: configuration
k_usb_cfgdscrsz +
k_usb_ifcdscrsz +
k_usb_ndpdscrsz +
k_usb_ndpdscrsz, // total length lo
0, // total length hi
1, // number of interfaces 2 to accomodate the DFU
0x01, // configuration value
0x00, // index of string descriptor
0xC0, // attributes: bus powered, no remote wakeup
0xFA, // _max power: 500ma
// interface descriptor: BOT mass storage
k_usb_ifcdscrsz, // length of descriptor in bytes
k_usb_dscr_typ_interface, // descriptor type: interface
0, // interface number
0, // alternate interface
2, // number of endpoints
0x08, // usb interface class: mass storage
0x02, // usb interface subclass: SFF
0x50, // interface protocol: BOT (bulk only transport)
0x00, // interface string index
// endpoint descriptor: bulk out
k_usb_ndpdscrsz, // length of descriptor in bytes
0x05, // descriptor type: endpoint
0x02, // endpoint 2, out
0x02, // bulk
k_fs_maxpktsz, // max packet size lo
0x00, // max packet size hi
0x01, // polling interval
// endpoint descriptor: bulk in
k_usb_ndpdscrsz, // length of descriptor in bytes
0x05, // descriptor type: endpoint
0x82, // endpoint 2, in
0x02, // bulk
k_fs_maxpktsz, // max packet size lo
0x00, // max packet size hi
0x00 // polling interval
};
#endif
//------------------------------------------------------------------------------
// high speed configuration descriptor
uint8 code g_hs_cfg_dscr[] =
{
k_usb_cfgdscrsz, // length of descriptor in bytes
k_usb_dscr_typ_config, // descriptor type: configuration
k_usb_cfgdscrsz +
k_usb_ifcdscrsz +
k_usb_ndpdscrsz +
k_usb_ndpdscrsz, // total length lo
0, // total length hi
1, // number of interfaces
0x01, // configuration value
0x00, // index of string descriptor
0xC0, // attributes: bus powered, no remote wakeup
0xFA, // _max power: 500ma
// interface descriptor: BOT mass storage
k_usb_ifcdscrsz, // length of descriptor in bytes
k_usb_dscr_typ_interface, // descriptor type: interface
0, // interface number
0, // alternate interface
2, // number of endpoints
0x08, // usb interface class: mass storage
0x02, // usb interface subclass: SFF
0x50, // interface protocol: BOT (bulk only transport)
0x00, // interface string index
// endpoint descriptor: bulk out
k_usb_ndpdscrsz, // length of descriptor in bytes
0x05, // descriptor type: endpoint
0x02, // endpoint 2, out
0x02, // bulk
_l(k_hs_maxpktsz), // max packet size lo
_h(k_hs_maxpktsz), // max packet size hi
0x01, // polling interval
// endpoint descriptor: bulk in
k_usb_ndpdscrsz, // length of descriptor in bytes
0x05, // descriptor type: endpoint
0x82, // endpoint 2, in
0x02, // bulk
_l(k_hs_maxpktsz), // max packet size lo
_h(k_hs_maxpktsz), // max packet size hi
0x00, // polling interval
};
//------------------------------------------------------------------------------
// other speed configuration descriptor
//------------------------------------------------------------------------------
// full speed other speed configuration descriptor
uint8 code g_fs_oscfg_dscr[] =
{
k_usb_cfgdscrsz, // length of descriptor in bytes
k_usb_dscr_typ_osconfig, // descriptor type: other speed configuration
k_usb_cfgdscrsz +
k_usb_ifcdscrsz +
k_usb_ndpdscrsz +
k_usb_ndpdscrsz, // total length lo
0, // total length hi
1, // number of interfaces
0x01, // configuration value
0x00, // index of string descriptor
0xC0, // attributes: bus powered, no remote wakeup
0xFA, // _max power: 500ma
// interface descriptor: BOT mass storage
k_usb_ifcdscrsz, // length of descriptor in bytes
k_usb_dscr_typ_interface, // descriptor type: interface
0, // interface number
0, // alternate interface
2, // number of endpoints
0x08, // usb interface class: mass storage
0x02, // usb interface subclass: SFF
0x50, // interface protocol: BOT (bulk only transport)
0x00, // interface string index
// endpoint descriptor: bulk out
k_usb_ndpdscrsz, // length of descriptor in bytes
0x05, // descriptor type: endpoint
0x02, // endpoint 2, out
0x02, // bulk
k_fs_maxpktsz, // max packet size lo
0x00, // max packet size hi
0x01, // polling interval
// endpoint descriptor: bulk in
k_usb_ndpdscrsz, // length of descriptor in bytes
0x05, // descriptor type: endpoint
0x82, // endpoint 2, in
0x02, // bulk
k_fs_maxpktsz, // max packet size lo
0x00, // max packet size hi
0x00, // polling interval
};
//------------------------------------------------------------------------------
// high speed other speed configuration descriptor
uint8 code g_hs_oscfg_dscr[] =
{
k_usb_cfgdscrsz, // length of descriptor in bytes
k_usb_dscr_typ_osconfig, // descriptor type: other speed configuration
k_usb_cfgdscrsz +
k_usb_ifcdscrsz +
k_usb_ndpdscrsz +
k_usb_ndpdscrsz, // total length lo
0, // total length hi
1, // number of interfaces
0x01, // configuration value
0x00, // index of string descriptor
0xC0, // attributes: bus powered, no remote wakeup
0xFA, // _max power: 500ma
// interface descriptor: BOT mass storage
k_usb_ifcdscrsz, // length of descriptor in bytes
k_usb_dscr_typ_interface, // descriptor type: interface
0, // interface number
0, // alternate interface
2, // number of endpoints
0x08, // usb interface class: mass storage
0x02, // usb interface subclass: SFF
0x50, // interface protocol: BOT (bulk only transport)
0x00, // interface string index
// endpoint descriptor: bulk out
k_usb_ndpdscrsz, // length of descriptor in bytes
0x05, // descriptor type: endpoint
0x02, // endpoint 2, out
0x02, // bulk
_l(k_hs_maxpktsz), // max packet size lo
_h(k_hs_maxpktsz), // max packet size hi
0x01, // polling interval
// endpoint descriptor: bulk in
k_usb_ndpdscrsz, // length of descriptor in bytes
0x05, // descriptor type: endpoint
0x82, // endpoint 2, in
0x02, // bulk
_l(k_hs_maxpktsz), // max packet size lo
_h(k_hs_maxpktsz), // max packet size hi
0x00, // polling interval
};
//------------------------------------------------------------------------------
// Declaration:
// void build_serial_dscr( uint8* bufp )
// Purpose:
// builds a custom serial string descriptor from whatever data
// whatever value is stored in the x_ata_dev_str_ser buffer
// and places the result in the location specified by buf
// Arguments:
// uint8* bufp - pointer to buffer to store dynamic descriptor
// Return:
// None
//------------------------------------------------------------------------------
void build_serial_dscr(uint8* bufp )
{
uint8 i ;
// zero the memory
for (i=0;i<2*41;i++)
bufp[i]=0;
// set length & type
bufp[0]=40;
bufp[1]=3 ;
// set the ascii string values
for (i=0;i<x_ata_dev_str_ser_sz; i++)
{
// skip every other byte (ansii->unicode)
bufp[2*i+2] = x_ata_dev_str_ser[i] ;
}
// viola. done
}
/*****************************************************************************/
/* bot_set_serial_number */
/* this function converts whatever is in the x_ata_dev_str_ser buffer or, if */
/* used, the serial eeprom, into a bulk-only compliant serial number of at */
/* least 12 bytes.
/*****************************************************************************/
void bot_set_serial_number() reentrant
{
#ifdef k_support_eeprom
uint8 i ;
// read length from eeprom
x_ata_dev_str_ser_sz = eeprom_read(0) ;
trace1(0, eep, 0, "Reading %d bytes of serial data", x_ata_dev_str_ser_sz) ;
for(i=0; i<x_ata_dev_str_ser_sz; i++)
{
x_ata_dev_str_ser[i] = eeprom_read(i+1);
trace2(0, atapi, 0, "ser[%d]: '%c'", i, x_ata_dev_str_ser[i]) ;
}
x_ata_dev_has_ser = k_true ;
#else // eeprom not supported
// don't report a serial number when requested
x_ata_dev_has_ser = k_false ;
#endif // k_support_eeprom
}
void fmc_serial_number_wr() reentrant
{
uint8 length;
uint8 i;
uint8 j;
uint8 eetemp ;
TRACE0(414, fmc, 0, "writing serial number") ;
mcu_begin_critical_section();
// enable eeprom
eeprom_write_enable() ;
i=0 ;
// write length (12 per the spec)
eeprom_write(i++, 12 ) ;
for(j=0;j<5;j++)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -