AnsweredAssumed Answered

stm32f303vc lcd hd44780 error xollect2.exe

Question asked by prasetyo.yoyok on Oct 25, 2014
Latest reply on Oct 31, 2014 by fm
somebody i have proble while i compile my program in coocox
i have stm32f3  test program which i combine with lcd driver






/* Includes ------------------------------------------------------------------*/
#include "main.h"




/* #defines --------------------------------------------------*/


/* #function prototypes --------------------------------------*/


/* #global variables -----------------------------------------*/
GPIO_InitTypeDef        GPIO_InitStructure;                                                       //structure used for setting up a GPIO port
RCC_ClocksTypeDef                RCC_Clocks;
/** @addtogroup STM32F3-Discovery_Demo
  * @{
  */


/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
#define ABS(x)         (x < 0) ? (-x) : x


#define L3G_Sensitivity_250dps     (float)   114.285f         /*!< gyroscope sensitivity with 250 dps full scale [LSB/dps] */
#define L3G_Sensitivity_500dps     (float)    57.1429f        /*!< gyroscope sensitivity with 500 dps full scale [LSB/dps] */
#define L3G_Sensitivity_2000dps    (float)    14.285f           /*!< gyroscope sensitivity with 2000 dps full scale [LSB/dps] */
#define PI                         (float)     3.14159265f


#define LSM_Acc_Sensitivity_2g     (float)     1.0f            /*!< accelerometer sensitivity with 2 g full scale [LSB/mg] */
#define LSM_Acc_Sensitivity_4g     (float)     0.5f            /*!< accelerometer sensitivity with 4 g full scale [LSB/mg] */
#define LSM_Acc_Sensitivity_8g     (float)     0.25f           /*!< accelerometer sensitivity with 8 g full scale [LSB/mg] */
#define LSM_Acc_Sensitivity_16g    (float)     0.0834f         /*!< accelerometer sensitivity with 12 g full scale [LSB/mg] */






/*lcd*/
#define HD44780_CMD_RESET                 0x30          /*!< Resets display - used in init 3x */
#define HD44780_CMD_CLEAR                 0x01          /*!< Clears display */
#define HD44780_CMD_RETURN_HOME           0x02          /*!< Sets DDRAM pointer to 0 */
#define HD44780_CMD_ENTRY_MODE            0x04          /*!< Sets how the pointer is updated after a character write */
#define HD44780_CMD_DISPLAY               0x08          /*!< Display settings */
#define HD44780_CMD_SHIFT                 0x10          /*!< Cursor and display movement */
#define HD44780_CMD_FUNCTION              0x20          /*!< Screen type setup */
#define HD44780_CMD_CGRAM_ADDR            0x40          /*!< Sets CGRAM address */
#define HD44780_CMD_DDRAM_ADDR            0x80          /*!< Sets DDRAM address */


/* ENTRY_MODE Command parameters */
#define HD44780_ENTRY_SHIFT_DISP                0x01               /*!< Shift display */
#define HD44780_ENTRY_SHIFT_CURS                0x00               /*!< Shift cursor */
#define HD44780_ENTRY_ADDR_INC                  0x02          /*!< Increments pointer */
#define HD44780_ENTRY_ADDR_DEC                  0x00               /*!< Decrements pointer */


/* DISPLAY Command parameters */
#define HD44780_DISP_ON                           0x04      /*!< Enables the display */
#define HD44780_DISP_OFF                          0x00      /*!< Disables the display */
#define HD44780_DISP_CURS_ON                      0x02      /*!< Enables cursor */
#define HD44780_DISP_CURS_OFF                     0x00      /*!< Disables cursor */
#define HD44780_DISP_BLINK_ON                    0x01      /*!< Enables cursor blinking */
#define HD44780_DISP_BLINK_OFF                 0x00      /*!< Disables cursor blinking */


/* SHIFT Command parameters */
#define HD44780_SHIFT_DISPLAY                   0x08      /*!< Shifts the display or shifts the cursor if not set */
#define HD44780_SHIFT_CURSOR                   0x00      /*!< Shifts the display or shifts the cursor if not set */
#define HD44780_SHIFT_RIGHT                     0x04      /*!< Shift to the right */
#define HD44780_SHIFT_LEFT                     0x00      /*!< Shift to the left  */


/* FUNCTION Command parameters */
#define HD44780_FUNC_BUS_8BIT                      0x10      /*!< 8 bit bus */
#define HD44780_FUNC_BUS_4BIT                      0x00      /*!< 4 bit bus */
#define HD44780_FUNC_LINES_2                       0x08      /*!< 2 lines */
#define HD44780_FUNC_LINES_1                       0x00      /*!< 1 line */
#define HD44780_FUNC_FONT_5x10                     0x04      /*!< 5x10 font */
#define HD44780_FUNC_FONT_5x8                      0x00      /*!< 5x8 font */


/* Busy Flag - actually not used */
#define HD44780_BUSY_FLAG                       0x80      /*!< Busy flag */




/***************************************************************
 *
 * CONFIGURATION
 *
 ***************************************************************/


#define HD44780_CONF_BUS                                   HD44780_FUNC_BUS_4BIT
#define HD44780_CONF_LINES                              HD44780_FUNC_LINES_2
#define HD44780_CONF_FONT                                   HD44780_FUNC_FONT_5x8


#define HD44780_DISP_LENGTH                                   16
#define HD44780_DISP_ROWS                                   2
#define HD44780_CONF_SCROLL_MS                              20


/* HD44780 Data lines - use the same port for all the lines */
#define HD44780_DATAPORT                                   GPIOB
#define HD44780_DATABIT0                                   GPIO_Pin_0     //not used in 4-bit mode
#define HD44780_DATABIT1                                   GPIO_Pin_1     //not used in 4-bit mode
#define HD44780_DATABIT2                                   GPIO_Pin_2     //not used in 4-bit mode
#define HD44780_DATABIT3                                   GPIO_Pin_3     //not used in 4-bit mode
#define HD44780_DATABIT4                                   GPIO_Pin_12
#define HD44780_DATABIT5                                   GPIO_Pin_13
#define HD44780_DATABIT6                                   GPIO_Pin_14
#define HD44780_DATABIT7                                   GPIO_Pin_15


/* HD44780 Control lines - use the same port for all the lines */
#define HD44780_CONTROLPORT                                   GPIOB
#define HD44780_RS_BIT                                        GPIO_Pin_10
#define HD44780_RW_BIT                                        GPIO_Pin_11
#define HD44780_EN_BIT                                        GPIO_Pin_9


/* defines the peripheral clocks that need to be enabled for the above pins */
#define HD44780_RCC_AHBPeriph                         RCC_AHBPeriph_GPIOB     //or something like "RCC_AHBPeriph_GPIOA | RCC_AHBPeriph_GPIOD"




/***************************************************************
 *
 * FUNCTIONS
 *
 ***************************************************************/


#define hd44780_RS_On()                      GPIO_WriteBit(HD44780_CONTROLPORT, HD44780_RS_BIT, Bit_SET)
#define hd44780_RS_Off()                     GPIO_WriteBit(HD44780_CONTROLPORT, HD44780_RS_BIT, Bit_RESET)
#define hd44780_RW_On()                      GPIO_WriteBit(HD44780_CONTROLPORT, HD44780_RW_BIT, Bit_SET)
#define hd44780_RW_Off()                 GPIO_WriteBit(HD44780_CONTROLPORT, HD44780_RW_BIT, Bit_RESET)
#define hd44780_EN_On()                      GPIO_WriteBit(HD44780_CONTROLPORT, HD44780_EN_BIT, Bit_SET)
#define hd44780_EN_Off()                 GPIO_WriteBit(HD44780_CONTROLPORT, HD44780_EN_BIT, Bit_RESET)


#define hd44780_EN_high_delay()          hd44780_Delay(20000);//4095)
#define hd44780_init_delay()             hd44780_Delay(127900)     //16ms
#define hd44780_init_delay2()            hd44780_Delay(51400)     //5ms
#define hd44780_init_delay3()            hd44780_Delay(10280)     //1ms
#define hd44780_init_end_delay()         hd44780_Delay(20560)     //2ms


#define hd44780_clear()                              hd44780_wr_cmd( HD44780_CMD_CLEAR )
#define hd44780_home()                               hd44780_wr_cmd( HD44780_CMD_RETURN_HOME )
#define hd44780_entry( inc_dec, shift )           hd44780_wr_cmd( ( HD44780_CMD_ENTRY_MODE | inc_dec | shift ) & 0x07 )
#define hd44780_display( on_off, cursor, blink )  hd44780_wr_cmd( ( HD44780_CMD_DISPLAY | on_off | cursor | blink ) & 0x0F )
#define hd44780_shift( inc_dec, shift )           hd44780_wr_cmd( ( HD44780_CMD_SHIFT | inc_dec | shift ) & 0x1F )
#define hd44780_function( bus, lines, font )      hd44780_wr_cmd( ( HD44780_CMD_FUNCTION | bus | lines | font ) & 0x3F )
#define hd44780_cgram_addr( addr )                hd44780_wr_cmd( HD44780_CMD_CGRAM_ADDR | ( addr & 0x3F ) )
#define hd44780_ddram_addr( addr )                hd44780_wr_cmd( HD44780_CMD_DDRAM_ADDR | ( addr & 0x7F ) )
#define hd44780_write_char( c )                   hd44780_wr_data( c & 0xff )


void hd44780_Delay(unsigned long del);
void hd44780_wr_hi_nibble(unsigned char data);
void hd44780_wr_lo_nibble(unsigned char data);
void hd44780_write(unsigned char data);
void hd44780_wr_cmd(unsigned char cmd);
void hd44780_wr_data(unsigned char data);


void HD44780_Init(void);
void HD44780_PutChar(unsigned char c);
void HD44780_GotoXY(unsigned char x, unsigned char y);
void HD44780_PutStr(char *str);
void HD44780_ClrScr(void);






/* Function used from the CooCox HD44780 library */
/********************************************************************************************/
void hd44780_wr_hi_nibble( unsigned char data )
{
     if ( data & 0x10 ) {
          GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT4 );
     } else {
          GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT4 );
     }
     if ( data & 0x20 ) {
          GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT5 );
     } else {
          GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT5 );
     }
     if ( data & 0x40 ) {
          GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT6 );
     } else {
          GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT6 );
     }
     if ( data & 0x80 ) {
          GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT7 );
     } else {
          GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT7 );
     }


    /* set the EN signal */
    hd44780_EN_On();


    /* wait */
    hd44780_EN_high_delay();


    /* reset the EN signal */
    hd44780_EN_Off();
}




#if HD44780_CONF_BUS == HD44780_FUNC_BUS_4BIT


void hd44780_wr_lo_nibble( unsigned char data )
{
     if ( data & 0x01 ) {
          GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT4 );
     } else {
          GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT4 );
     }
     if ( data & 0x02 ) {
          GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT5 );
     } else {
          GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT5 );
     }
     if ( data & 0x04 ) {
          GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT6 );
     } else {
          GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT6 );
     }
     if ( data & 0x08 ) {
          GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT7 );
     } else {
          GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT7 );
     }


    /* set the EN signal */
    hd44780_EN_On();


    /* wait */
    hd44780_EN_high_delay();


    /* reset the EN signal */
    hd44780_EN_Off();
}


/* 4bit bus version */
void hd44780_write( unsigned char data )
{
     /* send the data bits - high nibble first */
     hd44780_wr_hi_nibble( data );
     hd44780_wr_lo_nibble( data );
}
#endif /* HD44780_CONF_BUS == HD44780_FUNC_BUS_4BIT */




#if HD44780_CONF_BUS == HD44780_FUNC_BUS_8BIT


/* 8bit bus version */
void hd44780_write( unsigned char data )
{
     /* set the data bits */
     if ( data & 0x01 ) {
          GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT0 );
     } else {
          GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT0 );
     }
     if ( data & 0x02 ) {
          GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT1 );
     } else {
          GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT1 );
     }
     if ( data & 0x04 ) {
          GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT2 );
     } else {
          GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT2 );
     }
     if ( data & 0x08 ) {
          GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT3 );
     } else {
          GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT3 );
     }
     if ( data & 0x10 ) {
          GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT4 );
     } else {
          GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT4 );
     }
     if ( data & 0x20 ) {
          GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT5 );
     } else {
          GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT5 );
     }
     if ( data & 0x40 ) {
          GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT6 );
     } else {
          GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT6 );
     }
     if ( data & 0x80 ) {
          GPIO_SetBits( HD44780_DATAPORT, HD44780_DATABIT7 );
     } else {
          GPIO_ResetBits( HD44780_DATAPORT, HD44780_DATABIT7 );
     }


    /* tell the lcd that we have a command to read in */
    hd44780_EN_On();


    /* wait long enough so that the lcd can see the command */
    hd44780_EN_high_delay();


    /* reset the ce line */
    hd44780_EN_Off();
    hd44780_init_end_delay();


}
#endif /* HD44780_CONF_BUS == HD44780_FUNC_BUS_8BIT */




void hd44780_wr_cmd( unsigned char cmd )
{
     hd44780_RS_Off();
     hd44780_write( cmd );
}




void hd44780_wr_data( unsigned char data )
{
     hd44780_RS_On();
     hd44780_write( data );
}
/********************************************************************************************/






/*********************************************************************************************
Function name   : hd44780_Delay
Author                          : Grant Phillips
Date Modified   : 25/08/2013
Compiler        : Keil ARM-MDK (uVision V4.70.0.0)


Description               : Creates a delay which is simply a code loop which is independent from any
                                             hardware timers.


Special Note(s) : NONE


Parameters               : del          -     32-bit value to represent the delay cycles
Return value          : NONE
*********************************************************************************************/
void hd44780_Delay(unsigned long del)
{
     unsigned long i=0;


     while(i<del)
          i++;
}








/*********************************************************************************************
Function name   : HD44780_Init
Author                          : Grant Phillips
Date Modified   : 16/10/2013
Compiler        : Keil ARM-MDK (uVision V4.70.0.0)


Description               : Initializes the HD44780 lcd module


Special Note(s) : NONE


Parameters               : NONE
Return value          : NONE
*********************************************************************************************/
void HD44780_Init(void)
{
     GPIO_InitTypeDef GPIO_InitStructure;


     /* Configure the peripheral clocks for the HD44780 data and control lines */
     RCC_AHBPeriphClockCmd(HD44780_RCC_AHBPeriph, ENABLE);


     /* Configure the HD44780 Data lines (DB7 - DB4) as outputs*/
     GPIO_InitStructure.GPIO_Pin = HD44780_DATABIT7 | HD44780_DATABIT6 | HD44780_DATABIT5 | HD44780_DATABIT4;
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
     GPIO_Init(HD44780_DATAPORT, &GPIO_InitStructure);


     /* Configure the HD44780 Control lines (RS, RW, EN) as outputs*/
     GPIO_InitStructure.GPIO_Pin = HD44780_RS_BIT | HD44780_RW_BIT | HD44780_EN_BIT;
     GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
     GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
     GPIO_Init(HD44780_CONTROLPORT, &GPIO_InitStructure);


  /* clear control bits */
     hd44780_EN_Off();
     hd44780_RS_Off();
     hd44780_RW_Off();


     /* wait initial delay for LCD to settle */
  /* reset procedure - 3 function calls resets the device */
  hd44780_init_delay();
  hd44780_wr_hi_nibble( HD44780_CMD_RESET );
  hd44780_init_delay2();
  hd44780_wr_hi_nibble( HD44780_CMD_RESET );
  hd44780_init_delay3();
  hd44780_wr_hi_nibble( HD44780_CMD_RESET );


     #if HD44780_CONF_BUS == HD44780_FUNC_BUS_4BIT
    /* 4bit interface */
  hd44780_wr_hi_nibble( HD44780_CMD_FUNCTION );
  #endif /* HD44780_CONF_BUS == HD44780_FUNC_BUS_4BIT */


  /* sets the configured values - can be set again only after reset */
  hd44780_function( HD44780_CONF_BUS, HD44780_CONF_LINES, HD44780_CONF_FONT );


  /* turn the display on with no cursor or blinking */
     hd44780_display( HD44780_DISP_ON, HD44780_DISP_CURS_OFF, HD44780_DISP_BLINK_OFF );


  /* clear the display */
  hd44780_clear();


  /* addr increment, shift cursor */
     hd44780_entry( HD44780_ENTRY_ADDR_INC, HD44780_ENTRY_SHIFT_CURS );


}






/*********************************************************************************************
Function name   : HD44780_PutChar
Author                          : Grant Phillips
Date Modified   : 16/10/2013
Compiler        : Keil ARM-MDK (uVision V4.70.0.0)


Description               : Prints a character at the current character cursor position


Special Note(s) : NONE


Parameters               : c                    -     character to print


Return value          : NONE
*********************************************************************************************/
void HD44780_PutChar(unsigned char c)
{
     hd44780_wr_data(c & 0xff);
}






/*********************************************************************************************
Function name   : HD44780_GotoXY
Author                          : Grant Phillips
Date Modified   : 16/10/2013
Compiler        : Keil ARM-MDK (uVision V4.70.0.0)


Description               : Changes the position of the current character cursor from where the next
                                             characters will be printed.


Special Note(s) : NONE


Parameters               : x                    -     column position (0 - HD44780_DISP_LENGTH-1)
                                             y                    -     row position (0 - HD44780_DISP_ROWS-1)


Return value          : NONE
*********************************************************************************************/
void HD44780_GotoXY(unsigned char x, unsigned char y)
{
  unsigned char copy_y=0;


  if(x > (HD44780_DISP_LENGTH-1))
          x = 0;


     if(y > (HD44780_DISP_ROWS-1))
          y = 0;


     switch(y)
  {
          case 0:  copy_y = 0x80; break;
          case 1:  copy_y = 0xc0; break;
          case 2:  copy_y = 0x94; break;
          case 3:  copy_y = 0xd4; break;
  }
     hd44780_wr_cmd(x + copy_y);
}






/*********************************************************************************************
Function name   : HD44780_PutStr
Author                          : Grant Phillips
Date Modified   : 16/10/2013
Compiler        : Keil ARM-MDK (uVision V4.70.0.0)


Description               : Prints a string at the current character cursor position.


Special Note(s) : NONE


Parameters               : str               -     string (char array) to print


Return value          : NONE
*********************************************************************************************/
void HD44780_PutStr(char *str)
{
      unsigned int i=0;


     do
     {
          HD44780_PutChar(str[i]);
          i++;
     }while(str[i]!='\0');
}






/*********************************************************************************************
Function name   : HD44780_ClrScr
Author                          : Grant Phillips
Date Modified   : 16/10/2013
Compiler        : Keil ARM-MDK (uVision V4.70.0.0)


Description               : Clears the display


Special Note(s) : NONE


Parameters               : NONE
Return value          : NONE
*********************************************************************************************/
void HD44780_ClrScr(void)
{
     hd44780_wr_cmd(HD44780_CMD_CLEAR);
}


/*lcd*/












/* Private variables ---------------------------------------------------------*/
  RCC_ClocksTypeDef RCC_Clocks;
uint32_t TimingDelay = 0;
uint32_t UserButtonPressed = 0;
float HeadingValue = 0.0f;
float MagBuffer[3] = {0.0f}, AccBuffer[3] = {0.0f}, Buffer[3] = {0.0f};
uint8_t Xval, Yval = 0x00;


uint8_t DataReady = 0;
uint8_t PrevXferComplete = 1;
uint32_t USBConnectTimeOut = 100;


// Unused global variables that have to be included to ensure correct compiling */
// ###### DO NOT CHANGE ######
// ===============================================================================
/*
 *
 *uint32_t TimingDelay = 0;                                                                                     //used with the Delay function
uint8_t DataReady = 0;
uint32_t USBConnectTimeOut = 100;
uint32_t UserButtonPressed = 0;
uint8_t PrevXferComplete = 1;
*/
// ===============================================================================
float fNormAcc,fSinRoll,fCosRoll,fSinPitch,fCosPitch = 0.0f, RollAng = 0.0f, PitchAng = 0.0f;
float fTiltedX,fTiltedY = 0.0f;
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/


/**
  * @brief  Main program.
  * @param  None 
  * @retval None
  */
