]> rtime.felk.cvut.cz Git - pes-rpp/rpp-simulink.git/commitdiff
Added MOUT test to the test suite. Fixed MOUT library module to store value on simula...
authorCarlos Jenkins <carlos@jenkins.co.cr>
Sat, 15 Jun 2013 14:44:08 +0000 (16:44 +0200)
committerCarlos Jenkins <carlos@jenkins.co.cr>
Sat, 15 Jun 2013 14:44:08 +0000 (16:44 +0200)
12 files changed:
rpp/lib/apps/rpp-test-suite/src/can.c
rpp/lib/apps/rpp-test-suite/src/din.c
rpp/lib/apps/rpp-test-suite/src/eth.c
rpp/lib/apps/rpp-test-suite/src/fr.c
rpp/lib/apps/rpp-test-suite/src/hout.c
rpp/lib/apps/rpp-test-suite/src/lin.c
rpp/lib/apps/rpp-test-suite/src/mout.c
rpp/lib/apps/rpp-test-suite/src/sci.c
rpp/lib/apps/rpp-test-suite/src/sdc.c
rpp/lib/apps/rpp-test-suite/src/sdr.c
rpp/lib/rpp-lib.lib
rpp/lib/rpp/src/rpp/mout.c

index a34ef24693734d5628dcc1ed423cb4cdcaaa63d0..c4f261a01fd3da7eafa40a0e6cdf1d5d217ccdb8 100644 (file)
@@ -30,7 +30,7 @@
 
 
 /**
- * Test the CAN module.
+ * CAN Test entry point.
  */
 void test_can()
 {
index fc2407dda9042612ae421d422c652a232eb7dc9b..771fd140353271894457093ea873f33226ce2a55 100644 (file)
@@ -48,7 +48,7 @@ void din_test_task(void* par)
             "===========================================================\r\n"
         );
     rpp_sci_printf((const char*)
-            "01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16\r\n"
+            " 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16\r\n"
           //  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
         );
 
index 72b3560b5d9e98ac78ae5cb2248ce4457d03cc2c..edb7df382d182995a374f15dbc6ec87b429cba8c 100644 (file)
@@ -30,7 +30,7 @@
 
 
 /**
- * Test the ETH module.
+ * ETH Test entry point.
  */
 void test_eth()
 {
index 78d9e70ac6767df1ca0c49498a865435bef782e2..5e62084bec886493f6b1533910a90eaff765edd6 100644 (file)
@@ -30,7 +30,7 @@
 
 
 /**
- * Test the FR module.
+ * FR Test entry point.
  */
 void test_fr()
 {
index d9be97bd01f0c573786e8eeaf1e8a41e80a8cc04..33c6b1a40e13e0c5510977d2061379aa7651009a 100644 (file)
@@ -30,7 +30,7 @@
 
 
 /**
- * Test the HOUT module.
+ * HOUT Test entry point.
  */
 void test_hout()
 {
index 432b32140f87d7d8f47c7807ab7ae02093af5275..aa8dd53e76ce1dc2ce225456d16ef98eaaf5dd08 100644 (file)
@@ -30,7 +30,7 @@
 
 
 /**
- * Test the LIN module.
+ * LIN Test entry point.
  */
 void test_lin()
 {
index f1f383d9f6efc4d7a15510cb4335f5ec452c145b..4e7214b6a5e296e93efb47980fe2642c16168618 100644 (file)
 #include "rpp/rpp.h"
 #include "test.h"
 
+#define FREQ_MILLIS     1000
+
+
+// Task control
+static boolean_t stop_tasks = FALSE;
+static uint8_t tasks_running = 0;
+
 
 /**
- * Test the MOUT module.
+ * FreeRTOS Task that toggle the MOUT outputs, then reads the diagnostics and
+ * compare.
  */
-void test_mout()
+void mout_test_task(void* par)
 {
     rpp_sci_printf((const char*)
-            "MOUT test is unimplemented. Press any key to continue...\r\n"
+            "Power Output Test:\r\n"
+        );
+    rpp_sci_printf((const char*)
+            "===========================================================\r\n"
+        );
+    rpp_sci_printf((const char*)
+            "1     2     3     4     5     6\r\n"
+          // 1:BAD 1:BAD 1:BAD 1:BAD 1:BAD 1:BAD
+          // 1: OK 1: OK 1: OK 1: OK 1: OK 1: OK
         );
+
+    // 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
     wait_for_quit();
+    stop_tasks = TRUE;
+    while(tasks_running > 0) {
+        taskYIELD();
+    }
+    stop_tasks = FALSE;
+
+
+    /// Reset module configuration
+    uint8_t pin;
+    for(pin = 1; pin <= 6; pin++) {
+        rpp_mout_set(pin, LOW);
+    }
+
+
+    rpp_sci_printf((const char*)"\r\n");
+
+    return;
 }
 
index c0a0b3580722abb06640b5fdad831cfd14e5fd0d..cd9f362b486dc88fef9bbfe886cb9df00f3efaf1 100644 (file)
@@ -30,7 +30,7 @@
 
 
 /**
- * Test the SCI module.
+ * SCI Test entry point.
  */
 void test_sci()
 {
index 770bd0be3475f82aaed52b0af999bcd0c77e4dd4..0be3f0a5ee3c2cec1a4d959804d8c32445b121cf 100644 (file)
@@ -30,7 +30,7 @@
 
 
 /**
- * Test the SDC module.
+ * SDC Test entry point.
  */
 void test_sdc()
 {
index e4f3305d7a31ca3c53965abf2e46f63cf569bc7c..b0cfb962e0760907e86e89d9c9e456e6585522c0 100644 (file)
@@ -102,7 +102,7 @@ void test_sdr()
     xTaskHandle test_task_handle;
 
     // Spawn noise task first, and later enable logging. Depending on the time
-    // required the first logs might not be registeres, but that's ok, is better
+    // required the first logs might not be registered, but that's ok, is better
     // to check if logging could be enabled after data is being sent that enable
     // command processor (which output messages to the SCI), and that inmediatly
     // after the noise task could not be created, forcing to close the just
index 84b4e20d6055f8cbc73a57d8ddbb93eeb0c08934..4a3e35be7802a3d327a67a08b07c23fb3132810c 100644 (file)
Binary files a/rpp/lib/rpp-lib.lib and b/rpp/lib/rpp-lib.lib differ
index a4b0555d9daa973f273847a96b2810879d0e1209..950091477c4606c16853361a2616de3209cdad77 100644 (file)
@@ -63,9 +63,9 @@ int8_t rpp_mout_set(uint8_t pin, uint8_t val)
         return -2;
     }
 
-    #if rppCONFIG_DRV == 1
     uint8_t idx = pin - 1;
 
+    #if rppCONFIG_DRV == 1
     // Set and store value
     if(drv_mout_set(idx, val) != SUCCESS) {
         return -3;
@@ -85,6 +85,8 @@ int8_t rpp_mout_set(uint8_t pin, uint8_t val)
     if(drv_mout_diag(idx) != val) {
         return -4;
     }
+    #else
+    cache[idx] = val;
     #endif
 
     return SUCCESS;