]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/commitdiff
Fixed some minor and other mayor bugs. Changes simulation to static memory to avoid...
authorCarlos Jenkins <carlos@jenkins.co.cr>
Mon, 10 Jun 2013 02:52:30 +0000 (04:52 +0200)
committerCarlos Jenkins <carlos@jenkins.co.cr>
Mon, 10 Jun 2013 02:52:30 +0000 (04:52 +0200)
19 files changed:
apps/rpp-test-suite/include/test.h
apps/rpp-test-suite/src/ain.c
apps/rpp-test-suite/src/aout.c
apps/rpp-test-suite/src/can.c
apps/rpp-test-suite/src/din.c
apps/rpp-test-suite/src/eth.c
apps/rpp-test-suite/src/fr.c
apps/rpp-test-suite/src/hbr.c
apps/rpp-test-suite/src/hout.c
apps/rpp-test-suite/src/lin.c
apps/rpp-test-suite/src/lout.c
apps/rpp-test-suite/src/main.c
apps/rpp-test-suite/src/mout.c
apps/rpp-test-suite/src/sci.c
apps/rpp-test-suite/src/sdc.c
apps/rpp-test-suite/src/sdr.c
apps/rpp-test-suite_posix/.cproject
rpp/src/drv/adc.c
rpp/src/rpp/sdr.c

index 6b7e5c8a6a33e70a4feccbfdaa85512142a98289..b509a0a1eba96f1dcbf823430d54c0e3060ad738 100644 (file)
@@ -12,8 +12,8 @@
 #ifndef __RPP_TEST_H
 #define __RPP_TEST_H
 
-#define TEST_TASK_PRIORITY   1
-#define TEST_TASK_TASK     512
+#define TEST_TASK_PRIORITY   0
+#define TEST_TASK_STACK    512
 
 void wait_for_quit();
 void busy_infinite_loop();
index f9c899060d6c8aac6d3dfeee7289c1cc9fa5a051..905601440a6fe46f6c8065629ca6f8716d187c9e 100644 (file)
@@ -45,9 +45,6 @@ void ain_test_task(void* par)
 
     while(TRUE) {
 
-        // Wait until next step
-        vTaskDelayUntil(&last_wake_time, freq_ticks);
-
         // Update inputs
         rpp_ain_update();
 
@@ -72,6 +69,9 @@ void ain_test_task(void* par)
                 rpp_ain_get(11),
                 rpp_ain_get(12)
             );
+
+        // Wait until next step
+        vTaskDelayUntil(&last_wake_time, freq_ticks);
     }
 }
 
