This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.include "p24Hxxxx.inc" | |
.text | |
.global __reset | |
__reset: | |
; Turn of analog to digital converter for all pins | |
mov #0xffff, W0 | |
mov W0, AD1PCFGL | |
; Set RA0 through RA3 as inputs (1), the rest as outputs (0) (easy way to remember: 1 looks like I for In, 0 looks like O for Out) | |
mov #0xf, W0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Flags to control how message handlers may be invoked. | |
* Message handlers can be invoked in a number of ways, depending on the threading model and thread safety of the handler. | |
*/ | |
enum HandlerFlags | |
{ | |
/* Threading Model Flags *******************/ | |
USER_MASK = 0x000f, // ..000000001111 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn clojure-games | |
"Test Gist for http://clojure-games.org" | |
[] | |
(println "Hello from clojure-games.org")) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TestModule : public MessageListener | |
{ | |
private: | |
// Instance variables which are modified by message handlers must be explicityly marked as mutable, since message handlers are const functions - this makes it obvious what is accessed. | |
mutable int value; | |
mutable const Mailbox& mailbox; | |
StateMachineMessageFunctor stateMachine; | |
// Message handlers | |
static void testHandler (const Message* const message, const Conversation con) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef unsigned int MessageID; | |
typedef unsigned int Conversation; | |
class Message | |
{ | |
public: | |
virtual ~Message () {} | |
virtual const MessageID& messageID () const=0; | |
virtual const char* senderName () const=0; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <class T> void map (std::deque<T> list, void (*f) (T)) { | |
for (std::deque<T>::iterator iter = list.begin(); iter != list.end(); iter++) { | |
#ifdef PARALLEL_MAP | |
ThreadPool::getIdle()->run<T>(f, *iter); | |
#else | |
f(*iter); | |
#endif | |
} | |
} | |
template <class T, class A1> void map (std::deque<T> list, void (*f) (T, A1), A1 arg1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <list> | |
#include <iostream> | |
// Replace with real mutex. | |
class Mutex | |
{ | |
public: | |
void lock () {} | |
void unlock () {} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@std.in; | |
a = [[int\]] <- 0; | |
op = [[char\]] <- ' '; | |
b = [[int\]] <- 0; | |
r = [[int\]] <- 0; | |
0 { | |
clock => [[int ms]] { | |
("\r" + ms/1000.0 + ":" + a + op + b + "=" + r) ->std.out; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun do-op a b op { | |
match op | |
with '+: a + b | |
with '-: a - b | |
with '*: a * b | |
with '/: a / b | |
with _: error | |
} | |
flow gen a b ops -> res { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(run-components | |
(make-component "Comp1" | |
{:init (fn [v s] | |
(event :print nil) | |
(event :set-msg "Ho") | |
(event :print nil) | |
{:msg "Hi"}) | |
:print (fn [v s] | |
(println (:msg s))) | |
:set-msg (fn [v s] |
NewerOlder