Analysis of Windows CE-Based LED driver code

Source: Internet
Author: User

Based on the tq2440 hardware platform, this platform processor s3c2440a has four LEDs in this platform for testing and displaying the running status of other hardware. The LED driver is a typical I/O driver, simple but sound. It is a typical example of learning Windows CE embedded platform. First, let's take a look at the circuit diagram of this platform!

The four LEDs respectively add a 1 k pair of resistance, and the other end is connected to the 3.3v voltage. Next, let's look at the interface of the core board.

 

The four LEDs are controlled by gpb5, gpb6, gpb7, and gpb8, both of which are in the gpio ports of group B. Next, we will introduce the specific compiling process. The fixed stream-driven interface is as follows;

Gio_deinit, gio_init, gio_iocontrol, gio_open, and gio_close.

The compilation process is as follows;

Virtual Address ing -- set the gpb I/O port as the output port -- call gio_iocontrol for control -- disable the driver. The most important steps in these processes are the first step. The code is listed below;

V_piopregs = (volatile s3c2440a_ioport_reg *) virtualalloc (0, sizeof (s3c2440a_ioport_reg), mem_reserve, page_noaccess );
If (v_piopregs = NULL)
{
Errormsg (1, (text ("For iopregs: virtualalloc faigpio! /R/N ")));
Retvalue = false;
}
Else
{
If (! Virtualcopy (pvoid) v_piopregs, (pvoid) (s3c2440a_base_reg_pa_ioport> 8), sizeof (s3c2440a_ioport_reg), page_physical | page_readwrite | page_nocache ))
{
Errormsg (1, (text ("For iopregs: virtualcopy faigpio! /R/N ")));
Retvalue = false;
}
}

If (! Retvalue)
{
If (v_piopregs)
{
Virtualfree (pvoid) v_piopregs, 0, mem_release );
}

V_piopregs = NULL;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.