EEPROM write/read access via USB implemented.
This commit is contained in:
parent
598c2c67f3
commit
7c76f3303e
6 changed files with 44 additions and 19 deletions
|
@ -67,11 +67,15 @@ int main(int argc, char **argv)
|
||||||
}
|
}
|
||||||
#endif
|
#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(2);
|
||||||
|
|
||||||
// int usb_control_msg(usb_dev_handle *dev, int requesttype, int request, int value, int index, char *bytes, int size, int timeout);
|
// 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
|
// 32 bit in 2 transmission
|
||||||
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, 0x7217, 0, buffer, 0, 300);
|
||||||
//sleep(2);
|
//sleep(2);
|
||||||
usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_FRAME, 0x0700, 1, buffer, 0, 300);
|
usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_FRAME, 0x0743, 1, buffer, 0, 300);
|
||||||
|
|
||||||
// bitwise set/get
|
// 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);
|
//usb_control_msg(handle, USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_ENDPOINT_OUT, CUSTOM_RQ_SET_STATUS, 0, 25, buffer, 0, 5000);
|
||||||
|
|
|
@ -108,28 +108,30 @@ CINCS = -Iusbdrv
|
||||||
# -Wall...: warning level
|
# -Wall...: warning level
|
||||||
# -Wa,...: tell GCC to pass this to the assembler.
|
# -Wa,...: tell GCC to pass this to the assembler.
|
||||||
# -adhlns...: create assembler listing
|
# -adhlns...: create assembler listing
|
||||||
CFLAGS = #-g$(DEBUG)
|
|
||||||
CFLAGS += $(CDEFS) $(CINCS)
|
|
||||||
CFLAGS += -O$(OPT)
|
|
||||||
#CFLAGS += -funsigned-char
|
#CFLAGS += -funsigned-char
|
||||||
#CFLAGS += -funsigned-bitfields
|
#CFLAGS += -funsigned-bitfields
|
||||||
#CFLAGS += -fpack-struct
|
#CFLAGS += -fpack-struct
|
||||||
#CFLAGS += -fshort-enums
|
#CFLAGS += -fshort-enums
|
||||||
#CFLAGS += -fno-split-wide-types
|
#CFLAGS += -fno-split-wide-types
|
||||||
CFLAGS += -fno-move-loop-invariants
|
|
||||||
CFLAGS += -fno-tree-scev-cprop
|
|
||||||
#CFLAGS += -fno-inline-small-functions
|
#CFLAGS += -fno-inline-small-functions
|
||||||
#CFLAGS += -fno-tree-loop-optimize
|
#CFLAGS += -fno-tree-loop-optimize
|
||||||
#CFLAGS += -mcall-prologues
|
#CFLAGS += -mcall-prologues
|
||||||
#CFLAGS += -mtiny-stack
|
#CFLAGS += -mtiny-stack
|
||||||
#CFLAGS += -mint8
|
#CFLAGS += -mint8
|
||||||
|
#CFLAGS += -fdata-sections
|
||||||
|
#CFLAGS = -g$(DEBUG)
|
||||||
|
|
||||||
|
CFLAGS += -fno-move-loop-invariants
|
||||||
|
CFLAGS += -fno-tree-scev-cprop
|
||||||
|
CFLAGS += -ffunction-sections
|
||||||
|
|
||||||
|
CFLAGS += $(CDEFS) $(CINCS)
|
||||||
|
CFLAGS += -O$(OPT)
|
||||||
CFLAGS += -Wall -Wstrict-prototypes
|
CFLAGS += -Wall -Wstrict-prototypes
|
||||||
CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
|
CFLAGS += -Wa,-adhlns=$(<:.c=.lst)
|
||||||
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
CFLAGS += $(CSTANDARD)
|
CFLAGS += $(CSTANDARD)
|
||||||
CFLAGS += -DF_CPU=$(F_CPU)
|
CFLAGS += -DF_CPU=$(F_CPU)
|
||||||
CFLAGS += -ffunction-sections
|
|
||||||
#CFLAGS += -fdata-sections
|
|
||||||
CFLAGS += -Wl,--gc-sections
|
CFLAGS += -Wl,--gc-sections
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,11 +16,10 @@
|
||||||
|
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
|
||||||
// Cube-Data
|
// Cube-Data
|
||||||
uint32_t cube = 0xffffffff;
|
uint32_t cube = 0xffffffff;
|
||||||
// Bit Offset in Cube-Data
|
// Bit Offset in Cube-Data
|
||||||
uint8_t cube_level; // = 0; // Ebene
|
uint8_t cube_level; // Aktive Ebene
|
||||||
|
|
||||||
// Prototypen
|
// Prototypen
|
||||||
void init(void);
|
void init(void);
|
||||||
|
|
|
@ -18,5 +18,8 @@
|
||||||
|
|
||||||
#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_SET_EEPROM 3
|
||||||
|
#define CUSTOM_RQ_GET_EEPROM 4
|
||||||
|
#define CUSTOM_RQ_LOAD_EEPROM 5
|
||||||
|
|
||||||
#endif /* __REQUESTS_H_INCLUDED__ */
|
#endif /* __REQUESTS_H_INCLUDED__ */
|
||||||
|
|
|
@ -25,6 +25,10 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
||||||
} else if ( rq->bRequest == CUSTOM_RQ_SET_FRAME )
|
} else if ( rq->bRequest == CUSTOM_RQ_SET_FRAME )
|
||||||
{
|
{
|
||||||
|
|
||||||
|
/* requires more flash space
|
||||||
|
cube = (cube & (uint32_t)0xffff0000) |
|
||||||
|
( rq->wValue.bytes[0] + (rq->wValue.bytes[1] << 8) ) |
|
||||||
|
( (uint32_t)(rq->wIndex.bytes[0] + (rq->wIndex.bytes[1] << 8)) << 16 );*/
|
||||||
if ( rq->wIndex.bytes[0] == 0 )
|
if ( rq->wIndex.bytes[0] == 0 )
|
||||||
{
|
{
|
||||||
cube = (cube & (uint32_t)0xffff0000) |
|
cube = (cube & (uint32_t)0xffff0000) |
|
||||||
|
@ -36,7 +40,14 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
||||||
(rq->wValue.bytes[1] << 8)) << 16);
|
(rq->wValue.bytes[1] << 8)) << 16);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*} else if ( rq->bRequest == CUSTOM_RQ_SET_EEPROM )
|
||||||
|
{
|
||||||
|
eeprom_write_dword(&eep_anim[0], 0x07007007);*/
|
||||||
|
} else if ( rq->bRequest == CUSTOM_RQ_LOAD_EEPROM )
|
||||||
|
{
|
||||||
|
cube = eeprom_read_dword( &eep_anim[rq->wIndex.bytes[0]] );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
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 */
|
||||||
}
|
}
|
||||||
|
@ -46,17 +57,15 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
||||||
void init_usb(void)
|
void init_usb(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
uint8_t i, j, k;
|
uint8_t i;
|
||||||
|
|
||||||
usbInit();
|
usbInit();
|
||||||
usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */
|
usbDeviceDisconnect(); /* enforce re-enumeration, do this while interrupts are disabled! */
|
||||||
|
|
||||||
i = 0;
|
// fake USB disconnect for > 250 ms
|
||||||
j = 0;
|
while(--i)
|
||||||
k = 50;
|
{
|
||||||
while(--i) { /* fake USB disconnect for > 250 ms */
|
asm volatile("nop"::);
|
||||||
while(--k)
|
|
||||||
while(--j) { asm volatile("nop"::); }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
usbDeviceConnect();
|
usbDeviceConnect();
|
||||||
|
|
|
@ -10,6 +10,12 @@
|
||||||
#ifndef __usb_h__
|
#ifndef __usb_h__
|
||||||
#define __usb_h__
|
#define __usb_h__
|
||||||
|
|
||||||
|
#include <avr/eeprom.h>
|
||||||
|
|
||||||
|
#ifndef EEMEM
|
||||||
|
#define EEMEM __attribute__ ((section (".eeprom")))
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -49,8 +55,10 @@ PROGMEM char usbHidReportDescriptor[22] = { /* USB report descriptor */
|
||||||
|
|
||||||
void init_usb(void);
|
void init_usb(void);
|
||||||
|
|
||||||
|
uint32_t eep_anim[32] EEMEM;
|
||||||
|
|
||||||
// usb buffer
|
// usb buffer
|
||||||
extern volatile uint32_t cube; // Framebuffer
|
extern uint32_t cube; // Framebuffer
|
||||||
|
|
||||||
#endif // __usb_h__
|
#endif // __usb_h__
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue