PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Examples
Multicore
Cog Run Example.c
1
/*
2
Cog Run Example.c
3
4
Run function that blinks a light with another cog continuously.
5
6
http://learn.parallax.com/multicore-approaches/simple-multicore
7
*/
8
9
#include "
simpletools.h
"
// Library include
10
11
void
blink();
// Forward declaration
12
13
int
main
()
// Main function
14
{
15
cog_run
(blink, 128);
// Run blink in other cog
16
}
17
18
void
blink()
// Blink function for other cog
19
{
20
while
(1)
// Endless loop for other cog
21
{
22
high
(26);
// P26 LED on
23
pause
(100);
// ...for 0.1 seconds
24
low
(26);
// P26 LED off
25
pause
(100);
// ...for 0.1 seconds
26
}
27
}
28
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_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