cancel
Showing results for 
Search instead for 
Did you mean: 

communication by USB. How to send the signal of buttom from stm32f103rb to pc

conghung43
Associate II
Posted on April 23, 2014 at 22:21

I received the number from PC  but I can't send the signal of buttom from board to PC . HELP ME .

image :http://codientu.org/attachments/imag0416-jpg.12624/

project : https://docs.google.com/file/d/0B0dFyiUNuvSQTFIwYmVJUkU3TWs/edit

software in PC : https://docs.google.com/file/d/0B0dFyiUNuvSQYThfX0FZcWtsZm8/edit

https://docs.google.com/file/d/0B0dFyiUNuvSQTklKczZBelFQeFU/edit

3 REPLIES 3
Posted on April 23, 2014 at 23:10

Isn't there a HID Joystick/Example somewhere?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
conghung43
Associate II
Posted on April 24, 2014 at 16:57

/**

  ******************************************************************************

  * @file    usb_endp.c

  * @author  MCD Application Team

  * @version V4.0.0

  * @date    21-January-2013

  * @brief   Endpoint routines

  ******************************************************************************

  * @attention

  *

  * <h2><center>&copy; COPYRIGHT 2013 STMicroelectronics</center></h2>

  *

  * Licensed under MCD-ST Liberty SW License Agreement V2, (the ''License'');

  * You may not use this file except in compliance with the License.

  * You may obtain a copy of the License at:

  *

  *        http://www.st.com/software_license_agreement_liberty_v2

  *

  * Unless required by applicable law or agreed to in writing, software 

  * distributed under the License is distributed on an ''AS IS'' BASIS, 

  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

  * See the License for the specific language governing permissions and

  * limitations under the License.

  *

  ******************************************************************************

  */

/* Includes ------------------------------------------------------------------*/

#include ''hw_config.h''

#include ''usb_lib.h''

#include ''usb_istr.h''

/* Private typedef -----------------------------------------------------------*/

/* Private define ------------------------------------------------------------*/

/* Private macro -------------------------------------------------------------*/

/* Private variables ---------------------------------------------------------*/

uint8_t Receive_Buffer[64];

extern __IO uint8_t PrevXferComplete;

/* Private function prototypes -----------------------------------------------*/

/* Private functions ---------------------------------------------------------*/

/*******************************************************************************

* Function Name  : EP1_OUT_Callback.

* Description    : EP1 OUT Callback Routine.

* Input          : None.

* Output         : None.

* Return         : None.

*******************************************************************************/

uint8_t kt=0;

uint8_t txBuff[64];

void EP1_OUT_Callback(void)

{

  //ham nay quyet dinh se lam gi khi nhan duoc du lieu

uint8_t i;

USB_SIL_Read(EP1_OUT, Receive_Buffer);

if(Receive_Buffer[0]) {

GPIO_SetBits(GPIOB, GPIO_Pin_8 );

} else {

GPIO_ResetBits(GPIOB, GPIO_Pin_8 | GPIO_Pin_9);

}

//doc du lieu nhan duoc

//gui nguoc du lieu quay lai

//------------------------------------

if ((PrevXferComplete) && (bDeviceState == CONFIGURED))

    {

      Send_Buffer[0] = 0x05; 

      

      for(i=0; i<64; ++i) {

 txBuff[i]=Receive_Buffer[i];

 }

      

      /* Write the descriptor through the endpoint */

      USB_SIL_Write(EP1_IN, (uint8_t*) txBuff, 64);  

      

      SetEPTxValid(ENDP1);

      

      PrevXferComplete = 0;

    }

//------------------------------------

  SetEPRxStatus(ENDP1, EP_RX_VALID);

 

}

/*******************************************************************************

* Function Name  : EP1_IN_Callback.

* Description    : EP1 IN Callback Routine.

* Input          : None.

* Output         : None.

* Return         : None.

*******************************************************************************/

void EP1_IN_Callback(void)

{

  PrevXferComplete = 1;

}

/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

conghung43
Associate II
Posted on April 24, 2014 at 17:01

this project in       STM32-USB-FS---> project ----> custom_HID --->MDK-ARM----> custom_HID.uvproj  

thank you