comparison libs/STM32F10x_StdPeriph_Lib_V3.5.0/Project/STM32F10x_StdPeriph_Examples/Lib_DEBUG/RunTime_Check/main.c @ 0:c59513fd84fb

Initial commit of STM32 test code.
author Daniel O'Connor <darius@dons.net.au>
date Mon, 03 Oct 2011 21:19:15 +1030
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:c59513fd84fb
1 /**
2 ******************************************************************************
3 * @file Lib_DEBUG/RunTime_Check/main.c
4 * @author MCD Application Team
5 * @version V3.5.0
6 * @date 08-April-2011
7 * @brief Main program body
8 ******************************************************************************
9 * @attention
10 *
11 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
12 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
13 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
14 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
15 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
16 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
17 *
18 * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
19 ******************************************************************************
20 */
21
22 /* Includes ------------------------------------------------------------------*/
23 #include "stm32f10x.h"
24 #include "stm32f10x_ip_dbg.h"
25 #include "stm32_eval.h"
26 #include <stdio.h>
27
28 /** @addtogroup STM32F10x_StdPeriph_Examples
29 * @{
30 */
31
32 /** @addtogroup Lib_DEBUG_RunTime_Check
33 * @{
34 */
35
36 /* Private typedef -----------------------------------------------------------*/
37 /* Private define ------------------------------------------------------------*/
38 /* Private macro -------------------------------------------------------------*/
39 /* Private variables ---------------------------------------------------------*/
40 USART_InitTypeDef USART_InitStructure;
41
42 /* Private function prototypes -----------------------------------------------*/
43 #ifdef __GNUC__
44 /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
45 set to 'Yes') calls __io_putchar() */
46 #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
47 #else
48 #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
49 #endif /* __GNUC__ */
50
51 /* Private functions ---------------------------------------------------------*/
52
53 /**
54 * @brief Main program.
55 * @param None
56 * @retval None
57 */
58 int main(void)
59 {
60 /*!< At this stage the microcontroller clock setting is already configured,
61 this is done through SystemInit() function which is called from startup
62 file (startup_stm32f10x_xx.s) before to branch to application main.
63 To reconfigure the default setting of SystemInit() function, refer to
64 system_stm32f10x.c file
65 */
66
67 GPIO_InitTypeDef GPIOA_InitStructure;
68
69 /* USARTx configured as follow:
70 - BaudRate = 115200 baud
71 - Word Length = 8 Bits
72 - One Stop Bit
73 - No parity
74 - Hardware flow control disabled (RTS and CTS signals)
75 - Receive and transmit enabled
76 */
77 USART_InitStructure.USART_BaudRate = 115200;
78 USART_InitStructure.USART_WordLength = USART_WordLength_8b;
79 USART_InitStructure.USART_StopBits = USART_StopBits_1;
80 USART_InitStructure.USART_Parity = USART_Parity_No;
81 USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
82 USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
83
84 STM_EVAL_COMInit(COM1, &USART_InitStructure);
85
86 /* Initialize all peripherals pointers */
87 debug();
88
89 printf("\r\n STM32F10x Firmware Library compiled with FULL ASSERT function... \n\r");
90 printf("...Run-time checking enabled \n\r");
91
92 /* Simulate wrong parameter passed to library function ---------------------*/
93 /* To enable SPI1 clock, RCC_APB2PeriphClockCmd function must be used and
94 not RCC_APB1PeriphClockCmd */
95 RCC_APB1PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
96
97 /* Some member of GPIOA_InitStructure structure are not initialized */
98 GPIOA_InitStructure.GPIO_Pin = GPIO_Pin_6;
99 GPIOA_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
100 /* GPIOA_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; */
101 GPIO_Init(GPIOA, &GPIOA_InitStructure);
102
103 while (1)
104 {
105 }
106
107 }
108
109 #ifdef USE_FULL_ASSERT
110
111 /**
112 * @brief Reports the name of the source file and the source line number
113 * where the assert_param error has occurred.
114 * @param file: pointer to the source file name
115 * @param line: assert_param error line source number
116 * @retval None
117 */
118 void assert_failed(uint8_t* file, uint32_t line)
119 {
120 /* User can add his own implementation to report the file name and line number */
121
122 printf("\n\r Wrong parameter value detected on\r\n");
123 printf(" file %s\r\n", file);
124 printf(" line %d\r\n", line);
125
126 /* Infinite loop */
127 /* while (1)
128 {
129 } */
130 }
131
132 #endif
133
134 /**
135 * @brief Retargets the C library printf function to the USART.
136 * @param None
137 * @retval None
138 */
139 PUTCHAR_PROTOTYPE
140 {
141 /* Place your implementation of fputc here */
142 /* e.g. write a character to the USART */
143 USART_SendData(EVAL_COM1, (uint8_t) ch);
144
145 /* Loop until the end of transmission */
146 while(USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET)
147 {
148 }
149
150 return ch;
151 }
152
153 /**
154 * @}
155 */
156
157 /**
158 * @}
159 */
160
161 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/