diff options
author | laforge <laforge@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2006-09-20 11:44:10 +0000 |
---|---|---|
committer | laforge <laforge@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> | 2006-09-20 11:44:10 +0000 |
commit | 514b0f72f50b50b75ef855f008c888f29989d68e (patch) | |
tree | 4a48031e2d2e95512ae3dc868301b5314c317081 /firmware/src/os/usbcmd_generic.c | |
parent | 20b657d7d20508b2a5fedf2e7a59a30e3d9a2fa4 (diff) |
- Add OpenPICC register definition (and USB command handling)
- Add automatic generation of include/compile.h with svn revision and compiletime
- Add openpcd_compile_version structure to obtain version via USB
- Move LED commands into new CMD_CLS_GENERIC family
- Update TODO
- Add support for large (2048 byte) request contexts in addition to 64byte
- Shrink req_ctx size by collapsing rx and tx buffer into one
- move definition of DFU_API_LOCATION to header file
- Implement large req_ctx aware USB transmit / refill routines
- Implement TX refilling for IRQ Endpoint
- Print version information at startup time
- move some generic req_ctx processing into usb_handler.c
- Some further work on DFU (still not finished)
- Only use '-Os' for DFU, use '-O2' for application code
git-svn-id: https://svn.openpcd.org:2342/trunk@208 6dc7ffe9-61d6-0310-9af1-9938baff3ed1
Diffstat (limited to 'firmware/src/os/usbcmd_generic.c')
-rw-r--r-- | firmware/src/os/usbcmd_generic.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/firmware/src/os/usbcmd_generic.c b/firmware/src/os/usbcmd_generic.c new file mode 100644 index 0000000..9dec14e --- /dev/null +++ b/firmware/src/os/usbcmd_generic.c @@ -0,0 +1,49 @@ +/* Some generel USB API commands, common between OpenPCD and OpenPICC + * (C) 2006 by Harald Welte <hwelte@hmw-consulting.de> + */ + +#include <string.h> +#include <sys/types.h> +#include <openpcd.h> +#include <os/req_ctx.h> +#include <os/usb_handler.h> +#include <os/led.h> +#include <os/dbgu.h> +#include <os/main.h> + +static int gen_usb_rx(struct req_ctx *rctx) +{ + struct openpcd_hdr *poh = (struct openpcd_hdr *) rctx->data; + struct openpcd_compile_version *ver = + (struct openpcd_compile_version *) poh->data; + int ret = 1; + + rctx->tot_len = sizeof(*poh); + + switch (poh->cmd) { + case OPENPCD_CMD_GET_VERSION: + DEBUGP("GET_VERSION "); + memcpy(ver, &opcd_version, sizeof(*ver)); + rctx->tot_len += sizeof(*ver); + poh->flags |= OPENPCD_FLAG_RESPOND; + break; + case OPENPCD_CMD_SET_LED: + DEBUGP("SET LED(%u,%u) ", poh->reg, poh->val); + led_switch(poh->reg, poh->val); + break; + default: + DEBUGP("UNKNOWN "); + return USB_ERR(USB_ERR_CMD_UNKNOWN); + break; + } + + if (poh->flags & OPENPCD_FLAG_RESPOND) + return USB_RET_RESPOND; + return 0; +} + +void usbcmd_gen_init(void) +{ + usb_hdlr_register(&gen_usb_rx, OPENPCD_CMD_CLS_GENERIC); +} + |