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

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [sw/] [dev/] [blinky.c] - Blame information for rev 53

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 47 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    blinky.c
4
//
5
// Project:     CMod S6 System on a Chip, ZipCPU demonstration project
6
//
7
// Purpose:     To toggle/blink the LEDs in a fashion that will let us know
8
//              1) that the CPU is running, 2) that the LEDs are working, and
9
//      even better, 3) that the buttons are working.
10
//
11
//
12
// Creator:     Dan Gisselquist, Ph.D.
13
//              Gisselquist Technology, LLC
14
//
15
////////////////////////////////////////////////////////////////////////////////
16
//
17
// Copyright (C) 2015-2017, Gisselquist Technology, LLC
18
//
19
// This program is free software (firmware): you can redistribute it and/or
20
// modify it under the terms of  the GNU General Public License as published
21
// by the Free Software Foundation, either version 3 of the License, or (at
22
// your option) any later version.
23
//
24
// This program is distributed in the hope that it will be useful, but WITHOUT
25
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
26
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
27
// for more details.
28
//
29
// You should have received a copy of the GNU General Public License along
30
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
31
// target there if the PDF file isn't present.)  If not, see
32
// <http://www.gnu.org/licenses/> for a copy.
33
//
34
// License:     GPL, v3, as defined and found on www.gnu.org,
35
//              http://www.gnu.org/licenses/gpl.html
36
//
37
//
38
////////////////////////////////////////////////////////////////////////////////
39
//
40
//
41
#include "board.h"
42
 
43
void    zip_idle(void);
44
 
45
void entry(void) {
46
        const char      *msg = "Hello, World!\r\n", *ptr = msg;
47
        int     count = 0;
48
 
49
        _sys->io_spio = 0x0fa;
50
        _sys->io_timer = TM_REPEAT | (TM_ONE_SECOND/4);
51
        _sys->io_pic = INT_ENABLEV(INT_TIMER)|INT_CLEAR(INT_TIMER);
52
 
53
        do {
54
                zip_idle();
55
                int picv = _sys->io_pic;
56
                if (picv & INT_TIMER) {
57
                        int ledv = _sys->io_spio;
58
                        ledv <<= 1;
59
                        ledv = ledv & 0x0f;
60
                        if (ledv == 0)
61
                                ledv = 1;
62
                        _sys->io_spio = ledv | 0x0f0;
63
 
64
                        if (*ptr)
65
                                _sys->io_uart = (unsigned)*ptr++;
66
                        if (count++ > 4*60) {
67
                                count = 0;
68
                                ptr = msg;
69
                        }
70
                }
71
 
72
                _sys->io_pic = INT_ENABLEV(INT_TIMER)|INT_CLEAR(INT_TIMER);
73
        } while(1);
74
}
75
 
76
// PPONP16P
77
// 00120O91
78
// 00120NM3
79
// 00120E91 = 1183377 ~= 91029 / char, at 0x208d 8333/baud, 83,330 per char

powered by: WebSVN 2.1.0

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