Page 187 - 3-1
P. 187

USART_Cmd(USART1, ENABLE);
              /*      DIR485_L;  */


                  /* Enable USART1 global interrupt */
                  NVIC_EnableIRQ(USART1_IRQn);
              }


              /*void USART1_IRQHandler(void)
              {
                      u8 c;
                      if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET)
                      {
                          c=USART1->DR;
                              USART1_SendByte(c);
                      }
              }*/


              void USART2_SendByte(u16 Data)
              {
                 while (!(USART2->SR & USART_FLAG_TXE));
                 USART2->DR = (Data & (uint16_t)0x01FF);


              }
              void USART2Write(u8* data,u16 len)
              {
                      u16 i;
              //      DIR485_H ;
                      for (i=0; i<len; i++){
                              USART2_SendByte(data[i]);
                      }
              //      Delay10us(1000);
              //      DIR485_L;
              }
              void USART2_Configuration(void)
              {
                      USART_InitTypeDef USART_InitStructure;
                      USART_InitStructure.USART_BaudRate              = 115200 ;
                      USART_InitStructure.USART_WordLength            = USART_WordLength_8b;
                      USART_InitStructure.USART_StopBits             = USART_StopBits_1;
                      USART_InitStructure.USART_Parity              = USART_Parity_No ;





                                                         - 187 -
   182   183   184   185   186   187   188   189   190   191   192