Re: PWM Driver

From: David V (davev_at_)
Date: 03/31/04


Date: Wed, 31 Mar 2004 10:52:03 -0600

This is good info but how do i build the driver?

Are there examples of driver templates that are well documented that work
with platform builder 4.2?

David V

"Paul G. Tobey [eMVP]" <ptobey_no_spam@instrument_no_spam.com> wrote in
message news:ugyoXzzFEHA.1912@TK2MSFTNGP10.phx.gbl...
> You might do something roughly like this in your driver:
>
> PHYSICAL_ADDRESS phys = { g_IoBase, 0 };
> PVOID pBase = MmMapIoSpace( phys, g_IoLen, FALSE );
> g_DataReg = (PUCHAR)pBase + DATA_REG_OFFSET;
> g_ControlReg = (PUCHAR)pBase + CONTROL_REG_OFFSET;
>
> // Write a byte to the data register.
> WRITE_PORT_UCHAR( g_DataReg, val );
>
> Of course, you'll have to select the correct value for g_IoBase to match
the
> set of registers on the processor that you intend to use (GPIO or
whatever).
>
> Paul T.
>
> "David V" <davev@> wrote in message
> news:%23PphynzFEHA.1272@TK2MSFTNGP12.phx.gbl...
> > The microsoft help files are the most useless help files I have ever
seen.
> > The word Platform has multiple meanings and the steps are unclear and
> > imcomplete.
> >
> > I have been through the CE training (2530, 2535, 2540) and still can't
> write
> > a driver to access a register internal to the processor.
> >
> > Can anyone provide a simple and well documented example on how to do
this?
> >
> > David V
> >
> > "Geoff Smith" <smith.geoffrey@fixme.comcast.net> wrote in message
> > news:u5HPaWqFEHA.2732@tk2msftngp13.phx.gbl...
> > > David -
> > > Streams drivers are very common across several operating systems.
> The
> > > API they expose allows them to be accessed via a file-like set of
> > functions.
> > > The MSDN and Platform Builder docs describe them quite well.
> > RegisterDevice
> > > has been replaced by ActivateDeviceEx. When you call this function
your
> > PWM
> > > driver PWM_Init should get called.
> > >
> > > CreateFile will call PWM_Open
> > > WriteFile - PWM_Write
> > > ReadFile - you get the picture.
> > >
> > > The catch all is DeviceIoControl - you use this for everything not
> > > applicable to the other stream APIs.
> > >
> > > Points to note:
> > > -Your ini function should be PWM_Init not PWM_INIT
> > > -You should export your entry points in a DEF file
> > > -You can load your driver at boot time using the HKLM\Builtin key
> > > - Don't be afraid to read the MSDN and PB docs
> > > - Consider attending a CE training course
> > >
> > > --
> > > Geoff Smith
> > > eMVP
> > > ==
> > >
> > >
> > > "David V" <davev@> wrote in message
> > > news:%23GyDRTpFEHA.3540@TK2MSFTNGP09.phx.gbl...
> > > > I am trying to write a dll for a PWM driver. I am using Platform
> Builder
> > > 4.2
> > > > for the x-scale.
> > > >
> > > > When i try to register the dll I use the code below and get error
type
> > 1.
> > > > dll = RegisterDevice(L"PWM", 1, L"pwm.dll", 0);
> > > >
> > > >
> > > > In my dll project I have a init function, PWM_INIT.
> > > >
> > > >
> > > > What should the signature be for this function? I have seen 3
> different
> > > > signatures. One with 2 input parameters, One that returns a BOOL.
One
> > that
> > > > returns a DWORD handle.
> > > >
> > > > What should the handle be if all i want to do I use PWM_IOControl?
> > > >
> > > > There don't seem to be an good examples on how to write a driver.
All
> > the
> > > > examples are poorly commented and extremely confusing.
> > > >
> > > >
> > > > Dave V.
> > > >
> > > >
> > >
> > >
> >
> >
>
>



Relevant Pages

  • Re: Quad core CPU detected but shows as single core in 2.6.23.1
    ... pnp: PnP ACPI init ... Generic PHY: Registered new driver ... PCI: Firmware left 0000:00:04.0 e100 interrupts enabled, disabling ... Internal registers self-test: passed. ...
    (Linux-Kernel)
  • 2.6.15-rc5-mm2 does not boot on AMD64 with sata_sil
    ... Using ACPI for IRQ routing ... Uniform CD-ROM driver Revision: 3.20 ... Using ACPI for SMP configuration information Allocating PCI resources starting at e2000000 Checking aperture... ... Real Time Clock Driver v1.12 hw_random: AMD768 system management I/O registers at 0x8000. ...
    (Linux-Kernel)
  • Re: [BUG 2.6.20-rc3-mm1] raid1 mount blocks for ever
    ... Generic PHY: Registered new driver ... SGI XFS with ACLs, security attributes, no debug enabled ... XFS mounting filesystem sdb6 ...
    (Linux-Kernel)
  • device driver for the SGI system clock, mmtimer
    ... The driver has been widely used for applications on the Altix platform. ... +static int mmtimer_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg); ... * of the page where the registers are mapped) for the counter in question. ...
    (Linux-Kernel)
  • x86_86 SMP megaraid_mbox hangups and panics.
    ... Having hangs and kernel panics trying to boot AMD64 SMP with an LSI MegaRaid 320-1 card using megaraid_mbox driver. ... I'm trying to boot a monolithic vanilla 2.6.16.1 64-bit SMP on a SuperMicro Opteron server running a dualcore AMD 270 CPU and 8G of RAM. ... 64-bit ACPI disabled - does not work. ... AMD768 system management I/O registers at 0x5000. ...
    (Linux-Kernel)