readme.txt

来自「飞思卡尔的mx21处理器的pwm驱动程序源码」· 文本 代码 · 共 119 行

TXT
119
字号

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~

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?