int main(void)
{  
     /*lcd */
     char buf[21];                                        //declare a string variable of 21 chars
       unsigned char i;


          /* Set the SysTick Interrupt to occur every 1ms) */
          RCC_GetClocksFreq(&RCC_Clocks);
          if (SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000))
               while(1);                                                                                                                                  //will end up in this infinite loop if there was an error with Systick_Config


          HD44780_Init();                                                            //initialize the lcd
          /*lcd */
           /*   uint8_t i = 0;*/
  /* SysTick end of count event each 10ms */
  RCC_GetClocksFreq(&RCC_Clocks);
  SysTick_Config(RCC_Clocks.HCLK_Frequency / 100);
  
  /* Initialize LEDs and User Button available on STM32F3-Discovery board */
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);
  STM_EVAL_LEDInit(LED5);
  STM_EVAL_LEDInit(LED6);
  STM_EVAL_LEDInit(LED7);
  STM_EVAL_LEDInit(LED8);
  STM_EVAL_LEDInit(LED9);
  STM_EVAL_LEDInit(LED10);
  
  STM_EVAL_PBInit(BUTTON_USER, BUTTON_MODE_EXTI); 


  /* Configure the USB */
  Demo_USB();
  
  /* Reset UserButton_Pressed variable */
  UserButtonPressed = 0x00; 
   
  /* Infinite loop */
  while (1)
  {
       /*lcd */
          HD44780_ClrScr();                                                    //clear the display
          Delay(1000);
          HD44780_GotoXY(0,0);                                             //set the character cursor to col=0, row=0
          HD44780_PutStr("Hello World!");                    //display text
          Delay(500);


          HD44780_GotoXY(0,1);                                             //set the character cursor to col=0, row=1
          for(i=1;i<=8;i++)
  {
               sprintf(buf, "%d " , i);                            //print a integer value and space to the buf string
    HD44780_PutStr(buf);                      //write a string variable to the LCD
    Delay(500);
  }
          Delay(1000);


          HD44780_ClrScr();                                                    //clear the display
          sprintf(buf, "Good Bye");                                //store a string constant into the buf string variable
  HD44780_GotoXY(0,0);                                             //set the character cursor to col=0, row=0
  for(i=0;i<=7;i++)
  {
     HD44780_PutChar(buf[i]);                     //display a character on the LCD
     Delay(500);
  }


          HD44780_GotoXY(4,1);                                             //set the character cursor to col=4, row=1
  for(i=65;i<=72;i++)
  {
    HD44780_PutChar(i);                                          //display a integer value as a byte onn the LCD
                                                                                                         //driver will convert it to the correpsonding ASCII char
    Delay(500);
  }
          Delay(1000);
          /*lcd */
    /* LEDs Off */
    STM_EVAL_LEDOff(LED3);
    STM_EVAL_LEDOff(LED6);
    STM_EVAL_LEDOff(LED7);
    STM_EVAL_LEDOff(LED4);
    STM_EVAL_LEDOff(LED10);
    STM_EVAL_LEDOff(LED8);
    STM_EVAL_LEDOff(LED9);
    STM_EVAL_LEDOff(LED5);
    
    /* Waiting User Button is pressed */
    while (UserButtonPressed == 0x00)
    {
         HD44780_PutStr("Hello World!");
      /* Toggle LD3 */
      STM_EVAL_LEDToggle(LED3);
      /* Insert 50 ms delay */
      Delay(5);
      /* Toggle LD5 */
      STM_EVAL_LEDToggle(LED5);
      /* Insert 50 ms delay */
      Delay(5);
      /* Toggle LD7 */
      STM_EVAL_LEDToggle(LED7);
      /* Insert 50 ms delay */
      Delay(5);
      /* Toggle LD9 */
      STM_EVAL_LEDToggle(LED9);
      /* Insert 50 ms delay */
      Delay(5);
      /* Toggle LD10 */
      STM_EVAL_LEDToggle(LED10);
      /* Insert 50 ms delay */
      Delay(5);
      /* Toggle LD8 */
      STM_EVAL_LEDToggle(LED8);
      /* Insert 50 ms delay */
      Delay(5); 
      /* Toggle LD6 */
      STM_EVAL_LEDToggle(LED6);
      /* Insert 50 ms delay */
      Delay(5);
      /* Toggle LD4 */
      STM_EVAL_LEDToggle(LED4);
      /* Insert 50 ms delay */
      Delay(5);
    }
    
    DataReady = 0x00;
    
    /* All LEDs Off */
    STM_EVAL_LEDOff(LED3);
    STM_EVAL_LEDOff(LED6);
    STM_EVAL_LEDOff(LED7);
    STM_EVAL_LEDOff(LED4);
    STM_EVAL_LEDOff(LED10);
    STM_EVAL_LEDOff(LED8);
    STM_EVAL_LEDOff(LED9);
    STM_EVAL_LEDOff(LED5); 
    
    /* Demo Gyroscope */
    Demo_GyroConfig();


    /* Waiting User Button is pressed */
    while (UserButtonPressed == 0x01)
    {
      /* Wait for data ready */
      while(DataReady != 0x05)
      {}
      DataReady = 0x00;
      
      /* LEDs Off */
      STM_EVAL_LEDOff(LED3);
      STM_EVAL_LEDOff(LED6);
      STM_EVAL_LEDOff(LED7);
      STM_EVAL_LEDOff(LED4);
      STM_EVAL_LEDOff(LED10);
      STM_EVAL_LEDOff(LED8);
      STM_EVAL_LEDOff(LED9);
      STM_EVAL_LEDOff(LED5);
      
      /* Read Gyro Angular data */
      Demo_GyroReadAngRate(Buffer);
         
      /* Update autoreload and capture compare registers value*/
      Xval = ABS((int8_t)(Buffer[0]));
      Yval = ABS((int8_t)(Buffer[1])); 
      
      if ( Xval>Yval)
      {
        if ((int8_t)Buffer[0] > 5.0f)
        { 
          /* LD10 On */
          STM_EVAL_LEDOn(LED10);
        }
        if ((int8_t)Buffer[0] < -5.0f)
        { 
          /* LD3 On */
          STM_EVAL_LEDOn(LED3);
        }
      }
      else
      {
        if ((int8_t)Buffer[1] < -5.0f)
        {
          /* LD6 on */
          STM_EVAL_LEDOn(LED6);
        }
        if ((int8_t)Buffer[1] > 5.0f)
        {
          /* LD7 On */
          STM_EVAL_LEDOn(LED7);
        } 
      }
    }
        
    DataReady = 0x00;
    
    /* LEDs Off */
    STM_EVAL_LEDOff(LED4);
    STM_EVAL_LEDOff(LED3);
    STM_EVAL_LEDOff(LED6);
    STM_EVAL_LEDOff(LED7);
    STM_EVAL_LEDOff(LED10);
    STM_EVAL_LEDOff(LED8);
    STM_EVAL_LEDOff(LED9);
    STM_EVAL_LEDOff(LED5);
    
    /* Demo Compass */
    Demo_CompassConfig();
    
    /* Waiting User Button is pressed */
    while (UserButtonPressed == 0x02)
    {
      /* Wait for data ready */
      while(DataReady !=0x05)
      {}
      DataReady = 0x00;
      
      /* Read Compass data */
      Demo_CompassReadMag(MagBuffer);
      Demo_CompassReadAcc(AccBuffer);
      
      for(i=0;i<3;i++)
        AccBuffer[i] /= 100.0f;
      
      fNormAcc = sqrt((AccBuffer[0]*AccBuffer[0])+(AccBuffer[1]*AccBuffer[1])+(AccBuffer[2]*AccBuffer[2]));
      
      fSinRoll = -AccBuffer[1]/fNormAcc;
      fCosRoll = sqrt(1.0-(fSinRoll * fSinRoll));
      fSinPitch = AccBuffer[0]/fNormAcc;
      fCosPitch = sqrt(1.0-(fSinPitch * fSinPitch));
     if ( fSinRoll >0)
     {
       if (fCosRoll>0)
       {
         RollAng = acos(fCosRoll)*180/PI;
       }
       else
       {
         RollAng = acos(fCosRoll)*180/PI + 180;
       }
     }
     else
     {
       if (fCosRoll>0)
       {
         RollAng = acos(fCosRoll)*180/PI + 360;
       }
       else
       {
         RollAng = acos(fCosRoll)*180/PI + 180;
       }
     }
     
      if ( fSinPitch >0)
     {
       if (fCosPitch>0)
       {
            PitchAng = acos(fCosPitch)*180/PI;
       }
       else
       {
          PitchAng = acos(fCosPitch)*180/PI + 180;
       }
     }
     else
     {
       if (fCosPitch>0)
       {
            PitchAng = acos(fCosPitch)*180/PI + 360;
       }
       else
       {
          PitchAng = acos(fCosPitch)*180/PI + 180;
       }
     }


      if (RollAng >=360)
      {
        RollAng = RollAng - 360;
      }
      
      if (PitchAng >=360)
      {
        PitchAng = PitchAng - 360;
      }
      
      fTiltedX = MagBuffer[0]*fCosPitch+MagBuffer[2]*fSinPitch;
      fTiltedY = MagBuffer[0]*fSinRoll*fSinPitch+MagBuffer[1]*fCosRoll-MagBuffer[1]*fSinRoll*fCosPitch;
      
      HeadingValue = (float) ((atan2f((float)fTiltedY,(float)fTiltedX))*180)/PI;
 
      if (HeadingValue < 0)
      {
        HeadingValue = HeadingValue + 360;    
      }
      
      if ((RollAng <= 40.0f) && (PitchAng <= 40.0f))
      {
        if (((HeadingValue < 25.0f)&&(HeadingValue >= 0.0f))||((HeadingValue >=340.0f)&&(HeadingValue <= 360.0f)))
        {
          STM_EVAL_LEDOn(LED10);
          STM_EVAL_LEDOff(LED3);
          STM_EVAL_LEDOff(LED6);
          STM_EVAL_LEDOff(LED7);
          STM_EVAL_LEDOff(LED4);
          STM_EVAL_LEDOff(LED8);
          STM_EVAL_LEDOff(LED9);
          STM_EVAL_LEDOff(LED5);
        }
        else  if ((HeadingValue <70.0f)&&(HeadingValue >= 25.0f))
        {
          STM_EVAL_LEDOn(LED9);
          STM_EVAL_LEDOff(LED6);
          STM_EVAL_LEDOff(LED10);
          STM_EVAL_LEDOff(LED3);
          STM_EVAL_LEDOff(LED8);
          STM_EVAL_LEDOff(LED5);
          STM_EVAL_LEDOff(LED4);
          STM_EVAL_LEDOff(LED7);
        } 
        else  if ((HeadingValue < 115.0f)&&(HeadingValue >= 70.0f))
        {
          STM_EVAL_LEDOn(LED7);
          STM_EVAL_LEDOff(LED3);
          STM_EVAL_LEDOff(LED4);
          STM_EVAL_LEDOff(LED9);
          STM_EVAL_LEDOff(LED10);
          STM_EVAL_LEDOff(LED8);
          STM_EVAL_LEDOff(LED6);
          STM_EVAL_LEDOff(LED5);
        }
        else  if ((HeadingValue <160.0f)&&(HeadingValue >= 115.0f))
        {
          STM_EVAL_LEDOn(LED5);
          STM_EVAL_LEDOff(LED6);
          STM_EVAL_LEDOff(LED10);
          STM_EVAL_LEDOff(LED8);
          STM_EVAL_LEDOff(LED9);
          STM_EVAL_LEDOff(LED7);
          STM_EVAL_LEDOff(LED4);
          STM_EVAL_LEDOff(LED3);
        } 
        else  if ((HeadingValue <205.0f)&&(HeadingValue >= 160.0f))
        {
          STM_EVAL_LEDOn(LED3);
          STM_EVAL_LEDOff(LED6);
          STM_EVAL_LEDOff(LED4);
          STM_EVAL_LEDOff(LED8);
          STM_EVAL_LEDOff(LED9);
          STM_EVAL_LEDOff(LED5);
          STM_EVAL_LEDOff(LED10);
          STM_EVAL_LEDOff(LED7);
        } 
        else  if ((HeadingValue <250.0f)&&(HeadingValue >= 205.0f))
        {
          STM_EVAL_LEDOn(LED4);
          STM_EVAL_LEDOff(LED6);
          STM_EVAL_LEDOff(LED10);
          STM_EVAL_LEDOff(LED8);
          STM_EVAL_LEDOff(LED9);
          STM_EVAL_LEDOff(LED5);
          STM_EVAL_LEDOff(LED3);
          STM_EVAL_LEDOff(LED7);
        } 
        else  if ((HeadingValue < 295.0f)&&(HeadingValue >= 250.0f))
        {
          STM_EVAL_LEDOn(LED6);
          STM_EVAL_LEDOff(LED9);
          STM_EVAL_LEDOff(LED10);
          STM_EVAL_LEDOff(LED8);
          STM_EVAL_LEDOff(LED3);
          STM_EVAL_LEDOff(LED5);
          STM_EVAL_LEDOff(LED4);
          STM_EVAL_LEDOff(LED7);
        }        
        else  if ((HeadingValue < 340.0f)&&(HeadingValue >= 295.0f))
        {
          STM_EVAL_LEDOn(LED8);
          STM_EVAL_LEDOff(LED6);
          STM_EVAL_LEDOff(LED10);
          STM_EVAL_LEDOff(LED7);
          STM_EVAL_LEDOff(LED9);
          STM_EVAL_LEDOff(LED3);
          STM_EVAL_LEDOff(LED4);
          STM_EVAL_LEDOff(LED5);
        }
      }
      else
      {
        /* Toggle All LEDs */
        STM_EVAL_LEDToggle(LED7);
        STM_EVAL_LEDToggle(LED6);
        STM_EVAL_LEDToggle(LED10);
        STM_EVAL_LEDToggle(LED8);
        STM_EVAL_LEDToggle(LED9);
        STM_EVAL_LEDToggle(LED3);
        STM_EVAL_LEDToggle(LED4);
        STM_EVAL_LEDToggle(LED5);
        /* Delay 50ms */
        Delay(5);
      }
    }
  }
}




