aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorChristian Starkjohann <cs+github@obdev.at>2008-05-04 20:07:30 +0000
committerChristian Starkjohann <cs+github@obdev.at>2008-05-04 20:07:30 +0000
commit3db37d1c9e5cfde7f7364927c8f03e83369fc033 (patch)
tree926a8f704035524e7fcd8771a589a725ab9d7163 /examples
parentb730907357a33a47e4691977a0229172e6c2d3b3 (diff)
downloadv-usb-3db37d1c9e5cfde7f7364927c8f03e83369fc033.tar.gz
v-usb-3db37d1c9e5cfde7f7364927c8f03e83369fc033.tar.bz2
v-usb-3db37d1c9e5cfde7f7364927c8f03e83369fc033.zip
- converted tabs to spaces
- use usbMsgLen_t in usbFunctionSetup()
Diffstat (limited to 'examples')
-rw-r--r--examples/custom-class/firmware/main.c24
-rw-r--r--examples/hid-custom-rq/firmware/main.c28
-rw-r--r--examples/hid-data/firmware/main.c26
-rw-r--r--examples/hid-mouse/firmware/main.c24
4 files changed, 52 insertions, 50 deletions
diff --git a/examples/custom-class/firmware/main.c b/examples/custom-class/firmware/main.c
index 2d93db9..940f62e 100644
--- a/examples/custom-class/firmware/main.c
+++ b/examples/custom-class/firmware/main.c
@@ -34,7 +34,7 @@ different port or bit, change the macros below:
/* ----------------------------- USB interface ----------------------------- */
/* ------------------------------------------------------------------------- */
-uchar usbFunctionSetup(uchar data[8])
+usbMsgLen_t usbFunctionSetup(uchar data[8])
{
usbRequest_t *rq = (void *)data;
@@ -50,16 +50,16 @@ usbRequest_t *rq = (void *)data;
usbMsgPtr = dataBuffer; /* tell the driver which data to return */
return 1; /* tell the driver to send 1 byte */
}
- return 0; /* default for not implemented requests: return no data back to host */
+ return 0; /* default for not implemented requests: return no data back to host */
}
/* ------------------------------------------------------------------------- */
-int main(void)
+int main(void)
{
uchar i;
- wdt_enable(WDTO_1S);
+ wdt_enable(WDTO_1S);
/* Even if you don't use the watchdog, turn it off here. On newer devices,
* the status of the watchdog (on/off, period) is PRESERVED OVER RESET!
*/
@@ -68,8 +68,8 @@ uchar i;
* That's the way we need D+ and D-. Therefore we don't need any
* additional hardware initialization.
*/
- odDebugInit();
- usbInit();
+ odDebugInit();
+ usbInit();
usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */
i = 0;
while(--i){ /* fake USB disconnect for > 250 ms */
@@ -78,14 +78,14 @@ uchar i;
}
usbDeviceConnect();
LED_PORT_DDR |= _BV(LED_BIT); /* make the LED bit an output */
- sei();
+ sei();
DBG1(0x01, 0, 0); /* debug output: main loop starts */
- for(;;){ /* main event loop */
+ for(;;){ /* main event loop */
DBG1(0x02, 0, 0); /* debug output: main loop iterates */
- wdt_reset();
- usbPoll();
- }
- return 0;
+ wdt_reset();
+ usbPoll();
+ }
+ return 0;
}
/* ------------------------------------------------------------------------- */
diff --git a/examples/hid-custom-rq/firmware/main.c b/examples/hid-custom-rq/firmware/main.c
index 85cae06..e813093 100644
--- a/examples/hid-custom-rq/firmware/main.c
+++ b/examples/hid-custom-rq/firmware/main.c
@@ -54,7 +54,7 @@ PROGMEM char usbHidReportDescriptor[22] = { /* USB report descriptor */
/* ------------------------------------------------------------------------- */
-uchar usbFunctionSetup(uchar data[8])
+usbMsgLen_t usbFunctionSetup(uchar data[8])
{
usbRequest_t *rq = (void *)data;
@@ -78,16 +78,16 @@ usbRequest_t *rq = (void *)data;
* won't call them either because our descriptor defines no meaning.
*/
}
- return 0; /* default for not implemented requests: return no data back to host */
+ return 0; /* default for not implemented requests: return no data back to host */
}
/* ------------------------------------------------------------------------- */
-int main(void)
+int main(void)
{
uchar i;
- wdt_enable(WDTO_1S);
+ wdt_enable(WDTO_1S);
/* Even if you don't use the watchdog, turn it off here. On newer devices,
* the status of the watchdog (on/off, period) is PRESERVED OVER RESET!
*/
@@ -96,8 +96,8 @@ uchar i;
* That's the way we need D+ and D-. Therefore we don't need any
* additional hardware initialization.
*/
- odDebugInit();
- usbInit();
+ odDebugInit();
+ usbInit();
usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */
i = 0;
while(--i){ /* fake USB disconnect for > 250 ms */
@@ -106,14 +106,16 @@ uchar i;
}
usbDeviceConnect();
LED_PORT_DDR |= _BV(LED_BIT); /* make the LED bit an output */
- sei();
+ sei();
DBG1(0x01, 0, 0); /* debug output: main loop starts */
- for(;;){ /* main event loop */
- DBG1(0x02, 0, 0); /* debug output: main loop iterates */
- wdt_reset();
- usbPoll();
- }
- return 0;
+ for(;;){ /* main event loop */
+#if 0 /* this is a bit too aggressive for a debug output */
+ DBG2(0x02, 0, 0); /* debug output: main loop iterates */
+#endif
+ wdt_reset();
+ usbPoll();
+ }
+ return 0;
}
/* ------------------------------------------------------------------------- */
diff --git a/examples/hid-data/firmware/main.c b/examples/hid-data/firmware/main.c
index 3ef68d5..e9b2d44 100644
--- a/examples/hid-data/firmware/main.c
+++ b/examples/hid-data/firmware/main.c
@@ -82,7 +82,7 @@ uchar usbFunctionWrite(uchar *data, uchar len)
/* ------------------------------------------------------------------------- */
-uchar usbFunctionSetup(uchar data[8])
+usbMsgLen_t usbFunctionSetup(uchar data[8])
{
usbRequest_t *rq = (void *)data;
@@ -91,12 +91,12 @@ usbRequest_t *rq = (void *)data;
/* since we have only one report type, we can ignore the report-ID */
bytesRemaining = 128;
currentAddress = 0;
- return 0xff; /* use usbFunctionRead() to obtain data */
+ return USB_NO_MSG; /* use usbFunctionRead() to obtain data */
}else if(rq->bRequest == USBRQ_HID_SET_REPORT){
/* since we have only one report type, we can ignore the report-ID */
bytesRemaining = 128;
currentAddress = 0;
- return 0xff; /* use usbFunctionWrite() to receive data from host */
+ return USB_NO_MSG; /* use usbFunctionWrite() to receive data from host */
}
}else{
/* ignore vendor type requests, we don't use any */
@@ -106,11 +106,11 @@ usbRequest_t *rq = (void *)data;
/* ------------------------------------------------------------------------- */
-int main(void)
+int main(void)
{
uchar i;
- wdt_enable(WDTO_1S);
+ wdt_enable(WDTO_1S);
/* Even if you don't use the watchdog, turn it off here. On newer devices,
* the status of the watchdog (on/off, period) is PRESERVED OVER RESET!
*/
@@ -119,8 +119,8 @@ uchar i;
* That's the way we need D+ and D-. Therefore we don't need any
* additional hardware initialization.
*/
- odDebugInit();
- usbInit();
+ odDebugInit();
+ usbInit();
usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */
i = 0;
while(--i){ /* fake USB disconnect for > 250 ms */
@@ -128,14 +128,14 @@ uchar i;
_delay_ms(1);
}
usbDeviceConnect();
- sei();
+ sei();
DBG1(0x01, 0, 0); /* debug output: main loop starts */
- for(;;){ /* main event loop */
+ for(;;){ /* main event loop */
DBG1(0x02, 0, 0); /* debug output: main loop iterates */
- wdt_reset();
- usbPoll();
- }
- return 0;
+ wdt_reset();
+ usbPoll();
+ }
+ return 0;
}
/* ------------------------------------------------------------------------- */
diff --git a/examples/hid-mouse/firmware/main.c b/examples/hid-mouse/firmware/main.c
index 0f3fd42..7667fe7 100644
--- a/examples/hid-mouse/firmware/main.c
+++ b/examples/hid-mouse/firmware/main.c
@@ -97,7 +97,7 @@ char d;
/* ------------------------------------------------------------------------- */
-uchar usbFunctionSetup(uchar data[8])
+usbMsgLen_t usbFunctionSetup(uchar data[8])
{
usbRequest_t *rq = (void *)data;
@@ -119,16 +119,16 @@ usbRequest_t *rq = (void *)data;
}else{
/* no vendor specific requests implemented */
}
- return 0; /* default for not implemented requests: return no data back to host */
+ return 0; /* default for not implemented requests: return no data back to host */
}
/* ------------------------------------------------------------------------- */
-int main(void)
+int main(void)
{
uchar i;
- wdt_enable(WDTO_1S);
+ wdt_enable(WDTO_1S);
/* Even if you don't use the watchdog, turn it off here. On newer devices,
* the status of the watchdog (on/off, period) is PRESERVED OVER RESET!
*/
@@ -137,8 +137,8 @@ uchar i;
* That's the way we need D+ and D-. Therefore we don't need any
* additional hardware initialization.
*/
- odDebugInit();
- usbInit();
+ odDebugInit();
+ usbInit();
usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */
i = 0;
while(--i){ /* fake USB disconnect for > 250 ms */
@@ -146,20 +146,20 @@ uchar i;
_delay_ms(1);
}
usbDeviceConnect();
- sei();
+ sei();
DBG1(0x01, 0, 0); /* debug output: main loop starts */
- for(;;){ /* main event loop */
+ for(;;){ /* main event loop */
DBG1(0x02, 0, 0); /* debug output: main loop iterates */
- wdt_reset();
- usbPoll();
+ wdt_reset();
+ usbPoll();
if(usbInterruptIsReady()){
/* called after every poll of the interrupt endpoint */
advanceCircleByFixedAngle();
DBG1(0x03, 0, 0); /* debug output: interrupt report prepared */
usbSetInterrupt((void *)&reportBuffer, sizeof(reportBuffer));
}
- }
- return 0;
+ }
+ return 0;
}
/* ------------------------------------------------------------------------- */