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

Subversion Repositories de1_olpcl2294_system

[/] [de1_olpcl2294_system/] [trunk/] [sw/] [ecos/] [debug/] [main.c] - Blame information for rev 8

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 qaztronic
//
2
//
3
//
4
 
5
#include <stdio.h>
6
#include <math.h>
7
#include <stdlib.h>
8
 
9
#include <cyg/kernel/kapi.h>
10
 
11
#include "LPC22xx.h"
12
#include "lib_dbg_sh.h"
13 8 qaztronic
#include "oc_gpio.h"
14 7 qaztronic
 
15
extern void dbg_sh(void);
16
 
17 8 qaztronic
static cyg_interrupt int1;
18
static cyg_handle_t int1_handle;
19 7 qaztronic
 
20 8 qaztronic
 
21
//
22
// Interrupt service routine for interrupt 1.
23
//
24
cyg_uint32 interrupt_1_isr(
25
            cyg_vector_t vector,
26
            cyg_addrword_t data)
27
{
28
  // Block this interrupt from occurring until
29
  // the DSR completes.
30
  cyg_interrupt_mask( vector );
31
 
32
  // disable and clear gpio b intr
33
  OC_GPIO_B_RGPIO_INTE &= 0x7fffffff;
34
  OC_GPIO_B_RGPIO_INTS &= 0x7fffffff;
35
 
36
 
37
  // Tell the processor that we have received
38
  // the interrupt.
39
  cyg_interrupt_acknowledge( vector );
40
 
41
  // Tell the kernel that chained interrupt processing
42
  // is done and the DSR needs to be executed next.
43
  return( CYG_ISR_HANDLED | CYG_ISR_CALL_DSR );
44
}
45
 
46
// 
47
// Deferred service routine for interrupt 1.
48
// 
49
void interrupt_1_dsr(
50
       cyg_vector_t vector,
51
       cyg_ucount32 count,
52
       cyg_addrword_t data)
53
{
54
 
55
  hex_led_command( DE1_HEX_LED_INCREMENT, 0);
56
 
57
  OC_GPIO_B_RGPIO_INTE |=  0x80000000;
58
 
59
  // Allow this interrupt to occur again.
60
  cyg_interrupt_unmask( vector );
61
}
62
 
63
 
64 7 qaztronic
/* now declare (and allocate space for) some kernel objects,
65
   like the two threads we will use */
66
cyg_thread thread_s[2];         /* space for two thread objects */
67
 
68
char stack[2][4096];            /* space for two 4K stacks */
69
 
70
/* now the handles for the threads */
71
cyg_handle_t dbg_shell_thread, simple_threadB;
72
 
73
/* and now variables for the procedure which is the thread */
74
cyg_thread_entry_t dbg_shell;
75
cyg_thread_entry_t simple_program;
76
 
77
/* we install our own startup routine which sets up threads */
78
void cyg_user_start(void)
79 8 qaztronic
{
80 7 qaztronic
  // enable cs3
81
  PINSEL2 = 0x0f814924;
82
 
83
  // configure BCFG3
84
  *((unsigned int *)0xFFE0000C) = 0x20007de7;
85 8 qaztronic
 
86
  // reset FPGA
87
  *((unsigned int *)0x83300000) = 0x00000001;
88
  cyg_thread_delay(10);
89 7 qaztronic
 
90
  // configure gpio
91 8 qaztronic
  fled_init(0x00000003);
92
  hex_led_init(0x00);
93 7 qaztronic
 
94
  cyg_thread_create(4, dbg_shell, (cyg_addrword_t) 0,
95
                    "DBG Shell", (void *) stack[0], 4096,
96
                    &dbg_shell_thread, &thread_s[0]);
97 8 qaztronic
 
98 7 qaztronic
  cyg_thread_create(4, simple_program, (cyg_addrword_t) 1,
99
                    "Thread B", (void *) stack[1], 4096,
100
                    &simple_threadB, &thread_s[1]);
101
 
102
  cyg_thread_resume(dbg_shell_thread);
103
  cyg_thread_resume(simple_threadB);
104 8 qaztronic
 
105
 
106
  cyg_vector_t int1_vector = CYGNUM_HAL_INTERRUPT_EINT3;
107
//   cyg_priority_t int1_priority = CYGNUM_HAL_PRI_HIGH;
108
  cyg_priority_t int1_priority = 0;
109
 
110
  //
111
  // Create interrupt 1.
112
  //
113
  cyg_interrupt_create(
114
     int1_vector,
115
     int1_priority,
116
     0,
117
     &interrupt_1_isr,
118
     &interrupt_1_dsr,
119
     &int1_handle,
120
     &int1);
121
 
122
  // Attach the interrupt created to the vector.
123
  cyg_interrupt_attach( int1_handle );
124
 
125
  // configure gpio b
126
  OC_GPIO_B_RGPIO_INTS &= 0x7fffffff;
127
  OC_GPIO_B_RGPIO_INTE =  0x80000000;
128
  OC_GPIO_B_RGPIO_CTRL =  0x00000001;
129
 
130
  // configure eint3
131
  *((unsigned int *)0xE002C004) |= 0x20000000;
132
 
133
 
134
  // Unmask the interrupt we just configured.
135
  cyg_interrupt_unmask( int1_vector );
136
 
137 7 qaztronic
}
138
 
139
/* this is a simple program which runs in a thread */
140
void dbg_shell(cyg_addrword_t data)
141
{
142
  int message = (int) data;
143
 
144
  printf("Beginning execution; thread data is %d\n", message);
145
 
146
  dbg_sh();
147
 
148
}
149
 
150
/* this is a simple program which runs in a thread */
151
void simple_program(cyg_addrword_t data)
152
{
153
 
154
  for (;;) {
155
 
156 8 qaztronic
    OC_GPIO_B_RGPIO_OUT ^= 0x00000001;
157
//     hex_led_command( DE1_HEX_LED_INCREMENT, 0);
158 7 qaztronic
 
159 8 qaztronic
    cyg_thread_delay(100);
160 7 qaztronic
  }
161 8 qaztronic
 
162 7 qaztronic
}
163
 
164
 

powered by: WebSVN 2.1.0

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