MMA7455 code problems

Hi all, Im new to forum and arduino. Im currently trying to run this code I found for the MMA7455 acclerometer. I'm getting this error message when i compile it. If anyone could help me figure out whats the problem i would be very thankful.

This the error im getting

main.cpp.o: In function main': C:\Users\MJ\Desktop\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/main.cpp:11: undefined reference to setup'
C:\Users\MJ\Desktop\arduino-1.0-windows\arduino-1.0\hardware\arduino\cores\arduino/main.cpp:14: undefined reference to `loop'

Heres the code.

MMA_7455.cpp

#include <wire.h>
#include <stdio.h>
 
#define MMA7455_I2C_ADDRESS      0x1D
 
//MMA7455 Registers
#define MMA7455_XOUTL            0x00
#define MMA7455_XOUTH            0x01
#define MMA7455_YOUTL            0x02
#define MMA7455_YOUTH            0x03
#define MMA7455_ZOUTL            0x04
#define MMA7455_ZOUTH            0x05
#define MMA7455_XOUT8            0x06
#define MMA7455_YOUT8            0x07
#define MMA7455_ZOUT8            0x08
#define MMA7455_STATUS           0x09
#define MMA7455_DETSRC           0x0A
#define MMA7455_TOUT             0x0B
#define MMA7455_I2CAD            0x0D
#define MMA7455_USRINF           0x0E
#define MMA7455_WHOAMI           0x0F
#define MMA7455_XOFFL            0x10
#define MMA7455_XOFFH            0x11
#define MMA7455_YOFFL            0x12
#define MMA7455_YOFFH            0x13
#define MMA7455_ZOFFL            0x14
#define MMA7455_ZOFFH            0x15
#define MMA7455_MCTL             0x16
#define MMA7455_INTRST           0x17
#define MMA7455_CTL1             0x18
#define MMA7455_CTL2             0x19
#define MMA7455_LDTH             0x1A
#define MMA7455_PDTH             0x1B
#define MMA7455_PW               0x1C
#define MMA7455_LT               0x1D
#define MMA7455_TW               0x1E
 
static FILE uartout = {0} ;
static int uart_putchar (char c, FILE *stream)
{
    Serial.write(c) ;
    return 0 ;
}
 
void setup()
{
  Wire.begin();        // join i2c bus (address optional for master)
  Serial.begin(9600);  // start serial for output
 
  fdev_setup_stream (&amp;uartout, uart_putchar, NULL, _FDEV_SETUP_WRITE);
 
  // The uart is the standard output device STDOUT.
  stdout = &amp;uartout ;
 
  mma7455WriteReg(MMA7455_MCTL, 0x01);
}
 
 
 
unsigned char mma7455ReadReg(unsigned char reg)
{
  //Write register address first
  Wire.beginTransmission(MMA7455_I2C_ADDRESS);
  Wire.write(reg);
  Wire.endTransmission();
 
  //Then read the data back
  Wire.requestFrom(MMA7455_I2C_ADDRESS, 1);  
 
  if(Wire.available())
  {
    return Wire.read();
  }
 
  //Return zero if no data available
  return 0;
}
 
void mma7455WriteReg(unsigned char reg, unsigned char value)
{
  //Write register address first
  Wire.beginTransmission(MMA7455_I2C_ADDRESS);
  Wire.write(reg);
 
  //And then write data
  Wire.write(value);
 
  Wire.endTransmission();
}
 
 
 
void loop()
{
  printf(&quot;X = %u\n\r&quot;, mma7455ReadReg(MMA7455_XOUT8));
  printf(&quot;Y = %u\n\r&quot;, mma7455ReadReg(MMA7455_YOUT8));
  printf(&quot;Z = %u\n\r&quot;, mma7455ReadReg(MMA7455_ZOUT8));
 
  delay(500);
}
 
</stdio.h></wire.h>

MMA_7455.h

[quote]
#ifndef MMA_7455_h
#define MMA_7455_h


#include [color=#006699]"Arduino.h"[/color]  [color=#7E7E7E]//#include "WProgram.h"[/color]
#include [color=#006699]"Wire.h"[/color]

[color=#CC6600]class[/color] MMA_7455
{
  [color=#CC6600]public[/color]:
    MMA_7455();
    [color=#CC6600]void[/color] initSensitivity([color=#CC6600]int[/color] sensitivity);
    [color=#CC6600]void[/color] calibrateOffset([color=#CC6600]float[/color] x_axis_offset, [color=#CC6600]float[/color] y_axis_offset, [color=#CC6600]float[/color] z_axis_offset);
    [color=#CC6600]unsigned[/color] [color=#CC6600]char[/color] readAxis([color=#CC6600]char[/color] axis);
  [color=#CC6600]private[/color]:
    [color=#CC6600]unsigned[/color] [color=#CC6600]char[/color] _buffer;
    [color=#CC6600]float[/color] _x_axis_offset;
    [color=#CC6600]float[/color] _y_axis_offset;
    [color=#CC6600]float[/color] _z_axis_offset;
};

#endif

[/quote]

Can you clarify what files are where - you mention MMA7455.cpp, but this has a setup() and loop() function - those belong only in the sketch itself (.ino or .pde file)

Didnt mean to put the .cpp guess I'm used to putting it for my c++ programs. This is within the sketch.

And where is the .h included? Whats </stdio.h></wire.h> ?
Why is there " in the code?

I think you need to re-edit the posting with the actual code, its looking rather too garbled. You need to copy and paste from a text-editor, perhaps you are copying from some other kind of app that garbles program text?

Ok here are the right codes. I dont know where that other code came from. Sorry for the mix up.

#include "MMA_7455.h"
#include <Wire.h>

#define MMA_7455_ADDRESS 0x1D //I2C Adsress for the sensor
#define MMA_7455_MODE_CONTROLL 0x16 //Call the sensors Mode Control

#define MMA_7455_2G_MODE 0x05 //Set Sensitivity to 2g
#define MMA_7455_4G_MODE 0x09 //Set Sensitivity to 4g
#define MMA_7455_8G_MODE 0x01 //Set Sensitivity to 8g

#define X_OUT 0x06 //Register for reading the X-Axis
#define Y_OUT 0x07 //Register for reading the Y-Axis
#define Z_OUT 0x08 //Register for reading the Z-Axis

MMA_7455::MMA_7455()
{ 
  Wire.begin();
}

void MMA_7455::initSensitivity(int sensitivity)
{
  delay(1000);
  Wire.beginTransmission(MMA_7455_ADDRESS);
  Wire.write(MMA_7455_MODE_CONTROLL);
  if(sensitivity == 2)
  {
    Wire.write(MMA_7455_2G_MODE);  //Set Sensitivity to 2g Detection
  }
  if(sensitivity == 4)
  {
    Wire.write(MMA_7455_2G_MODE);  //Set Sensitivity to 4g Detection
  }
  if(sensitivity == 8)
  {
    Wire.write(MMA_7455_2G_MODE);  //Set Sensitivity to 8g Detection
  }
  Wire.endTransmission();
  delay(1000);
}

void MMA_7455::calibrateOffset(float x_axis_offset, float y_axis_offset, float z_axis_offset)
{
  _x_axis_offset = x_axis_offset;
  _y_axis_offset = y_axis_offset;
  _z_axis_offset = z_axis_offset;
}
unsigned char MMA_7455::readAxis(char axis)
{
  Wire.beginTransmission(MMA_7455_ADDRESS);
  if(axis == 'x' || axis == 'X')
  {
    Wire.write(X_OUT);
  }
  if(axis == 'y' || axis == 'Y')
  {
    Wire.write(Y_OUT);
  }
  if(axis == 'z' || axis == 'Z')
  {
    Wire.write(Z_OUT);
  }
  Wire.endTransmission();
  Wire.beginTransmission(MMA_7455_ADDRESS);
  Wire.requestFrom(MMA_7455_ADDRESS, 1);
  if(Wire.available())
  {
    _buffer = Wire.read();
  }
  if(axis == 'x' || axis == 'X')
  {
    _buffer = _buffer + _x_axis_offset;
  }
  if(axis == 'y' || axis == 'Y')
  {
    _buffer = _buffer + _y_axis_offset;
  }
  if(axis == 'z' || axis == 'Z')
  {
    _buffer = _buffer + _z_axis_offset;
  }

  return _buffer;
}
#ifndef MMA_7455_h
#define MMA_7455_h


#include "Arduino.h"  //#include "WProgram.h"
#include "Wire.h"

class MMA_7455
{
  public:
    MMA_7455();
    void initSensitivity(int sensitivity);
    void calibrateOffset(float x_axis_offset, float y_axis_offset, float z_axis_offset);
    unsigned char readAxis(char axis);
  private:
    unsigned char _buffer;
    float _x_axis_offset;
    float _y_axis_offset;
    float _z_axis_offset;
};

#endif