自娱自乐10之Linux DMA使用2(DMA使用实例,用timer作DMA请求源实现流水灯)

本文介绍了如何使用Linux DMA结合定时器来实现流水灯效果,以S3C2440平台为例,阐述了通过定时器中断触发DMA传输到GPIO口的方法,实现了灯的依次点亮。虽然无法展示实际现象,但后续计划探讨在UDC驱动中应用DMA。
摘要由CSDN通过智能技术生成

我想大家听过流水灯的实现,有很多方法,有一种是用定时器实现的。

通常是利用定时器中断,今天我要用timer作为DMA请求源,当timer时间到启动DMA传输,这样把一个一个数送的gpio口。实现流水灯

下面是代码,我的流水灯只流一次,平台是s3c2440

/***********************************
 Copyright(C), 2013 LDP
 FileName:  tiemr.c
 Author:    wwxxxxll
 Date:          
 Description: linux-3.2-36
 History:       
 Author       Date            Desc
************************************/

#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <linux/miscdevice.h>
#include <linux/dma-mapping.h>
#include <linux/slab.h>
#include <linux/interrupt.h>

#include <asm/io.h>
#include <asm/mach/time.h>

#include <mach/regs-gpio.h>
#include <mach/regs-gpioj.h>
#include <mach/hardware.h>
#include <mach/dma.h>

#include <plat/regs-timer.h>
#include <plat/gpio-fns.h>
#include <plat/dma-ops.h>



#define DEVICE_NAME			"timer1" 

#define DMA_TEST
//如果不定义DMA_TEST,就是一个timer1中断驱动

#ifdef DMA_TEST

#define SIZE 4

struct timer_data
{
    struct samsung_dma_ops * timer_dma_ops;
    struct samsung_dma_info info;
	struct samsung_dma_prep_info pre_info;
	dma_addr_t dma_addr;
    unsigned ch;
	void * buf;
};

static struct timer_data timer1_data;

static struct s3c2410_dma_client timer1_dma_client = 
{
	.name = "samsung-timer-dma",
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值