📄 spidemo.c
字号:
#include <linux/types.h>#include <linux/stat.h>#include <linux/fcntl.h>#include <stdio.h>#include "spi.h"int dev_handle,boot_handle,PacketNum,DotNum;unsigned char bootdata[60*1024],*p;unsigned int filelen;unsigned long temp;int boot(){ boot_handle=open("bootload.bin",O_RDONLY); if(boot_handle==-1) { printf("Boot file not found,reset dsp fauler!\n"); close(dev_handle); return -1; } filelen=lseek(boot_handle,0,SEEK_END); lseek(boot_handle,0,SEEK_SET); read(boot_handle,bootdata,filelen); close(boot_handle); ioctl(dev_handle,SPI_SET_BOOTLEN,filelen); return ioctl(dev_handle,SPI_SEND_BOOTDATA,bootdata);} int main(){ dev_handle=open("/dev/spi_drv",O_RDWR); if(dev_handle==-1) { printf("Device not exist,check system!\n"); return -1; } boot(); /* for(temp=0;temp<0x1ffffff;temp++){}; ioctl(dev_handle,SPI_BLIGHT_ON,NULL); */ ioctl(dev_handle,SPI_MODEM_RESET,NULL); close(dev_handle); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -