Hello everyone, I'm working on learning C to help a guy out who is developing a product that uses an industrial controller and he needs the programming modified to make some updates to his proto-types. His old programmer went out of business so he was hopping that I could help him out a little.
Now he was pretty sure the programs are wrote in C and not C++ but he's not positive. I'm just wanting to make sure before I get too deep in C and find out its C++.......... LOL Also I was wondering which "dialect" it is wrote in so I can get a compiler for it.
Here is a chunk of the code if that will help out any.............. If you need any more info let me know and I'll see what I can do....... THANKS for the help I really appreciate it!!!
Code:
// Unit_Tool.c Main
// Description
// This is the main start up routines
//
//
//////////////////////////////////////////////////////////////////////
#define TERN_186
#include "unit_tool.h"
//extern float cf_offset;
//extern float divisor1;
//extern float pounds;
//extern float net_load_mult;
//extern float divisor2;
extern uchar spike_filter;
//extern unsigned int Test;
extern float var_1;
extern float var_2;
extern float var_3;
extern float var_4;
extern float var_5;
extern uint tbl[];
extern int num_stored;
unsigned char ser1_in_buf[MAXISIZE];
unsigned char ser1_out_buf[MAXOSIZE];
int isize,osize;
extern COM ser1_com;
COM * c1;
unsigned char baud;
extern float *heap_ptr;
extern float *temp_ptr;
/////////////////////////////////////////////////////////////////////////
//
// main function
//
/////////////////////////////////////////////////////////////////////////
void main(void)
{
//unsigned int temp;
float ftemp;
ae_init(); // calls initiation of the i/o of the Tern unit
//unsigned int sp1ct;
c1 = &ser1_com;
baud = 9; /* 19,200 baud for SER1 */
isize=MAXISIZE;
osize=MAXOSIZE;
s1_init(baud,ser1_in_buf,isize,ser1_out_buf,osize,c1);
// You may modify SP1CT for Even Parity Check, 7 data bits
// sp1ct=inport(0xff10); // SP1CT
// outport(0xff10,0x0018|sp1ct); // bit4=1 Even, bit3=1 Parity Enable
// pio_init(12, 2); // P12 for Multiplexer Select
// pio_wr(12,0);
// outport(0xfff2,0x0000); // AUXCON, MCS, IO Bus 16-bit
delay_ms(800); // waiting for LCD ready at power on
delay_ms(800);
elcd_init(); // Calls the start up displays on the LCD
Restore(); // Calls all the restore fuctions to restore all the variables
// stored in the eeprom
if(var_1 == 0.00) // only used to get the coefficent values closed the first
var_1 = 0.50; // if restored from eeprom this code is not needed
if(var_2 == 0.00)
var_2 = 0.08; // updated from 0.04 to 0.08 4/9/08 jlp
if(var_3 == 0.00)
var_3 = 22.28;
if(var_4 == 0.00)
var_4 = 3.15;
if(var_5 == 0.00)
var_5 = 11.0;
if(tbl[1] == tbl[2]) reset_calib_table(); // added 5/2/08 to ensure the cal table has
// been initialized to something close. Had noticed that table was all 65535's
spike_filter = 10;
// Test = 0;
heap_ptr = malloc(201*sizeof(float));
elcd_ClearScreen();
if(heap_ptr == NULL)
{
elcd_WriteText("MALLOC failed!", 0,112);
delay_ms(1000);
delay_ms(1000);
}
temp_ptr = malloc(201*sizeof(unsigned int));
elcd_ClearScreen();
if(temp_ptr == NULL)
{
elcd_WriteText("Temp storage MALLOC failed!", 0,112);
delay_ms(1000);
delay_ms(1000);
}
ftemp = (float)heap_ptr[200];
if((ftemp > 200.)||(ftemp < 1.))
{ // 7/23/08 tweeked to look using floats, clear the [0] too jlp
heap_ptr[200] = 0;
heap_ptr[0] = 0.;
}
num_stored = heap_ptr[200]; // recapture the count from unerased memory 7/17/08
display_intro(); // displays start up screens
while(1) // do forever
{
menu();
}