@@ -83,11 +83,13 @@ void test_ain(void)
 {
     xTaskHandle test_task_handle;
 
+    rpp_sci_printf((const char*)"Try to create task.\r\n");
     portBASE_TYPE task_created = xTaskCreate(ain_test_task,
                     (const signed char*)"ain_test_task",
-                    TEST_TASK_TASK, NULL, TEST_TASK_PRIORITY,
+                    TEST_TASK_STACK, NULL, TEST_TASK_PRIORITY,
                     &test_task_handle
             );
+    rpp_sci_printf((const char*)"After try to create task.\r\n");
 
     if(task_created != pdPASS) {
 
@@ -102,6 +104,7 @@ void test_ain(void)
 
     wait_for_quit();
     vTaskDelete(test_task_handle);
+    vTaskDelay(4); // Allow the idle task to free memory
 
     // Reset module
     // - Not required
index d18a491444fbc086b35a354a446d21e3f6563b88..806ba8ed38a6930306debcab4c2e4802c9913c15 100644 (file)
@@ -81,9 +81,6 @@ void aout_test_task(void* par)
 
         for(i = 0; i < SAMPLE_RATE_HZ; i++, samples++) {
 
-            // Wait until next step
-            vTaskDelayUntil(&last_wake_time, freq_ticks);
-
             for(pin = 1; pin <= 4; pin++) {
 
                 // Calculate sine sample
@@ -98,6 +95,9 @@ void aout_test_task(void* par)
 
             // Update outputs
             rpp_aout_update();
+
+            // Wait until next step
+            vTaskDelayUntil(&last_wake_time, freq_ticks);
         }
 
         rpp_sci_printf((const char*)
@@ -118,7 +118,7 @@ void test_aout(void)
 
     portBASE_TYPE task_created = xTaskCreate(aout_test_task,
                     (const signed char*)"aout_test_task",
-                    TEST_TASK_TASK, NULL, TEST_TASK_PRIORITY,
+                    TEST_TASK_STACK, NULL, TEST_TASK_PRIORITY,
                     &test_task_handle
             );
 
index 5f4184ad54cc4230f1d2ce8fd796d22813aef37d..a34ef24693734d5628dcc1ed423cb4cdcaaa63d0 100644 (file)
@@ -35,7 +35,7 @@
 void test_can()
 {
     rpp_sci_printf((const char*)
-            "CAN test is unimplemented. Press 'q' to continue...\r\n"
+            "CAN test is unimplemented. Press any key to continue...\r\n"
         );
     wait_for_quit();
 }
index 25ce2edc03071de784215343d26ece79ec7b1ec4..a68fa531be234d434b04e5a6f6f5d8dd5d650829 100644 (file)
@@ -52,9 +52,6 @@ void din_test_task(void* par)
 
     while(TRUE) {
 
-        // Wait until next step
-        vTaskDelayUntil(&last_wake_time, freq_ticks);
-
         // Update inputs
         rpp_din_update();
 
@@ -83,6 +80,9 @@ void din_test_task(void* par)
                 rpp_din_get(15, FALSE),
                 rpp_din_get(16, FALSE)
             );
+
+        // Wait until next step
+        vTaskDelayUntil(&last_wake_time, freq_ticks);
     }
 }
 
@@ -96,7 +96,7 @@ void test_din(void)
 
     portBASE_TYPE task_created = xTaskCreate(din_test_task,
                     (const signed char*)"din_test_task",
-                    TEST_TASK_TASK, NULL, TEST_TASK_PRIORITY,
+                    TEST_TASK_STACK, NULL, TEST_TASK_PRIORITY,
                     &test_task_handle
             );
 
index cb0ffdeddf960d969825cff36a1f1d81ec57a049..72b3560b5d9e98ac78ae5cb2248ce4457d03cc2c 100644 (file)
@@ -35,7 +35,7 @@
 void test_eth()
 {
     rpp_sci_printf((const char*)
-            "ETH test is unimplemented. Press 'q' to continue...\r\n"
+            "ETH test is unimplemented. Press any key to continue...\r\n"
         );
     wait_for_quit();
 }
index 196a7a5df50a81e61ac6751abb86871e1ac598b6..78d9e70ac6767df1ca0c49498a865435bef782e2 100644 (file)
@@ -35,7 +35,7 @@
 void test_fr()
 {
     rpp_sci_printf((const char*)
-            "FR test is unimplemented. Press 'q' to continue...\r\n"
+            "FR test is unimplemented. Press any key to continue...\r\n"
         );
     wait_for_quit();
 }
index 99d2be5e66485ea1e947ea70c848b3743232ab4b..3a8a28fa356419a2e3ef894071c1d81617f8c68a 100644 (file)
@@ -75,11 +75,11 @@ void hbr_test_task(void* par)
 
         for(i = 0; i < SAMPLE_RATE_HZ; i++, samples++) {
 
-            // Wait until next step
-            vTaskDelayUntil(&last_wake_time, freq_ticks);
-
             // Update H-Bridge
             rpp_hbr_control(sin(i * step));
+
+            // Wait until next step
+            vTaskDelayUntil(&last_wake_time, freq_ticks);
         }
 
         rpp_sci_printf(
@@ -100,7 +100,7 @@ void test_hbr(void)
 
     portBASE_TYPE task_created = xTaskCreate(hbr_test_task,
                     (const signed char*)"hbr_test_task",
-                    TEST_TASK_TASK, NULL, TEST_TASK_PRIORITY,
+                    TEST_TASK_STACK, NULL, TEST_TASK_PRIORITY,
                     &test_task_handle
             );
 
index b01d708685df7b9ffac889f64f1753a1c2947bfe..d9be97bd01f0c573786e8eeaf1e8a41e80a8cc04 100644 (file)
@@ -35,7 +35,7 @@
 void test_hout()
 {
     rpp_sci_printf((const char*)
-            "HOUT test is unimplemented. Press 'q' to continue...\r\n"
+            "HOUT test is unimplemented. Press any key to continue...\r\n"
         );
     wait_for_quit();
 }
index 04e8c435a029b96f3f997df45d6fc2cb9cdd86bf..432b32140f87d7d8f47c7807ab7ae02093af5275 100644 (file)
@@ -35,7 +35,7 @@
 void test_lin()
 {
     rpp_sci_printf((const char*)
-            "LIN test is unimplemented. Press 'q' to continue...\r\n"
+            "LIN test is unimplemented. Press any key to continue...\r\n"
         );
     wait_for_quit();
 }
index 2c60663d8f44be0779d4b06c51834e81405deedd..9726d3086b3a6e4b5a6daf8f09bfab075a4c5c0a 100644 (file)
@@ -51,9 +51,6 @@ void lout_test_task(void* par)
     uint8_t p = 0;
     while(TRUE) {
 
-        // Wait until next step
-        vTaskDelayUntil(&last_wake_time, freq_ticks);
-
         // Output counter
         for(p = 1; p <= 8; p++) {
             if(is_bit_set(c, p - 1)) {
@@ -70,6 +67,9 @@ void lout_test_task(void* par)
             );
 
         c++;
+
+        // Wait until next step
+        vTaskDelayUntil(&last_wake_time, freq_ticks);
     }
 }
 
@@ -83,7 +83,7 @@ void test_lout(void)
 
     portBASE_TYPE task_created = xTaskCreate(lout_test_task,
                     (const signed char*)"lout_test_task",
-                    TEST_TASK_TASK, NULL, TEST_TASK_PRIORITY,
+                    TEST_TASK_STACK, NULL, TEST_TASK_PRIORITY,
                     &test_task_handle
             );
 
index e6749902e778158e0db33b0e0b7d803d23853b2b..cf333a41cdc6e9a6f1c933c0e355ea4669906257 100644 (file)
@@ -184,10 +184,7 @@ void test_cmdproc(void* par)
  */
 void wait_for_quit()
 {
-    while(TRUE) {
-        if(rpp_sci_getc() == 'q') {
-            break;
-        }
+    while(rpp_sci_getc() < 0) {
         vTaskDelay(INPUT_IDLE / portTICK_RATE_MS);
     }
 }
@@ -226,7 +223,7 @@ int main(void)
     portBASE_TYPE task_created =
         xTaskCreate(test_cmdproc,
                 (const signed char*)"test_cmdproc",
-                512, NULL, 0, NULL
+                512, NULL, TEST_TASK_PRIORITY, NULL
             );
 
     if(task_created != pdPASS) {
index c4d00ca363cd6626bbe1dbfea2c63f6bb1501ceb..f1f383d9f6efc4d7a15510cb4335f5ec452c145b 100644 (file)
@@ -35,7 +35,7 @@
 void test_mout()
 {
     rpp_sci_printf((const char*)
-            "MOUT test is unimplemented. Press 'q' to continue...\r\n"
+            "MOUT test is unimplemented. Press any key to continue...\r\n"
         );
     wait_for_quit();
 }
index 9f97ec0ce4346bd8b3f5414b271e6f6cbb732e4c..c0a0b3580722abb06640b5fdad831cfd14e5fd0d 100644 (file)
@@ -38,7 +38,7 @@ void test_sci()
     // the SCI API
     rpp_sci_printf((const char*)
             "You're using the SCI, reading this and typing this command.\r\n"
-            "Press 'q' to continue...\r\n"
+            "Press any key to continue...\r\n"
         );
     wait_for_quit();
 }
index 5658bc38d3bcab0a0cbbe6b36824a3bb876ec5be..770bd0be3475f82aaed52b0af999bcd0c77e4dd4 100644 (file)
@@ -35,7 +35,7 @@
 void test_sdc()
 {
     rpp_sci_printf((const char*)
-            "SDC test is unimplemented. Press 'q' to continue...\r\n"
+            "SDC test is unimplemented. Press any key to continue...\r\n"
         );
     wait_for_quit();
 }
index 6282af71d781b67849fdcf170f200f2e1de39fee..94dffd85f5f46d30bfdb35f32109e7a6498c230f 100644 (file)
@@ -48,15 +48,15 @@ void sdr_test_task(void* par)
     uint32_t i = 0;
     while(TRUE) {
 
-        // Wait until next step
-        vTaskDelayUntil(&last_wake_time, freq_ticks);
-
         // Put something in the log
         rpp_sdr_printf((const char*)
                 "This is the noise generator at iteration %d "
                 "putting some noise value %d.", i, rand()
             );
         i++;
+
+        // Wait until next step
+        vTaskDelayUntil(&last_wake_time, freq_ticks);
     }
 }
 
@@ -77,7 +77,7 @@ void test_sdr(void)
     // opened command processor.
     portBASE_TYPE task_created = xTaskCreate(sdr_test_task,
                     (const signed char*)"sdr_test_task",
-                    TEST_TASK_TASK, NULL, TEST_TASK_PRIORITY,
+                    TEST_TASK_STACK, NULL, TEST_TASK_PRIORITY,
                     &test_task_handle
             );
 
index 2556788f9ce0c5e0cb1ea8378868dcfc9a8a8b1b..a4b33c0181ec9cd113625337fc2b3984f41fb5d0 100644 (file)
@@ -74,4 +74,7 @@
                        <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
                </scannerConfigBuildInfo>
        </storageModule>
+       <storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
+       <storageModule moduleId="null.devicePreference"/>
+       <storageModule moduleId="cpuFamily"/>
 </cproject>
index 28d476e496320d6ac5c10fe70720729e626123c0..81a5a3297a114300d33bfb686e65688a2725b899 100644 (file)
@@ -42,7 +42,9 @@ void drv_adc_init()
 {
     // Create semaphores
     vSemaphoreCreateBinary(adcSemaphore_ADC1GRP1);
+    xSemaphoreTake(adcSemaphore_ADC1GRP1, 0);
     vSemaphoreCreateBinary(adcSemaphore_ADC2GRP1);
+    xSemaphoreTake(adcSemaphore_ADC2GRP1, 0);
 
     adcMutex_AIN       = xSemaphoreCreateMutex();
     adcMutex_HOUTIFBK  = xSemaphoreCreateMutex();
index 137d23f146d56e66a85e627cbd13f58701957be8..6afaef3b9fa26eafa3e15fcf06ab415ef8f467db 100644 (file)
@@ -235,6 +235,11 @@ void rpp_sdr_cmdproc(void *p)
 // Flag to check if SDR module is initialized
 static boolean_t initialized = FALSE;
 
+// Memory for Simulation only
+#if (rppCONFIG_DRV == 0) && defined(FREERTOS_POSIX)
+static uint8_t memory_simulation[1024*1024]; // Allocate 1MB for test
+#endif
+
 // Initialize SDR module
 int8_t rpp_sdr_init()
 {
@@ -248,10 +253,12 @@ int8_t rpp_sdr_init()
 
     // Create log show semaphore
     vSemaphoreCreateBinary(show_semaphore);
+    xSemaphoreTake(show_semaphore, 0);
 
     // Create semaphore for outer applications to wait cmdproc to exit.
     // Non static! The symbol should be exported, so use the full prefix.
     vSemaphoreCreateBinary(rpp_sdr_cmdproc_semaphore);
+    xSemaphoreTake(rpp_sdr_cmdproc_semaphore, 0);
 
     // Define memory bounds
     #if rppCONFIG_DRV == 1
@@ -259,8 +266,8 @@ int8_t rpp_sdr_init()
     memory_start   = (uint8_t*)RPP_SDR_ADDR_START;
     memory_end     = (uint8_t*)RPP_SDR_ADDR_END;
     #elif defined(FREERTOS_POSIX)
-    memory_size    = 1024*1024; // Allocate 1MB for test
-    memory_start   = (uint8_t*)malloc(memory_size);
+    memory_size    = sizeof(memory_simulation);
+    memory_start   = (uint8_t*)&memory_simulation;
     memory_end     = (uint8_t*)(memory_start + memory_size - 1);
     #endif
     memory_current = memory_start;
@@ -327,9 +334,6 @@ int8_t rpp_sdr_setup(boolean_t enable)
 // Memory available
 uint32_t rpp_sdr_available()
 {
-    if(!log_enabled) {
-        return 0;
-    }
     return (uint32_t)(memory_end - memory_current + 1);
 }