OpenCBM
usbcfg.c
Go to the documentation of this file.
1 /*
2  * USB configuration application for the xum1541
3  * Copyright 2010 Nate Lawson <nate@root.org>
4  * Copyright 2010 Wolfgang Moser
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version
9  * 2 of the License, or (at your option) any later version.
10  */
11 
19 #include <stdarg.h>
20 #include <stdio.h>
21 #include <string.h>
22 #include <errno.h>
23 
24 #include "opencbm.h"
25 
26 #include "arch.h"
27 #include "archlib_ex.h"
28 #include "xum1541_types.h"
29 
30 
37 int ARCH_MAINDECL
38 main(int argc, char **argv)
39 {
40  int ret;
41  CBM_FILE HandleXum1541 = NULL;
42 
43  ret = opencbm_plugin_init();
44  if (ret == 0) {
45  ret = opencbm_plugin_driver_open(&HandleXum1541, 0);
46  }
47  if (ret != 0) {
48  fprintf(stderr, "initialization error, aborting\n");
49  exit(1);
50  }
51  if (xum1541_plugin_control_msg(HandleXum1541, XUM1541_ENTER_BOOTLOADER) == 0) {
52  fprintf(stderr, "Success. xum1541 now in bootloader mode.\n");
53  fprintf(stderr, "Run your firmware update program now.\n");
54  } else {
55  fprintf(stderr, "error entering bootloader mode, aborting\n");
56  }
57  opencbm_plugin_driver_close(HandleXum1541);
58  opencbm_plugin_uninit();
59  exit(0);
60 }
void CBMAPIDECL opencbm_plugin_driver_close(CBM_FILE HandleDevice)
Closes the driver.
Definition: i_opencbm.c:454
int CBMAPIDECL opencbm_plugin_driver_open(CBM_FILE *HandleDevice, const char *const Port)
Opens the driver.
Definition: i_opencbm.c:405
int CBMAPIDECL xum1541_plugin_control_msg(CBM_FILE HandleDevice, unsigned int cmd)
Sends a command to the xum1541 device.
int ARCH_MAINDECL main(int argc, char **argv)
Initialize the xum1541 device This function tries to find and identify the xum1541 device...
Definition: usbcfg.c:38
#define CBM_FILE
Definition: opencbm.h:87
DLL interface for accessing the driver.
Define makros and functions which account for differences between the different architectures.