Commit 2479f73c authored by Brian Johnson's avatar Brian Johnson

Select database based on programmer model

This means you need the programmer attached to list chip info
parent 2e389c5f
......@@ -16,19 +16,35 @@
*/
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include "database.h"
#include "minipro.h"
device_t devices[] =
device_t infoic_devices[] =
{
#include "devices.h"
#include "infoic_devices.h"
{ .name = NULL }, };
device_t infoic2plus_devices[] =
{
#include "infoic2plus_devices.h"
{ .name = NULL }, };
device_t *get_device_table(minipro_handle_t *handle)
{
if (strcmp(handle->model, "TL866II+") == 0) {
return &(infoic2plus_devices[0]);
}
return &(infoic_devices[0]);
}
device_t *get_device_by_name(const char *name)
device_t *get_device_by_name(minipro_handle_t *handle, const char *name)
{
device_t *device;
for (device = &(devices[0]); device[0].name; device = &(device[1]))
for (device = get_device_table(handle); device[0].name; device = &(device[1]))
{
if (!strcasecmp(name, device->name))
return (device);
......
......@@ -23,6 +23,8 @@
#include <stdint.h>
#include "fuses.h"
typedef struct minipro_handle minipro_handle_t;
typedef struct device
{
const char *name;
......@@ -48,8 +50,7 @@ typedef struct device
#define WORD_SIZE(device) (((device)->opts4 & 0xFF000000) == 0x01000000 ? 2 : 1)
extern device_t devices[];
device_t *get_device_by_name(const char *name);
device_t *get_device_table(minipro_handle_t *handle);
device_t *get_device_by_name(minipro_handle_t *handle, const char *name);
#endif
This diff is collapsed.
......@@ -33,7 +33,7 @@
#include "error.h"
minipro_handle_t * minipro_open(device_t *device)
minipro_handle_t * minipro_open(const char *device_name)
{
int32_t ret;
uint16_t expected_firmware;
......@@ -75,7 +75,6 @@ minipro_handle_t * minipro_open(device_t *device)
ERROR2("IO error: claim_interface: %s\n", libusb_error_name(ret));
}
handle->device = device;
minipro_get_system_info(handle, &info);
switch (info.device_status) {
......@@ -151,6 +150,14 @@ minipro_handle_t * minipro_open(device_t *device)
fprintf(stderr, " Found %s (%#03x)\n", handle->firmware_str, handle->firmware);
}
if (device_name != NULL) {
handle->device = get_device_by_name(handle, device_name);
if (handle->device == NULL) {
minipro_close(handle);
ERROR2("Device %s not found\n", device_name);
}
}
return (handle);
}
......
......@@ -131,7 +131,7 @@ enum GND_PINS
GND40
};
minipro_handle_t *minipro_open(device_t *device);
minipro_handle_t *minipro_open(const char *device_name);
void minipro_close(minipro_handle_t *handle);
void minipro_get_system_info(minipro_handle_t *handle, minipro_report_info_t *info);
uint32_t msg_send(minipro_handle_t *handle, uint8_t *buf, size_t length);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment