#include <stdio.h>
#include <stdlib.h>
typedef struct
{
int pwm;
int current;
} filcal_struct;
void dataFunction(filcal_struct **filcalTable, int size);
void dataFunction(filcal_struct **filcalTable, int size)
{
int i;
printf("*** %s init ***\n", __FUNCTION__
); for (i=0; i<size; i++)
{
filcalTable
[i
]->pwm
= rand(); filcalTable
[i
]->current
= rand();
printf("point %i: pwm = %i, current = %i\n", i
, filcalTable
[i
]->pwm
, filcalTable
[i
]->current
); }
}
int main(void) {
filcal_struct *data;
int i;
#define TABLE_SIZE 4
// init
data
= malloc(TABLE_SIZE
* sizeof(filcal_struct
*)); for (i=0; i<(int)TABLE_SIZE; i++)
{
data
[i
] = malloc(sizeof(filcal_struct
)); }
// go crunch the data
dataFunction(&data, TABLE_SIZE);
// dataFunction(&data, 3);
// report
printf("*** %s usage ***\n", __FUNCTION__
); for (i=0; i<(int)TABLE_SIZE; i++)
{
printf("point %i: pwm = %i, current = %i\n", i
, data
[i
]->pwm
, data
[i
]->current
); }
return 0;
}