?? ide_x_hw.c
字號:
Parameters:
Unit - Unit number.
Return value:
Value of the RD DATA register.
*/
FS_u16 FS_IDE_HW_X_GetData(FS_u32 Unit) {
FS_u16 data;
data = _FS_IDE_HW_ReadBUS(Unit, 0x02, 0x00);
return data;
}
/*********************************************************************
*
* FS_IDE_HW_X_SetFeatures
*
Description:
FS driver hardware layer function. Set the FEATURES register.
Parameters:
Unit - Unit number.
Data - Value to write to the FEATURES register.
Return value:
None.
*/
void FS_IDE_HW_X_SetFeatures(FS_u32 Unit, unsigned char Data) {
_FS_IDE_HW_WriteBUS(Unit, 0x02, 0x01, Data);
}
/*********************************************************************
*
* FS_IDE_HW_X_GetError
*
Description:
FS driver hardware layer function. Read the ERROR register.
Parameters:
Unit - Unit number.
Return value:
Value of the ERROR register.
*/
unsigned char FS_IDE_HW_X_GetError(FS_u32 Unit) {
unsigned char data;
data = _FS_IDE_HW_ReadBUS(Unit, 0x02, 0x01) & 0xff;
return data;
}
/*********************************************************************
*
* FS_IDE_HW_X_SetSectorCount
*
Description:
FS driver hardware layer function. Set the SECTOR COUNT register.
Parameters:
Unit - Unit number.
Data - Value to write to the SECTOR COUNT register.
Return value:
None.
*/
void FS_IDE_HW_X_SetSectorCount(FS_u32 Unit, unsigned char Data) {
_FS_IDE_HW_WriteBUS(Unit, 0x02, 0x02, Data);
}
/*********************************************************************
*
* FS_IDE_HW_X_GetSectorCount
*
Description:
FS driver hardware layer function. Read the SECTOR COUNT register.
Parameters:
Unit - Unit number.
Return value:
Value of the SECTOR COUNT register.
*/
unsigned char FS_IDE_HW_X_GetSectorCount(FS_u32 Unit) {
unsigned char data;
data = _FS_IDE_HW_ReadBUS(Unit, 0x02, 0x02) & 0xff;
return data;
}
/*********************************************************************
*
* FS_IDE_HW_X_SetSectorNo
*
Description:
FS driver hardware layer function. Set the SECTOR NUMBER register.
Parameters:
Unit - Unit number.
Data - Value to write to the SECTOR NUMBER register.
Return value:
None.
*/
void FS_IDE_HW_X_SetSectorNo(FS_u32 Unit, unsigned char Data) {
_FS_IDE_HW_WriteBUS(Unit, 0x02, 0x03, Data);
}
/*********************************************************************
*
* FS_IDE_HW_X_GetSectorNo
*
Description:
FS driver hardware layer function. Read the SECTOR NUMBER register.
Parameters:
Unit - Unit number.
Return value:
Value of the SECTOR NUMBER register.
*/
unsigned char FS_IDE_HW_X_GetSectorNo(FS_u32 Unit) {
unsigned char data;
data = _FS_IDE_HW_ReadBUS(Unit, 0x02, 0x03) & 0xff;
return data;
}
/*********************************************************************
*
* FS_IDE_HW_X_SetCylLow
*
Description:
FS driver hardware layer function. Set the CYLINDER LOW register.
Parameters:
Unit - Unit number.
Data - Value to write to the CYLINDER LOW register.
Return value:
None.
*/
void FS_IDE_HW_X_SetCylLow(FS_u32 Unit, unsigned char Data) {
_FS_IDE_HW_WriteBUS(Unit, 0x02, 0x04, Data);
}
/*********************************************************************
*
* FS_IDE_HW_X_GetCylLow
*
Description:
FS driver hardware layer function. Read the CYLINDER LOW register.
Parameters:
Unit - Unit number.
Return value:
Value of the CYLINDER LOW register.
*/
unsigned char FS_IDE_HW_X_GetCylLow(FS_u32 Unit) {
unsigned char data;
data = _FS_IDE_HW_ReadBUS(Unit, 0x02, 0x04) & 0xff;
return data;
}
/*********************************************************************
*
* FS_IDE_HW_X_SetCylHigh
*
Description:
FS driver hardware layer function. Set the CYLINDER HIGH register.
Parameters:
Unit - Unit number.
Data - Value to write to the CYLINDER HIGH register.
Return value:
None.
*/
void FS_IDE_HW_X_SetCylHigh(FS_u32 Unit, unsigned char Data) {
_FS_IDE_HW_WriteBUS(Unit, 0x02, 0x05, Data);
}
/*********************************************************************
*
* FS_IDE_HW_X_GetCylHigh
*
Description:
FS driver hardware layer function. Read the CYLINDER HIGH register.
Parameters:
Unit - Unit number.
Return value:
Value of the CYLINDER HIGH register.
*/
unsigned char FS_IDE_HW_X_GetCylHigh(FS_u32 Unit) {
unsigned char data;
data = _FS_IDE_HW_ReadBUS(Unit, 0x02, 0x05) & 0xff;
return data;
}
/*********************************************************************
*
* FS_IDE_HW_X_SetDevice
*
Description:
FS driver hardware layer function. Set the DEVICE/HEAD register.
Parameters:
Unit - Unit number.
Data - Value to write to the DEVICE/HEAD register.
Return value:
None.
*/
void FS_IDE_HW_X_SetDevice(FS_u32 Unit, unsigned char Data) {
_FS_IDE_HW_WriteBUS(Unit, 0x02, 0x06, Data);
}
/*********************************************************************
*
* FS_IDE_HW_X_GetDevice
*
Description:
FS driver hardware layer function. Read the DEVICE/HEAD register.
Parameters:
Unit - Unit number.
Return value:
Value of the DEVICE/HEAD register.
*/
unsigned char FS_IDE_HW_X_GetDevice(FS_u32 Unit) {
unsigned char data;
data = _FS_IDE_HW_ReadBUS(Unit, 0x02, 0x06) & 0xff;
return data;
}
/*********************************************************************
*
* FS_IDE_HW_X_SetCommand
*
Description:
FS driver hardware layer function. Set the COMMAND register.
Parameters:
Unit - Unit number.
Data - Value to write to the COMMAND register.
Return value:
None.
*/
void FS_IDE_HW_X_SetCommand(FS_u32 Unit, unsigned char Data) {
_FS_IDE_HW_WriteBUS(Unit, 0x02, 0x07, Data);
}
/*********************************************************************
*
* FS_IDE_HW_X_GetStatus
*
Description:
FS driver hardware layer function. Read the STATUS register.
Parameters:
Unit - Unit number.
Return value:
Value of the STATUS register.
*/
unsigned char FS_IDE_HW_X_GetStatus(FS_u32 Unit) {
unsigned char data;
data = _FS_IDE_HW_ReadBUS(Unit, 0x02, 0x07) & 0xff;
return data;
}
/*********************************************************************
*
* FS_IDE_HW_X_SetDevControl
*
Description:
FS driver hardware layer function. Set the DEVICE CONTROL register.
Parameters:
Unit - Unit number.
Data - Value to write to the DEVICE CONTROL register.
Return value:
None.
*/
void FS_IDE_HW_X_SetDevControl(FS_u32 Unit, unsigned char Data) {
_FS_IDE_HW_WriteBUS(Unit, 0x01, 0x06, Data);
}
/*********************************************************************
*
* FS_IDE_HW_X_GetAltStatus
*
Description:
FS driver hardware layer function. Read the ALTERNATE STATUS register.
Parameters:
Unit - Unit number.
Return value:
Value of the ALTERNATE STATUS register.
*/
unsigned char FS_IDE_HW_X_GetAltStatus(FS_u32 Unit) {
unsigned char data;
data = _FS_IDE_HW_ReadBUS(Unit, 0x01, 0x06) & 0xff;
return data;
}
/*********************************************************************
*
* FS_IDE_HW_X_DetectStatus
*
Description:
FS driver hardware layer function. Check if the device is present.
Parameters:
Unit - Unit number.
Return value:
==0 - Device is connected.
!=0 - Device has not been found.
*/
char FS_IDE_HW_X_DetectStatus(FS_u32 Unit) {
static char init;
if (!init) {
init = 1;
PD7 = 0xff; /* P70 - P77 output */
P7 = 0xff;
PD8 = 0xf0; /* P80 - P83 input / P84 - P87 output */
P8 = 0xff;
PRCR |= 0x04; /* allow PD9 change */
PD9 = 0x00; /* P90 - P97 input */
PRCR &= 0xfb; /* disable PD9 change */
PD10 = 0x00; /* P100 - P107 input */
}
/* check CD1 & CD2 */
if (P8 & 0x03) {
return 1;
}
return 0;
}
/*********************************************************************
*
* FS_IDE_HW_X_HWReset
*
Description:
FS driver hardware layer function. This function is called, when
the driver detects a new media is present. For ATA HD drives, there
is no action required and this function can be empty.
When using a CF card, please be aware, that the card needs to be
power cycled while ~OE is grounded. If the card is inserted, VCC &
GND will provide the card before ~OE is connected and the card will
be in PC Card ATA mode.
Parameters:
Unit - Unit number.
Return value:
None.
*/
void FS_IDE_HW_X_HWReset(FS_u32 Unit) {
volatile unsigned long int to;
if (Unit!=0) {
return;
}
P8 |= 0x10; /* power off */
PD7 = 0x00;
to = 10000;
while (to) {
to--;
}
PD7 = 0xff;
P8 &= 0xef; /* power on */
P7 |= 0x80; /* RESET high */
P7 &= 0x7f; /* RESET low */
FS__IDE_DELAY_RESET;
P7 |= 0x80; /* RESET high */
}
#endif /* FS_USE_IDE_DRIVER */
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -