USB_FS and mouse click

Discussion of the PSoC CY8C24x94 and other PSoC like USB parts from Cypress should be discussed here. This forum is limited to the discussion of USB portion of those parts. Other forums should still be used to discuss the non USB features of these parts.

Moderator: ericb

USB_FS and mouse click

Postby xar » Thu Oct 25, 2012 2:57 pm

I'm trying emulate left button click like this:
Code: Select all
Mouse_Data[0] = 1;
while(!USBFS_1_GetEPAckState(1));
USBFS_1_LoadInEP(1, (uint8 *)Mouse_Data, 3);

Buttonon certainly still pressed.
but when i'm trying "press" and "release" button like this:
Code: Select all
Mouse_Data[0] = 1;
while(!USBFS_1_GetEPAckState(1));
USBFS_1_LoadInEP(1, (uint8 *)Mouse_Data, 3);
while(!USBFS_1_GetEPAckState(1));           
Mouse_Data[0] = 0;
USBFS_1_LoadInEP(1, (uint8 *)Mouse_Data, 3);    

I do not receive any result.

In old samples i saw USB_TOGGLE and USB_NOTOGGLE params in USBFS_1_LoadInEP, but USBFS_1_LoadInEP function has no this param. in what problem?
xar
Newbie
Newbie
 
Posts: 3
Joined: Wed Oct 10, 2012 11:09 am

Re: USB_FS and mouse click

Postby orob » Wed Dec 26, 2012 9:23 am

I realize this is a few months old, but you need to toggle the USB each time you send except for the first time.
orob
The Big Cheese
The Big Cheese
 
Posts: 606
Joined: Wed Sep 26, 2007 9:06 am
Location: US

Re: USB_FS and mouse click

Postby xar » Sun Jan 06, 2013 8:52 am

orob, can you show sources of your realization?
xar
Newbie
Newbie
 
Posts: 3
Joined: Wed Oct 10, 2012 11:09 am

Re: USB_FS and mouse click

Postby orob » Sun Jan 06, 2013 1:41 pm

To clarify... the usb toggle flag needs to be used each time data is sent to the PC.

I once had this same question and Ganesh Raaja now with Cypress had posted an answer. Here is his great summary. Does that help with the question you originally submitted?

Perhaps some code will help:

Code: Select all
main(){
  int Mousebutton;
 while(1){
// Mousebutton would be a flag that is set to 1 or 0 when a button is pressed or released
//say port 2 pin 0 
//it could be by a port pin polling check shown below
//or it could be set in an interrupt routine when it triggers. 
    if ((PRT2DR & 0x01) == 0x01){
      Mousebutton = 1;
    }else{
      Mousebutton = 0;
    }

    if(Mousebutton == 1){ //if mouse button is pressed
      Mouse_Data[0] = 1;
      while(!USBFS_1_GetEPAckState(1));
      USBFS_1_LoadInEP(1, (uint8 *)Mouse_Data, USB_TOGGLE);
    }else{ // mouse button is not pressed
      while(!USBFS_1_GetEPAckState(1));           
      Mouse_Data[0] = 0;
      USBFS_1_LoadInEP(1, (uint8 *)Mouse_Data, USB_TOGGLE);   
    } // if
  } // while
}// main
orob
The Big Cheese
The Big Cheese
 
Posts: 606
Joined: Wed Sep 26, 2007 9:06 am
Location: US


Return to “%s” USB

Who is online

Users browsing this forum: No registered users and 1 guest

cron