⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pwm.h

📁 飞思卡尔的mx21处理器的pwm驱动程序源码
💻 H
字号:
/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * Copyright (C) 2002 Freescale Semiconductors HK Ltd
 *
 */


#ifndef PWM_H
#define PWM_H

#include <linux/timer.h>
#include <linux/sched.h>

#include "MX2_def.h"
#include "PWM_def.h"

#ifdef U32
#undef U32
#endif
#define U32			unsigned int

#ifdef U16
#undef U16
#endif
#define U16			unsigned short

#ifdef U8
#undef U8
#endif
#define U8			unsigned char


#define MOD_NAME        	"pwm"
#define DEV_IRQ_NAME		MOD_NAME
#define DEV_IRQ_ID		MOD_NAME
#define AITC_PWM_INT		23

#define MAX_ID 			0x14

#define	_reg(REG)		(*((volatile unsigned long *)(REG)))

//#define	PK(fmt, args...)	printk(fmt, ## args)
#define	PK(...)

#define	PWM_FIFO_AV		0x20
#define	PWM_IRQ_AV		0x80

typedef struct timer_list timer_blk_t;

typedef struct timerStruct
{
	timer_blk_t	*timer_blk_ptr;
	int		period;
	void		(*timer_func)(unsigned long);
	int		stop_flag;
}PWM_Timer_t;



// functions and interface
static int pwm_open(struct inode * inode,
		struct file * filp);
static int pwm_release(struct inode * inode,
		struct file * filp);
static ssize_t pwm_read(struct file * ,
		char * ,
		size_t ,
		loff_t * l);
static int pwm_ioctl(struct inode * inode,
		struct file *filp,
		unsigned int cmd ,
		unsigned long arg);
static ssize_t pwm_write(struct file *filp,
		const char *buf,
		size_t count,
		loff_t *f_pos);
static int pwm_fasync(int fd,
		struct file *filp,
		int mode);
static int __init initpwm();

static int checkDevice(struct inode *pInode);
void test(void);

int CreateTimer(PWM_Timer_t *timer);
int StartTimer(PWM_Timer_t *timer);
int StopTimer(PWM_Timer_t *timer);
void	pwmIntFunc();

void StopPwm();

static int handle_pm_event(struct pm_dev *dev, pm_request_t rqst, void *data);

static PWM_Timer_t pwmTimer;
static timer_blk_t timer_blk;

#endif //PWM_H

⌨️ 快捷键说明

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