📄 lcdpower.c
字号:
//written by bcng xiyong,2007-7-1
//set gpj4 to zero to give a kill signal to chip ltc2950
//a guidline about how to use gpio_driver
//p[0] is the address of the iocon of the io
//p[1] is the bit place, from 0 to xx,
//for example, GPJ4, p[1] is 0x4;
//for write function, the 3th parameter, if the second bit is set, them use keep before
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
#define GPGCON 0x56000060
#define GPG4 0x4
int main(int argc,char *argv[])
{
int fd,FunctionIndex,boolON=1;
unsigned long p[2];
char *charon="on";
if ((argc>2)||(argc<2))
{
printf("parameter error\n");
return 0;
}
//printf("param is %s\n",*(argv+1));
if ( !strcmp( *(argv+1),"on") ) boolON=1;
else
if ( !strcmp( *(argv+1),"off") ) boolON=0;
else
{
printf("parameter error\n");
return 0;
}
fd=open("/dev/gpio",O_RDWR | O_NOCTTY);
if (fd < 0)
{
printf("can not open gpio!\n");
return 0;
}
p[0]=GPGCON; //GPJCON
p[1]=GPG4;
if (boolON)
{
printf("Power on\n");
write(fd,p,5);
}
else
{
printf("Power off\n");
write(fd,p,0);
}
return 1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -