Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: help arm7s256 using usb
PostPosted: Thu Jun 10, 2010 1:12 pm 
Offline

Joined: Thu Jun 10, 2010 12:24 pm
Posts: 1
i m working with arm7s256 interface pc by usb bus.
but i dont connected.
do you can help me?
do you can for me a code to connected with pc by usb bus ?
thanks!
my code:
/*----------------------------------------------------------------------------
* Name: MOUSE.C
* Purpose: USB Mouse Demo
* Version: V1.10
*----------------------------------------------------------------------------
* This file is part of the uVision/ARM development tools.
* Copyright (c) 2005-2006 Keil Software. All rights reserved.
* This software may only be used under the terms of a valid, current,
* end user licence from KEIL for a compatible version of KEIL software
* development tools. Nothing else gives you the right to use it.
*---------------------------------------------------------------------------*/

#include <AT91SAM7S256.H> /* AT91SAM7S256 definitions */

#include "Board.h"

#include "type.h"

#include "usb.h"
#include "usbcfg.h"
#include "usbhw.h"
#include "usbcore.h"

#include "mouse.h"


AT91S_PIO * pPIO = AT91C_BASE_PIOA; /* Global Pointer to PIO */


BYTE MouseInReport[4]; /* Mouse Input Report */
/* Byte0.0: 1st Button (Left) */
/* Byte0.1: 2nd Button (Right) */
/* Byte0.2: 3rd Button */
/* Byte1: Relative X Pos */
/* Byte2: Relative Y Pos */
/* Byte3: Relative Wheel Pos */

/*
* Get Mouse Input Report -> MouseInReport
* Parameters: None
* Return Value: None
*/

void GetMouseInReport (void) {
DWORD key;

key = pPIO->PIO_PDSR; /* Read Pin Data */
if ((key & SW1) != 0) { /* Check if SW1 is not pressed */
switch (key & (SW2)) {
case SW2: /* SW3 pressed & SW2 not pressed */
MouseInReport[1] = +4; /* +X: Right Movement */
break;
default:
MouseInReport[1] = 0; /* No X Movement */
break;
}
MouseInReport[2] = 0; /* No Y Movement */
} else { /* SW1 is pressed */
MouseInReport[1] = 0; /* No X Movement */
switch (key & SW2) {
case SW2: /* SW3 pressed & SW2 not pressed */
MouseInReport[2] = +4; /* +Y: Down Movement */
break;
default:
MouseInReport[2] = 0; /* No Y Movement */
break;
}
}
MouseInReport[3] = 0; /* Wheel not used */
}


/* Main Program */

int main (void) {
DWORD n;

/* Enable Clock for PIO */
AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_PIOA);

pPIO->PIO_PER = LED_MASK; /* Enable PIO for LED1,2 */
pPIO->PIO_OER = LED_MASK; /* LED1,2 are Outputs */
pPIO->PIO_SODR = LED_MASK; /* Turn off LED's ("1") */

USB_Init();
//USB_Configure (TRUE);
//USB_Reset();
/* USB Initialization */
USB_Connect(TRUE); /* USB Connect */

while (1) { /* Loop forever */
GetMouseInReport();
n = pPIO->PIO_PDSR; /* Read Pin Data */
if ((n & SW1) == 0) { /* Check if SW1 is pressed */
pPIO->PIO_CODR = LED1; /* Turn On LED1 */
} else {
pPIO->PIO_SODR = LED1; /* Turn Off LED1 */
}
for (n = 0; n < 100; n++); /* Delay */
}
}


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Google [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron