Some more changes.

This commit is contained in:
Kai Lauterbach 2011-12-10 00:49:39 +01:00
parent beb8d0c4e2
commit 1ceeaf0d1e
5 changed files with 14 additions and 64 deletions

View file

@ -11,7 +11,8 @@
#include "main.h" #include "main.h"
// Main // Main
int main(void) int __attribute__((OS_main))
main()
{ {
// Initialisierung // Initialisierung
init(); init();
@ -20,9 +21,7 @@ int main(void)
// Hauptschleife // Hauptschleife
for (;;) for (;;)
{ {
//wdt_reset(); // we are alive, so don't reset the µC
usbPoll(); // keep connected usbPoll(); // keep connected
} }
} }

View file

@ -16,14 +16,11 @@
#include <avr/interrupt.h> #include <avr/interrupt.h>
#include <avr/io.h> #include <avr/io.h>
#include <util/delay.h>
// Cube-Data // Cube-Data
//volatile uint32_t cube = 0x07007007; // Aktuelles Frame uint32_t cube = 0xffffffff;
volatile uint32_t cube = 0xffffffff; // Aktuelles Frame
//volatile uint32_t cube = 0x00000000; // Aktuelles Frame
// Bit Offset in Cube-Data // Bit Offset in Cube-Data
volatile uint8_t cube_level = 0; // Ebene uint8_t cube_level; // = 0; // Ebene
// Prototypen // Prototypen
void init(void); void init(void);

View file

@ -16,9 +16,7 @@
#ifndef __REQUESTS_H_INCLUDED__ #ifndef __REQUESTS_H_INCLUDED__
#define __REQUESTS_H_INCLUDED__ #define __REQUESTS_H_INCLUDED__
#define CUSTOM_RQ_SET_LED 1 #define CUSTOM_RQ_SET_LED 1
#define CUSTOM_RQ_SET_FRAME 2 #define CUSTOM_RQ_SET_FRAME 2
//#define CUSTOM_RQ_GET_STATUS 255
#endif /* __REQUESTS_H_INCLUDED__ */ #endif /* __REQUESTS_H_INCLUDED__ */

View file

@ -28,29 +28,15 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
if ( rq->wIndex.bytes[0] == 0 ) if ( rq->wIndex.bytes[0] == 0 )
{ {
cube = (cube & (uint32_t)0xffff0000) | cube = (cube & (uint32_t)0xffff0000) |
rq->wValue.bytes[0] + ( rq->wValue.bytes[0] +
(rq->wValue.bytes[1] << 8); (rq->wValue.bytes[1] << 8));
//} else if ( rq->wIndex.bytes[0] == 1 )
} else { } else {
cube = (cube & (uint32_t)0x0000ffff) | cube = (cube & (uint32_t)0x0000ffff) |
((uint32_t)(rq->wValue.bytes[0] + ((uint32_t)(rq->wValue.bytes[0] +
(rq->wValue.bytes[1] << 8)) << 16); (rq->wValue.bytes[1] << 8)) << 16);
} }
//} else if ( rq->bRequest == CUSTOM_RQ_GET_STATUS ) {
// Send one byte to the USB host.
//static uchar dataBuffer[1]; // buffer must stay valid when usbFunctionSetup returns
//usbMsgPtr = 0; // tell the driver which data to return
//return 1; // tell the driver to send 1 byte
//return 0; // tell the driver to send 0 byte
} }
//} else {
/* class requests USBRQ_HID_GET_REPORT and USBRQ_HID_SET_REPORT are
* not implemented since we never call them. The operating system
* 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 */
} }
@ -59,44 +45,22 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
void init_usb(void) void init_usb(void)
{ {
uchar i;
uint8_t i, j, k;
usbInit(); usbInit();
usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */ usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */
i = 0; i = 0;
j = 0;
k = 50;
while(--i) { /* fake USB disconnect for > 250 ms */ while(--i) { /* fake USB disconnect for > 250 ms */
//wdt_reset(); while(--k)
_delay_ms(1); while(--j) { asm volatile("nop"::); }
//sleep_nop(255);
} }
usbDeviceConnect(); usbDeviceConnect();
sei(); // enable global interrupts
} }
/* TODO add to the projects main
init_usb();
// 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!
//
// RESET status: all port bits are inputs without pull-up.
// That's the way we need D+ and D-. Therefore we don't need any
// additional hardware initialization.
wdt_enable(WDTO_1S);
...mainloop start...
wdt_reset(); // we are alive, please dont reset the µC (optional)
usbPoll(); // keep the usb connection up
...end mainloop...
*/
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */

View file

@ -21,12 +21,6 @@ We assume that an LED is connected to port B bit 0. If you connect it to a
different port or bit, change the macros below: different port or bit, change the macros below:
*/ */
#include <avr/interrupt.h> /* for sei() */
//#include <avr/io.h>
//#include <avr/wdt.h>
#include <util/delay.h> /* for _delay_ms() */
//#include <avr/pgmspace.h> /* required by usbdrv.h */
#include "usbconfig.h" #include "usbconfig.h"
#include "usbdrv.h" #include "usbdrv.h"
#include "requests.h" /* The custom request numbers we use */ #include "requests.h" /* The custom request numbers we use */
@ -56,8 +50,6 @@ PROGMEM char usbHidReportDescriptor[22] = { /* USB report descriptor */
void init_usb(void); void init_usb(void);
// usb buffer // usb buffer
//extern uint8_t buffer[3][3][3]; // Framebuffer
//extern uint8_t cube[3][3][3]; // Framebuffer
extern volatile uint32_t cube; // Framebuffer extern volatile uint32_t cube; // Framebuffer
#endif // __usb_h__ #endif // __usb_h__