Jump to content


[c] conversione codice IO


This topic has been archived. This means that you cannot reply to this topic.
2 replies to this topic

#1 Guest__*

Guest__*
  • Ospiti

Posted 18 January 2012 - 10:03

...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)


#2 MadJackal

MadJackal

    Schiavo

  • Membri
  • PipPipPipPipPip
  • 3105 posts

Posted 30 January 2012 - 00:50

Dovresti provare a guardare la documentazione per ioperm (che già hai visto) e sys/io.h (che include tutte le macro out*/in* per manipolare le porte anche da userspace).
In Soviet Italy, the evil army owns you!

#3 Guest__*

Guest__*
  • Ospiti

Posted 30 January 2012 - 09:01

Dovresti provare a guardare la documentazione per ioperm (che già hai visto) e sys/io.h (che include tutte le macro out*/in* per manipolare le porte anche da userspace).



...si si...avevo trovato qualcosa a riguardo...per ora il progetto è sospeso...