Beispiel #1
0
/**
  * @brief  Configure USART peripheral  
  * @param  None
  * @retval None
  */
static void USART_Config(void)
{
  /* High speed internal clock prescaler: 1*/
  CLK_SYSCLKDivConfig(CLK_SYSCLKDiv_1);
  
  /* EVAL COM (USARTx) configuration -----------------------------------------*/
  /* USART configured as follow:
        - BaudRate = 9600 baud  
        - Word Length = 8 Bits
        - One Stop Bit
        - No parity
        - Receive and transmit enabled
  */
  STM_EVAL_COMInit(COM1, (uint32_t)9600, USART_WordLength_8b, USART_StopBits_1,
                   USART_Parity_No, (USART_Mode_TypeDef)(USART_Mode_Tx | USART_Mode_Rx));

  /* Set Prescaler*/
  USART_SetPrescaler(EVAL_COM1, 0x1);

  USART_IrDAConfig(EVAL_COM1, USART_IrDAMode_Normal);

  USART_IrDACmd(EVAL_COM1, ENABLE);
}
Beispiel #2
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* System Clocks Configuration */
  RCC_Configuration();

  /* Initialize the LCD */
  STM3210C_LCD_Init();
  /* Clear the LCD */ 
  LCD_Clear(White);
  /* Set the LCD Text Color */
  LCD_SetTextColor(Black);
  printf("   STM3210C-EVAL    \n");
  printf("Irda receive example\n");
  printf("Set JP16 to IRXD\n\n");

  /* Configure the GPIO ports */
  GPIO_Configuration();

  //////////////////////////////////////////////////////
  NVIC_Configuration();
  //////////////////////////////////////////////////////

  /* Initialize Leds mounted on STM3210X-EVAL board */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);
  
/* USARTy configuration ------------------------------------------------------*/
  /* USARTy 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;
  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;
  
  /* Configure the USARTy */
  USART_Init(USARTy, &USART_InitStructure);
  /* Enable the USARTy */
  USART_Cmd(USARTy, ENABLE);

  /* Set the USARTy prescaler */
  USART_SetPrescaler(USARTy, 0x1);
  /* Configure the USARTy IrDA mode */
  USART_IrDAConfig(USARTy, USART_IrDAMode_Normal);

  /* Enable the USARTy IrDA mode */
  USART_IrDACmd(USARTy, ENABLE);

  //////////////////////////////////////////////////////////////////////////
  TIM_TimeBaseStructure.TIM_Period = 4095;
  TIM_TimeBaseStructure.TIM_Prescaler = 10;
  TIM_TimeBaseStructure.TIM_ClockDivision = 0;
  TIM_TimeBaseStructure.TIM_CounterMode = TIM_CounterMode_Up;

  TIM_TimeBaseInit(TIM3, &TIM_TimeBaseStructure);

  /* Output Compare Toggle Mode configuration: Channel1 */
  TIM_OCInitStructure.TIM_OCMode = TIM_OCMode_Toggle;
  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
  TIM_OCInitStructure.TIM_Pulse = speed;
  TIM_OCInitStructure.TIM_OCPolarity = TIM_OCPolarity_High;
  TIM_OC1Init(TIM3, &TIM_OCInitStructure);

  TIM_OC1PreloadConfig(TIM3, TIM_OCPreload_Disable);

  /* Output Compare Toggle Mode configuration: Channel2 */
  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
  TIM_OCInitStructure.TIM_Pulse = speed;

  TIM_OC2Init(TIM3, &TIM_OCInitStructure);

  TIM_OC2PreloadConfig(TIM3, TIM_OCPreload_Disable);

  /* Output Compare Toggle Mode configuration: Channel3 */
  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
  TIM_OCInitStructure.TIM_Pulse = speed;

  TIM_OC3Init(TIM3, &TIM_OCInitStructure);

  TIM_OC3PreloadConfig(TIM3, TIM_OCPreload_Disable);

  /* Output Compare Toggle Mode configuration: Channel4 */
  TIM_OCInitStructure.TIM_OutputState = TIM_OutputState_Enable;
  TIM_OCInitStructure.TIM_Pulse = speed;

  TIM_OC4Init(TIM3, &TIM_OCInitStructure);

  TIM_OC4PreloadConfig(TIM3, TIM_OCPreload_Disable);

  /* TIM enable counter */
  TIM_Cmd(TIM3, ENABLE);

  /* TIM IT enable */
  
  TIM_ITConfig(TIM3,TIM_IT_Update | TIM_IT_CC1,ENABLE);
  //////////////////////////////////////////////////////////

  while (1)
  {
    /* Wait until a byte is received */
    while(USART_GetFlagStatus(USARTy, USART_FLAG_RXNE) == RESET)
    {
    }
    /* Read the received byte */
	data = USART_ReceiveData(USARTy);
	//printf("data = %d\n",data);
	if(data == 0xff)
	{
		while(USART_GetFlagStatus(USARTy, USART_FLAG_RXNE) == RESET)
    	{
			
    	}
	    ReceivedData = (JOY_State_TypeDef)USART_ReceiveData(USARTy);
	    switch(ReceivedData)
	    {
	      case JOY_UP:
			printf("---JOY_UP---\n");
			funcNum = 1;
	        break;
	      case JOY_DOWN:
			printf("---JOY_DOWN---\n"); 
			funcNum = 2;
	        break;
	      case JOY_LEFT:
			printf("---JOY_LEFT---\n");
			funcNum = 3;
	        break;
	      case JOY_RIGHT:
			printf("---JOY_RIGHT---\n");
			funcNum = 4;
	        break;
	      case JOY_CENTER:
			printf("---JOY_CENTER---\n");
	        break;
	      case JOY_NONE:
	//	  	LCD_ClearLine(Line5);
	        break;
	      default:
	        break;
	    }
	}
	else if(data == 0xee)
	{
		while(USART_GetFlagStatus(USARTy, USART_FLAG_RXNE) == RESET)
    	{
			
    	}
		value = USART_ReceiveData(USARTy);
		speed = value<<4;
		//printf("\n speed = %d\n",speed) ;
	}
  }
}
Beispiel #3
0
/**
  * @brief  Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f10x_xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f10x.c file
     */     
       
  /* System Clocks Configuration */
  RCC_Configuration();

  /* Configure the GPIO ports */
  GPIO_Configuration();

  /* Initialize Leds mounted on STM3210X-EVAL board */
  STM_EVAL_LEDInit(LED1);
  STM_EVAL_LEDInit(LED2);
  STM_EVAL_LEDInit(LED3);
  STM_EVAL_LEDInit(LED4);
  
/* USARTy configuration ------------------------------------------------------*/
  /* USARTy 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;
  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;
  
  /* Configure the USARTy */
  USART_Init(USARTy, &USART_InitStructure);
  /* Enable the USARTy */
  USART_Cmd(USARTy, ENABLE);

  /* Set the USARTy prescaler */
  USART_SetPrescaler(USARTy, 0x1);
  /* Configure the USARTy IrDA mode */
  USART_IrDAConfig(USARTy, USART_IrDAMode_Normal);

  /* Enable the USARTy IrDA mode */
  USART_IrDACmd(USARTy, ENABLE);

  while (1)
  {
    /* Wait until a byte is received */
    while(USART_GetFlagStatus(USARTy, USART_FLAG_RXNE) == RESET)
    {
    }
    /* Read the received byte */
    ReceivedData = (JOYState_TypeDef)USART_ReceiveData(USARTy);

    switch(ReceivedData)
    {
      case JOY_UP:
        STM_EVAL_LEDOn(LED1);
        STM_EVAL_LEDOff(LED2);
        STM_EVAL_LEDOff(LED3);
        STM_EVAL_LEDOff(LED4);     
        break;
      case JOY_DOWN:
        STM_EVAL_LEDOn(LED2);
        STM_EVAL_LEDOff(LED1);
        STM_EVAL_LEDOff(LED3);
        STM_EVAL_LEDOff(LED4); 
        break;
      case JOY_LEFT:
        STM_EVAL_LEDOn(LED3);
        STM_EVAL_LEDOff(LED1);
        STM_EVAL_LEDOff(LED2);
        STM_EVAL_LEDOff(LED4);
        break;
      case JOY_RIGHT:
        STM_EVAL_LEDOn(LED4);
        STM_EVAL_LEDOff(LED1);
        STM_EVAL_LEDOff(LED2);
        STM_EVAL_LEDOff(LED3);        
        break;
      case JOY_SEL:
        STM_EVAL_LEDOn(LED1);
        STM_EVAL_LEDOn(LED2);
        STM_EVAL_LEDOn(LED3);
        STM_EVAL_LEDOn(LED4);
        break;
      case JOY_NONE:
        break;
      default:
        break;
    }
  }
}
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /* System Clocks Configuration */
  RCC_Configuration();

  /* Configure the GPIO ports */
  GPIO_Configuration();