/**
  * @brief  Configure the USB.
  * @param  None
  * @retval None
  */
void Demo_USB (void)
{
  Set_System();
  Set_USBClock();
  USB_Interrupts_Config();
  
  USB_Init();


  while ((bDeviceState != CONFIGURED)&&(USBConnectTimeOut != 0))
  {}
}


/**
  * @brief  Configure the Mems to gyroscope application.
  * @param  None
  * @retval None
  */
void Demo_GyroConfig(void)
{
  L3GD20_InitTypeDef L3GD20_InitStructure;
  L3GD20_FilterConfigTypeDef L3GD20_FilterStructure;
  
  /* Configure Mems L3GD20 */
  L3GD20_InitStructure.Power_Mode = L3GD20_MODE_ACTIVE;
  L3GD20_InitStructure.Output_DataRate = L3GD20_OUTPUT_DATARATE_1;
  L3GD20_InitStructure.Axes_Enable = L3GD20_AXES_ENABLE;
  L3GD20_InitStructure.Band_Width = L3GD20_BANDWIDTH_4;
  L3GD20_InitStructure.BlockData_Update = L3GD20_BlockDataUpdate_Continous;
  L3GD20_InitStructure.Endianness = L3GD20_BLE_LSB;
  L3GD20_InitStructure.Full_Scale = L3GD20_FULLSCALE_500; 
  L3GD20_Init(&L3GD20_InitStructure);
   
  L3GD20_FilterStructure.HighPassFilter_Mode_Selection =L3GD20_HPM_NORMAL_MODE_RES;
  L3GD20_FilterStructure.HighPassFilter_CutOff_Frequency = L3GD20_HPFCF_0;
  L3GD20_FilterConfig(&L3GD20_FilterStructure) ;
  
  L3GD20_FilterCmd(L3GD20_HIGHPASSFILTER_ENABLE);
}


