+
+ // Calculate wait time in OS ticks
+ static const portTickType freq_ticks = FREQ_MILLIS / portTICK_RATE_MS;
+ portTickType last_wake_time = xTaskGetTickCount();
+
+ uint8_t i;
+ uint8_t pin;
+ boolean_t state = FALSE;
+ while(!stop_tasks) {
+
+ // Toggle state
+ for(pin = 1; pin <= 6; pin++) {
+ rpp_mout_set(pin, state);
+ }
+ state = !state;
+
+ rpp_sci_printf((const char*)
+ "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
+ "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
+ );
+
+ for(pin = 1; pin <= 6; pin++) {
+ rpp_sci_printf((const char*)
+ "%d: ", rpp_mout_get(pin)
+ );
+ }
+
+ for(i = 0; i < 10; i++) {
+
+ // Wait until next step
+ if(!stop_tasks) {
+ vTaskDelayUntil(&last_wake_time, freq_ticks);
+ } else {
+ break;
+ }
+
+ rpp_sci_printf((const char*)
+ "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
+ "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
+ );
+
+ for(pin = 1; pin <= 6; pin++) {
+ rpp_sci_printf((const char*)
+ "%d:%s ", rpp_mout_get(pin),
+ (rpp_mout_get(pin) == rpp_mout_diag(pin)) ? " OK" : "BAD"
+ );
+ }
+
+ }
+ }
+
+ // Delete myself
+ tasks_running--;
+ vTaskDelete(NULL);
+}
+
+
+/**
+ * MOUT Test entry point.
+ */
+void test_mout()
+{
+ /// Configure module
+ // - Not needed
+
+
+ /// Spawn tasks
+ xTaskHandle test_task_handle;
+
+ portBASE_TYPE task_created = xTaskCreate(mout_test_task,
+ (const signed char*)"mout_test_task",
+ TEST_TASK_STACK, NULL, TEST_TASK_PRIORITY,
+ &test_task_handle
+ );
+
+ if(task_created != pdPASS) {
+
+ rpp_sci_printf((const char*)
+ "ERROR: Problem spawning the test task. "
+ "Error code: %d\r\n", (uint32_t)task_created
+ );
+ wait_for_quit();
+ return;
+ }
+ tasks_running++;
+
+
+ // Wait for user exit