From 83c18361d821819208e5d8024e8b557c359fdc7d Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@6dc7ffe9-61d6-0310-9af1-9938baff3ed1> Date: Sat, 9 Sep 2006 04:42:17 +0000 Subject: - cosmetic cleanup git-svn-id: https://svn.openpcd.org:2342/trunk@146 6dc7ffe9-61d6-0310-9af1-9938baff3ed1 --- openpcd/firmware/src/main_usb.c | 1 - openpcd/firmware/src/openpcd.h | 3 --- openpcd/firmware/src/os/dbgu.h | 1 + openpcd/firmware/src/os/dfu.c | 14 +++++++------- openpcd/firmware/src/os/dfu.h | 4 ++-- openpcd/firmware/src/os/main.c | 7 +++++++ openpcd/firmware/src/os/req_ctx.c | 2 +- openpcd/firmware/src/os/usb_handler.c | 1 + openpcd/firmware/src/os/usb_handler.h | 2 ++ openpcd/firmware/src/pcd/main_analog.c | 1 - openpcd/firmware/src/pcd/main_dumbreader.c | 2 -- openpcd/firmware/src/pcd/main_pwm.c | 2 -- openpcd/firmware/src/pcd/main_reqa.c | 1 - openpcd/firmware/src/pcd/pwm.c | 4 ++-- openpcd/firmware/src/pcd/rc632.c | 2 +- openpcd/firmware/src/start/Cstartup.S | 3 ++- 16 files changed, 26 insertions(+), 24 deletions(-) diff --git a/openpcd/firmware/src/main_usb.c b/openpcd/firmware/src/main_usb.c index ee9556c..abb6948 100644 --- a/openpcd/firmware/src/main_usb.c +++ b/openpcd/firmware/src/main_usb.c @@ -31,7 +31,6 @@ int _main_dbgu(char key) void _init_func(void) { - udp_init(); usbtest_init(); } diff --git a/openpcd/firmware/src/openpcd.h b/openpcd/firmware/src/openpcd.h index a368996..51fa98d 100644 --- a/openpcd/firmware/src/openpcd.h +++ b/openpcd/firmware/src/openpcd.h @@ -99,7 +99,4 @@ #define OPENPCD_IRQ_PRIO_UDP (AT91C_AIC_PRIOR_LOWEST+1) #define OPENPCD_IRQ_PRIO_RC632 AT91C_AIC_PRIOR_LOWEST -extern void _init_func(void); -extern void _main_func(void); - #endif /* _OPENPCD_H */ diff --git a/openpcd/firmware/src/os/dbgu.h b/openpcd/firmware/src/os/dbgu.h index 8dd34be..e29e351 100644 --- a/openpcd/firmware/src/os/dbgu.h +++ b/openpcd/firmware/src/os/dbgu.h @@ -26,6 +26,7 @@ void AT91F_DBGU_Init(void); void AT91F_DBGU_Printk( char *buffer); void AT91F_DBGU_Frame( char *buffer); int AT91F_DBGU_Get( char *val); +void dbgu_rb_flush(void); #ifndef __WinARM__ void AT91F_DBGU_scanf(char * type,unsigned int * val); #endif diff --git a/openpcd/firmware/src/os/dfu.c b/openpcd/firmware/src/os/dfu.c index ec99cef..25040db 100644 --- a/openpcd/firmware/src/os/dfu.c +++ b/openpcd/firmware/src/os/dfu.c @@ -24,8 +24,8 @@ #define DEBUGE DEBUGP #define DEBUGI DEBUGP #else -#define DEBUGE(x, args ...) -#define DEBUGI(x, args ...) +#define DEBUGE(x, args ...) do { } while (0) +#define DEBUGI(x, args ...) do { } while (0) #endif /* this is only called once before DFU mode, no __dfufunc required */ @@ -160,7 +160,7 @@ static __dfufunc int handle_upload(u_int16_t val, u_int16_t len) if (ptr + len > AT91C_IFLASH_SIZE) len = AT91C_IFLASH_SIZE - (u_int32_t) ptr; - udp_ep0_send_data(ptr, len); + udp_ep0_send_data((char *)ptr, len); ptr+= len; return len; @@ -176,7 +176,7 @@ static __dfufunc void handle_getstatus(void) dstat.bStatus = status; dstat.bState = dfu_state; dstat.iString = 0; - udp_ep0_send_data(&dstat, sizeof(dstat)); + udp_ep0_send_data((char *)&dstat, sizeof(dstat)); } static void __dfufunc handle_getstate(void) @@ -368,7 +368,7 @@ send_zlp: static u_int8_t cur_config; /* USB DFU Device descriptor in DFU mode */ -__dfustruct struct usb_device_descriptor dfu_dev_descriptor = { +__dfustruct const struct usb_device_descriptor dfu_dev_descriptor = { .bLength = USB_DT_DEVICE_SIZE, .bDescriptorType = USB_DT_DEVICE, .bcdUSB = 0x0100, @@ -386,7 +386,7 @@ __dfustruct struct usb_device_descriptor dfu_dev_descriptor = { }; /* USB DFU Config descriptor in DFU mode */ -__dfustruct struct _dfu_desc dfu_cfg_descriptor = { +__dfustruct const struct _dfu_desc dfu_cfg_descriptor = { .ucfg = { .bLength = USB_DT_CONFIG_SIZE, .bDescriptorType = USB_DT_CONFIG, @@ -665,7 +665,7 @@ void __dfufunc dfu_main(void) while (1) ; } -struct dfuapi __dfufunctab dfu_api = { +const struct dfuapi __dfufunctab dfu_api = { .ep0_send_data = &udp_ep0_send_data, .ep0_send_zlp = &udp_ep0_send_zlp, .ep0_send_stall = &udp_ep0_send_stall, diff --git a/openpcd/firmware/src/os/dfu.h b/openpcd/firmware/src/os/dfu.h index a663688..e68f62d 100644 --- a/openpcd/firmware/src/os/dfu.h +++ b/openpcd/firmware/src/os/dfu.h @@ -72,8 +72,8 @@ struct dfuapi { u_int16_t val, u_int16_t len); void (*dfu_switch)(void); u_int8_t *dfu_state; - struct usb_device_descriptor *dfu_dev_descriptor; - struct _dfu_desc *dfu_cfg_descriptor; + const struct usb_device_descriptor *dfu_dev_descriptor; + const struct _dfu_desc *dfu_cfg_descriptor; }; diff --git a/openpcd/firmware/src/os/main.c b/openpcd/firmware/src/os/main.c index c40fd79..4f637e5 100644 --- a/openpcd/firmware/src/os/main.c +++ b/openpcd/firmware/src/os/main.c @@ -3,6 +3,9 @@ #include #include #include +#include +#include +#include #include "../openpcd.h" int main(void) @@ -14,6 +17,10 @@ int main(void) /* call application specific init function */ _init_func(); + /* initialize USB */ + udp_init(); + udp_open(); + // Enable User Reset and set its minimal assertion to 960 us AT91C_BASE_RSTC->RSTC_RMR = AT91C_RSTC_URSTEN | (0x4 << 8) | (unsigned int)(0xA5 << 24); diff --git a/openpcd/firmware/src/os/req_ctx.c b/openpcd/firmware/src/os/req_ctx.c index 831d48e..99d248b 100644 --- a/openpcd/firmware/src/os/req_ctx.c +++ b/openpcd/firmware/src/os/req_ctx.c @@ -31,7 +31,7 @@ struct req_ctx *req_ctx_find_get(unsigned long old_state, unsigned long new_stat u_int8_t req_ctx_num(struct req_ctx *ctx) { - return ((void *)ctx - (void *)&req_ctx[0])/sizeof(*ctx); + return ((char *)ctx - (char *)&req_ctx[0])/sizeof(*ctx); } void req_ctx_set_state(struct req_ctx *ctx, unsigned long new_state) diff --git a/openpcd/firmware/src/os/usb_handler.c b/openpcd/firmware/src/os/usb_handler.c index 82620be..274353c 100644 --- a/openpcd/firmware/src/os/usb_handler.c +++ b/openpcd/firmware/src/os/usb_handler.c @@ -21,6 +21,7 @@ static usb_cmd_fn *cmd_hdlrs[16]; int usb_hdlr_register(usb_cmd_fn *hdlr, u_int8_t class) { cmd_hdlrs[class] = hdlr; + return 0; } void usb_hdlr_unregister(u_int8_t class) diff --git a/openpcd/firmware/src/os/usb_handler.h b/openpcd/firmware/src/os/usb_handler.h index a281c66..3efcc1f 100644 --- a/openpcd/firmware/src/os/usb_handler.h +++ b/openpcd/firmware/src/os/usb_handler.h @@ -2,12 +2,14 @@ #define _USB_HANDLER_H #include "openpcd.h" +#include #define MAX_PAYLOAD_LEN (64 - sizeof(struct openpcd_hdr)) typedef int usb_cmd_fn(struct req_ctx *rctx); extern int usb_hdlr_register(usb_cmd_fn *hdlr, u_int8_t class); +extern void usb_hdlr_unregister(u_int8_t class); extern void usb_in_process(void); extern void usb_out_process(void); diff --git a/openpcd/firmware/src/pcd/main_analog.c b/openpcd/firmware/src/pcd/main_analog.c index 45869e1..8ffa1d4 100644 --- a/openpcd/firmware/src/pcd/main_analog.c +++ b/openpcd/firmware/src/pcd/main_analog.c @@ -19,7 +19,6 @@ void _init_func(void) { - //udp_init(); trigger_init(); rc632_init(); DEBUGPCRF("turning on RF"); diff --git a/openpcd/firmware/src/pcd/main_dumbreader.c b/openpcd/firmware/src/pcd/main_dumbreader.c index 9e20876..1535e27 100644 --- a/openpcd/firmware/src/pcd/main_dumbreader.c +++ b/openpcd/firmware/src/pcd/main_dumbreader.c @@ -12,8 +12,6 @@ void _init_func(void) { rc632_init(); - udp_init(); - udp_open(); rc632_test(RAH); } diff --git a/openpcd/firmware/src/pcd/main_pwm.c b/openpcd/firmware/src/pcd/main_pwm.c index 85d304a..691c27d 100644 --- a/openpcd/firmware/src/pcd/main_pwm.c +++ b/openpcd/firmware/src/pcd/main_pwm.c @@ -95,8 +95,6 @@ void _init_func(void) pwm_duty_set_percent(0, 22); /* 22% of 9.43uS = 2.07uS */ rc632_modulate_mfin(); - udp_init(); - DEBUGPCRF("Initializing SSC RX"); ssc_rx_init(); } diff --git a/openpcd/firmware/src/pcd/main_reqa.c b/openpcd/firmware/src/pcd/main_reqa.c index 179b423..e28fdff 100644 --- a/openpcd/firmware/src/pcd/main_reqa.c +++ b/openpcd/firmware/src/pcd/main_reqa.c @@ -26,7 +26,6 @@ void _init_func(void) { - //udp_init(); trigger_init(); DEBUGPCRF("enabling RC632"); rc632_init(); diff --git a/openpcd/firmware/src/pcd/pwm.c b/openpcd/firmware/src/pcd/pwm.c index ef1ee3f..e05699b 100644 --- a/openpcd/firmware/src/pcd/pwm.c +++ b/openpcd/firmware/src/pcd/pwm.c @@ -107,7 +107,7 @@ void pwm_duty_set_percent(int channel, u_int16_t duty) static int pwm_usb_in(struct req_ctx *rctx) { struct openpcd_hdr *poh = (struct openpcd_hdr *) &rctx->rx.data[0]; - struct openpcd_hdr *pih = (struct openpcd_hdr *) &rctx->tx.data[0]; + /* struct openpcd_hdr *pih = (struct openpcd_hdr *) &rctx->tx.data[0]; */ u_int32_t *freq; switch (poh->cmd) { @@ -126,7 +126,7 @@ static int pwm_usb_in(struct req_ctx *rctx) case OPENPCD_CMD_PWM_FREQ_SET: if (rctx->rx.tot_len < sizeof(*poh)+4) break; - freq = (void *) poh + sizeof(*poh); + freq = (unsigned char *) poh + sizeof(*poh); pwm_freq_set(0, *freq); break; case OPENPCD_CMD_PWM_FREQ_GET: diff --git a/openpcd/firmware/src/pcd/rc632.c b/openpcd/firmware/src/pcd/rc632.c index 9fc7428..620d0a0 100644 --- a/openpcd/firmware/src/pcd/rc632.c +++ b/openpcd/firmware/src/pcd/rc632.c @@ -397,7 +397,7 @@ static int rc632_usb_in(struct req_ctx *rctx) break; case OPENPCD_CMD_READ_FIFO: { - u_int16_t req_len = poh->val, remain_len, pih_len; + u_int16_t req_len = poh->val, remain_len = req_len, pih_len; if (req_len > MAX_PAYLOAD_LEN) { pih_len = MAX_PAYLOAD_LEN; remain_len -= pih_len; diff --git a/openpcd/firmware/src/start/Cstartup.S b/openpcd/firmware/src/start/Cstartup.S index 731d4c3..1c9f1db 100644 --- a/openpcd/firmware/src/start/Cstartup.S +++ b/openpcd/firmware/src/start/Cstartup.S @@ -19,11 +19,12 @@ //#define DEBUG_LL #ifdef DEBUG_LL +/* Debugging macros for switching on/off LED1 (green) */ #define PIOA_PER 0xFFFFF400 #define PIOA_OER 0xFFFFF410 #define PIOA_SODR 0xFFFFF430 #define PIOA_CODR 0xFFFFF434 -#define LED1 25 +#define LED1 25 /* this only works on OpenPICC, not Olimex */ .macro led1on ldr r2, =PIOA_CODR mov r1, #(1 << LED1) -- cgit v1.2.3