PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Multicore
Cog End Example.c
1
/*
2
Cog End Example.c
3
4
Run function that blinks a light with another cog continuously.
5
Shut down that other cog from main routine.
6
7
http://learn.parallax.com/multicore-approaches/stopping-cores
8
*/
9
10
#include "
simpletools.h
"
// Library include
11
12
void
blink();
// Forward declaration
13
14
int
main
()
// Main function
15
{
16
int
*cog =
cog_run
(blink, 128);
// Run blink in other cog
17
pause
(3000);
// Wait while other cog blinks LED
18
cog_end
(cog);
19
}
20
21
void
blink()
// Blink function for other cog
22
{
23
while
(1)
// Endless loop for other cog
24
{
25
high
(26);
// P26 LED on
26
pause
(100);
// ...for 0.1 seconds
27
low
(26);
// P26 LED off
28
pause
(100);
// ...for 0.1 seconds
29
}
30
}
31
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
low
void low(int pin)
Set an I/O pin to output-low.
Definition:
low.c:19
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
main
int main(void)
Definition:
GraphicsTest.c:20
cog_end
void cog_end(int *coginfo)
End function code running in another cog that was launched with cog_run.
Definition:
cogend.c:15
cog_run
int * cog_run(void(*function)(void *par), int stacksize)
Run a function's code in the next available cog (processor).
Definition:
cogrun.c:15
high
void high(int pin)
Set an I/O pin to output-high.
Definition:
high.c:19
Generated on Fri May 20 2022 16:48:04 for PropWare by
1.8.17