?? testpwm.c
字號:
/******************************* file : testpwm.c ****************************** Version : 1.0 Function: The PWM driver test Auther: BIT 11/2006*******************************************************************************/#include <stdio.h>#include <unistd.h>#include <fcntl.h>#include <stdlib.h>#include <math.h>#include "disp_pic.h"/******************************************************************************output a pwm wave*******************************************************************************/main(){ int fd; unsigned int pwm_data; unsigned char str_temp[32]; unsigned char temp; printf("\n******************\n"); printf(" PWM Test Program.\n"); printf("******************\n"); fd=open("/dev/pwm",O_RDWR); if(fd<0) { printf("Can't open device file: pwm\n"); perror("Open: "); exit(-1); } while(1) { printf("\n\n****************************************************\n"); printf("Input the decimal of the PWM (0-4095) :\n"); printf("--For example, if you input '654', then the H:L of the pwm output is (654 : 4095-654)\n"); fgets(str_temp,32,stdin); pwm_data=atoi(str_temp); pwm_data&=0xfff; printf("What you input is : 0x%x\n",pwm_data); ioctl(fd,0,pwm_data); }}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -