int prt, buffindex = 0;
PM9603AP
double convert_24bits(double value)
// This function will sort out the 24 bits of the register
values
{
if (fabs(value) > 0x7FFFFF)
{
if (value > 0)
value = (16777216-value) * (-1);
else
value = (16777216+value)* (1);
}
return(value);
}
void spi_wait(void)
// This function will wait for the specified period, very
short time
{
int ti;
for (ti = 1; ti < 1 ; ti++);
}
void spi_out(unsigned char value)
// Put value on the parallel port
{
int n;
portval = value;
outport(prt,(~portval));
// Remove the ~ if you dont use opto couplers
for(n=0 ; n< delay_time ; n++); // Specify the pulse
width
}
void spi_clock(void)
// This function will pulse CLK pin of spi port
{
spi_wait();
spi_out(portval | CLK_b); // or
spi_wait();
sames
11/18