drive_pwm
所属分类:单片机开发
开发工具:Unix_Linux
文件大小:11KB
下载次数:28
上传日期:2007-02-26 15:01:55
上 传 者:
yannan611
说明: 飞思卡尔的mx21处理器的pwm驱动程序源码,绝对好用。
(the mx21 Freescale's processor pwm driver source code, absolutely everything.)
文件列表:
pwm\PWM_def.h (1554, 2004-11-10)
pwm\Makefile (387, 2004-11-10)
pwm\MX2_def.h (6508, 2004-11-10)
pwm\pwm.h (2584, 2004-11-10)
pwm\pwm.c (16548, 2004-11-10)
pwm\MX1_def.h (3751, 2004-11-10)
pwm (0, 2006-06-22)
PWM Linux device driver
version: beta release
This document describe the APIs and testing procedure of LinuxBSP PWM sample driver.
[ API ]
- open
- ioctl
- write
1. OPEN
int open(char *driver, int operation)
* Open PWM driver
Input parameters:
driver: Device driver name
operation: Operation to the driver
Return:
driver handle
Example:
handle = open("pwm", O_RDWR);
2. IOCTL
void ioctl( int handle, int operation, int arg)
* Set WAV file sampling rate and data length
Input parameters:
handle: driver handle
operation: Operation to the driver PWM_IOC_MODE, PWM_IOC_SFREQ or PWM_IOC_SDATALEN
PWM_IOC_MODE : Set mode (play or tone)
PWM_IOC_SFREQ : Set sampling frequency
PWM_IOC_SDATALEN : Set data length
arg:
argument
Example:
// Set WAV file sampling rate
ioctl(handle, PWM_IOC_SFREQ, SAM_RATE);
// Set WAV file data length
ioctl(handle, PWM_IOC_SDATALEN, DATA_LEN);
* Set Tone file
Input parameters:
handle: driver handle
operation: Operation to the driver PWM_IOC_SFREQ or PWM_IOC_SDATALEN
PWM_IOC_MODE : Set mode (play or tone)
PWM_IOC_SPERIOD : Set period of playing samples
PWM_IOC_SSAMPLE : Set sample register
arg:
argument
Example:
ioctl(handle, PWM_IOC_SMODE, PWM_TONE_MODE);
ioctl(handle, PWM_IOC_SPERIOD, 250);
ioctl(handle, PWM_IOC_SSAMPLE, 0x5f0);
3. WRITE
int write( int handle, char *data, int size)
* Play WAV/Tone data
Input parameters:
handle: driver handle
data: data buffer to be played
size: size of data buffer
Example:
write(handle, data, DATA_SZ);
[ Compile ]
- type "make"
- type "sh makeTestPWM"
[ Test ]
- Start hyperterminal
- 115200, N81
- Connect to MX1ADS SODIMM Uart port
- Reset ADS
- #cd tmp
- #zmrx
- In Hyperterminal, use zmodem to send "loadpwm"
- #zmrx
- In Hyperterminal, use zmodem to send "pwm.o"
- #zmrx
- In Hyperterminal, use zmodem to send "testplaymode"
- #zmrx
- In Hyperterminal, use zmodem to send "testtonemode"
- #sh loadpwm
- #./testplaymode
- You will hear a melody from PWM
- hit ENTER key to display # again after the melody played completely.
- #./testtonemode
- You will hear a tone for 5s
~END~
近期下载者:
相关文件:
收藏者: