File tree 3 files changed +13
-11
lines changed
3 files changed +13
-11
lines changed Original file line number Diff line number Diff line change 15
15
16
16
#include " CurieMailbox.h"
17
17
18
- int receiveChannel = 0 ; /* Receiving messages on this channel */
19
-
20
18
void setup (void ) {
21
19
Serial.begin (9600 );
22
20
23
21
/* Enable the mailbox */
24
22
CurieMailbox.begin ();
25
23
26
- /* Enable channel for receiving messages */
27
- CurieMailbox.enableReceive (receiveChannel);
24
+ /* Enable all channels for receiving messages */
25
+ for (int i = 0 ; i < CurieMailbox.numChannels ; ++i) {
26
+ CurieMailbox.enableReceive (i);
27
+ }
28
28
}
29
29
30
30
void printMessageAsString (CurieMailboxMsg msg)
31
31
{
32
32
char *p = (char *)msg.data ;
33
- Serial.print (" Received message ' " + String (p ) + " ' from channel " );
34
- Serial.println (msg. channel );
33
+ Serial.print (" Received message from channel " + String (msg. channel ) + " : " );
34
+ Serial.println (String (p) );
35
35
}
36
36
37
37
void loop (void ) {
Original file line number Diff line number Diff line change 4
4
#include " CurieMailbox.h"
5
5
6
6
#define BUFSIZE 33
7
- #define NUM_CHANNELS 8
8
7
#define CHANNEL_STS_MASK 0x1
9
8
#define CHANNEL_INT_MASK 0x2
10
9
#define CTRL_WORD_MASK 0x7FFFFFFF
11
10
#define CHALL_STATUS_MASK 0xFFFF
12
11
#define CHANNEL_STS_BITS (CHANNEL_STS_MASK | CHANNEL_INT_MASK)
13
12
14
- #define CAP_CHAN (chan ) chan = (chan >= NUM_CHANNELS) ? \
15
- NUM_CHANNELS - 1 : ((chan < 0 ) ? 0 : chan)
13
+ #define CAP_CHAN (chan ) chan = (chan >= CurieMailbox.numChannels) ?\
14
+ CurieMailbox.numChannels - 1 : ((chan < 0 ) \
15
+ ? 0 : chan)
16
16
17
17
/* Mailbox channel status register */
18
18
#define IO_REG_MAILBOX_CHALL_STS (SCSS_REGISTER_BASE + 0xAC0 )
@@ -122,7 +122,7 @@ static void mbox_isr (void)
122
122
123
123
sts = get_chall_sts ();
124
124
/* Get channel number */
125
- for (i = 0 ; i < NUM_CHANNELS ; ++i) {
125
+ for (i = 0 ; i < CurieMailbox. numChannels ; ++i) {
126
126
if (sts & (1 << (i * 2 + 1 ))) {
127
127
break ;
128
128
}
@@ -135,7 +135,7 @@ static void mbox_hardware_init (void)
135
135
{
136
136
int i;
137
137
138
- for (i = 0 ; i < NUM_CHANNELS ; ++i) {
138
+ for (i = 0 ; i < CurieMailbox. numChannels ; ++i) {
139
139
mbox[i].sts &= ~(CHANNEL_STS_BITS);
140
140
}
141
141
}
Original file line number Diff line number Diff line change 5
5
6
6
class CurieMailboxClass {
7
7
public:
8
+ const int numChannels = 8 ;
9
+
8
10
CurieMailboxClass (void );
9
11
void begin (void );
10
12
void begin (bool master);
You can’t perform that action at this time.
0 commit comments