#ifndef USE_STM3210C_EVAL
  /* Initialize JoyStick Button mounted on STM3210X-EVAL board */       
  STM_EVAL_PBInit(Button_UP, Mode_GPIO);
  STM_EVAL_PBInit(Button_DOWN, Mode_GPIO);
  STM_EVAL_PBInit(Button_LEFT, Mode_GPIO);
  STM_EVAL_PBInit(Button_RIGHT, Mode_GPIO);
  STM_EVAL_PBInit(Button_SEL, Mode_GPIO);
#else
  /* Configure the IO Expander */
  if (IOE_Config())
  {
    /* IO Expander config error */
    while(1);
  }
#endif  
     
/* USARTy configuration ------------------------------------------------------*/
  /* USARTy 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;
  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;

  /* Configure the USARTy */
  USART_Init(USARTy, &USART_InitStructure);
  /* Enable the USARTy */
  USART_Cmd(USARTy, ENABLE);
  /* Set the USARTy prescaler */
  USART_SetPrescaler(USARTy, 0x1);
  /* Configure the USARTy IrDA mode */
  USART_IrDAConfig(USARTy, USART_IrDAMode_Normal);

  /* Enable the USARTy IrDA mode */
  USART_IrDACmd(USARTy, ENABLE);


  while (1)
  {
    /* Read Key */
    MyKey = ReadKey();

    switch(MyKey)
    {
      case JOY_UP:
        USART_SendData(USARTy, JOY_UP);
        while(USART_GetFlagStatus(USARTy, USART_FLAG_TXE) == RESET)
        {
        }
        break;
      case JOY_DOWN:
        USART_SendData(USARTy, JOY_DOWN);
        while(USART_GetFlagStatus(USARTy, USART_FLAG_TXE) == RESET)
        {
        }
        break;
      case JOY_LEFT:
        USART_SendData(USARTy, JOY_LEFT);
        while(USART_GetFlagStatus(USARTy, USART_FLAG_TXE) == RESET)
        {
        }
        break;
      case JOY_RIGHT:
        USART_SendData(USARTy, JOY_RIGHT);
        while(USART_GetFlagStatus(USARTy, USART_FLAG_TXE) == RESET)
        {
        }
        break;
      case JOY_CENTER:
        USART_SendData(USARTy, JOY_CENTER);
        while(USART_GetFlagStatus(USARTy, USART_FLAG_TXE) == RESET)
        {
        }
        break;
      case JOY_NONE:
        USART_SendData(USARTy, JOY_NONE);
        while(USART_GetFlagStatus(USARTy, USART_FLAG_TXE) == RESET)
        {
        } 
        break;
      default:
        break;
    }
  }
}
Beispiel #5
0
/*******************************************************************************
* Function Name  : main
* Description    : Main program
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
int main(void)
{
#ifdef DEBUG
  debug();
#endif

  /* System Clocks Configuration */
  RCC_Configuration();
       
  /* NVIC configuration */
  NVIC_Configuration();

  /* Configure the GPIO ports */
  GPIO_Configuration();

/* USART3 configuration ------------------------------------------------------*/
  /* USART3 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;
  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;

  
  /* Configure the USART3 */
  USART_Init(USART3, &USART_InitStructure);
  /* Enable the USART3 */
  USART_Cmd(USART3, ENABLE);

  /* Set the USART3 prescaler */
  USART_SetPrescaler(USART3, 0x1);
  /* Configure the USART3 IrDA mode */
  USART_IrDAConfig(USART3, USART_IrDAMode_Normal);

  /* Enable the USART3 IrDA mode */
  USART_IrDACmd(USART3, ENABLE);

  while (1)
  {
    /* Wait until a byte is received */
    while(USART_GetFlagStatus(USART3, USART_FLAG_RXNE) == RESET)
    {
    }
    /* Read the received byte */
    ReceivedData = USART_ReceiveData(USART3);

    switch(ReceivedData)
    {
      case UP:
        GPIO_Write(GPIO_LED, GPIO_Pin_6);     
        break;
      case DOWN:
        GPIO_Write(GPIO_LED, GPIO_Pin_7);
        break;
      case LEFT:
        GPIO_Write(GPIO_LED, GPIO_Pin_8);
        break;
      case RIGHT:
        GPIO_Write(GPIO_LED, GPIO_Pin_9);
        break;
      case SEL:
        GPIO_Write(GPIO_LED, GPIO_Pin_6 | GPIO_Pin_7 | GPIO_Pin_8 | GPIO_Pin_9);        
        break;
      case NOKEY:
        break;
      default:
        break;
    }
  }
}
Beispiel #6
0
/******************************************************************************
 * USART1 Initialization Code Template
******************************************************************************/
void USART1__Init()
{
    USART_InitTypeDef USART_InitStruct;
    
    #if (STRCMP($modeSelect$, USART_MODE_SYNCHRONOUS) == 1)
    //PUT_A_NEW_LINE_HERE
    USART_ClockInitTypeDef USART_ClockInitStruct;
    #endif
    
    #if (!STRCMP($USARTIntSet$, 0))
    NVIC_InitTypeDef NVIC_InitStructure;
	#endif
	
    //PUT_A_NEW_LINE_HERE
    //
    // Enable peripheral clock of USART1 and GPIOA
    //
    RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE);
   
    //PUT_A_NEW_LINE_HERE	
    //
    // USART Config
    //	
    USART_InitStruct.USART_BaudRate = $baudRate$;
    USART_InitStruct.USART_WordLength = $dataBits$;
    USART_InitStruct.USART_StopBits = $stopBits$;
    USART_InitStruct.USART_Parity = $parityBits$;
    USART_InitStruct.USART_Mode = $modeSet$;
    USART_InitStruct.USART_HardwareFlowControl = $HardwareFlowControl$;
    USART_Init(USART1, &USART_InitStruct);  
  
    #if ($guardTime$ != 0)
    //PUT_A_NEW_LINE_HERE	
    //
    // Set Guard Time
    //
    USART_SetGuardTime(USART1, $guardTime$);
    #endif
	
    //PUT_A_NEW_LINE_HERE
    USART_WakeUpConfig(USART1, $WakeUpmethod$);
	
    //PUT_A_NEW_LINE_HERE	
    #if (STRCMP($modeSelect$, USART_MODE_NORMAL) == 1)
    
    #elif (STRCMP($modeSelect$, USART_MODE_IRDA) == 1)
    //PUT_A_NEW_LINE_HERE
    //
    //USART IrDA  Mode Config
    //
    USART_IrDAConfig(USART1, $IrDAModeSel$);
    USART_IrDACmd(USART1, ENABLE);
    
    #elif (STRCMP($modeSelect$, USART_MODE_DMA) == 1)
    //PUT_A_NEW_LINE_HERE
    //
    //USART DMA Mode Config
    //
    USART_DMACmd(USART1, $DMAReq$, ENABLE);
	
    #elif (STRCMP($modeSelect$, USART_MODE_SYNCHRONOUS) == 1)
    //PUT_A_NEW_LINE_HERE
    //
    // USART Synchronous Mode Config
    //
    USART_Clock_InitStruct.USART_Clock = USART_CLOCK_ENABLE;
    USART_Clock_InitStruct.USART_CPOL = $synClockPolSet$;
    USART_Clock_InitStruct.USART_CPHA = $synClockPhaseSet$;
    USART_Clock_InitStruct.USART_LastBit = $lastbitenable$;
    USART_ClockInit(USART1, &USART_Clock_InitStruct);
	
    #elif (STRCMP($modeSelect$, USART_MODE_LIN) == 1)
    //PUT_A_NEW_LINE_HERE
    //
    // USART LIN Mode Config
    //
    USART_LINBreakDetectLengthConfig(USART1, $LINBreakDetectLen$);
    USART_LINCmd(USART1, ENABLE);
	
    #elif (STRCMP($modeSelect$, USART_MODE_SMARTCARD) == 1)
    //PUT_A_NEW_LINE_HERE
    //
    // USART SmartCard Mode Config
    //
    USART_SmartCardCmd(USART1, ENABLE);
    #elif (STRCMP($NACKTrans$, ENABLE) == 1)
    //PUT_A_NEW_LINE_HERE
    USART_SmartCardNACKCmd(USART1, ENABLE);
	
    #elif (STRCMP($modeSelect$, USART_MODE_HALFDUPLEX) == 1)
    //PUT_A_NEW_LINE_HERE
    //
    // USART HalfDuplex Mode Config
    //
    USART_HalfDuplexCmd(USART1, ENABLE);	
    #endif
    
    
    #if (!STRCMP($USARTIntSet$, 0))
    //PUT_A_NEW_LINE_HERE
    //
    // Enable the USART Interrupt Function 
    //
    USART_ITConfig(USART1, $USARTIntSet$, ENABLE);
    NVIC_InitStructure.NVIC_IRQChannel = USART1_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
    #endif
}
Beispiel #7
0
/**
  * @brief   Main program
  * @param  None
  * @retval None
  */
