First implementation of the new ISR.

This commit is contained in:
Kai Lauterbach 2011-11-29 19:39:57 +01:00 committed by Aaron Mueller
parent 87535e87e7
commit 8a2a2d99ed
4 changed files with 22 additions and 24 deletions

View file

@ -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)
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.
// bei cube_row_offset % 3 eine Ebene weiter schalten (ABC-Leitungen durch rotieren)
// bei Systemstart muss A aktiviert sein.
cube_layer++;
// 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)
if (cube_layer > 2)
cube_layer = 0;
}

View file

@ -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);

View file

@ -19,14 +19,15 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
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

View file

@ -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__