Put static variable of dfu.c into context structure

This commit is contained in:
Stefan Rueger
2024-05-08 22:32:27 +01:00
parent 0c565354aa
commit 6d8fce594c
2 changed files with 7 additions and 6 deletions

View File

@@ -88,8 +88,6 @@ int dfu_upload(struct dfu_dev *dfu, void * ptr, int size) {
* is sent to the device.
*/
static uint16_t wIndex = 0;
/* INTERNAL FUNCTION PROTOTYPES
*/
@@ -325,10 +323,10 @@ int dfu_dnload(struct dfu_dev *dfu, void *ptr, int size)
int result;
pmsg_trace("dfu_dnload(): issuing control OUT message, wIndex = %d, ptr = %p, size = %d\n",
wIndex, ptr, size);
cx->dfu_wIndex, ptr, size);
result = usb_control_msg(dfu->dev_handle,
USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_DNLOAD, wIndex++, 0,
USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_DNLOAD, cx->dfu_wIndex++, 0,
ptr, size, dfu->timeout);
if (result < 0) {
@@ -354,10 +352,10 @@ int dfu_upload(struct dfu_dev *dfu, void *ptr, int size)
int result;
pmsg_trace("dfu_upload(): issuing control IN message, wIndex = %d, ptr = %p, size = %d\n",
wIndex, ptr, size);
cx->dfu_wIndex, ptr, size);
result = usb_control_msg(dfu->dev_handle,
0x80 | USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_UPLOAD, wIndex++, 0,
0x80 | USB_TYPE_CLASS | USB_RECIP_INTERFACE, DFU_UPLOAD, cx->dfu_wIndex++, 0,
ptr, size, dfu->timeout);
if (result < 0) {

View File

@@ -1568,6 +1568,9 @@ typedef struct {
LISTID cfg_pushedcomms; // Temporarily pushed main comments
int cfg_pushed; // ... for memory sections
int cfg_init_search; // used in cfg_comp_search()
// Static variable from dfu.c
uint16_t dfu_wIndex; // A running number for USB messages
} cx_t;
extern cx_t *cx;