1 | /**
|
2 | ******************************************************************************
|
3 | * @file main.c
|
4 | * @author EGü
|
5 | * @version V1
|
6 | * @date 29.08.2012
|
7 | * @brief Main program body
|
8 | */
|
9 |
|
10 | /* Includes ------------------------------------------------------------------*/
|
11 | #include "stm32f10x.h"
|
12 | #include "main.h"
|
13 | #include <stdio.h>
|
14 | /* Private constants ---------------------------------------------------------*/
|
15 | char ReceivedData = NULL;
|
16 | /* Private function prototypes -----------------------------------------------*/
|
17 | #ifdef __GNUC__
|
18 | /* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf
|
19 | set to 'Yes') calls __io_putchar() */
|
20 | #define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
|
21 | #else
|
22 | #define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)
|
23 | #endif /* __GNUC__ */
|
24 | /* Main Routine ---------------------------------------------------------*/
|
25 | int main(void)
|
26 | {
|
27 | SystemInit();
|
28 | /* Enable GPIOA, GPIOB, GPIOC, GPIOD, GPIOE and AFIO clocks */
|
29 | RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB |RCC_APB2Periph_GPIOC
|
30 | | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE | RCC_APB2Periph_AFIO, ENABLE );
|
31 |
|
32 |
|
33 | UARTInit();
|
34 | while(1) {
|
35 | printf("TEST TEST TEST ");
|
36 | }
|
37 | }
|
38 |
|
39 | void UARTInit()
|
40 | {
|
41 | /* USARTx configured as follow:
|
42 | - BaudRate = 115200 baud
|
43 | - Word Length = 8 Bits
|
44 | - One Stop Bit
|
45 | - No parity
|
46 | - Hardware flow control disabled (RTS and CTS signals)
|
47 | - Receive and transmit enabled
|
48 | */
|
49 | USART_InitTypeDef USART_InitStructure;
|
50 | USART_InitStructure.USART_BaudRate = 115200;
|
51 | USART_InitStructure.USART_WordLength = USART_WordLength_8b;
|
52 | USART_InitStructure.USART_StopBits = USART_StopBits_1;
|
53 | USART_InitStructure.USART_Parity = USART_Parity_No;
|
54 | USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
|
55 | USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx;
|
56 | COMInit(USART2, &USART_InitStructure); //bei dir heißt das anders!
|
57 | }
|
58 |
|
59 |
|
60 | /**
|
61 | * @brief Retargets the C library printf function to the USART.
|
62 | * @param None
|
63 | * @retval None
|
64 | */
|
65 | PUTCHAR_PROTOTYPE
|
66 | {
|
67 | /* Place your implementation of fputc here */
|
68 | /* e.g. write a character to the USART */
|
69 | USART_SendData(USART2, (uint8_t) ch);
|
70 |
|
71 | /* Loop until the end of transmission */
|
72 | while (USART_GetFlagStatus(USART2, USART_FLAG_TC) == RESET)
|
73 | {}
|
74 |
|
75 | return ch;
|
76 | }
|
77 |
|
78 | #ifdef USE_FULL_ASSERT
|
79 |
|
80 | /**
|
81 | * @brief Reports the name of the source file and the source line number
|
82 | * where the assert_param error has occurred.
|
83 | * @param file: pointer to the source file name
|
84 | * @param line: assert_param error line source number
|
85 | * @retval None
|
86 | */
|
87 | void assert_failed(uint8_t* file, uint32_t line)
|
88 | {
|
89 | /* User can add his own implementation to report the file name and line number,
|
90 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
|
91 |
|
92 | /* Infinite loop */
|
93 | while (1)
|
94 | {
|
95 | }
|
96 | }
|
97 | #endif
|