OpenCores
URL https://opencores.org/ocsvn/igor/igor/trunk

Subversion Repositories igor

[/] [igor/] [trunk/] [avr/] [eth-test/] [dev/] [ledstk500.c] - Blame information for rev 4

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 4 atypic
#include <avr/io.h>
2
 
3
#include <stdint.h>
4
#include <stdlib.h>
5
#include <device.h>
6
 
7
/* Example device for adding device-specific hooks. */
8
 
9
#define LED_INIT 0xFE
10
#define LED_UNINIT 0x0F
11
#define LED_ERROR 0xF0
12
 
13
static igordev_read_fn_t led_read;
14
static igordev_init_fn_t led_init;
15
static igordev_write_fn_t led_write;
16
static igordev_deinit_fn_t led_deinit;
17
 
18
struct igordev igordev_ledstk500 = {
19
        .init = led_init,
20
        .deinit = led_deinit,
21
        .read = led_read,
22
        .write = led_write,
23
        .write_status = 0,
24
        .read_status = 0,
25
        .priv = NULL
26
};
27
 
28
/* Example initialization routine. */
29
void
30
led_init()
31
{
32
        /* Initialize buffers. Could probably be device-independent */
33
        igordev_ledstk500.read_status = igordev_ledstk500.write_status = IDEV_STATUS_OK;
34
 
35
        DDRC = 0xFF;
36
        /* Initialize skelton device-specific stuff. */
37
        PORTC = LED_INIT;
38
}
39
 
40
/* Example read routine. */
41
uint8_t
42
led_read(uint8_t *data, uint8_t num)
43
{
44
 
45
        if (num == 0)
46
                return (0);
47
        /* Read only the status of the device if num > 0 */
48
        /* Read data into device buffers and set pointer. */
49
        *data = PORTC;
50
        return (1);
51
}
52
 
53
/* Example write routine. */
54
uint8_t
55
led_write(uint8_t *data, uint8_t num)
56
{
57
        if (num == 0)
58
                return (0);
59
        PORTC = *data;
60
        return (0);
61
}
62
 
63
/* Deinit. */
64
void
65
led_deinit(void)
66
{
67
        PORTC = LED_UNINIT;
68
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.