ally
18-01-2012, 09:01
...avrei la necessità di gestire l'IO di una scheda madre...ho trovato uno stralcio di codice che dovrei convertire da turbo c 3.0 a c per linux...il codice è lunghetto ma basa il suo funzionamento su questi due metodi e un terzo metodo di sleep/delay...
int SMBUS_Read_Byte(int offset,int DEVID)
{
int RetVal=0;
outportb(SMBus_Port,0x0fe);
outportb(SMBus_Port+0x04,DEVID+1);
outportb(SMBus_Port+0x03,offset+0);
outportb(SMBus_Port+0x02,0x48);
delay(200);
if(WaitReady(SMBus_Port))
{
RetVal = inp(SMBus_Port+0x05);
}
return RetVal;
}
void SMBUS_Write_Byte(int Dev_id,int Reg_index,int Value)
{
outportb(SMBus_Port+0x04,Dev_id);
delay(5);
Chk_SMBUS_Ready();
outportb(SMBus_Port+0x03,Reg_index);
delay(5);
outportb(SMBus_Port+0x05,(Value & 0xFF));
delay(5);
outportb(SMBus_Port+0x02,0x48);
delay(25);
Chk_SMBUS_Ready();
}
...esperienze in merito?...su un precedente programma di gestione watchdog hardware era necessario abilitare la lettura/scrittura per il device su i^2c anche se nella documentazione questa parte non era segnalata...
ioperm(0x2e, 0x2e, 1)
int SMBUS_Read_Byte(int offset,int DEVID)
{
int RetVal=0;
outportb(SMBus_Port,0x0fe);
outportb(SMBus_Port+0x04,DEVID+1);
outportb(SMBus_Port+0x03,offset+0);
outportb(SMBus_Port+0x02,0x48);
delay(200);
if(WaitReady(SMBus_Port))
{
RetVal = inp(SMBus_Port+0x05);
}
return RetVal;
}
void SMBUS_Write_Byte(int Dev_id,int Reg_index,int Value)
{
outportb(SMBus_Port+0x04,Dev_id);
delay(5);
Chk_SMBUS_Ready();
outportb(SMBus_Port+0x03,Reg_index);
delay(5);
outportb(SMBus_Port+0x05,(Value & 0xFF));
delay(5);
outportb(SMBus_Port+0x02,0x48);
delay(25);
Chk_SMBUS_Ready();
}
...esperienze in merito?...su un precedente programma di gestione watchdog hardware era necessario abilitare la lettura/scrittura per il device su i^2c anche se nella documentazione questa parte non era segnalata...
ioperm(0x2e, 0x2e, 1)