@@ -3,6 +3,8 | |||
|
3 | 3 | |
|
4 | 4 | #define NB_GPTIMER 3 |
|
5 | 5 | |
|
6 | #include <stdint.h> | |
|
7 | ||
|
6 | 8 | struct apbuart_regs_str{ |
|
7 | 9 | volatile unsigned int data; |
|
8 | 10 | volatile unsigned int status; |
@@ -173,9 +175,12 typedef struct{ | |||
|
173 | 175 | // |
|
174 | 176 | unsigned int buffer_length; // 0x8c = buffer length in burst 2688 / 16 = 168 |
|
175 | 177 | // |
|
176 |
volatile |
|
|
177 |
volatile |
|
|
178 |
volatile |
|
|
178 | volatile int16_t v_dummy; // 0x90 | |
|
179 | volatile int16_t v; // 0x90 | |
|
180 | volatile int16_t e1_dummy; // 0x94 | |
|
181 | volatile int16_t e1; // 0x94 | |
|
182 | volatile int16_t e2_dummy; // 0x98 | |
|
183 | volatile int16_t e2; // 0x98 | |
|
179 | 184 | } waveform_picker_regs_0_1_18_t; |
|
180 | 185 | |
|
181 | 186 | //********************* |
@@ -351,21 +351,21 rtems_task avgv_task(rtems_task_argument | |||
|
351 | 351 | { |
|
352 | 352 | #define MOVING_AVERAGE 16 |
|
353 | 353 | rtems_status_code status; |
|
354 |
static |
|
|
355 |
static |
|
|
356 |
static |
|
|
357 |
|
|
|
358 |
|
|
|
359 |
|
|
|
360 |
|
|
|
361 |
|
|
|
362 |
|
|
|
354 | static int32_t v[MOVING_AVERAGE] = {0}; | |
|
355 | static int32_t e1[MOVING_AVERAGE] = {0}; | |
|
356 | static int32_t e2[MOVING_AVERAGE] = {0}; | |
|
357 | int32_t average_v; | |
|
358 | int32_t average_e1; | |
|
359 | int32_t average_e2; | |
|
360 | int32_t newValue_v; | |
|
361 | int32_t newValue_e1; | |
|
362 | int32_t newValue_e2; | |
|
363 | 363 | unsigned char k; |
|
364 | 364 | unsigned char indexOfOldValue; |
|
365 | 365 | |
|
366 | 366 | BOOT_PRINTF("in AVGV ***\n"); |
|
367 | 367 | |
|
368 |
if (rtems_rate_monotonic_ident( name_avgv_rate_monotonic, & |
|
|
368 | if (rtems_rate_monotonic_ident( name_avgv_rate_monotonic, &AVGV_id) != RTEMS_SUCCESSFUL) { | |
|
369 | 369 | status = rtems_rate_monotonic_create( name_avgv_rate_monotonic, &AVGV_id ); |
|
370 | 370 | if( status != RTEMS_SUCCESSFUL ) { |
|
371 | 371 | PRINTF1( "rtems_rate_monotonic_create failed with status of %d\n", status ); |
@@ -382,12 +382,12 rtems_task avgv_task(rtems_task_argument | |||
|
382 | 382 | |
|
383 | 383 | // initialize values |
|
384 | 384 | indexOfOldValue = MOVING_AVERAGE - 1; |
|
385 |
average_v = |
|
|
386 |
average_e1 = |
|
|
387 |
average_e2 = |
|
|
388 |
newValue_v = |
|
|
389 |
newValue_e1 = |
|
|
390 |
newValue_e2 = |
|
|
385 | average_v = 0; | |
|
386 | average_e1 = 0; | |
|
387 | average_e2 = 0; | |
|
388 | newValue_v = 0; | |
|
389 | newValue_e1 = 0; | |
|
390 | newValue_e2 = 0; | |
|
391 | 391 | |
|
392 | 392 | k = INIT_CHAR; |
|
393 | 393 | |
@@ -401,9 +401,9 rtems_task avgv_task(rtems_task_argument | |||
|
401 | 401 | else |
|
402 | 402 | { |
|
403 | 403 | // get new values |
|
404 | newValue_v = waveform_picker_regs->v; | |
|
405 | newValue_e1 = waveform_picker_regs->e1; | |
|
406 | newValue_e2 = waveform_picker_regs->e2; | |
|
404 | newValue_v = (int32_t) waveform_picker_regs->v; | |
|
405 | newValue_e1 = (int32_t) waveform_picker_regs->e1; | |
|
406 | newValue_e2 = (int32_t) waveform_picker_regs->e2; | |
|
407 | 407 | |
|
408 | 408 | // compute the moving average |
|
409 | 409 | average_v = average_v + newValue_v - v[k]; |
@@ -424,9 +424,9 rtems_task avgv_task(rtems_task_argument | |||
|
424 | 424 | k++; |
|
425 | 425 | } |
|
426 | 426 | //update int16 values |
|
427 |
hk_lfr_sc_v_f3_as_int16 = (int16_t) (average_v / |
|
|
428 |
hk_lfr_sc_e1_f3_as_int16 = |
|
|
429 |
hk_lfr_sc_e2_f3_as_int16 = |
|
|
427 | hk_lfr_sc_v_f3_as_int16 = (int16_t) (average_v / MOVING_AVERAGE ); | |
|
428 | hk_lfr_sc_e1_f3_as_int16 = (int16_t) (average_e1 / MOVING_AVERAGE ); | |
|
429 | hk_lfr_sc_e2_f3_as_int16 = (int16_t) (average_e2 / MOVING_AVERAGE ); | |
|
430 | 430 | } |
|
431 | 431 | |
|
432 | 432 | PRINTF("in AVGV *** deleting task\n"); |
General Comments 0
You need to be logged in to leave comments.
Login now