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

Subversion Repositories s6soc

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

Go to most recent revision | 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 "asmstartup.h"
42
#include "board.h"
43
 
44
void    zip_idle(void);
45
 
46
asm("\t.section\t.start\n"
47
"\t.global\t_start\n"
48
"\t.type\t_start,@function\n"
49
"_start:\n"
50
"\tMOV\tkernel_exit(PC),uPC\n"
51
"\tLDI 104,R0\n"
52
"\tSW R0,0x41c\n"
53
"\tLDI 0xff,R0\n"
54
"\tSW R0,0x414\n"
55
"\tLDI\t_top_of_stack,SP\n"
56
"\tJSR\tentry\n"
57
"\tNEXIT\tR0\n"
58
"kernel_exit:\n"
59
"\tBUSY\n"
60
"\t.section\t.text");
61
 
62
void entry(void) {
63
        const char      *msg = "Hello, World!\r\n", *ptr = msg;
64
        int     count = 0;
65
 
66
        _sys->io_spio = 0x0fa;
67
        _sys->io_timer = TM_REPEAT | (TM_ONE_SECOND/4);
68
        _sys->io_pic = INT_ENABLEV(INT_TIMER)|INT_CLEAR(INT_TIMER);
69
 
70
        do {
71
                zip_idle();
72
                int picv = _sys->io_pic;
73
                if (picv & INT_TIMER) {
74
                        int ledv = _sys->io_spio;
75
                        ledv <<= 1;
76
                        ledv = ledv & 0x0f;
77
                        if (ledv == 0)
78
                                ledv = 1;
79
                        _sys->io_spio = ledv | 0x0f0;
80
 
81
                        if (*ptr)
82
                                _sys->io_uart = (unsigned)*ptr++;
83
                        if (count++ > 4*60) {
84
                                count = 0;
85
                                ptr = msg;
86
                        }
87
                }
88
 
89
                _sys->io_pic = INT_ENABLEV(INT_TIMER)|INT_CLEAR(INT_TIMER);
90
        } while(1);
91
}
92
 
93
// PPONP16P
94
// 00120O91
95
// 00120NM3
96
// 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.