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;
}