1. SD 卡挂载
1) 插入sd卡,查看sd 设备信息
#插入sd卡,查看sd 设备信息
fdisk -l
2) 挂载 sd 卡
mount /dev/mmcblk0p1 /mnt/
2. 检测lcd 屏幕是否正常
cat /dev/urandom > /dev/fb0
3. LRADC KEY键值检测
1)硬件电路图
2)终端输入:key 按下按键,即可打印相应键值
3)ADC 检测源码
如果检测到键值115 的按键按下,则执行某种操作
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <poll.h>
#include <signal.h>
#include <sys/types.h>
#include <unistd.h>
#include <fcntl.h>
#include <linux/input.h>
int fd;
int flag_signal = 0;
int count = 0;
void signal_func(int signum)
{
struct input_event buttons_event, leds_event;
/* [cgw]: 异步通知产生时返回的数据 */
read(fd, &buttons_event, sizeof(struct input_event));
if(buttons_event.code == 115) {
flag_signal = 1;
}
/* [cgw]: 打印事件类型,事件码,事件值 */
printf("type: 0x%x code: 0x%x value: 0x%x\n",
buttons_event.type,
buttons_event.code,
buttons_event.value);
}
int readKeySignal() {
int Oflags;
/* [cgw]: 设置需要处理的信号SIGIO,即输入文件会请求一个SIGIO
* 信号,当有新数据到来这个信号会发给filp->f_owner进程
*/
signal(SIGIO, signal_func);
fd = open("/dev/input/event0", O_RDWR | O_NONBLOCK);
//printf("fd = 0x%x\n", fd);
if (fd < 0)
{
printf("can't open!\n");
return -1;
}
/* [cgw]: 根据文件标识符fd,设置能够获得这个文件的进程(owner)
* getpid()获得当前进程ID
*/
fcntl(fd, F_SETOWN, getpid());
/* [cgw]: 获得file->f_flags标志 */
Oflags = fcntl(fd, F_GETFL);
/* [cgw]: 置位FASYNC使能异步通知 */
fcntl(fd, F_SETFL, Oflags | FASYNC);
return 0;
}
int main() {
readKeySignal();
while() {
if(flag_signal == 1){
printf("count = %d \n", count);
//处理自己的事务
//.......
count += 1;
flag_signal = 0;
}
}
return 0;
}
4. wifi 无线网络设定
1)配置wifi
#打开网络
ifconfig wlan0 up
#打开配置文件,填入路由器的 ssid 和 password
vi /etc/wpa_supplicant.conf
填入路由器的 ssid 和 password
network={
ssid="SINLINX"
key_mgmt=WPA-PSK
psk="sinlinx8911771"
}
2)开启网络,拼通百度
wpa_supplicant -D nl80211 -i wlan0 -c /etc/wpa_supplicant.conf -B
udhcpc -i wlan0
ping baidu.com