Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual

Page 94

Advertising
background image

KTD-S0057-I

Page 90 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


/* verify and prepare the contents of areas */

for (chn = 0; chn < channels; chn++)

{

if ((areas[chn].first % 8) != 0)

{

printf ("areas[%i].first == %i, aborting...\n", chn, areas[chn].first);

exit

(EXIT_FAILURE);

}

samples[chn] = (((unsigned char *) areas[chn].addr) + (areas[chn].first / 8));

if ((areas[chn].step % 16) != 0)

{

printf ("areas[%i].step == %i, aborting...\n", chn, areas[chn].step);

exit

(EXIT_FAILURE);

}

steps[chn] = areas[chn].step / 8;

samples[chn] += offset * steps[chn];

}

/* fill the channel areas */

while (count-- > 0)

{

union

{

float

f;

int

i;

}

fval;

int res, i;

if

(is_float)

{

fval.f = sin (phase) * maxval;

res = fval.i;

}

else

res = sin (phase) * maxval;

if

(to_unsigned)

res ^= 1U << (format_bits - 1);

for (chn = 0; chn < channels; chn++)

{

/* generate data in native endian format */

if

(big_endian)

{

for (i = 0; i < bps; i++)

*(samples[chn] + phys_bps - 1 - i) = (res >> i * 8) & 0xff;

}

else

{

for (i = 0; i < bps; i++)

*(samples[chn] + i) = (res >> i * 8) & 0xff;

}

samples[chn] += steps[chn];

}

Advertising
This manual is related to the following products: