![Fastwel CPB902 User Manual Download Page 85](http://html.mh-extra.com/html/fastwel/cpb902/cpb902_user-manual_546458085.webp)
General Software® BIOS
CPB902
C P B 9 0 2 U s e r M a n u a l
83
© 2 0 0 8 F a s t w e l v . 1 . 5 b E
5.11.2
User
LEDs
Control
USER_LED1 and USER_LED2 user LEDs are switched on and off by writing logical 1 or 0
respectively to GPIO4 and GPIO5 lines of the GPIO processor unit. Sample LED control program
code fragments are given below.
Attention!
GPIO3 … GPIO0 lines are used by the system.
Incorrect handling of these lines may lead to system failure.
//Enable GPIO processor unit
//32-bit output of the value 0x80006040 to 0xCF8 port
outpd(0xCF8,0x80006040);
//32-bit input from 0xCFC port
SB_MISC_REG_cont = inpd(0xCFC);
if(!(SB_MISC_REG_cont & 0x2))
{
outpd(0xCF8,0x80006040);
//Enable GPIO unit
outp(0xCFC,SB_MISC_REG_cont|0x02);
}
//Obtaining GPIO base address and saving it to gpio_base variable
outpd(0xCF8,0x80006044);
gpio_base = inpw(0xCFC)&0xFFFE;
//Check the lines direction
direction_reg_cont = inp(gpio_base);
if(direction_reg_cont&0x30)
{
//Set GPIO4 and GPIO5 lines to output
outp(gpio_base,direction_reg_cont&0xCF);
}
//Get GPIO lines state from data source
read_control_reg_cont = inp(gp1);
if(read_control_reg_cont)
//GPIO state read directly from GPIO lines
outp(gp1,0x00);
//Switch USER_LED1 on/off
if(inp(gp6)&0x10)
//Switch USER_LED1 off
outp(gp6,inp(gp6)&0xEF);
else
//Switch USER_LED1 on
outp(gp6,inp(gp6)|0x10);
//Switch USER_LED2 on/off
if(inp(gp6)&0x20)
//Switch USER_LED2 off
outp(gp6,inp(gp6)&0xDF);
else
// Switch USER_LED2 on
outp(gp6,inp(gp6)|0x20);
More details on GPIO unit operation can be found in STPC Vega Programming manual.