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

Subversion Repositories amber

[/] [amber/] [trunk/] [sw/] [boot-loader-ethmac/] [led.c] - Blame information for rev 80

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 80 csantifort
/*----------------------------------------------------------------
2
//                                                              //
3
//  boot-loader-ethmac.c                                        //
4
//                                                              //
5
//  This file is part of the Amber project                      //
6
//  http://www.opencores.org/project,amber                      //
7
//                                                              //
8
//  Description                                                 //
9
//  The main functions for the boot loader application. This    //
10
//  application is embedded in the FPGA's SRAM and is used      //
11
//  to load larger applications into the DDR3 memory on         //
12
//  the development board.                                      //
13
//                                                              //
14
//  Author(s):                                                  //
15
//      - Conor Santifort, csantifort.amber@gmail.com           //
16
//                                                              //
17
//////////////////////////////////////////////////////////////////
18
//                                                              //
19
// Copyright (C) 2011 Authors and OPENCORES.ORG                 //
20
//                                                              //
21
// This source file may be used and distributed without         //
22
// restriction provided that this copyright statement is not    //
23
// removed from the file and that any derivative work contains  //
24
// the original copyright notice and the associated disclaimer. //
25
//                                                              //
26
// This source file is free software; you can redistribute it   //
27
// and/or modify it under the terms of the GNU Lesser General   //
28
// Public License as published by the Free Software Foundation; //
29
// either version 2.1 of the License, or (at your option) any   //
30
// later version.                                               //
31
//                                                              //
32
// This source is distributed in the hope that it will be       //
33
// useful, but WITHOUT ANY WARRANTY; without even the implied   //
34
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
35
// PURPOSE.  See the GNU Lesser General Public License for more //
36
// details.                                                     //
37
//                                                              //
38
// You should have received a copy of the GNU Lesser General    //
39
// Public License along with this source; if not, download it   //
40
// from http://www.opencores.org/lgpl.shtml                     //
41
//                                                              //
42
----------------------------------------------------------------*/
43
 
44
#include "amber_registers.h"
45
#include "timer.h"
46
#include "led.h"
47
 
48
 
49
/* global variables */
50
time_t* led_flash_timer_g;
51
 
52
 
53
void init_led()
54
{
55
    /* Turn off all LEDs */
56
    led_clear();
57
 
58
    /* create some timers */
59
    led_flash_timer_g = new_timer();
60
    set_timer(led_flash_timer_g, 500);
61
}
62
 
63
 
64
void process_led()
65
{
66
    /* Flash a heartbeat LED */
67
    if (timer_expired(led_flash_timer_g)) {
68
        led_flip(0);
69
        set_timer(led_flash_timer_g, 500);
70
        }
71
}
72
 
73
 
74
/* turn off all leds */
75
void led_clear()
76
{
77
    *(unsigned int *) ADR_AMBER_TEST_LED = 0;
78
}
79
 
80
 
81
/* led is either 0,1,2 or 3 */
82
void led_flip(int led)
83
{
84
    int current_value;
85
    current_value = *(unsigned int *) ADR_AMBER_TEST_LED;
86
    *(unsigned int *) ADR_AMBER_TEST_LED = current_value ^ (1<<led);
87
}
88
 
89
 
90
 
91
/* led is either 0,1,2 or 3 */
92
void led_on(int led)
93
{
94
    int current_value;
95
    current_value = *(unsigned int *) ADR_AMBER_TEST_LED;
96
    *(unsigned int *) ADR_AMBER_TEST_LED = current_value | (1<<led);
97
}
98
 
99
 
100
 
101
/* led is either 0,1,2 or 3 */
102
void led_off(int led)
103
{
104
    int current_value;
105
    current_value = *(unsigned int *) ADR_AMBER_TEST_LED;
106
    *(unsigned int *) ADR_AMBER_TEST_LED = current_value & ~(1<<led);
107
}
108
 
109
 
110
/* led is either 0,1,2 or 3 */
111
void led_123(int value)
112
{
113
    int current_value;
114
    current_value = *(unsigned int *) ADR_AMBER_TEST_LED;
115
    *(unsigned int *) ADR_AMBER_TEST_LED = (current_value & 1) | value<<1;
116
}

powered by: WebSVN 2.1.0

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