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