diff options
Diffstat (limited to 'openpcd/firmware/src/led.c')
-rw-r--r-- | openpcd/firmware/src/led.c | 26 |
1 files changed, 25 insertions, 1 deletions
diff --git a/openpcd/firmware/src/led.c b/openpcd/firmware/src/led.c index b3dcfc7..ec203e5 100644 --- a/openpcd/firmware/src/led.c +++ b/openpcd/firmware/src/led.c @@ -1,7 +1,10 @@ #include <sys/types.h> -#include <include/lib_AT91SAM7.h> +#include <errno.h> +#include <lib_AT91SAM7.h> +#include <openpcd.h> #include "openpcd.h" +#include "usb_handler.h" #include "dbgu.h" static int led2port(int led) @@ -51,10 +54,31 @@ int led_toggle(int led) return !on; } +static int led_usb_rx(struct req_ctx *rctx) +{ + struct openpcd_hdr *poh = (struct openpcd_hdr *) &rctx->rx.data[0]; + int ret = 1; + + switch (poh->cmd) { + case OPENPCD_CMD_SET_LED: + DEBUGP("SET LED(%u,%u) ", poh->reg, poh->val); + led_switch(poh->reg, poh->val); + break; + default: + DEBUGP("UNKNOWN "); + ret = -EINVAL; + break; + } + req_ctx_put(rctx); + return 1; +}; + void led_init(void) { AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, OPENPCD_PIO_LED1); AT91F_PIO_CfgOutput(AT91C_BASE_PIOA, OPENPCD_PIO_LED2); led_switch(1, 0); led_switch(2, 0); + + usb_hdlr_register(&led_usb_rx, OPENPCD_CMD_CLS_LED); } |