/**
  * @brief  Calculate the angular Data rate Gyroscope.
  * @param  pfData : Data out pointer
  * @retval None
  */
void Demo_GyroReadAngRate (float* pfData)
{
  uint8_t tmpbuffer[6] ={0};
  int16_t RawData[3] = {0};
  uint8_t tmpreg = 0;
  float sensitivity = 0;
  int i =0;


  L3GD20_Read(&tmpreg,L3GD20_CTRL_REG4_ADDR,1);
  
  L3GD20_Read(tmpbuffer,L3GD20_OUT_X_L_ADDR,6);
  
  /* check in the control register 4 the data alignment (Big Endian or Little Endian)*/
  if(!(tmpreg & 0x40))
  {
    for(i=0; i<3; i++)
    {
      RawData[i]=(int16_t)(((uint16_t)tmpbuffer[2*i+1] << 8) + tmpbuffer[2*i]);
    }
  }
  else
  {
    for(i=0; i<3; i++)
    {
      RawData[i]=(int16_t)(((uint16_t)tmpbuffer[2*i] << 8) + tmpbuffer[2*i+1]);
    }
  }
  
  /* Switch the sensitivity value set in the CRTL4 */
  switch(tmpreg & 0x30)
  {
  case 0x00:
    sensitivity=L3G_Sensitivity_250dps;
    break;
    
  case 0x10:
    sensitivity=L3G_Sensitivity_500dps;
    break;
    
  case 0x20:
    sensitivity=L3G_Sensitivity_2000dps;
    break;
  }
  /* divide by sensitivity */
  for(i=0; i<3; i++)
  {
    pfData[i]=(float)RawData[i]/sensitivity;
  }
}


/**
  * @brief  Configure the Mems to compass application.
  * @param  None
  * @retval None
  */
void Demo_CompassConfig(void)
{
  LSM303DLHCMag_InitTypeDef LSM303DLHC_InitStructure;
  LSM303DLHCAcc_InitTypeDef LSM303DLHCAcc_InitStructure;
  LSM303DLHCAcc_FilterConfigTypeDef LSM303DLHCFilter_InitStructure;
  
  /* Configure MEMS magnetometer main parameters: temp, working mode, full Scale and Data rate */
  LSM303DLHC_InitStructure.Temperature_Sensor = LSM303DLHC_TEMPSENSOR_DISABLE;
  LSM303DLHC_InitStructure.MagOutput_DataRate =LSM303DLHC_ODR_30_HZ ;
  LSM303DLHC_InitStructure.MagFull_Scale = LSM303DLHC_FS_8_1_GA;
  LSM303DLHC_InitStructure.Working_Mode = LSM303DLHC_CONTINUOS_CONVERSION;
  LSM303DLHC_MagInit(&LSM303DLHC_InitStructure);
  
   /* Fill the accelerometer structure */
  LSM303DLHCAcc_InitStructure.Power_Mode = LSM303DLHC_NORMAL_MODE;
  LSM303DLHCAcc_InitStructure.AccOutput_DataRate = LSM303DLHC_ODR_50_HZ;
  LSM303DLHCAcc_InitStructure.Axes_Enable= LSM303DLHC_AXES_ENABLE;
  LSM303DLHCAcc_InitStructure.AccFull_Scale = LSM303DLHC_FULLSCALE_2G;
  LSM303DLHCAcc_InitStructure.BlockData_Update = LSM303DLHC_BlockUpdate_Continous;
  LSM303DLHCAcc_InitStructure.Endianness=LSM303DLHC_BLE_LSB;
  LSM303DLHCAcc_InitStructure.High_Resolution=LSM303DLHC_HR_ENABLE;
  /* Configure the accelerometer main parameters */
  LSM303DLHC_AccInit(&LSM303DLHCAcc_InitStructure);
  
  /* Fill the accelerometer LPF structure */
  LSM303DLHCFilter_InitStructure.HighPassFilter_Mode_Selection =LSM303DLHC_HPM_NORMAL_MODE;
  LSM303DLHCFilter_InitStructure.HighPassFilter_CutOff_Frequency = LSM303DLHC_HPFCF_16;
  LSM303DLHCFilter_InitStructure.HighPassFilter_AOI1 = LSM303DLHC_HPF_AOI1_DISABLE;
  LSM303DLHCFilter_InitStructure.HighPassFilter_AOI2 = LSM303DLHC_HPF_AOI2_DISABLE;


  /* Configure the accelerometer LPF main parameters */
  LSM303DLHC_AccFilterConfig(&LSM303DLHCFilter_InitStructure);
}


