STM32F10x_StdPeriph_Examples/Lib_DEBUG/main.c

Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    Lib_DEBUG/main.c 
00004   * @author  MCD Application Team
00005   * @version V3.4.0
00006   * @date    10/15/2010
00007   * @brief   Main program body
00008   ******************************************************************************
00009   * @copy
00010   *
00011   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00012   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
00013   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
00014   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
00015   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
00016   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00017   *
00018   * <h2><center>&copy; COPYRIGHT 2010 STMicroelectronics</center></h2>
00019   */ 
00020 
00021 /* Includes ------------------------------------------------------------------*/
00022 #include "stm32f10x.h"
00023 #include "lib_dbg.h"
00024 #include "stm32_eval.h"
00025 #include <stdio.h>
00026 
00027 /** @addtogroup STM32F10x_StdPeriph_Examples
00028   * @{
00029   */
00030 
00031 /** @addtogroup Lib_DEBUG
00032   * @{
00033   */ 
00034 
00035 /* Private typedef -----------------------------------------------------------*/
00036 /* Private define ------------------------------------------------------------*/
00037 /* Private macro -------------------------------------------------------------*/
00038 /* Private variables ---------------------------------------------------------*/
00039  USART_InitTypeDef USART_InitStructure;
00040 
00041 /* Private function prototypes -----------------------------------------------*/
00042 #ifdef __GNUC__
00043   /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
00044      set to 'Yes') calls __io_putchar() */
00045   #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
00046 #else
00047   #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
00048 #endif /* __GNUC__ */
00049 
00050 /* Private functions ---------------------------------------------------------*/
00051 
00052 /**
00053   * @brief  Main program.
00054   * @param  None
00055   * @retval None
00056   */
00057 int main(void)
00058 {
00059   /*!< At this stage the microcontroller clock setting is already configured, 
00060        this is done through SystemInit() function which is called from startup
00061        file (startup_stm32f10x_xx.s) before to branch to application main.
00062        To reconfigure the default setting of SystemInit() function, refer to
00063        system_stm32f10x.c file
00064      */     
00065        
00066   GPIO_InitTypeDef GPIOA_InitStructure;
00067 
00068   /* USARTx configured as follow:
00069         - BaudRate = 115200 baud  
00070         - Word Length = 8 Bits
00071         - One Stop Bit
00072         - No parity
00073         - Hardware flow control disabled (RTS and CTS signals)
00074         - Receive and transmit enabled
00075   */
00076   USART_InitStructure.USART_BaudRate = 115200;
00077   USART_InitStructure.USART_WordLength = USART_WordLength_8b;
00078   USART_InitStructure.USART_StopBits = USART_StopBits_1;
00079   USART_InitStructure.USART_Parity = USART_Parity_No;
00080   USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
00081   USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
00082 
00083   STM_EVAL_COMInit(COM1, &USART_InitStructure);
00084 
00085   /* Initialize all peripherals pointers */
00086   debug();
00087   
00088   printf("\r\n STM32F10x Firmware Library compiled with FULL ASSERT function... \n\r");
00089   printf("...Run-time checking enabled  \n\r");
00090 
00091   /* Simulate wrong parameter passed to library function ---------------------*/
00092   /* To enable SPI1 clock, RCC_APB2PeriphClockCmd function must be used and
00093      not RCC_APB1PeriphClockCmd */
00094   RCC_APB1PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
00095   
00096   /* Some member of GPIOA_InitStructure structure are not initialized */
00097   GPIOA_InitStructure.GPIO_Pin = GPIO_Pin_6;
00098   GPIOA_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
00099   /* GPIOA_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; */
00100   GPIO_Init(GPIOA, &GPIOA_InitStructure);
00101   
00102   while (1)
00103   {
00104   }
00105 
00106 }
00107 
00108 #ifdef  USE_FULL_ASSERT
00109 /**
00110   * @brief  Reports the name of the source file and the source line number
00111   *         where the assert_param error has occurred.
00112   * @param  file: pointer to the source file name
00113   * @param  line: assert_param error line source number
00114   * @retval None
00115   */
00116 void assert_failed(uint8_t* file, uint32_t line)
00117 { 
00118   /* User can add his own implementation to report the file name and line number */
00119 
00120   printf("\n\r Wrong parameter value detected on\r\n");
00121   printf("       file  %s\r\n", file);
00122   printf("       line  %d\r\n", line);
00123     
00124   /* Infinite loop */
00125   /* while (1)
00126   {
00127   } */
00128 }
00129 #endif
00130 
00131 /**
00132   * @brief  Retargets the C library printf function to the USART.
00133   * @param  None
00134   * @retval None
00135   */
00136 PUTCHAR_PROTOTYPE
00137 {
00138   /* Place your implementation of fputc here */
00139   /* e.g. write a character to the USART */
00140   USART_SendData(EVAL_COM1, (uint8_t) ch);
00141 
00142   /* Loop until the end of transmission */
00143   while(USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET)
00144   {
00145   }
00146 
00147   return ch;
00148 }
00149 
00150 /**
00151   * @}
00152   */
00153 
00154 /**
00155   * @}
00156   */
00157 
00158 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
STM32F10x Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit  www.st.com/STM32