🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: alt.comp.lang.learn.c-c++
Article #332

Re: using hardware port-address

#332
From: Thomas_Matthews
Date: Tue, 16 May 2000 00:00
34 lines
2104 bytes
In article <#5SATlxv$GA.170@net003s>,
  "MS Lucas" <famlucas@famlucas.penguinpowered.com> wrote:
> How can i use an i/o port off my computer in CBuilder ?
> I want to read/write data from/to an i/o port. In Pascal you can use
the
> command port[address] := value but what is the equivalent of this in C
>
> Question 2
> How can I use basic code in a C program. The reason is that I'm
writing a
> program for a CPU on an add-on card that is using a basic-dialect.
>
> Maurice Lucas

Since other people are giving platform specific advice, I'll chip in my
two cents:

The method I use to access hardware is to use a pointer and assign the
hardware item's address into the pointer.  The pointer's type depends on
the data width of the hardware item.  For example:

const volatile unsigned int * Uart_Base_Ptr =
    (volatile unsigned int *) (0xFFFD0000);

and
unsigned int Uart_Value = *Uart_Base_Ptr;

Just remember that you want to make sure that the pointer points to a
volatile location because the hardware devices may change their data
values without telling the program.


Sent via Deja.com http://www.deja.com/
Before you buy.
Technical Details
Message-ID: <8fs8gv$t2e$1@nnrp1.deja.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <#5SATlxv$GA.170@net003s>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f8d38,5a4aa760b0ec40a
X-Google-Attributes: gidf8d38,public
X-Google-Thread: 1014db,5a4aa760b0ec40a
X-Google-Attributes: gid1014db,public
X-Google-Thread: 114592,5a4aa760b0ec40a
X-Google-Attributes: gid114592,public
X-Google-Thread: 103c8d,5a4aa760b0ec40a
X-Google-Attributes: gid103c8d,public
From: Thomas_Matthews@tecmar.com
Subject: Re: using hardware port-address
Date: 2000/05/16
Message-ID: <8fs8gv$t2e$1@nnrp1.deja.com>
X-Deja-AN: 624199685
References: <#5SATlxv$GA.170@net003s>
X-Http-Proxy: 1.0 x33.deja.com:80 (Squid/1.1.22) for client 206.247.119.3
Organization: Deja.com - Before you buy.
X-Article-Creation-Date: Tue May 16 19:45:39 2000 GMT
X-MyDeja-Info: XMYDJUIDthomas_matthews
Newsgroups: alt.comp.lang.learn.c-c++,borland.public.cpp.language,borland.public.cppbuilder.language,comp.lang.c
X-Http-User-Agent: Mozilla/4.08 [en] (Win95; I ;Nav)