/**
* @brief Read LSM303DLHC output register, and calculate the acceleration ACC=(1/SENSITIVITY)* (out_h*256+out_l)/16 (12 bit rappresentation)
* @param pnData: pointer to float buffer where to store data
* @retval None
*/
void Demo_CompassReadAcc(float* pfData)
{
  int16_t pnRawData[3];
  uint8_t ctrlx[2];
  uint8_t buffer[6], cDivider;
  uint8_t i = 0;
  float LSM_Acc_Sensitivity = LSM_Acc_Sensitivity_2g;
  
  /* Read the register content */
  LSM303DLHC_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG4_A, ctrlx,2);
  LSM303DLHC_Read(ACC_I2C_ADDRESS, LSM303DLHC_OUT_X_L_A, buffer, 6);
   
  if(ctrlx[1]&0x40)
    cDivider=64;
  else
    cDivider=16;


  /* check in the control register4 the data alignment*/
  if(!(ctrlx[0] & 0x40) || (ctrlx[1] & 0x40)) /* Little Endian Mode or FIFO mode */
  {
    for(i=0; i<3; i++)
    {
      pnRawData[i]=((int16_t)((uint16_t)buffer[2*i+1] << 8) + buffer[2*i])/cDivider;
    }
  }
  else /* Big Endian Mode */
  {
    for(i=0; i<3; i++)
      pnRawData[i]=((int16_t)((uint16_t)buffer[2*i] << 8) + buffer[2*i+1])/cDivider;
  }
  /* Read the register content */
  LSM303DLHC_Read(ACC_I2C_ADDRESS, LSM303DLHC_CTRL_REG4_A, ctrlx,2);




  if(ctrlx[1]&0x40)
  {
    /* FIFO mode */
    LSM_Acc_Sensitivity = 0.25;
  }
  else
  {
    /* normal mode */
    /* switch the sensitivity value set in the CRTL4*/
    switch(ctrlx[0] & 0x30)
    {
    case LSM303DLHC_FULLSCALE_2G:
      LSM_Acc_Sensitivity = LSM_Acc_Sensitivity_2g;
      break;
    case LSM303DLHC_FULLSCALE_4G:
      LSM_Acc_Sensitivity = LSM_Acc_Sensitivity_4g;
      break;
    case LSM303DLHC_FULLSCALE_8G:
      LSM_Acc_Sensitivity = LSM_Acc_Sensitivity_8g;
      break;
    case LSM303DLHC_FULLSCALE_16G:
      LSM_Acc_Sensitivity = LSM_Acc_Sensitivity_16g;
      break;
    }
  }


  /* Obtain the mg value for the three axis */
  for(i=0; i<3; i++)
  {
    pfData[i]=(float)pnRawData[i]/LSM_Acc_Sensitivity;
  }


}


/**
  * @brief  calculate the magnetic field Magn.
* @param  pfData: pointer to the data out
  * @retval None
  */
void Demo_CompassReadMag (float* pfData)
{
  static uint8_t buffer[6] = {0};
  uint8_t CTRLB = 0;
  uint16_t Magn_Sensitivity_XY = 0, Magn_Sensitivity_Z = 0;
  uint8_t i =0;
  LSM303DLHC_Read(MAG_I2C_ADDRESS, LSM303DLHC_CRB_REG_M, &CTRLB, 1);
  
  LSM303DLHC_Read(MAG_I2C_ADDRESS, LSM303DLHC_OUT_X_H_M, buffer, 1);
  LSM303DLHC_Read(MAG_I2C_ADDRESS, LSM303DLHC_OUT_X_L_M, buffer+1, 1);
  LSM303DLHC_Read(MAG_I2C_ADDRESS, LSM303DLHC_OUT_Y_H_M, buffer+2, 1);
  LSM303DLHC_Read(MAG_I2C_ADDRESS, LSM303DLHC_OUT_Y_L_M, buffer+3, 1);
  LSM303DLHC_Read(MAG_I2C_ADDRESS, LSM303DLHC_OUT_Z_H_M, buffer+4, 1);
  LSM303DLHC_Read(MAG_I2C_ADDRESS, LSM303DLHC_OUT_Z_L_M, buffer+5, 1);
  /* Switch the sensitivity set in the CRTLB*/
  switch(CTRLB & 0xE0)
  {
  case LSM303DLHC_FS_1_3_GA:
    Magn_Sensitivity_XY = LSM303DLHC_M_SENSITIVITY_XY_1_3Ga;
    Magn_Sensitivity_Z = LSM303DLHC_M_SENSITIVITY_Z_1_3Ga;
    break;
  case LSM303DLHC_FS_1_9_GA:
    Magn_Sensitivity_XY = LSM303DLHC_M_SENSITIVITY_XY_1_9Ga;
    Magn_Sensitivity_Z = LSM303DLHC_M_SENSITIVITY_Z_1_9Ga;
    break;
  case LSM303DLHC_FS_2_5_GA:
    Magn_Sensitivity_XY = LSM303DLHC_M_SENSITIVITY_XY_2_5Ga;
    Magn_Sensitivity_Z = LSM303DLHC_M_SENSITIVITY_Z_2_5Ga;
    break;
  case LSM303DLHC_FS_4_0_GA:
    Magn_Sensitivity_XY = LSM303DLHC_M_SENSITIVITY_XY_4Ga;
    Magn_Sensitivity_Z = LSM303DLHC_M_SENSITIVITY_Z_4Ga;
    break;
  case LSM303DLHC_FS_4_7_GA:
    Magn_Sensitivity_XY = LSM303DLHC_M_SENSITIVITY_XY_4_7Ga;
    Magn_Sensitivity_Z = LSM303DLHC_M_SENSITIVITY_Z_4_7Ga;
    break;
  case LSM303DLHC_FS_5_6_GA:
    Magn_Sensitivity_XY = LSM303DLHC_M_SENSITIVITY_XY_5_6Ga;
    Magn_Sensitivity_Z = LSM303DLHC_M_SENSITIVITY_Z_5_6Ga;
    break;
  case LSM303DLHC_FS_8_1_GA:
    Magn_Sensitivity_XY = LSM303DLHC_M_SENSITIVITY_XY_8_1Ga;
    Magn_Sensitivity_Z = LSM303DLHC_M_SENSITIVITY_Z_8_1Ga;
    break;
  }
  
  for(i=0; i<2; i++)
  {
    pfData[i]=(float)((int16_t)(((uint16_t)buffer[2*i] << 8) + buffer[2*i+1])*1000)/Magn_Sensitivity_XY;
  }
  pfData[2]=(float)((int16_t)(((uint16_t)buffer[4] << 8) + buffer[5])*1000)/Magn_Sensitivity_Z;
}


