1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/projects/pingpong/main.c

34 lines
730 B
C

#include <stdio.h>
#include <thread.h>
#include <msg.h>
#include <kernel.h>
void second_thread(void) {
printf("second_thread starting.\n");
msg m;
while(1) {
msg_receive(&m);
// printf("2nd: got msg from %i\n", m.sender_pid);
m.content.value++;
msg_send(&m, m.sender_pid, true);
}
}
int main(void)
{
printf("Hello world!\n");
msg m;
int pid = thread_create(KERNEL_CONF_STACKSIZE_MAIN, PRIORITY_MAIN-1, CREATE_WOUT_YIELD | CREATE_STACKTEST, second_thread, "pong");
m.content.value = 1;
while(1) {
msg_send(&m, pid, true);
msg_receive(&m);
printf("Got msg with content %i\n", m.content.value);
}
}