#include "mbed.h"
//#include "platform/mbed_thread.h"
#include <math.h>

#define SPI3_MOSI D11  //SDA
#define SPI3_MISO D12  //SDO
#define SPI3_SCLK D13  //SCL
#define SPI3_CS A3
#define I2CSDA PA_10
#define I2CSCL PA_9
DigitalOut LCD_RS(A0);   // RS
DigitalOut LCD_EN(D9);    // E
DigitalOut LCD_RW(D10);    //RW
BusOut data1(D3, D4, D5, D6);
SPI ADXL345(SPI3_MOSI,SPI3_MISO,SPI3_SCLK);
I2C TMP102(I2CSDA,I2CSCL);
DigitalOut ADXL345_cs(SPI3_CS);
DigitalOut LXG1(A1);// the pin for green LED
DigitalOut LXR1(A2);// the pin for red LED
DigitalOut buzzer(D2);
Serial pc(USBTX, USBRX);
const int TMP102Address = 0x90; //TMP102 Address 
char ConfigRegisterTMP102[3]; //Config Register 
char TemperatureRegister[2]; //Temperature Register
float Temperature,lastT=0; //Final Temperature Value in Degree Celsius
char buffer[6];// read data
int16_t data[3];// compute x,y,z
float x,y,z,lastx=0,lasty=0,lastz=0;// x,y,z and their change value
float changesx,changesy,changesz,changesT;
float SumA;
DigitalIn button (A6,PullDown);
void lcdCommand(char value) {
    LCD_RS = 0;      // 设置为命令模式
    //LCD_EN = 1;      // 使能信号置高
    LCD_RW = 0;      
    //LCD_EN = 0;
    data1 = (value) >> 4;
    LCD_EN = 1;  
    wait_ms(10);  
    LCD_EN = 0;       // 使能信号置低，完成数据传输
    data1 = (value);	 
    LCD_EN = 1;       // 使能信号置高，为下一次传输做准备
    wait_ms(10);
    LCD_EN = 0;       // 使能信号置低，完成数据传输
       
}

void LCD_WriteData(char value) {
    LCD_RS = 1;      // 设置为数据模式
    LCD_RW = 0;        // 使能信号置高
    //LCD_EN = 0;
    data1 = (value) >> 4;
    LCD_EN = 1; 
    wait_ms(10);
    LCD_EN = 0;       // 使能信号置低，完成数据传输
      // 使能信号置高，为下一次传输做准备
    data1 = (value);
    LCD_EN = 1; 
    wait_ms(10);
    LCD_EN = 0;
     // 等待一段时间
}

void LCD_SetCursor(unsigned char Line,unsigned char Column)
{
	if(Line==1)
	{
		lcdCommand(0x80|(Column-1));
	}
	else if(Line==2)
	{
		lcdCommand(0x80|(Column-1+0x40));
	}
}

void ConfigureTMP102()
{
    ConfigRegisterTMP102[0] = 0x01; //Point to config register
    ConfigRegisterTMP102[1] = 0x60; //Upper byte with Shut Down disabled
    ConfigRegisterTMP102[2] = 0xA0; //Lower byte
    TMP102.write(TMP102Address, ConfigRegisterTMP102, 3); //Write 3 bytes
}

void ADXL345_SPI_Initialise()
{
    ADXL345_cs=1;// strat wirte
    ADXL345.format(8,3);
    ADXL345.frequency(2000000);
    ADXL345_cs=0;// end write
    ADXL345.write(0x31);
    ADXL345.write(0x0B);
    ADXL345_cs=1;
    ADXL345_cs=0;
    ADXL345.write(0x2D);
    ADXL345.write(0x08);
    ADXL345_cs=1;
}

void LCD_Init()
{
	// lcdCommand(0x38);
	// lcdCommand(0x0c);
	// lcdCommand(0x06);
	// lcdCommand(0x01);
    LCD_RS = 0;
    LCD_EN = 0;
    LCD_RW = 0;
    lcdCommand(0x01);	// 清屏
    lcdCommand(0x02);	// 显示模式，光标复位
    lcdCommand(0x0);
    lcdCommand(0x0c);	// 显示开、光标关、闪烁关（一般做带键盘输入的才加入光标，常用的计量显示不显示光标）
    lcdCommand(0x28);	// 4位数据模式、两行显示、5*7点阵
    lcdCommand(0x0);
    lcdCommand(0x01);	// 清屏
}


void LCD_ShowChar(unsigned char Line,unsigned char Column,char Char)
{
	LCD_SetCursor(Line,Column);
	LCD_WriteData(Char);
}


void LCD_ShowString(unsigned char Line,unsigned char Column,char *String)
{
	unsigned char i;
	LCD_SetCursor(Line,Column);
	for(i=0;String[i]!='\0';i++)
	{
		LCD_WriteData(String[i]);
	}
}

为这个代码加上英文注释请注意格式