Page 186 - 3-1
P. 186

#define DIR485_H GPIOC->BSRR=1<<1
              #define DIR485_L GPIOC->BRR=1<<1




              #endif







              #include "stm32f10x.h"
              #include "USART.h"


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


              }
              void USART1Write(u8* data,u16 len)
              {
                      u16 i;
              //      DIR485_H ;
                      for (i=0; i<len-1; i++){
                              USART1_SendByte(data[i]);
                      }
              //      Delay10us(1000);
              //      DIR485_L;
              }
              void USART1_Configuration(void)
              {
                      USART_InitTypeDef USART_InitStructure;
                      USART_InitStructure.USART_BaudRate              = 9600 ;
                      USART_InitStructure.USART_WordLength            = USART_WordLength_8b;
                      USART_InitStructure.USART_StopBits             = USART_StopBits_1;
                      USART_InitStructure.USART_Parity              = USART_Parity_No ;
                      USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
                      USART_InitStructure.USART_Mode                                 = USART_Mode_Rx |
              USART_Mode_Tx;
                      USART_Init(USART1, &USART_InitStructure);
                      USART_ITConfig(USART1, USART_IT_RXNE, ENABLE);




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