int main(void)
{
  /*!< At this stage the microcontroller clock setting is already configured, 
       this is done through SystemInit() function which is called from startup
       file (startup_stm32f10x_xx.s) before to branch to application main.
       To reconfigure the default setting of SystemInit() function, refer to
       system_stm32f10x.c file
     */     
       
  /* System Clocks Configuration */
  RCC_Configuration();

  /* Configure the GPIO ports */
  GPIO_Configuration();

#ifndef USE_STM3210C_EVAL
  /* Initialize JoyStick Button mounted on STM3210X-EVAL board */       
  STM_EVAL_PBInit(BUTTON_UP, BUTTON_MODE_GPIO);
  STM_EVAL_PBInit(BUTTON_DOWN, BUTTON_MODE_GPIO);
  STM_EVAL_PBInit(BUTTON_LEFT, BUTTON_MODE_GPIO);
  STM_EVAL_PBInit(BUTTON_RIGHT, BUTTON_MODE_GPIO);
  STM_EVAL_PBInit(BUTTON_SEL, BUTTON_MODE_GPIO);
#else
  /* Configure the IO Expander */
  if (IOE_Config())
  {
    /* IO Expander config error */
    while(1);
  }
#endif  
     
/* USARTy configuration ------------------------------------------------------*/
  /* USARTy 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;
  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;

  /* Configure the USARTy */
  USART_Init(USARTy, &USART_InitStructure);
  /* Enable the USARTy */
  USART_Cmd(USARTy, ENABLE);
  /* Set the USARTy prescaler */
  USART_SetPrescaler(USARTy, 0x1);
  /* Configure the USARTy IrDA mode */
  USART_IrDAConfig(USARTy, USART_IrDAMode_Normal);

  /* Enable the USARTy IrDA mode */
  USART_IrDACmd(USARTy, ENABLE);


  while (1)
  {
    /* Read Key */
    MyKey = ReadKey();

    switch(MyKey)
    {
      case JOY_UP:
        USART_SendData(USARTy, JOY_UP);
        while(USART_GetFlagStatus(USARTy, USART_FLAG_TXE) == RESET)
        {
        }
        break;
      case JOY_DOWN:
        USART_SendData(USARTy, JOY_DOWN);
        while(USART_GetFlagStatus(USARTy, USART_FLAG_TXE) == RESET)
        {
        }
        break;
      case JOY_LEFT:
        USART_SendData(USARTy, JOY_LEFT);
        while(USART_GetFlagStatus(USARTy, USART_FLAG_TXE) == RESET)
        {
        }
        break;
      case JOY_RIGHT:
        USART_SendData(USARTy, JOY_RIGHT);
        while(USART_GetFlagStatus(USARTy, USART_FLAG_TXE) == RESET)
        {
        }
        break;
      case JOY_SEL:
        USART_SendData(USARTy, JOY_SEL);
        while(USART_GetFlagStatus(USARTy, USART_FLAG_TXE) == RESET)
        {
        }
        break;
      case JOY_NONE:
        USART_SendData(USARTy, JOY_NONE);
        while(USART_GetFlagStatus(USARTy, USART_FLAG_TXE) == RESET)
        {
        } 
        break;
      default:
        break;
    }
  }
}