我想大家听过流水灯的实现,有很多方法,有一种是用定时器实现的。
通常是利用定时器中断,今天我要用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",