Rev 41 | Rev 134 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 41 | Rev 110 | ||
---|---|---|---|
Line 56... | Line 56... | ||
56 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
56 | // ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
57 | //#include <stdio.h> |
57 | //#include <stdio.h> |
58 | #include "91x_lib.h" |
58 | #include "91x_lib.h" |
59 | #include "uart1.h" |
59 | #include "uart1.h" |
Line -... | Line 60... | ||
- | 60 | ||
- | 61 | #define UART2_BAUD_RATE 57600 //Baud Rate for the serial interfaces |
|
- | 62 | ||
60 | 63 | ||
61 | /********************************************************/ |
64 | /********************************************************/ |
62 | /* Initialize UART2 */ |
65 | /* Initialize UART2 */ |
63 | /********************************************************/ |
66 | /********************************************************/ |
64 | void UART2_Init(void) |
67 | void UART2_Init(void) |
65 | { |
68 | { |
66 | UART_InitTypeDef UART_InitStructure; |
69 | UART_InitTypeDef UART_InitStructure; |
Line 67... | Line 70... | ||
67 | GPIO_InitTypeDef GPIO_InitStructure; |
70 | GPIO_InitTypeDef GPIO_InitStructure; |
Line 68... | Line 71... | ||
68 | 71 | ||
Line 69... | Line 72... | ||
69 | SerialPutString("\r\n UART2 init..."); |
72 | UART1_PutString("\r\n UART2 init..."); |
70 | 73 | ||
Line 101... | Line 104... | ||
101 | */ |
104 | */ |
102 | UART_StructInit(&UART_InitStructure); |
105 | UART_StructInit(&UART_InitStructure); |
103 | UART_InitStructure.UART_WordLength = UART_WordLength_8D; |
106 | UART_InitStructure.UART_WordLength = UART_WordLength_8D; |
104 | UART_InitStructure.UART_StopBits = UART_StopBits_1; |
107 | UART_InitStructure.UART_StopBits = UART_StopBits_1; |
105 | UART_InitStructure.UART_Parity = UART_Parity_No ; |
108 | UART_InitStructure.UART_Parity = UART_Parity_No ; |
106 | UART_InitStructure.UART_BaudRate = BAUD_RATE; |
109 | UART_InitStructure.UART_BaudRate = UART2_BAUD_RATE; |
107 | UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None; |
110 | UART_InitStructure.UART_HardwareFlowControl = UART_HardwareFlowControl_None; |
108 | UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx; |
111 | UART_InitStructure.UART_Mode = UART_Mode_Tx_Rx; |
109 | UART_InitStructure.UART_FIFO = UART_FIFO_Enable; |
112 | UART_InitStructure.UART_FIFO = UART_FIFO_Enable; |
110 | UART_InitStructure.UART_TxFIFOLevel = UART_FIFOLevel_1_2; |
113 | UART_InitStructure.UART_TxFIFOLevel = UART_FIFOLevel_1_2; |
111 | UART_InitStructure.UART_RxFIFOLevel = UART_FIFOLevel_1_2; |
114 | UART_InitStructure.UART_RxFIFOLevel = UART_FIFOLevel_1_2; |
Line 119... | Line 122... | ||
119 | // configure the uart 2 interupt line as an IRQ with priority 9 (0 is highest) |
122 | // configure the uart 2 interupt line as an IRQ with priority 9 (0 is highest) |
120 | VIC_Config(UART2_ITLine, VIC_IRQ, 9); |
123 | VIC_Config(UART2_ITLine, VIC_IRQ, 9); |
121 | // enable the uart 2 IRQ |
124 | // enable the uart 2 IRQ |
122 | VIC_ITCmd(UART2_ITLine, ENABLE); |
125 | VIC_ITCmd(UART2_ITLine, ENABLE); |
Line 123... | Line 126... | ||
123 | 126 | ||
124 | SerialPutString("ok"); |
127 | UART1_PutString("ok"); |
Line 125... | Line 128... | ||
125 | } |
128 | } |
126 | 129 | ||
127 | 130 | ||
Line 128... | Line 131... | ||
128 | void UART2_Deinit(void) |
131 | void UART2_Deinit(void) |
129 | { |
132 | { |
130 | GPIO_InitTypeDef GPIO_InitStructure; |
133 | GPIO_InitTypeDef GPIO_InitStructure; |
131 | 134 | ||
Line 132... | Line 135... | ||
132 | SerialPutString("\r\n UART2 deinit..."); |
135 | UART1_PutString("\r\n UART2 deinit..."); |
Line 155... | Line 158... | ||
155 | GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull; |
158 | GPIO_InitStructure.GPIO_Type = GPIO_Type_PushPull; |
156 | GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable; |
159 | GPIO_InitStructure.GPIO_IPConnected = GPIO_IPConnected_Disable; |
157 | GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1; |
160 | GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1; |
158 | GPIO_Init(GPIO3, &GPIO_InitStructure); |
161 | GPIO_Init(GPIO3, &GPIO_InitStructure); |
Line 159... | Line 162... | ||
159 | 162 | ||
160 | SerialPutString("ok"); |
163 | UART1_PutString("ok"); |
Line 161... | Line 164... | ||
161 | } |
164 | } |
162 | 165 | ||
163 | /********************************************************/ |
166 | /********************************************************/ |