/**
  * @brief  Inserts a delay time.
  * @param  nTime: specifies the delay time length, in 10 ms.
  * @retval None
  */
void Delay(__IO uint32_t nTime)
{
  TimingDelay = nTime;


  while(TimingDelay != 0);
}


/**
  * @brief  Decrements the TimingDelay variable.
  * @param  None
  * @retval None
  */
void TimingDelay_Decrement(void)
{
  if (TimingDelay != 0x00)
  { 
    TimingDelay--;
  }
}


/**
  * @brief  Basic management of the timeout situation.
  * @param  None.
  * @retval None.
  */
uint32_t LSM303DLHC_TIMEOUT_UserCallback(void)
{
  return 0;
}


/**
  * @brief  Basic management of the timeout situation.
  * @param  None.
  * @retval None.
  */
uint32_t L3GD20_TIMEOUT_UserCallback(void)
{
  return 0;
}


#ifdef  USE_FULL_ASSERT


/**
  * @brief  Reports the name of the source file and the source line number
  *         where the assert_param error has occurred.
  * @param  file: pointer to the source file name
  * @param  line: assert_param error line source number
  * @retval None
  */
void assert_failed(uint8_t* file, uint32_t line)

  /* User can add his own implementation to report the file name and line number,
     ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */


  /* Infinite loop */
  while (1)
  {
  }
}
#endif


/**
  * @}
  */


/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/












  [cc] 41 total files to be compiled.
       [cc] arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -Wall -ffunction-sections -g -O0 -c -DSTM32F303VC -DSTM32F30X -DUSE_STDPERIPH_DRIVER -IE:\kuliah\ARM\Test_STM32F303\stm_lib\inc -IE:\kuliah\ARM\Test_STM32F303\stm_lib -IE:\kuliah\ARM\Test_STM32F303\stm_usb\inc -IE:\kuliah\ARM\Test_STM32F303 -IE:\kuliah\ARM\Test_STM32F303\stm_usb -IE:\kuliah\ARM\Test_STM32F303\cmsis -IE:\kuliah -IE:\kuliah\ARM -IE:\kuliah\ARM\Test_STM32F303\cmsis_boot -IE:\kuliah\ARM\Test_STM32F303\utils E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_iwdg.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_opamp.c E:\kuliah\ARM\Test_STM32F303\stm_usb\src\usb_core.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_crc.c E:\kuliah\ARM\Test_STM32F303\cmsis_boot\startup\startup_stm32f303.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_rcc.c E:\kuliah\ARM\Test_STM32F303\utils\stm32f3_discovery_lsm303dlhc.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_flash.c E:\kuliah\ARM\Test_STM32F303\cmsis_boot\system_stm32f30x.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_adc.c E:\kuliah\ARM\Test_STM32F303\stm_usb\src\usb_int.c E:\kuliah\ARM\Test_STM32F303\usb_desc.c E:\kuliah\ARM\Test_STM32F303\stm_usb\src\usb_regs.c E:\kuliah\ARM\Test_STM32F303\hw_config.c E:\kuliah\ARM\Test_STM32F303\usb_prop.c E:\kuliah\ARM\Test_STM32F303\stm32f30x_it.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_comp.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_gpio.c E:\kuliah\ARM\Test_STM32F303\usb_pwr.c E:\kuliah\ARM\Test_STM32F303\stm_usb\src\usb_init.c E:\kuliah\ARM\Test_STM32F303\main.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_dma.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_exti.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_spi.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_i2c.c E:\kuliah\ARM\Test_STM32F303\stm_usb\src\usb_sil.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_rtc.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_misc.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_tim.c E:\kuliah\ARM\Test_STM32F303\utils\stm32f3_discovery_l3gd20.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_dbgmcu.c E:\kuliah\ARM\Test_STM32F303\usb_endp.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_syscfg.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_pwr.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_wwdg.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_can.c E:\kuliah\ARM\Test_STM32F303\stm_usb\src\usb_mem.c E:\kuliah\ARM\Test_STM32F303\utils\stm32f3_discovery.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_dac.c E:\kuliah\ARM\Test_STM32F303\usb_istr.c E:\kuliah\ARM\Test_STM32F303\stm_lib\src\stm32f30x_usart.c
       [cc] Starting link
       [cc] arm-none-eabi-gcc -mcpu=cortex-m4 -mthumb -g -nostartfiles -Wl,-Map=Test_STM32F303.map -O0 -Wl,--gc-sections -LC:\CooCox\CoIDE\configuration\ProgramData\Test_STM32F303 -Wl,-TC:\CooCox\CoIDE\configuration\ProgramData\Test_STM32F303/arm-gcc-link.ld -g -o Test_STM32F303.elf ..\obj\stm32f30x_iwdg.o ..\obj\stm32f30x_opamp.o ..\obj\usb_core.o ..\obj\stm32f30x_crc.o ..\obj\startup_stm32f303.o ..\obj\stm32f30x_rcc.o ..\obj\stm32f3_discovery_lsm303dlhc.o ..\obj\stm32f30x_flash.o ..\obj\system_stm32f30x.o ..\obj\stm32f30x_adc.o ..\obj\usb_int.o ..\obj\usb_desc.o ..\obj\usb_regs.o ..\obj\hw_config.o ..\obj\usb_prop.o ..\obj\stm32f30x_it.o ..\obj\stm32f30x_comp.o ..\obj\stm32f30x_gpio.o ..\obj\usb_pwr.o ..\obj\usb_init.o ..\obj\main.o ..\obj\stm32f30x_dma.o ..\obj\stm32f30x_exti.o ..\obj\stm32f30x_spi.o ..\obj\stm32f30x_i2c.o ..\obj\usb_sil.o ..\obj\stm32f30x_rtc.o ..\obj\stm32f30x_misc.o ..\obj\stm32f30x_tim.o ..\obj\stm32f3_discovery_l3gd20.o ..\obj\stm32f30x_dbgmcu.o ..\obj\usb_endp.o ..\obj\stm32f30x_syscfg.o ..\obj\stm32f30x_pwr.o ..\obj\stm32f30x_wwdg.o ..\obj\stm32f30x_can.o ..\obj\usb_mem.o ..\obj\stm32f3_discovery.o ..\obj\stm32f30x_dac.o ..\obj\usb_istr.o ..\obj\stm32f30x_usart.o -L..\..\.. -lm
       [cc] c:/program files/gnu tools arm embedded/4.7 2013q2/bin/../lib/gcc/arm-none-eabi/4.7.4/../../../../arm-none-eabi/lib/armv7e-m\libg.a(lib_a-sbrkr.o): In function `_sbrk_r':
       [cc] sbrkr.c:(.text._sbrk_r+0xc): undefined reference to `_sbrk'
       [cc] collect2.exe: error: ld returned 1 exit status

Outcomes