From 64bafd5f0f0e9d622b8a618dc5782816c6fb33f1 Mon Sep 17 00:00:00 2001 From: Carlos Jenkins Date: Mon, 10 Jun 2013 04:52:30 +0200 Subject: [PATCH] Fixed some minor and other mayor bugs. Changes simulation to static memory to avoid malloc, just in case. Also changed the delay of all task to the end of the first iteration, so they don't wait for one iteration (some are quite long, 1s). --- apps/rpp-test-suite/include/test.h | 4 ++-- apps/rpp-test-suite/src/ain.c | 11 +++++++---- apps/rpp-test-suite/src/aout.c | 8 ++++---- apps/rpp-test-suite/src/can.c | 2 +- apps/rpp-test-suite/src/din.c | 8 ++++---- apps/rpp-test-suite/src/eth.c | 2 +- apps/rpp-test-suite/src/fr.c | 2 +- apps/rpp-test-suite/src/hbr.c | 8 ++++---- apps/rpp-test-suite/src/hout.c | 2 +- apps/rpp-test-suite/src/lin.c | 2 +- apps/rpp-test-suite/src/lout.c | 8 ++++---- apps/rpp-test-suite/src/main.c | 7 ++----- apps/rpp-test-suite/src/mout.c | 2 +- apps/rpp-test-suite/src/sci.c | 2 +- apps/rpp-test-suite/src/sdc.c | 2 +- apps/rpp-test-suite/src/sdr.c | 8 ++++---- apps/rpp-test-suite_posix/.cproject | 3 +++ rpp/src/drv/adc.c | 2 ++ rpp/src/rpp/sdr.c | 14 +++++++++----- 19 files changed, 53 insertions(+), 44 deletions(-) diff --git a/apps/rpp-test-suite/include/test.h b/apps/rpp-test-suite/include/test.h index 6b7e5c8..b509a0a 100644 --- a/apps/rpp-test-suite/include/test.h +++ b/apps/rpp-test-suite/include/test.h @@ -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(); diff --git a/apps/rpp-test-suite/src/ain.c b/apps/rpp-test-suite/src/ain.c index f9c8990..9056014 100644 --- a/apps/rpp-test-suite/src/ain.c +++ b/apps/rpp-test-suite/src/ain.c @@ -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 diff --git a/apps/rpp-test-suite/src/aout.c b/apps/rpp-test-suite/src/aout.c index d18a491..806ba8e 100644 --- a/apps/rpp-test-suite/src/aout.c +++ b/apps/rpp-test-suite/src/aout.c @@ -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 ); diff --git a/apps/rpp-test-suite/src/can.c b/apps/rpp-test-suite/src/can.c index 5f4184a..a34ef24 100644 --- a/apps/rpp-test-suite/src/can.c +++ b/apps/rpp-test-suite/src/can.c @@ -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(); } diff --git a/apps/rpp-test-suite/src/din.c b/apps/rpp-test-suite/src/din.c index 25ce2ed..a68fa53 100644 --- a/apps/rpp-test-suite/src/din.c +++ b/apps/rpp-test-suite/src/din.c @@ -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 ); diff --git a/apps/rpp-test-suite/src/eth.c b/apps/rpp-test-suite/src/eth.c index cb0ffde..72b3560 100644 --- a/apps/rpp-test-suite/src/eth.c +++ b/apps/rpp-test-suite/src/eth.c @@ -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(); } diff --git a/apps/rpp-test-suite/src/fr.c b/apps/rpp-test-suite/src/fr.c index 196a7a5..78d9e70 100644 --- a/apps/rpp-test-suite/src/fr.c +++ b/apps/rpp-test-suite/src/fr.c @@ -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(); } diff --git a/apps/rpp-test-suite/src/hbr.c b/apps/rpp-test-suite/src/hbr.c index 99d2be5..3a8a28f 100644 --- a/apps/rpp-test-suite/src/hbr.c +++ b/apps/rpp-test-suite/src/hbr.c @@ -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 ); diff --git a/apps/rpp-test-suite/src/hout.c b/apps/rpp-test-suite/src/hout.c index b01d708..d9be97b 100644 --- a/apps/rpp-test-suite/src/hout.c +++ b/apps/rpp-test-suite/src/hout.c @@ -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(); } diff --git a/apps/rpp-test-suite/src/lin.c b/apps/rpp-test-suite/src/lin.c index 04e8c43..432b321 100644 --- a/apps/rpp-test-suite/src/lin.c +++ b/apps/rpp-test-suite/src/lin.c @@ -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(); } diff --git a/apps/rpp-test-suite/src/lout.c b/apps/rpp-test-suite/src/lout.c index 2c60663..9726d30 100644 --- a/apps/rpp-test-suite/src/lout.c +++ b/apps/rpp-test-suite/src/lout.c @@ -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 ); diff --git a/apps/rpp-test-suite/src/main.c b/apps/rpp-test-suite/src/main.c index e674990..cf333a4 100644 --- a/apps/rpp-test-suite/src/main.c +++ b/apps/rpp-test-suite/src/main.c @@ -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) { diff --git a/apps/rpp-test-suite/src/mout.c b/apps/rpp-test-suite/src/mout.c index c4d00ca..f1f383d 100644 --- a/apps/rpp-test-suite/src/mout.c +++ b/apps/rpp-test-suite/src/mout.c @@ -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(); } diff --git a/apps/rpp-test-suite/src/sci.c b/apps/rpp-test-suite/src/sci.c index 9f97ec0..c0a0b35 100644 --- a/apps/rpp-test-suite/src/sci.c +++ b/apps/rpp-test-suite/src/sci.c @@ -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(); } diff --git a/apps/rpp-test-suite/src/sdc.c b/apps/rpp-test-suite/src/sdc.c index 5658bc3..770bd0b 100644 --- a/apps/rpp-test-suite/src/sdc.c +++ b/apps/rpp-test-suite/src/sdc.c @@ -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(); } diff --git a/apps/rpp-test-suite/src/sdr.c b/apps/rpp-test-suite/src/sdr.c index 6282af7..94dffd8 100644 --- a/apps/rpp-test-suite/src/sdr.c +++ b/apps/rpp-test-suite/src/sdr.c @@ -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 ); diff --git a/apps/rpp-test-suite_posix/.cproject b/apps/rpp-test-suite_posix/.cproject index 2556788..a4b33c0 100644 --- a/apps/rpp-test-suite_posix/.cproject +++ b/apps/rpp-test-suite_posix/.cproject @@ -74,4 +74,7 @@ + + + diff --git a/rpp/src/drv/adc.c b/rpp/src/drv/adc.c index 28d476e..81a5a32 100644 --- a/rpp/src/drv/adc.c +++ b/rpp/src/drv/adc.c @@ -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(); diff --git a/rpp/src/rpp/sdr.c b/rpp/src/rpp/sdr.c index 137d23f..6afaef3 100644 --- a/rpp/src/rpp/sdr.c +++ b/rpp/src/rpp/sdr.c @@ -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); } -- 2.39.2