diff --git a/client/test.c b/client/test.c index 2dc855b..c11b91e 100644 --- a/client/test.c +++ b/client/test.c @@ -68,33 +68,49 @@ int main(int argc, char **argv) #endif //usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_EEPROM, 0, 0, buffer, 0, 300); - usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_LOAD_EEPROM, 0, 1, buffer, 0, 300); - sleep(1); - usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_LOAD_EEPROM, 0, 0, buffer, 0, 300); - sleep(1); + //usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_EEPROM_SET_FRAME, 0, 1, buffer, 0, 300); + //sleep(1); + //usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_EEPROM_SET_FRAME, 0, 0, buffer, 0, 300); + //sleep(1); // int usb_control_msg(usb_dev_handle *dev, int requesttype, int request, int value, int index, char *bytes, int size, int timeout); // 32 bit in 2 transmission - usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_FRAME, 0x7217, 0, buffer, 0, 300); - //sleep(2); - usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_FRAME, 0x0743, 1, buffer, 0, 300); + usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_FRAME, 0x0000, 0, buffer, 0, 300); + usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_FRAME, 0x0000, 1, buffer, 0, 300); + + sleep(1); + + usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_FRAME, 0x7347, 0, buffer, 0, 300); + usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_FRAME, 0x0712, 1, buffer, 0, 300); + + sleep(1); + + usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_FRAME, 0x7007, 0, buffer, 0, 300); + usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_FRAME, 0x0700, 1, buffer, 0, 300); + + sleep(1); + + usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_FRAME, 0xffff, 0, buffer, 0, 300); + usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_FRAME, 0x07ff, 1, buffer, 0, 300); + + sleep(1); // bitwise set/get //usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, 0, 25, buffer, 0, 5000); - sleep(1); + //sleep(1); - int i = 0; + /*int i = 0; for (i = 0; i < 27; i++) { usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_LED, 1, i, buffer, 0, 300); - usleep(250000); + usleep(100000); } for (i = 26; i >= 0; i--) { usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_LED, 0, i, buffer, 0, 300); - usleep(250000); - } + usleep(100000); + }*/ usb_close(handle); return 0; diff --git a/firmware/isr_test.c b/firmware/isr_test.c deleted file mode 100644 index c77a6ab..0000000 --- a/firmware/isr_test.c +++ /dev/null @@ -1,52 +0,0 @@ - -#include -#include -#include - -int main (void) -{ - int PORTD = 0xff; - int PORTB = 0xff; - int cube = 0x000001ff; - int cube_level = 0; - - char test[100]; - - int i = 0; - for (i = 0; i < 3; i++) - { - - printf("-----------------\ncube_level = %d\n",cube_level); - - printf("PORTD = 0x%2x\n", PORTD); - printf("PORTB = 0x%2x\n", PORTB); - - PORTD &= 0x87; // 0x87 = 0b10000111; // 7tes Bit löschen (Leitung 9) und alle Ebenen deaktivieren - - printf("& 0b10000111: PORTD = 0x%2x\n", PORTD); - - PORTD |= ((1 << cube_level)<< 3); // cube_level setzen (Ebene A=0, B=1, C=2) - - printf("Level festlegen: PORTD = 0x%2x\n", PORTD); - - int tmp = cube_level * 9; - - printf("8 Bits aus cube: PORTD = 0x%2x\n", ((~cube & (0xff << tmp)) >> tmp)); - // PORTB = 1..8 - // 0 = leuchtet, 1 = leuchtet nicht (invertiert!) - PORTB = ((~cube & (0xff << tmp)) >> tmp); - - printf("Pins1-8: PORTB = 0x%2x\n", PORTB); - - // PORTD &= 0b10111111; // bereits oben erledigt - PORTD |= (((~cube & (1 << (tmp+8))) >> (tmp+8)) << 6); - - printf("Pin9: PORTD = 0x%2x\n", PORTD); - - cube_level++; - if (cube_level > 2) cube_level = 0; - - } - -} - diff --git a/firmware/main.c b/firmware/main.c index 2b77d81..049ce06 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -18,6 +18,11 @@ main() init(); init_usb(); + //cube_t c; + //cube = &c; + frame = 0x07ffffff; + //cube->level = 0x00; + // Hauptschleife for (;;) { @@ -62,19 +67,19 @@ ISR (TIMER1_COMPA_vect) // PORTD = __, 9, C, B, A,D+,D-,__ PORTD &= 0b10000111; // 7tes Bit löschen (Leitung 9) und alle Ebenen deaktivieren - PORTD |= (1 << 6) | ((1 << cube_level) << 3); // cube_level setzen (Ebene A=0, B=1, C=2) + PORTD |= (1 << 6) | ((1 << level) << 3); // level setzen (Ebene A=0, B=1, C=2) - uint32_t tmp = cube_level * 9; + uint8_t tmp = level * 9; // PORTB = 1..8 // 0 = leuchtet, 1 = leuchtet nicht (invertiert!) - PORTB = ~((cube >> tmp) & 0xff); + PORTB = ~((frame >> tmp) & 0xff); - if ( (((cube >> tmp) >> 8) & 0x01) ) + if ( (((frame >> tmp) >> 8) & 0x01) ) PORTD &= ~(1 << 6); // 9. led setzen falls notwendig - cube_level++; - if (cube_level > 2) cube_level = 0; + level++; + if (level > 2) level = 0; } diff --git a/firmware/main.h b/firmware/main.h index 609e9b6..b9d7158 100644 --- a/firmware/main.h +++ b/firmware/main.h @@ -14,12 +14,17 @@ // Includes #include "globals.h" +#include "type.h" + #include #include + // Cube-Data -uint32_t cube = 0xffffffff; +uint32_t frame = 0xffffffff; // Bit Offset in Cube-Data -uint8_t cube_level; // Aktive Ebene +uint8_t level; // Aktive Ebene + +//cube_t *cube; // Prototypen void init(void); diff --git a/firmware/requests.h b/firmware/requests.h index ae94e0f..6c86b13 100644 --- a/firmware/requests.h +++ b/firmware/requests.h @@ -16,10 +16,11 @@ #ifndef __REQUESTS_H_INCLUDED__ #define __REQUESTS_H_INCLUDED__ -#define CUSTOM_RQ_SET_LED 1 -#define CUSTOM_RQ_SET_FRAME 2 -#define CUSTOM_RQ_SET_EEPROM 3 -#define CUSTOM_RQ_GET_EEPROM 4 -#define CUSTOM_RQ_LOAD_EEPROM 5 +#define CUSTOM_RQ_SET_FRAME 1 +#define CUSTOM_RQ_EEPROM_STORE_FRAME 2 +#define CUSTOM_RQ_EEPROM_SET_FRAME 3 +#define CUSTOM_RQ_LOOP_ANIMATION 4 +#define CUSTOM_RQ_START_ANIMATION 5 +#define CUSTOM_RQ_STOP_ANIMATION 6 #endif /* __REQUESTS_H_INCLUDED__ */ diff --git a/firmware/usb.c b/firmware/usb.c index e1ed80a..9b57186 100644 --- a/firmware/usb.c +++ b/firmware/usb.c @@ -16,13 +16,13 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) if ( (rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_VENDOR ) { - if ( rq->bRequest == CUSTOM_RQ_SET_LED ) + /*if ( rq->bRequest == CUSTOM_RQ_SET_LED ) { if ( rq->wValue.bytes[0] == 1 ) cube |= ((uint32_t)1 << rq->wIndex.bytes[0]); else cube &= ~((uint32_t)1 << rq->wIndex.bytes[0]); - } else if ( rq->bRequest == CUSTOM_RQ_SET_FRAME ) + } else*/ if ( rq->bRequest == CUSTOM_RQ_SET_FRAME ) { /* requires more flash space @@ -31,21 +31,21 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) ( (uint32_t)(rq->wIndex.bytes[0] + (rq->wIndex.bytes[1] << 8)) << 16 );*/ if ( rq->wIndex.bytes[0] == 0 ) { - cube = (cube & (uint32_t)0xffff0000) | + frame = (frame & (uint32_t)0xffff0000) | ( rq->wValue.bytes[0] + - (rq->wValue.bytes[1] << 8)); + (rq->wValue.bytes[1] << 8) ); } else { - cube = (cube & (uint32_t)0x0000ffff) | - ((uint32_t)(rq->wValue.bytes[0] + - (rq->wValue.bytes[1] << 8)) << 16); + frame = (frame & (uint32_t)0x0000ffff) | + ((uint32_t)( rq->wValue.bytes[0] + + (rq->wValue.bytes[1] << 8) ) << 16); } - /*} else if ( rq->bRequest == CUSTOM_RQ_SET_EEPROM ) + } else if ( rq->bRequest == CUSTOM_RQ_EEPROM_STORE_FRAME ) { - eeprom_write_dword(&eep_anim[0], 0x07007007);*/ - } else if ( rq->bRequest == CUSTOM_RQ_LOAD_EEPROM ) + eeprom_write_dword(&eep_anim[0], 0x07007007); + } else if ( rq->bRequest == CUSTOM_RQ_EEPROM_SET_FRAME ) { - cube = eeprom_read_dword( &eep_anim[rq->wIndex.bytes[0]] ); + frame = eeprom_read_dword( &eep_anim[rq->wIndex.bytes[0]] ); } } diff --git a/firmware/usb.h b/firmware/usb.h index c15c8a3..eb2dd50 100644 --- a/firmware/usb.h +++ b/firmware/usb.h @@ -18,6 +18,8 @@ #include "globals.h" +#include "type.h" + /* This example should run on most AVRs with only little changes. No special hardware resources except INT0 are used. You may have to change usbconfig.h for @@ -58,7 +60,9 @@ void init_usb(void); uint32_t eep_anim[32] EEMEM; // usb buffer -extern uint32_t cube; // Framebuffer +extern uint32_t frame; // Framebuffer + +//extern cube_t *cube; #endif // __usb_h__