Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • aa00e43
  • /
  • blackfin
  • /
  • gptimers-example.c
Raw File Download
Permalinks

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge Iframe embedding
swh:1:cnt:283eba993d9d62115db668c3fa67ced228a047ac
directory badge Iframe embedding
swh:1:dir:ec16402fe8b2af71e204ab74985765106687cc0a
Citations

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
Generate software citation in BibTex format (requires biblatex-software package)
Generating citation ...
gptimers-example.c
/*
 * Simple gptimers example
 *	http://docs.blackfin.uclinux.org/doku.php?id=linux-kernel:drivers:gptimers
 *
 * Copyright 2007-2009 Analog Devices Inc.
 *
 * Licensed under the GPL-2 or later.
 */

#include <linux/interrupt.h>
#include <linux/module.h>

#include <asm/gptimers.h>
#include <asm/portmux.h>

/* ... random driver includes ... */

#define DRIVER_NAME "gptimer_example"

#ifdef IRQ_TIMER5
#define SAMPLE_IRQ_TIMER IRQ_TIMER5
#else
#define SAMPLE_IRQ_TIMER IRQ_TIMER2
#endif

struct gptimer_data {
	uint32_t period, width;
};
static struct gptimer_data data;

/* ... random driver state ... */

static irqreturn_t gptimer_example_irq(int irq, void *dev_id)
{
	struct gptimer_data *data = dev_id;

	/* make sure it was our timer which caused the interrupt */
	if (!get_gptimer_intr(TIMER5_id))
		return IRQ_NONE;

	/* read the width/period values that were captured for the waveform */
	data->width = get_gptimer_pwidth(TIMER5_id);
	data->period = get_gptimer_period(TIMER5_id);

	/* acknowledge the interrupt */
	clear_gptimer_intr(TIMER5_id);

	/* tell the upper layers we took care of things */
	return IRQ_HANDLED;
}

/* ... random driver code ... */

static int __init gptimer_example_init(void)
{
	int ret;

	/* grab the peripheral pins */
	ret = peripheral_request(P_TMR5, DRIVER_NAME);
	if (ret) {
		printk(KERN_NOTICE DRIVER_NAME ": peripheral request failed\n");
		return ret;
	}

	/* grab the IRQ for the timer */
	ret = request_irq(SAMPLE_IRQ_TIMER, gptimer_example_irq,
			IRQF_SHARED, DRIVER_NAME, &data);
	if (ret) {
		printk(KERN_NOTICE DRIVER_NAME ": IRQ request failed\n");
		peripheral_free(P_TMR5);
		return ret;
	}

	/* setup the timer and enable it */
	set_gptimer_config(TIMER5_id,
			WDTH_CAP | PULSE_HI | PERIOD_CNT | IRQ_ENA);
	enable_gptimers(TIMER5bit);

	return 0;
}
module_init(gptimer_example_init);

static void __exit gptimer_example_exit(void)
{
	disable_gptimers(TIMER5bit);
	free_irq(SAMPLE_IRQ_TIMER, &data);
	peripheral_free(P_TMR5);
}
module_exit(gptimer_example_exit);

MODULE_LICENSE("BSD");

Software Heritage — Copyright (C) 2015–2025, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Contact— JavaScript license information— Web API

back to top