From 8a2a2d99edaae394ad16eaabab275b7b98dcd315 Mon Sep 17 00:00:00 2001 From: Kai Lauterbach Date: Tue, 29 Nov 2011 19:39:57 +0100 Subject: [PATCH] First implementation of the new ISR. --- firmware/main.c | 24 ++++++++++-------------- firmware/main.h | 2 +- firmware/usb.c | 13 +++++++------ firmware/usb.h | 7 ++++--- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/firmware/main.c b/firmware/main.c index 083c55d..aec19ac 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -59,23 +59,19 @@ void init() } // Interruptvektor von TIMER1 -//SIGNAL(SIG_OUTPUT_COMPARE1A) // alte schreibweise ISR (TIMER1_COMPA_vect) { - // Vorgang für reihenweise Ausgabe. - // Alle Pins von PORTD auf LOW setzen - // Höchstes Bit in PORTA auf 0 setzen (Leitung 9 für letzte Reihe) - - // bei cube_row_offset % 3 eine Ebene weiter schalten (ABC-Leitungen durch rotieren) - // bei Systemstart muss A aktiviert sein. - - // bits der anzuzeigenden reihe auslesen (cube & (0b00000111 << cube_row_offset)) - // und in PORTD und Pin 8 von PORTA setzen - - // cube_row_offset += 3 // immer um 3 Bits weiter springen in 32Bit Variable - - // cube_row_offset auf 0 setzen wenn maximum überschritten (27-3 = 24) + PORTD &= 0xC7; // 0b11000111 + PORTD |= (1 << (cube_layer + 3)); // shift "1" to bit 3,4,5 in PortD + PORTB = ~(cube & (0xFF << (cube_layer * 9))); // set the lines 1 to 8 negated to the port b + PORTD = (~(cube & (1 << cube_layer * 9 + 8)) << 6) + | (PORTD & 0x7F); // 0b01111111 keep the ower 7 bits and set the 9. bit from the LEDCube data. + cube_layer++; + + if (cube_layer > 2) + cube_layer = 0; + } diff --git a/firmware/main.h b/firmware/main.h index 243866a..9479473 100644 --- a/firmware/main.h +++ b/firmware/main.h @@ -22,7 +22,7 @@ // Cube-Data volatile uint32_t cube = 0x00000000; // Bit Offset in Cube-Data -volatile uint8_t cube_row_offset = 0x00; +volatile uint8_t cube_layer = 0x00; // Prototypen void init(void); diff --git a/firmware/usb.c b/firmware/usb.c index 3915e30..6c5fddf 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -12,21 +12,22 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) { - usbRequest_t *rq = (void *)data; + usbRequest_t *rq = (void *)data; if ( (rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_VENDOR ) { if ( rq->bRequest == CUSTOM_RQ_SET_STATUS ) { - /*if (rq->wIndex.bytes[0] == 0) +/* + if (rq->wIndex.bytes[0] == 0) cube[0][0][0] = 1; if (rq->wIndex.bytes[0] == 1) cube[0][0][1] = 1; if (rq->wIndex.bytes[0] == 2) cube[0][0][2] = 1; if (rq->wIndex.bytes[0] == 3) - cube[0][1][0] = 1;*/ + cube[0][1][0] = 1; if (rq->wIndex.bytes[0] == 0) x = rq->wValue.bytes[0]; @@ -38,7 +39,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) z = rq->wValue.bytes[0]; else if (rq->wIndex.bytes[0] == 3) - cube[x][y][z] = rq->wValue.bytes[0]; + //cube[x][y][z] = rq->wValue.bytes[0]; } else if ( rq->bRequest == CUSTOM_RQ_GET_STATUS ) { // Send one byte to the USB host. @@ -48,7 +49,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) //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 @@ -69,7 +70,7 @@ void init_usb(void) usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */ i = 0; - while(--i){ /* fake USB disconnect for > 250 ms */ + while(--i) { /* fake USB disconnect for > 250 ms */ //wdt_reset(); _delay_ms(1); //sleep_nop(255); diff --git a/firmware/usb.h b/firmware/usb.h index f1e4c03..5db1cec 100644 --- a/firmware/usb.h +++ b/firmware/usb.h @@ -55,13 +55,14 @@ PROGMEM char usbHidReportDescriptor[22] = { /* USB report descriptor */ void init_usb(void); -volatile uint8_t x; +/*volatile uint8_t x; volatile uint8_t y; -volatile uint8_t z; +volatile uint8_t z;*/ // usb buffer //extern uint8_t buffer[3][3][3]; // Framebuffer -extern uint8_t cube[3][3][3]; // Framebuffer +//extern uint8_t cube[3][3][3]; // Framebuffer +extern uint32_t cube; // Framebuffer #endif // __usb_h__