神舟III号 串口2发送实验程序

/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*LED管脚初始化*/
  GPIO_InitTypeDef GPIO_InitStructure;
  RCC_APB2PeriphClockCmd(RCC_GPIO_LED, ENABLE);

  GPIO_InitStructure.GPIO_Pin = DS1_PIN|DS2_PIN|DS3_PIN|DS4_PIN ;
  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
  GPIO_Init(GPIO_LED, &GPIO_InitStructure);
  
  GPIO_SetBits(GPIO_LED, DS1_PIN|DS2_PIN|DS3_PIN|DS4_PIN);	/*关闭LED灯*/      
   
  /* USARTx configured as follow:
        - BaudRate = 115200 baud  
        - Word Length = 8 Bits
        - One Stop Bit
        - No parity
        - Hardware flow control disabled (RTS and CTS signals)
        - Receive and transmit enabled
  */
  /*串口参数配置*/
  USART_InitStructure.USART_BaudRate = 115200;                 /*设置波特率为115200*/
  USART_InitStructure.USART_WordLength = USART_WordLength_8b;  /*设置数据位为8位*/
  USART_InitStructure.USART_StopBits = USART_StopBits_1;       /*设置停止位为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;      /*发送与接收*/
  /*完成串口COM1的时钟配置、GPIO配置,根据上述参数初始化并使能*/

  //STM_EVAL_COMInit(COM1, &USART_InitStructure);
  STM_EVAL_COMInit(COM2, &USART_InitStructure);

  printf("\n\r---------------------------------------------\n ");
  printf("\n\rWWW.ARMJISHU.COM\n ");
  //printf("\n\r神舟III号 串口1发送实验程序\n");
  printf("\n\r神舟III号 串口2发送实验程序\n");

  while (1)
  {
  		GPIO_ResetBits(GPIO_LED, DS1_PIN);
		Delay(0x3FFFFF);
  		GPIO_SetBits(GPIO_LED, DS1_PIN);
		Delay(0x3FFFFF); 
		//printf("\n\r神舟III号 串口1测试程序\n");
		printf("\n\r神舟III号 串口2测试程序\n");	   
  }
}

/**
  * @brief  Retargets the C library printf function to the USART.
  * @param  None
  * @retval None
  */
PUTCHAR_PROTOTYPE
{
  /* Place your implementation of fputc here */
  /* e.g. write a character to the USART */
  //USART_SendData(EVAL_COM1, (uint8_t) ch); /*发送一个字符函数*/ 
  USART_SendData(EVAL_COM2, (uint8_t) ch); /*发送一个字符函数*/ 

  /* Loop until the end of transmission */
  //while (USART_GetFlagStatus(EVAL_COM1, USART_FLAG_TC) == RESET)/*等待发送完成*/
   while (USART_GetFlagStatus(EVAL_COM2, USART_FLAG_TC) == RESET)/*等待发送完成*/
  {
  
  }
  return ch;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值