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
cog_c_toggle
toggle_fw.cogc
1
/*
2
* code to toggle pins
3
* this is the cog C version of the code; it runs in a separate
4
* cog from the LMM kernel
5
* Copyright (c) 2011 Parallax, Inc.
6
* MIT Licensed (see at end of file for exact terms)
7
*/
8
9
#include <propeller.h>
10
#include "toggle.h"
11
12
/*
13
* our local variables (placed in cog memory) for speed
14
*/
15
static
_COGMEM
unsigned
int
waitdelay;
16
static
_COGMEM
unsigned
int
pins = 0xfffffff;
/* all pins except Serial IO and I2C */
17
static
_COGMEM
unsigned
int
nextcnt;
18
19
extern
int
togglecount;
20
21
_NATIVE
22
void
main
(
struct
toggle_mailbox
*m)
23
{
24
/* get a half second delay from parameters */
25
_DIRA = pins;
26
27
/* figure out how long to wait the first time */
28
nextcnt = _CNT + m->wait_time;
29
30
/* loop forever, updating the wait time from the mailbox */
31
for
(;;) {
32
waitdelay = m->wait_time;
33
_OUTA ^= pins;
34
togglecount++;
35
nextcnt = waitcnt2(nextcnt, waitdelay);
36
}
37
}
38
39
/* +--------------------------------------------------------------------
40
* | TERMS OF USE: MIT License
41
* +--------------------------------------------------------------------
42
* Permission is hereby granted, free of charge, to any person obtaining
43
* a copy of this software and associated documentation files
44
* (the "Software"), to deal in the Software without restriction,
45
* including without limitation the rights to use, copy, modify, merge,
46
* publish, distribute, sublicense, and/or sell copies of the Software,
47
* and to permit persons to whom the Software is furnished to do so,
48
* subject to the following conditions:
49
*
50
* The above copyright notice and this permission notice shall be
51
* included in all copies or substantial portions of the Software.
52
*
53
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
54
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
55
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
56
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
57
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
58
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
59
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
60
* +--------------------------------------------------------------------
61
*/
toggle_mailbox
Definition:
toggle.h:5
main
int main(void)
Definition:
GraphicsTest.c:20
Generated on Sat Aug 27 2016 00:58:10 for PropWare by
1.8.12