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
simple
mstimer.c
1
13
#include "simpletools.h"
// Include simpletools
14
#include "mstimer.h"
15
16
static
volatile
int
t, dt, cog;
// Global var for cogs to share
17
static
unsigned
int
stack[40 + 25];
// Stack vars for other cog
18
19
void
ms_timer(
void
*par);
20
21
int
mstime_start()
22
{
23
mstime_stop();
24
cog = 1 + cogstart(ms_timer, NULL, stack,
sizeof
(stack));
25
}
26
27
void
mstime_stop()
28
{
29
if
(cog)
30
{
31
cogstop(cog -1);
32
cog = 0;
33
}
34
}
35
36
int
mstime_get()
37
{
38
return
t;
39
}
40
41
void
mstime_reset()
42
{
43
t = 0;
44
}
45
46
void
mstime_set(
int
newTime)
47
{
48
t = newTime;
49
}
50
51
// Function runs in another cog
52
void
ms_timer(
void
*par)
53
{
54
dt = CLKFREQ/1000;
55
int
ticks = CNT;
56
while
(1)
57
{
58
waitcnt(ticks+=dt);
59
t++;
60
}
61
}
62
Generated on Sat Aug 27 2016 00:58:09 for PropWare by
1.8.12