PropWare
C++ objects and CMake build system for Parallax Propeller
Home
Download
Getting Started
Documentation
Reference
About
Related Links
Namespace List
Class List
File List
Examples
Build System
File List
File Members
propsideworkspace
Propeller GCC Demos
toggle
gas_toggle
toggle.c
1
11
#include "stdio.h"
// using temporary stdio
12
#include "propeller.h"
13
14
/*
15
* function to start up a new cog running the toggle
16
* code (which we've placed in the .coguser0 section)
17
*/
18
void
start_cog(
void
)
19
{
20
extern
unsigned
int
_load_start_coguser0[];
21
22
/* now start the kernel */
23
cognew(_load_start_coguser0, 0);
24
}
25
26
/* variables that we share between cogs */
27
volatile
unsigned
int
wait_time;
28
volatile
unsigned
int
pins;
29
30
31
/*
32
* main code
33
* This is the code running in the LMM cog (cog 0).
34
* It launches another cog to actually run the
35
* toggling code
36
*/
37
#define MIN_GAP 400000
38
39
void
main
(
int
argc,
char
* argv[])
40
{
41
int
n;
42
int
result;
43
unsigned
int
startTime;
44
unsigned
int
endTime;
45
unsigned
int
executionTime;
46
unsigned
int
rawTime;
47
48
printf(
"hello, world!\n"
);
49
50
/* set up the parameters for the other cog */
51
pins = 0x3fffffff;
52
wait_time = _clkfreq;
/* start by waiting for 1 second */
53
54
/* start the new cog */
55
start_cog();
56
printf(
"toggle cog has started\n"
);
57
58
/* every 2 seconds update the flashing frequency so the
59
light blinks faster and faster */
60
while
(1) {
61
sleep(2);
62
wait_time = wait_time >> 1;
63
if
(wait_time < MIN_GAP)
64
wait_time = _clkfreq;
65
}
66
}
67
68
/* +--------------------------------------------------------------------
69
* ¦ TERMS OF USE: MIT License
70
* +--------------------------------------------------------------------
71
* Permission is hereby granted, free of charge, to any person obtaining
72
* a copy of this software and associated documentation files
73
* (the "Software"), to deal in the Software without restriction,
74
* including without limitation the rights to use, copy, modify, merge,
75
* publish, distribute, sublicense, and/or sell copies of the Software,
76
* and to permit persons to whom the Software is furnished to do so,
77
* subject to the following conditions:
78
*
79
* The above copyright notice and this permission notice shall be
80
* included in all copies or substantial portions of the Software.
81
*
82
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
83
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
84
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
85
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
86
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
87
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
88
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
89
* +--------------------------------------------------------------------
90
*/
main
int main(void)
Definition:
GraphicsTest.c:20
Generated on Sat Aug 27 2016 00:58:09 for PropWare by
1.8.12