sPyNNaker neural_modelling 7.3.1
Loading...
Searching...
No Matches
munich_protocol.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2017 The University of Manchester
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * https://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
27#include <debug.h>
28#include <stdint.h>
29#include <stdbool.h>
30
31// ----------------------------------------------------------------------
32
34typedef struct {
35 uint32_t device : 3;
36 uint32_t payload_format : 1;
37 uint32_t instruction : 7;
38 uint32_t instance_key : 21;
45
47enum {
50 OFFSET_TO_D = 0
51};
52
54enum {
59};
60
70#define MUNICH_KEY(I, F, D) \
71 ((I << OFFSET_TO_I) | (F << OFFSET_TO_F) | (D << OFFSET_TO_D))
72
81#define MUNICH_KEY_I_D(I, D) MUNICH_KEY(I, 0, D)
82
87#define MUNICH_KEY_I(I) MUNICH_KEY(I, 0, 0)
88
90enum {
99};
100
102enum {
107
122
129
142
149
162
173
174 // set laser params for pushbot
181
182 // set led params for pushbot
191
192 // set speaker params for pushbot
201
202 // pushbot motor control
212
214enum {
226
228enum {
229 PAYLOAD_RETINA_NO_DOWN_SAMPLING_IN_PAYLOAD =
240
242enum {
243 PAYLOAD_MASTER_SLAVE_USE_INTERNAL_COUNTER = 0,
244 PAYLOAD_MASTER_SLAVE_SET_SLAVE = 1,
245 PAYLOAD_MASTER_SLAVE_SET_MASTER_CLOCK_NOT_STARTED = 2,
246 PAYLOAD_MASTER_SLAVE_SET_MASTER_CLOCK_ACTIVE = 4
247};
248
258
260typedef struct multicast_packet {
261 uint32_t key;
262 uint32_t payload;
263 uint32_t payload_flag;
265
268
272static uint32_t instance_key = 0;
273
274// ----------------------------------------------------------------------
275// Protocol core control
276
283static inline void set_protocol_mode(
284 munich_protocol_modes_e new_mode, uint32_t new_instance_key) {
285 mode = new_mode;
286 instance_key = new_instance_key;
287}
288
293 uint32_t new_key) {
294 return (multicast_packet) {
296 .payload = new_key,
297 .payload_flag = WITH_PAYLOAD
298 };
299}
300
306 return (multicast_packet) {
308 .payload = (uint32_t) mode,
309 .payload_flag = WITH_PAYLOAD
310 };
311}
312
313// ----------------------------------------------------------------------
314// Generic retina control
315
321 uint32_t new_key, uint32_t uart_id) {
322 return (multicast_packet) {
324 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
325 .payload = new_key,
326 .payload_flag = WITH_PAYLOAD
327 };
328}
329
334 uint32_t uart_id) {
335 return (multicast_packet) {
337 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
338 .payload = 0,
339 .payload_flag = NO_PAYLOAD
340 };
341}
342
346static inline multicast_packet munich_protocol_reset_retina(uint32_t uart_id) {
347 return (multicast_packet) {
348 .key = (RESET_RETINA_KEY | (uart_id << OFFSET_FOR_UART_ID) |
350 .payload = 0,
351 .payload_flag = NO_PAYLOAD
352 };
353}
354
355// ----------------------------------------------------------------------
356// Protocol master/slave control
357
362static inline multicast_packet
364 uint32_t uart_id) {
365 return (multicast_packet) {
366 .key = (MASTER_SLAVE_KEY | (uart_id << OFFSET_FOR_UART_ID) |
368 .payload = PAYLOAD_MASTER_SLAVE_USE_INTERNAL_COUNTER,
369 .payload_flag = WITH_PAYLOAD
370 };
371}
372
377 uint32_t uart_id) {
378 return (multicast_packet) {
379 .key = (MASTER_SLAVE_KEY | (uart_id << OFFSET_FOR_UART_ID) |
381 .payload = PAYLOAD_MASTER_SLAVE_SET_SLAVE,
382 .payload_flag = WITH_PAYLOAD
383 };
384}
385
389static inline multicast_packet
391 uint32_t uart_id) {
392 return (multicast_packet) {
393 .key = (MASTER_SLAVE_KEY | (uart_id << OFFSET_FOR_UART_ID) |
395 .payload = PAYLOAD_MASTER_SLAVE_SET_MASTER_CLOCK_NOT_STARTED,
396 .payload_flag = WITH_PAYLOAD
397 };
398}
399
403static inline multicast_packet
405 uint32_t uart_id) {
406 return (multicast_packet) {
407 .key = (MASTER_SLAVE_KEY | (uart_id << OFFSET_FOR_UART_ID) |
409 .payload = PAYLOAD_MASTER_SLAVE_SET_MASTER_CLOCK_ACTIVE,
410 .payload_flag = WITH_PAYLOAD
411 };
412}
413
420 uint32_t bias_id, uint32_t bias_value, uint32_t uart_id) {
421 return (multicast_packet) {
422 .key = (MASTER_SLAVE_KEY | (uart_id << OFFSET_FOR_UART_ID) |
424 .payload = ((bias_id << 0) | (bias_value << 8)),
425 .payload_flag = WITH_PAYLOAD
426 };
427}
428
429// ----------------------------------------------------------------------
430// Generic sensor control
431
436 uint32_t sensor_id) {
437 return (multicast_packet) {
439 .payload = (sensor_id << PAYLOAD_SENSOR_ID_OFFSET),
440 .payload_flag = WITH_PAYLOAD
441 };
442}
443
448 uint32_t sensor_id) {
449 return (multicast_packet) {
451 .payload = (sensor_id << PAYLOAD_SENSOR_ID_OFFSET),
452 .payload_flag = WITH_PAYLOAD
453 };
454}
455
460static inline multicast_packet
462 uint32_t sensor_id, uint32_t time_in_ms) {
463 return (multicast_packet) {
465 .payload = ((sensor_id << PAYLOAD_SENSOR_ID_OFFSET) |
466 (time_in_ms << PAYLOAD_OFFSET_FOR_SENSOR_TIME)),
467 .payload_flag = WITH_PAYLOAD
468 };
469}
470
471// ----------------------------------------------------------------------
472// Generic motor control
473
479 uint32_t enable_disable, uint32_t uart_id) {
480 return (multicast_packet) {
481 .key = DISABLE_MOTOR_KEY | (uart_id << OFFSET_FOR_UART_ID) |
483 .payload = enable_disable,
484 .payload_flag = WITH_PAYLOAD
485 };
486}
487
492static inline multicast_packet
494 uint32_t time_in_ms, uint32_t uart_id) {
495 return (multicast_packet) {
498 .payload = time_in_ms,
499 .payload_flag = WITH_PAYLOAD
500 };
501}
502
507static inline multicast_packet
509 uint32_t pwm_signal, uint32_t uart_id) {
510 return (multicast_packet) {
513 .payload = pwm_signal,
514 .payload_flag = WITH_PAYLOAD
515 };
516}
517
522static inline multicast_packet
524 uint32_t pwm_signal, uint32_t uart_id) {
525 return (multicast_packet) {
528 .payload = pwm_signal,
529 .payload_flag = WITH_PAYLOAD
530 };
531}
532
537static inline multicast_packet
539 uint32_t pwm_signal, uint32_t uart_id) {
540 return (multicast_packet) {
543 .payload = pwm_signal,
544 .payload_flag = WITH_PAYLOAD
545 };
546}
547
552static inline multicast_packet
554 uint32_t pwm_signal, uint32_t uart_id) {
555 return (multicast_packet) {
558 .payload = pwm_signal,
559 .payload_flag = WITH_PAYLOAD
560 };
561}
562
563// ----------------------------------------------------------------------
564// Generic pulse width modulation (PWM) control
565
571 uint32_t timer_period, uint32_t uart_id) {
572 return (multicast_packet) {
574 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
575 .payload = timer_period,
576 .payload_flag = WITH_PAYLOAD
577 };
578}
579
585 uint32_t timer_period, uint32_t uart_id) {
586 return (multicast_packet) {
588 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
589 .payload = timer_period,
590 .payload_flag = WITH_PAYLOAD
591 };
592}
593
599 uint32_t timer_period, uint32_t uart_id) {
600 return (multicast_packet) {
602 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
603 .payload = timer_period,
604 .payload_flag = WITH_PAYLOAD
605 };
606}
607
612static inline multicast_packet
614 uint32_t timer_period, uint32_t uart_id) {
615 return (multicast_packet) {
617 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
618 .payload = timer_period,
619 .payload_flag = WITH_PAYLOAD
620 };
621}
622
627static inline multicast_packet
629 uint32_t timer_period, uint32_t uart_id) {
630 return (multicast_packet) {
632 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
633 .payload = timer_period,
634 .payload_flag = WITH_PAYLOAD
635 };
636}
637
642static inline multicast_packet
644 uint32_t timer_period, uint32_t uart_id) {
645 return (multicast_packet) {
647 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
648 .payload = timer_period,
649 .payload_flag = WITH_PAYLOAD
650 };
651}
652
657static inline multicast_packet
659 uint32_t timer_period, uint32_t uart_id) {
660 return (multicast_packet) {
662 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
663 .payload = timer_period,
664 .payload_flag = WITH_PAYLOAD
665 };
666}
667
672static inline multicast_packet
674 uint32_t timer_period, uint32_t uart_id) {
675 return (multicast_packet) {
677 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
678 .payload = timer_period,
679 .payload_flag = WITH_PAYLOAD
680 };
681}
682
687static inline multicast_packet
689 uint32_t timer_period, uint32_t uart_id) {
690 return (multicast_packet) {
692 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
693 .payload = timer_period,
694 .payload_flag = WITH_PAYLOAD
695 };
696}
697
698// ----------------------------------------------------------------------
699// Generic I/O control
700
704 return (multicast_packet) {
706 .payload = 0,
707 .payload_flag = NO_PAYLOAD
708 };
709}
710
714// This is extremely hard to intuit the meaning of!
716 uint32_t payload) {
717 return (multicast_packet) {
719 .payload = payload,
720 .payload_flag = WITH_PAYLOAD
721 };
722}
723
727// This is extremely hard to intuit the meaning of!
728static inline multicast_packet
730 uint32_t payload) {
731 return (multicast_packet) {
733 .payload = payload,
734 .payload_flag = WITH_PAYLOAD
735 };
736}
737
741// This is extremely hard to intuit the meaning of!
742static inline multicast_packet
744 uint32_t payload) {
745 return (multicast_packet) {
747 .payload = payload,
748 .payload_flag = WITH_PAYLOAD
749 };
750}
751
755// This is extremely hard to intuit the meaning of!
756static inline multicast_packet
758 uint32_t payload) {
759 return (multicast_packet) {
761 .payload = payload,
762 .payload_flag = WITH_PAYLOAD
763 };
764}
765
766// ----------------------------------------------------------------------
767// PushBot laser control
768
773static inline multicast_packet
775 uint32_t total_period, uint32_t uart_id) {
777 log_error("The mode you configured is not the pushbot, "
778 "and so this message is invalid for mode %d", mode);
779 }
780
781 return (multicast_packet) {
783 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
784 .payload = total_period,
785 .payload_flag = WITH_PAYLOAD
786 };
787}
788
793static inline multicast_packet
795 uint32_t active_time, uint32_t uart_id) {
797 log_error("The mode you configured is not the pushbot, "
798 "and so this message is invalid for mode %d", mode);
799 }
800
801 return (multicast_packet) {
803 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
804 .payload = active_time,
805 .payload_flag = WITH_PAYLOAD
806 };
807}
808
814 uint32_t frequency, uint32_t uart_id) {
816 log_error("The mode you configured is not the pushbot, "
817 "and so this message is invalid for mode %d", mode);
818 }
819
820 return (multicast_packet) {
823 .payload = frequency,
824 .payload_flag = WITH_PAYLOAD
825 };
826}
827
828// ----------------------------------------------------------------------
829// PushBot speaker control
830
836static inline multicast_packet
838 uint32_t total_period, uint32_t uart_id) {
840 log_error("The mode you configured is not the pushbot, "
841 "and so this message is invalid for mode %d", mode);
842 }
843
844 return (multicast_packet) {
846 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
847 .payload = total_period,
848 .payload_flag = WITH_PAYLOAD
849 };
850}
851
857static inline multicast_packet
859 uint32_t active_time, uint32_t uart_id) {
861 log_error("The mode you configured is not the pushbot, "
862 "and so this message is invalid for mode %d", mode);
863 }
864
865 return (multicast_packet) {
867 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
868 .payload = active_time,
869 .payload_flag = WITH_PAYLOAD
870 };
871}
872
879 uint32_t frequency, uint32_t uart_id) {
881 log_error("The mode you configured is not the pushbot, "
882 "and so this message is invalid for mode %d", mode);
883 }
884
885 return (multicast_packet) {
888 .payload = frequency,
889 .payload_flag = WITH_PAYLOAD
890 };
891}
892
899 uint32_t melody, uint32_t uart_id) {
901 log_error("The mode you configured is not the pushbot, "
902 "and so this message is invalid for mode %d", mode);
903 }
904
905 return (multicast_packet) {
908 .payload = melody,
909 .payload_flag = WITH_PAYLOAD
910 };
911}
912
913// ----------------------------------------------------------------------
914// PushBot LED control
915
921 uint32_t total_period, uint32_t uart_id) {
923 log_error("The mode you configured is not the pushbot, "
924 "and so this message is invalid for mode %d", mode);
925 }
926
927 return (multicast_packet) {
929 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
930 .payload = total_period,
931 .payload_flag = WITH_PAYLOAD
932 };
933}
934
940 uint32_t active_time, uint32_t uart_id) {
942 log_error("The mode you configured is not the pushbot, "
943 "and so this message is invalid for mode %d", mode);
944 }
945
946 return (multicast_packet) {
948 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
949 .payload = active_time,
950 .payload_flag = WITH_PAYLOAD
951 };
952}
953
959 uint32_t active_time, uint32_t uart_id) {
961 log_error("The mode you configured is not the pushbot, "
962 "and so this message is invalid for mode %d", mode);
963 }
964
965 return (multicast_packet) {
967 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
968 .payload = active_time,
969 .payload_flag = WITH_PAYLOAD
970 };
971}
972
978 uint32_t frequency, uint32_t uart_id) {
980 log_error("The mode you configured is not the pushbot, "
981 "and so this message is invalid for mode %d", mode);
982 }
983
984 return (multicast_packet) {
987 .payload = frequency,
988 .payload_flag = WITH_PAYLOAD
989 };
990}
991
992// ----------------------------------------------------------------------
993// PushBot motor control
994
1000 state_t velocity, uint32_t uart_id) {
1002 log_error("The mode you configured is not the pushbot, "
1003 "and so this message is invalid for mode %d", mode);
1004 }
1005
1006 return (multicast_packet) {
1007 .key = (PUSH_BOT_MOTOR_0_PERMANENT_VELOCITY + uart_id) |
1009 .payload = velocity,
1010 .payload_flag = WITH_PAYLOAD
1011 };
1012}
1013
1019 uint32_t velocity, uint32_t uart_id) {
1021 log_error("The mode you configured is not the pushbot, "
1022 "and so this message is invalid for mode %d", mode);
1023 }
1024
1025 return (multicast_packet) {
1027 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
1028 .payload = velocity,
1029 .payload_flag = WITH_PAYLOAD
1030 };
1031}
1032
1037static inline multicast_packet
1039 uint32_t velocity, uint32_t uart_id) {
1041 log_error("The mode you configured is not the pushbot, "
1042 "and so this message is invalid for mode %d", mode);
1043 }
1044
1045 return (multicast_packet) {
1047 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
1048 .payload = velocity,
1049 .payload_flag = WITH_PAYLOAD
1050 };
1051}
1052
1057static inline multicast_packet
1059 uint32_t velocity, uint32_t uart_id) {
1061 log_error("The mode you configured is not the pushbot, "
1062 "and so this message is invalid for mode %d", mode);
1063 }
1064
1065 return (multicast_packet) {
1067 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
1068 .payload = velocity,
1069 .payload_flag = WITH_PAYLOAD
1070 };
1071}
1072
1073// ----------------------------------------------------------------------
1074// PushBot retina control
1075
1076static inline multicast_packet _key_retina(
1077 uint32_t retina_pixels, uint32_t time_stamps, uint32_t uart_id) {
1078 if (retina_pixels == 128 * 128) {
1079 // if fine, create message
1080 return (multicast_packet) {
1082 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
1083 .payload = (time_stamps | PAYLOAD_RETINA_NO_DOWN_SAMPLING),
1084 .payload_flag = WITH_PAYLOAD
1085 };
1086 }
1087 if (retina_pixels == 64 * 64) {
1088 return (multicast_packet) {
1090 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
1091 .payload = (time_stamps | PAYLOAD_RETINA_64_DOWN_SAMPLING),
1092 .payload_flag = WITH_PAYLOAD
1093 };
1094 }
1095 if (retina_pixels == 32 * 32) {
1096 return (multicast_packet) {
1098 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
1099 .payload = (time_stamps | PAYLOAD_RETINA_32_DOWN_SAMPLING),
1100 .payload_flag = WITH_PAYLOAD
1101 };
1102 }
1103 if (retina_pixels == 16 * 16) {
1104 return (multicast_packet) {
1106 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
1107 .payload = (time_stamps | PAYLOAD_RETINA_16_DOWN_SAMPLING),
1108 .payload_flag = WITH_PAYLOAD
1109 };
1110 }
1111
1112 log_error("The number of pixels is not supported in this protocol.");
1113 rt_error(RTE_SWERR);
1114 return (multicast_packet) {.key = 0, .payload = 0, .payload_flag = 0};
1115}
1116
1126 bool events_in_key, uint32_t retina_pixels,
1127 bool payload_holds_time_stamps, uint32_t size_of_time_stamp_in_bytes,
1128 uint32_t uart_id) {
1129 // if events in the key.
1130 if (events_in_key) {
1131 if (!payload_holds_time_stamps) {
1132 // not using payloads
1133 return _key_retina(retina_pixels, PAYLOAD_NO_TIMESTAMPS, uart_id);
1134 }
1135 // using payloads
1136 switch (size_of_time_stamp_in_bytes) {
1137 case 0:
1138 return _key_retina(
1139 retina_pixels, PAYLOAD_DELTA_TIMESTAMPS, uart_id);
1140 case 2:
1141 return _key_retina(
1142 retina_pixels, PAYLOAD_TWO_BYTE_TIME_STAMPS, uart_id);
1143 case 3:
1144 return _key_retina(
1145 retina_pixels, PAYLOAD_THREE_BYTE_TIME_STAMPS, uart_id);
1146 case 4:
1147 return _key_retina(
1148 retina_pixels, PAYLOAD_FOUR_BYTE_TIME_STAMPS, uart_id);
1149 default:
1150 log_error("Unknown size of timestamp in bytes: %d\n",
1151 size_of_time_stamp_in_bytes);
1153 return (multicast_packet) {
1154 .key = 0, .payload = 0, .payload_flag = 0
1155 };
1156 }
1157 } else {
1158 // using payloads to hold all events
1159
1160 // warn users about models
1161 log_warning("The current sPyNNaker models do not support the reception "
1162 "of packets with payloads, therefore you will need to add a "
1163 "adaptor model between the device and sPyNNaker models.");
1164
1165 // verify that its what the end user wants.
1166 if (payload_holds_time_stamps || (size_of_time_stamp_in_bytes == 0)) {
1167 log_error(
1168 "If you are using payloads to store events, you cannot"
1169 " have time stamps at all.");
1171 }
1172
1173 // if fine, create message
1174 return (multicast_packet) {
1176 (uart_id << OFFSET_FOR_UART_ID) | instance_key),
1177 .payload = (PAYLOAD_NO_TIMESTAMPS |
1178 PAYLOAD_RETINA_NO_DOWN_SAMPLING_IN_PAYLOAD),
1179 .payload_flag = WITH_PAYLOAD
1180 };
1181 }
1182}
void log_error(const char *message,...)
void log_warning(const char *message,...)
static uint32_t timer_period
Used for configuring the timer hardware.
static multicast_packet munich_protocol_turn_off_sensor_reporting(uint32_t sensor_id)
Creates a command to stop sensor reporting.
@ OFFSET_TO_F
Offset to F (format) field in command word.
@ OFFSET_TO_I
Offset to I (instruction) field in command word.
@ OFFSET_TO_D
Offset to D (device) field in command word.
static multicast_packet munich_protocol_push_bot_led_back_active_time(uint32_t active_time, uint32_t uart_id)
Creates a command to set the back LED active time.
static multicast_packet munich_protocol_push_bot_speaker_set_melody(uint32_t melody, uint32_t uart_id)
Creates a command to configure the speaker play a pre-programmed "melody".
static multicast_packet munich_protocol_pwm_pin_output_timer_b_duration(uint32_t timer_period, uint32_t uart_id)
Creates a command to set the PWM duty cycle period for Timer B.
static multicast_packet munich_protocol_master_slave_use_internal_counter(uint32_t uart_id)
Creates a command to tell the master/slave to use its internal event counter.
static multicast_packet munich_protocol_push_bot_led_front_active_time(uint32_t active_time, uint32_t uart_id)
Creates a command to set the front LED active time.
static uint32_t instance_key
The value of the ignored part of the key.
munich_protocol_modes_e
human readable definitions of each mode
@ MUNICH_PROTOCOL_PUSH_BOT
Push Bot.
@ MUNICH_PROTOCOL_BALL_BALANCER
Ball balancer.
@ MUNICH_PROTOCOL_FREE
Free.
@ MUNICH_PROTOCOL_RESET_TO_DEFAULT
Reset.
@ MUNICH_PROTOCOL_MY_ORO_BOTICS
MyORO.
@ MUNICH_PROTOCOL_SPOMNIBOT
Omnibot.
static multicast_packet munich_protocol_push_bot_laser_config_active_time(uint32_t active_time, uint32_t uart_id)
Creates a command to set the laser active time.
static multicast_packet munich_protocol_reset_retina(uint32_t uart_id)
Creates a command to reset a retina.
static multicast_packet munich_protocol_poll_individual_sensor_continuously(uint32_t sensor_id, uint32_t time_in_ms)
Creates a command to continuously poll a sensor.
static multicast_packet munich_protocol_set_retina_transmission_key(uint32_t new_key, uint32_t uart_id)
Creates a command to set the retina base key.
static multicast_packet munich_protocol_push_bot_laser_config_total_period(uint32_t total_period, uint32_t uart_id)
Creates a command to set the laser total period.
static multicast_packet munich_protocol_add_payload_logic_to_current_output(uint32_t payload)
Creates a command to add to the current output.
static multicast_packet munich_protocol_set_output_pattern_for_payload(uint32_t payload)
Creates a command to set an output pattern for a payload.
static multicast_packet munich_protocol_pwm_pin_output_timer_c_channel_1_ratio(uint32_t timer_period, uint32_t uart_id)
Creates a command to set the PWM duty cycle ratio for Timer C, Channel 1.
static munich_protocol_modes_e mode
The current mode.
static multicast_packet munich_protocol_pwm_pin_output_timer_b_channel_1_ratio(uint32_t timer_period, uint32_t uart_id)
Creates a command to set the PWM duty cycle ratio for Timer B, Channel 1.
static multicast_packet munich_protocol_generic_motor_total_period_duration(uint32_t time_in_ms, uint32_t uart_id)
Creates a command to turn a motor on for a period.
static multicast_packet munich_protocol_generic_motor0_raw_output_leak_to_0(uint32_t pwm_signal, uint32_t uart_id)
Creates a command to turn motor 0 on at a rate that decays to zero.
#define MUNICH_KEY_I_D(I, D)
Assembles a Munich key with zero munich_key_bitfields_t::instance_key and munich_key_bitfields_t::pay...
uint32_t payload
What payload to use.
static multicast_packet munich_protocol_pwm_pin_output_timer_c_duration(uint32_t timer_period, uint32_t uart_id)
Creates a command to set the PWM duty cycle period for Timer C.
static multicast_packet munich_protocol_set_retina_transmission(bool events_in_key, uint32_t retina_pixels, bool payload_holds_time_stamps, uint32_t size_of_time_stamp_in_bytes, uint32_t uart_id)
Creates a command to set how silicon retinas transmit.
@ PAYLOAD_RETINA_32_DOWN_SAMPLING
Retina down-samples to 32×32.
@ PAYLOAD_RETINA_NO_DOWN_SAMPLING
Retina is 128×128.
@ PAYLOAD_RETINA_64_DOWN_SAMPLING
Retina down-samples to 64×64.
@ PAYLOAD_RETINA_16_DOWN_SAMPLING
Retina down-samples to 16×16.
static multicast_packet munich_protocol_get_set_mode_command(void)
Creates a command to set the device mode.
static void set_protocol_mode(munich_protocol_modes_e new_mode, uint32_t new_instance_key)
Configures the protocol mode.
static multicast_packet munich_protocol_push_bot_speaker_config_active_time(uint32_t active_time, uint32_t uart_id)
Creates a command to adjust how the speaker runs in PCM mode.
static multicast_packet munich_protocol_pwm_pin_output_timer_a_channel_1_ratio(uint32_t timer_period, uint32_t uart_id)
Creates a command to set the PWM duty cycle ratio for Timer A, Channel 1.
munich_key_bitfields_t bitfields
Specific fields within the key.
static multicast_packet munich_protocol_query_state_of_io_lines(void)
Creates a command to ask for the state of the IO lines.
static multicast_packet munich_protocol_push_bot_laser_set_frequency(uint32_t frequency, uint32_t uart_id)
Creates a command to set the laser flash frequency.
static multicast_packet munich_protocol_push_bot_speaker_set_tone(uint32_t frequency, uint32_t uart_id)
Creates a command to configure the speaker play a particular frequency of tone.
static multicast_packet munich_protocol_generic_motor0_raw_output_permanent(uint32_t pwm_signal, uint32_t uart_id)
Creates a command to turn motor 0 on at a constant rate.
static multicast_packet munich_protocol_master_slave_set_master_clock_active(uint32_t uart_id)
Creates a command to set a UART clock active.
static multicast_packet munich_protocol_pwm_pin_output_timer_a_duration(uint32_t timer_period, uint32_t uart_id)
Creates a command to set the PWM duty cycle period for Timer A.
static multicast_packet munich_protocol_set_payload_pins_to_high_impedance(uint32_t payload)
Creates a command to set the payload pins to high-impedance mode.
static multicast_packet munich_protocol_generic_motor1_raw_output_leak_to_0(uint32_t pwm_signal, uint32_t uart_id)
Creates a command to turn motor 1 on at a rate that decays to zero.
uint32_t payload_flag
Whether the payload is defined.
static multicast_packet munich_protocol_get_configure_master_key_command(uint32_t new_key)
Creates a command to configure the master key.
static multicast_packet munich_protocol_master_slave_set_master_clock_not_started(uint32_t uart_id)
Creates a command to set a UART clock into the not-started state.
static multicast_packet munich_protocol_generic_motor_enable_disable(uint32_t enable_disable, uint32_t uart_id)
Creates a command to turn a motor on or off.
static multicast_packet munich_protocol_pwm_pin_output_timer_a_channel_0_ratio(uint32_t timer_period, uint32_t uart_id)
Creates a command to set the PWM duty cycle ratio for Timer A, Channel 0.
uint32_t payload_format
Payload format.
@ PAYLOAD_SENSOR_ID_OFFSET
Offset for sensor ID.
@ PAYLOAD_OFFSET_FOR_RETINA_SIZE
Offset for retina size.
@ PAYLOAD_OFFSET_FOR_TIMESTAMPS
Offset for timestamps.
@ PAYLOAD_OFFSET_FOR_SENSOR_TIME
Offset for sensor timestamp.
static multicast_packet munich_protocol_push_bot_led_set_frequency(uint32_t frequency, uint32_t uart_id)
Creates a command to set the LED flash frequency.
static multicast_packet munich_protocol_push_bot_led_total_period(uint32_t total_period, uint32_t uart_id)
Creates a command to set the total LED period.
static multicast_packet munich_protocol_bias_values(uint32_t bias_id, uint32_t bias_value, uint32_t uart_id)
Creates a command to set bias values for a UART.
static multicast_packet munich_protocol_push_bot_motor_0_leaking_towards_zero(uint32_t velocity, uint32_t uart_id)
Creates a command to set motor 0 moving, in leak-to-zero mode.
static multicast_packet munich_protocol_push_bot_motor_1_leaking_towards_zero(uint32_t velocity, uint32_t uart_id)
Creates a command to set motor 1 moving, in leak-to-zero mode.
static multicast_packet munich_protocol_pwm_pin_output_timer_b_channel_0_ratio(uint32_t timer_period, uint32_t uart_id)
Creates a command to set the PWM duty cycle ratio for Timer B, Channel 0.
static multicast_packet munich_protocol_master_slave_set_slave(uint32_t uart_id)
Creates a command to tell a UART to be a slave.
static multicast_packet munich_protocol_generic_motor1_raw_output_permanent(uint32_t pwm_signal, uint32_t uart_id)
Creates a command to turn motor 1 on at a constant rate.
@ MOTOR_TIMER_C_CHANNEL_1_ACTIVE_PERIOD_KEY
motor 1 output timer C ratio active period
@ MOTOR_TIMER_A_CHANNEL_1_ACTIVE_PERIOD_KEY
motor 1 output timer A ratio active period
@ REMOVE_PAYLOAD_TO_CURRENT_OUTPUT_KEY
remove payload (logic or (PL)) to current output from current output
@ PUSH_BOT_MOTOR_1_LEAKY_VELOCITY
Set motor 1 leaky velocity.
@ MOTOR_RUN_FOR_PERIOD_KEY
run motor for total period
@ PUSH_BOT_SPEAKER_CONFIG_ACTIVE_TIME
Set speaker active time (PCM)
@ PUSH_BOT_SPEAKER_TONE_BEEP
Tell speaker to beep.
@ MOTOR_1_RAW_LEAK_KEY
raw output for motor 1 (leak towards 0)
@ MOTOR_TIMER_B_TOTAL_PERIOD_KEY
motor output duration timer B period
@ PUSH_BOT_SPEAKER_TONE_MELODY
Tell speaker to play pre-programmed melody.
@ MOTOR_TIMER_C_CHANNEL_0_ACTIVE_PERIOD_KEY
motor 0 output timer C ratio active period
@ MOTOR_TIMER_A_CHANNEL_0_ACTIVE_PERIOD_KEY
motor 0 output timer A ratio active period
@ CHANGE_MODE
command key for setting up what mode of device running on the board
@ PUSH_BOT_MOTOR_0_LEAKY_VELOCITY
Set motor 0 leaky velocity.
@ MOTOR_TIMER_C_TOTAL_PERIOD_KEY
motor output duration timer C period
@ PUSH_BOT_LED_BACK_CONFIG_ACTIVE_TIME
Set LED back active period.
@ DISABLE_RETINA_EVENT_STREAMING
command for turning off retina output
@ PUSH_BOT_MOTOR_0_PERMANENT_VELOCITY
Set motor 0 permanent velocity.
@ CONFIGURE_MASTER_KEY
command key for setting up the master key of the board
@ PUSH_BOT_LASER_FREQUENCY
Set laser frequency.
@ MOTOR_0_RAW_PERM_KEY
raw output for motor 0 (permanent)
@ ACTIVE_RETINA_EVENT_STREAMING_SET_KEY
command for retina where events are the key
@ SET_TIMER_COUNTER_FOR_TIMESTAMPS
set timer / counter for timestamps
@ MOTOR_TIMER_B_CHANNEL_1_ACTIVE_PERIOD_KEY
motor 1 output timer B ratio active period
@ BIAS_KEY
command for setting bias
@ MOTOR_0_RAW_LEAK_KEY
raw output for motor 0 (leak towards 0)
@ PUSH_BOT_LASER_CONFIG_TOTAL_PERIOD
Set laser total period.
@ ACTIVE_RETINA_EVENT_STREAMING_KEYS_CONFIGURATION
command for retina where payload is events
@ PUSH_BOT_LED_FREQUENCY
Set LED frequency.
@ PUSH_BOT_LED_FRONT_CONFIG_ACTIVE_TIME
Set LED front active period.
@ DISABLE_MOTOR_KEY
disable motor
@ PUSH_BOT_LED_CONFIG_TOTAL_PERIOD
Set LED total period.
@ RESET_RETINA_KEY
reset retina key.
@ PUSH_BOT_LASER_CONFIG_ACTIVE_TIME
Set laser active period (out of total)
@ SET_OUTPUT_PATTERN_KEY
set output pattern to payload
@ SENSOR_REPORTING_OFF_KEY
request on-board sensor data
@ PUSH_BOT_MOTOR_1_PERMANENT_VELOCITY
Set motor 1 permanent velocity.
@ POLL_SENSORS_CONTINUOUSLY_KEY
poll sensors continuously
@ MOTOR_1_RAW_PERM_KEY
raw output for motor 1 (permanent)
@ MASTER_SLAVE_KEY
handle master / slave time sync
@ PUSH_BOT_SPEAKER_CONFIG_TOTAL_PERIOD
Set speaker total time period (PCM)
@ MOTOR_TIMER_A_TOTAL_PERIOD_KEY
motor output duration timer A period
@ QUERY_STATES_LINES_KEY
Query digital IO Signals.
@ POLL_SENSORS_ONCE_KEY
poll sensors once
@ ADD_PAYLOAD_TO_CURRENT_OUTPUT_KEY
add payload (logic or (PL)) to current output
@ SET_PAYLOAD_TO_HIGH_IMPEDANCE_KEY
set payload pins to high impedance
@ MOTOR_TIMER_B_CHANNEL_0_ACTIVE_PERIOD_KEY
motor 0 output timer B ratio active period
static multicast_packet munich_protocol_pwm_pin_output_timer_c_channel_0_ratio(uint32_t timer_period, uint32_t uart_id)
Creates a command to set the PWM duty cycle ratio for Timer C, Channel 0.
#define MUNICH_KEY_I(I)
Assembles a Munich key with zero for all fields except munich_key_bitfields_t::instruction.
static multicast_packet munich_protocol_remove_payload_logic_to_current_output(uint32_t payload)
Creates a command to remove from the current output.
static multicast_packet munich_protocol_push_bot_speaker_config_total_period(uint32_t total_period, uint32_t uart_id)
Creates a command to configure the speaker to run in PCM mode.
uint32_t device
Device identifier.
@ PAYLOAD_NO_TIMESTAMPS
No timestamps.
@ PAYLOAD_TWO_BYTE_TIME_STAMPS
Timestamps are two bytes (absolute)
@ PAYLOAD_THREE_BYTE_TIME_STAMPS
Timestamps are three bytes (absolute)
@ PAYLOAD_DELTA_TIMESTAMPS
Timestamps are deltas.
@ PAYLOAD_FOUR_BYTE_TIME_STAMPS
Timestamps are four bytes (absolute)
@ PUSH_BOT_UART_OFFSET_SPEAKER_LED_LASER
Device UART offset for the pushbot.
@ OFFSET_FOR_UART_ID
UART identifier offset.
uint32_t value
Overall key value.
static multicast_packet munich_protocol_disable_retina_event_streaming(uint32_t uart_id)
Creates a command to disable event streaming my a retina.
static multicast_packet munich_protocol_poll_sensors_once(uint32_t sensor_id)
Creates a command to poll a sensor once.
static multicast_packet munich_protocol_push_bot_motor_0_permanent(state_t velocity, uint32_t uart_id)
Creates a command to set motor 0 moving, in constant mode.
uint32_t key
What key to use.
uint32_t instance_key
Instance key (ignored)
static multicast_packet munich_protocol_push_bot_motor_1_permanent(uint32_t velocity, uint32_t uart_id)
Creates a command to set motor 1 moving, in constant mode.
uint32_t instruction
Device-specific instruction.
Description of multicast packet to send as part of Munich protocol.
The format of Munich device protocol keys.
Keys are really uint32_t, but contain bitfields within them.
REAL state_t
The type of a state variable.
RTE_SWERR
void rt_error(uint code,...)
NO_PAYLOAD
WITH_PAYLOAD