📄 device.c
字号:
// Notes:
// It is safe to call this function from interrupt handlers.
//
// Since:
//
//------------------------------------------------------------------------------
void dev_common_media_led_on() reentrant using 1
{
//turn on activity LED if there is any media present and the
//common media led attribute is set.
if (g_dev_attr_hl & kbm_attr_hl_gpio1_common_led)
{
if ((_mcu_register_rd(x_crd_ps) & (kbm_crd_ps_cf |
kbm_crd_ps_sm |
kbm_crd_ps_ms |
kbm_crd_ps_mmc |
kbm_crd_ps_sd )))
{
#ifdef k_mcu_97223
gpio_setbit(1);
#endif
#ifdef k_mcu_97210
gpio_setbit(0);
#endif
}
}
}
//------------------------------------------------------------------------------
// Name: dev_common_media_led_off
//
// Declaration: void dev_common_media_led_off() reentrant using 1
//
// Purpose: turns off GPIO1(USB97C223)/GPIO0(USB97C210) if common media LED
// attribute bit is set
//
// Arguments:
// None.
//
// Return:
// None.
//
// Notes:
// It is safe to call this function from interrupt handlers.
//
// Since:
//
//------------------------------------------------------------------------------
void dev_common_media_led_off() reentrant using 1
{
//turn off activity LED if there is any media present and the
//common media led attribute is set.
if (g_dev_attr_hl & kbm_attr_hl_gpio1_common_led)
{
if (!(_mcu_register_rd(x_crd_ps) & (kbm_crd_ps_cf |
kbm_crd_ps_sm |
kbm_crd_ps_ms |
kbm_crd_ps_mmc |
kbm_crd_ps_sd )))
{
#ifdef k_mcu_97223
gpio_clrbit(1);
#endif
#ifdef k_mcu_97210
gpio_clrbit(0);
#endif
}
}
}
#pragma AREGS
//------------------------------------------------------------------------------
// Name:
//
// Declaration:
//
// Purpose:
//
// Arguments:
//
// Return:
// None.
//
// Notes:
//
// Since:
// fmc.10 ver .97
//------------------------------------------------------------------------------
void dev_gpio_power_down() reentrant
{
// turn off all power to cards, indicator leds, etc
if (g_dev_attr_lo & kbm_attr_lo_activity_led_gpio_hi_on_spd)
{
trace0(0, pwr, 0, "setting the activity led gpio");
//drive the gpio high
#ifdef k_mcu_97210
gpio_setbit(0);
#endif
#ifdef k_mcu_97211
gpio_setbit(0);
gpio_setbit(1);
#endif
#ifdef k_mcu_97223
gpio_setbit(1);
#endif
#ifdef k_mcu_97242
gpio_setbit(1);
#endif
}
else
{
trace0(0, dev, 0, "clearing the activity led gpio");
//drive the gpio low
#ifdef k_mcu_97210
gpio_clrbit(0);
#endif
#ifdef k_mcu_97211
gpio_clrbit(0);
gpio_clrbit(1);
#endif
#ifdef k_mcu_97223
gpio_clrbit(1);
#endif
#ifdef k_mcu_97242
gpio_clrbit(1);
#endif
}
gpio_clrbit(5);
_mcu_register_set_bits(x_gpiob_out, kbm_gpio8 |kbm_gpio9 |kbm_gpio10 |kbm_gpio11 |kbm_gpio12 |kbm_gpio13 |kbm_gpio14 |kbm_gpio15);
#ifdef k_pfm_led
// turn off the activity/inserted LEDs
_mcu_register_clr_bits(x_gpiob_out, kbm_gpio12 |kbm_gpio13 |kbm_gpio14 |kbm_gpio15);
#endif
}
//+-----------------------------------------------------------------------------
// Name:
// dev_exception
//
// Declaration:
// void dev_exception(void);
//
// Purpose:
// Hard error. Log message to trace fifo and halt.
//
// Arguments:
// None.
//
// Return:
// Does not return.No return value.
//
// Since:
// fmc-1.0
//------------------------------------------------------------------------------
void dev_exception(uint16 ec) reentrant
{
ec=ec; // keep compiler happy for release builds
TRACE0(1, stk, 0, "** fatal exception **");
TRACE1(2, stk, 0, " code: %04x", ec);
TRACE1(3, stk, 0, " thd: %d", g_tid);
thread_halt();
}
//------------------------------------------------------------------------------
// Declaration:
// uint8 dev_rd_most_recent_config(void);
//
// Purpose:
// Report the most recent value set by a "set_configuration" request.
//
// Arguments:
// None.
//
// Return:
// A uint8 representing the most recent usb configuration value.
//------------------------------------------------------------------------------
uint8 dev_rd_most_recent_config() reentrant
{
return _most_recent_config;
}
//------------------------------------------------------------------------------
// Declaration:
// void dev_wr_most_recent_config(uint8 cfg);
//
// Purpose:
// Allow interface managers to clear it before rebooting.
//
// Arguments:
// None.
//
// Return:
// A uint8 representing the most recent usb configuration value.
//------------------------------------------------------------------------------
void dev_wr_most_recent_config(uint8 cfg) reentrant
{
_most_recent_config = cfg;
}
//+-----------------------------------------------------------------------------
// Name:
// dev_initialize
//
// Declaration:
// void dev_initialize(void);
//
// Purpose:
// Called once on POR. initialize device hardware.
//
// Arguments:
// None.
//
// Return:
// None.
//
// Since:
// fmc-1.0
//------------------------------------------------------------------------------
static void dev_initialize(void) reentrant;
static void dev_initialize() reentrant
{
trace0(0, dev, 1, "dev_initialize()");
#ifdef k_mcu_97201
// setup ATA control register. clr muxen to select ATA interface.
_mcu_register_set_bits(x_ata_ctl, kbm_ata_ctl_out_control);
_mcu_register_clr_bits(x_ata_ctl, kbm_ata_ctl_muxen);
#endif
#ifdef k_20x_family
// initialize test register so proper phy will be controlled
#ifdef k_rev_c_klsi_phy
XBYTE[0x3F10] = 0x01; // rev C klsi phy
#else
XBYTE[0x3F10] = 0x00; // rev A klsi phy
#endif
#endif
}
//+-----------------------------------------------------------------------------
// Name:
// dev_power_up
//
// Declaration:
// void dev_power_up(void);
//
// Purpose:
// Called on set-config(1), and resume if configuration is non-zero.
// Power on the flash media sockets as appropriate.
//
// Arguments:
// None.
//
// Return:
// None.
//
// Since:
// fmc-1.0
//------------------------------------------------------------------------------
static void dev_power_up(void) reentrant;
static void dev_power_up() reentrant
{
uint8 ps;
trace0(0, pwr, 1, "dev_power_up()");
dev_indicate_bus_speed();
// begin the boot sequence proper
//if 20X family we are configured run from crystal oscillator now
#ifdef k_20x_f
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -