mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-09-24 18:16:22 +03:00
s/\bpdata_t\b/struct pdata/g
This commit is contained in:
@@ -75,12 +75,11 @@
|
||||
#define MICRONUCLEUS_DEFAULT_TIMEOUT 500
|
||||
#define MICRONUCLEUS_MAX_MAJOR_VERSION 2
|
||||
|
||||
#define PDATA(pgm) ((pdata_t*)(pgm->cookie))
|
||||
#define PDATA(pgm) ((struct pdata *)(pgm->cookie))
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef struct pdata
|
||||
{
|
||||
struct pdata {
|
||||
usb_dev_handle* usb_handle;
|
||||
// Extended parameters
|
||||
bool wait_until_device_present;
|
||||
@@ -102,7 +101,7 @@ typedef struct pdata
|
||||
uint16_t user_reset_vector; // reset vector of user program
|
||||
bool write_last_page; // last page already programmed
|
||||
bool start_program; // require start after flash
|
||||
} pdata_t;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -111,8 +110,7 @@ static void delay_ms(uint32_t duration)
|
||||
usleep(duration * 1000);
|
||||
}
|
||||
|
||||
static int micronucleus_check_connection(pdata_t* pdata)
|
||||
{
|
||||
static int micronucleus_check_connection(struct pdata *pdata) {
|
||||
if (pdata->major_version >= 2)
|
||||
{
|
||||
uint8_t buffer[6] = { 0 };
|
||||
@@ -139,8 +137,7 @@ static int micronucleus_check_connection(pdata_t* pdata)
|
||||
}
|
||||
}
|
||||
|
||||
static bool micronucleus_is_device_responsive(pdata_t* pdata, struct usb_device* device)
|
||||
{
|
||||
static bool micronucleus_is_device_responsive(struct pdata *pdata, struct usb_device *device) {
|
||||
pdata->usb_handle = usb_open(device);
|
||||
if (pdata->usb_handle == NULL)
|
||||
{
|
||||
@@ -155,8 +152,7 @@ static bool micronucleus_is_device_responsive(pdata_t* pdata, struct usb_device*
|
||||
return result >= 0;
|
||||
}
|
||||
|
||||
static int micronucleus_reconnect(pdata_t* pdata)
|
||||
{
|
||||
static int micronucleus_reconnect(struct pdata *pdata) {
|
||||
struct usb_device* device = usb_device(pdata->usb_handle);
|
||||
|
||||
usb_close(pdata->usb_handle);
|
||||
@@ -176,8 +172,7 @@ static int micronucleus_reconnect(pdata_t* pdata)
|
||||
return -1;
|
||||
}
|
||||
|
||||
static int micronucleus_get_bootloader_info_v1(pdata_t* pdata)
|
||||
{
|
||||
static int micronucleus_get_bootloader_info_v1(struct pdata *pdata) {
|
||||
uint8_t buffer[4] = { 0 };
|
||||
int result = usb_control_msg(
|
||||
pdata->usb_handle,
|
||||
@@ -243,8 +238,7 @@ static int micronucleus_get_bootloader_info_v1(pdata_t* pdata)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int micronucleus_get_bootloader_info_v2(pdata_t* pdata)
|
||||
{
|
||||
static int micronucleus_get_bootloader_info_v2(struct pdata *pdata) {
|
||||
uint8_t buffer[6] = { 0 };
|
||||
int result = usb_control_msg(
|
||||
pdata->usb_handle,
|
||||
@@ -284,8 +278,7 @@ static int micronucleus_get_bootloader_info_v2(pdata_t* pdata)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int micronucleus_get_bootloader_info(pdata_t* pdata)
|
||||
{
|
||||
static int micronucleus_get_bootloader_info(struct pdata *pdata) {
|
||||
if (pdata->major_version >= 2)
|
||||
{
|
||||
return micronucleus_get_bootloader_info_v2(pdata);
|
||||
@@ -296,8 +289,7 @@ static int micronucleus_get_bootloader_info(pdata_t* pdata)
|
||||
}
|
||||
}
|
||||
|
||||
static void micronucleus_dump_device_info(pdata_t* pdata)
|
||||
{
|
||||
static void micronucleus_dump_device_info(struct pdata *pdata) {
|
||||
pmsg_notice("Bootloader version: %d.%d\n", pdata->major_version, pdata->minor_version);
|
||||
imsg_notice("Available flash size: %u\n", pdata->flash_size);
|
||||
imsg_notice("Page size: %u\n", pdata->page_size);
|
||||
@@ -308,8 +300,7 @@ static void micronucleus_dump_device_info(pdata_t* pdata)
|
||||
imsg_notice("Signature2: 0x%02X\n", pdata->signature2);
|
||||
}
|
||||
|
||||
static int micronucleus_erase_device(pdata_t* pdata)
|
||||
{
|
||||
static int micronucleus_erase_device(struct pdata *pdata) {
|
||||
pmsg_debug("micronucleus_erase_device()\n");
|
||||
|
||||
int result = usb_control_msg(
|
||||
@@ -351,8 +342,7 @@ static int micronucleus_erase_device(pdata_t* pdata)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int micronucleus_patch_reset_vector(pdata_t* pdata, uint8_t* buffer)
|
||||
{
|
||||
static int micronucleus_patch_reset_vector(struct pdata *pdata, uint8_t *buffer) {
|
||||
// Save user reset vector.
|
||||
uint16_t word0 = (buffer[1] << 8) | buffer[0];
|
||||
uint16_t word1 = (buffer[3] << 8) | buffer[2];
|
||||
@@ -394,8 +384,7 @@ static int micronucleus_patch_reset_vector(pdata_t* pdata, uint8_t* buffer)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void micronucleus_patch_user_vector(pdata_t* pdata, uint8_t* buffer)
|
||||
{
|
||||
static void micronucleus_patch_user_vector(struct pdata *pdata, uint8_t *buffer) {
|
||||
uint16_t user_reset_addr = pdata->bootloader_start - 4;
|
||||
uint16_t address = pdata->bootloader_start - pdata->page_size;
|
||||
if (user_reset_addr > 0x2000)
|
||||
@@ -416,8 +405,7 @@ static void micronucleus_patch_user_vector(pdata_t* pdata, uint8_t* buffer)
|
||||
}
|
||||
}
|
||||
|
||||
static int micronucleus_write_page_v1(pdata_t* pdata, uint32_t address, uint8_t* buffer, uint32_t size)
|
||||
{
|
||||
static int micronucleus_write_page_v1(struct pdata *pdata, uint32_t address, uint8_t *buffer, uint32_t size) {
|
||||
int result = usb_control_msg(
|
||||
pdata->usb_handle,
|
||||
USB_ENDPOINT_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
|
||||
@@ -434,8 +422,7 @@ static int micronucleus_write_page_v1(pdata_t* pdata, uint32_t address, uint8_t*
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int micronucleus_write_page_v2(pdata_t* pdata, uint32_t address, uint8_t* buffer, uint32_t size)
|
||||
{
|
||||
static int micronucleus_write_page_v2(struct pdata *pdata, uint32_t address, uint8_t *buffer, uint32_t size) {
|
||||
int result = usb_control_msg(
|
||||
pdata->usb_handle,
|
||||
USB_ENDPOINT_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
|
||||
@@ -470,8 +457,7 @@ static int micronucleus_write_page_v2(pdata_t* pdata, uint32_t address, uint8_t*
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int micronucleus_write_page(pdata_t* pdata, uint32_t address, uint8_t* buffer, uint32_t size)
|
||||
{
|
||||
static int micronucleus_write_page(struct pdata *pdata, uint32_t address, uint8_t *buffer, uint32_t size) {
|
||||
pmsg_debug("micronucleus_write_page(address=0x%04X, size=%d)\n", address, size);
|
||||
|
||||
if (address == 0)
|
||||
@@ -522,8 +508,7 @@ static int micronucleus_write_page(pdata_t* pdata, uint32_t address, uint8_t* bu
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int micronucleus_start(pdata_t* pdata)
|
||||
{
|
||||
static int micronucleus_start(struct pdata *pdata) {
|
||||
pmsg_debug("micronucleus_start()\n");
|
||||
|
||||
int result = usb_control_msg(
|
||||
@@ -546,7 +531,7 @@ static int micronucleus_start(pdata_t* pdata)
|
||||
|
||||
static void micronucleus_setup(PROGRAMMER *pgm) {
|
||||
pmsg_debug("micronucleus_setup()\n");
|
||||
pgm->cookie = mmt_malloc(sizeof(pdata_t));
|
||||
pgm->cookie = mmt_malloc(sizeof(struct pdata));
|
||||
}
|
||||
|
||||
static void micronucleus_teardown(PROGRAMMER* pgm) {
|
||||
@@ -558,7 +543,7 @@ static void micronucleus_teardown(PROGRAMMER* pgm) {
|
||||
static int micronucleus_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
pmsg_debug("micronucleus_initialize()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
struct pdata *pdata = PDATA(pgm);
|
||||
|
||||
int result = micronucleus_get_bootloader_info(pdata);
|
||||
if (result < 0)
|
||||
@@ -580,7 +565,7 @@ static void micronucleus_powerup(const PROGRAMMER *pgm) {
|
||||
static void micronucleus_powerdown(const PROGRAMMER *pgm) {
|
||||
pmsg_debug("micronucleus_powerdown()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
struct pdata *pdata = PDATA(pgm);
|
||||
if (pdata->write_last_page)
|
||||
{
|
||||
pdata->write_last_page = false;
|
||||
@@ -621,7 +606,7 @@ static int micronucleus_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p,
|
||||
return -1;
|
||||
}
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
struct pdata *pdata = PDATA(pgm);
|
||||
mem->buf[0] = 0x1E;
|
||||
mem->buf[1] = pdata->signature1;
|
||||
mem->buf[2] = pdata->signature2;
|
||||
@@ -631,14 +616,14 @@ static int micronucleus_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p,
|
||||
static int micronucleus_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
pmsg_debug("micronucleus_chip_erase()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
struct pdata *pdata = PDATA(pgm);
|
||||
return micronucleus_erase_device(pdata);
|
||||
}
|
||||
|
||||
static int micronucleus_open(PROGRAMMER* pgm, const char *port) {
|
||||
pmsg_debug("micronucleus_open(\"%s\")\n", port);
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
struct pdata *pdata = PDATA(pgm);
|
||||
const char *bus_name = NULL;
|
||||
char* dev_name = NULL;
|
||||
|
||||
@@ -790,7 +775,7 @@ static void micronucleus_close(PROGRAMMER* pgm)
|
||||
{
|
||||
pmsg_debug("micronucleus_close()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
struct pdata *pdata = PDATA(pgm);
|
||||
if (pdata->usb_handle != NULL)
|
||||
{
|
||||
usb_close(pdata->usb_handle);
|
||||
@@ -838,7 +823,7 @@ static int micronucleus_paged_write(const PROGRAMMER *pgm, const AVRPART *p, con
|
||||
|
||||
if (mem_is_flash(mem))
|
||||
{
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
struct pdata *pdata = PDATA(pgm);
|
||||
|
||||
if (n_bytes > page_size)
|
||||
{
|
||||
@@ -886,7 +871,7 @@ static int micronucleus_paged_write(const PROGRAMMER *pgm, const AVRPART *p, con
|
||||
static int micronucleus_parseextparams(const PROGRAMMER *pgm, const LISTID xparams) {
|
||||
pmsg_debug("micronucleus_parseextparams()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
struct pdata *pdata = PDATA(pgm);
|
||||
for (LNODEID node = lfirst(xparams); node != NULL; node = lnext(node))
|
||||
{
|
||||
const char* param = ldata(node);
|
||||
|
||||
39
src/teensy.c
39
src/teensy.c
@@ -59,12 +59,11 @@
|
||||
|
||||
#define TEENSY_CONNECT_WAIT 100
|
||||
|
||||
#define PDATA(pgm) ((pdata_t*)(pgm->cookie))
|
||||
#define PDATA(pgm) ((struct pdata *)(pgm->cookie))
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
typedef struct pdata
|
||||
{
|
||||
struct pdata {
|
||||
hid_device* hid_handle;
|
||||
uint16_t hid_usage;
|
||||
// Extended parameters
|
||||
@@ -78,7 +77,7 @@ typedef struct pdata
|
||||
// State
|
||||
bool erase_flash;
|
||||
bool reboot;
|
||||
} pdata_t;
|
||||
};
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
@@ -87,7 +86,7 @@ static void delay_ms(uint32_t duration)
|
||||
usleep(duration * 1000);
|
||||
}
|
||||
|
||||
static int teensy_get_bootloader_info(pdata_t* pdata, const AVRPART* p) {
|
||||
static int teensy_get_bootloader_info(struct pdata *pdata, const AVRPART *p) {
|
||||
switch (pdata->hid_usage)
|
||||
{
|
||||
case 0x19:
|
||||
@@ -156,8 +155,7 @@ static int teensy_get_bootloader_info(pdata_t* pdata, const AVRPART* p) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void teensy_dump_device_info(pdata_t* pdata)
|
||||
{
|
||||
static void teensy_dump_device_info(struct pdata *pdata) {
|
||||
pmsg_notice("HID usage: 0x%02X\n", pdata->hid_usage);
|
||||
pmsg_notice("Board: %s\n", pdata->board);
|
||||
pmsg_notice("Available flash size: %u\n", pdata->flash_size);
|
||||
@@ -166,8 +164,7 @@ static void teensy_dump_device_info(pdata_t* pdata)
|
||||
pdata->sig_bytes[0], pdata->sig_bytes[1], pdata->sig_bytes[2]);
|
||||
}
|
||||
|
||||
static int teensy_write_page(pdata_t* pdata, uint32_t address, const uint8_t* buffer, uint32_t size, bool suppress_warning)
|
||||
{
|
||||
static int teensy_write_page(struct pdata *pdata, uint32_t address, const uint8_t *buffer, uint32_t size, bool suppress_warning) {
|
||||
pmsg_debug("teensy_write_page(address=0x%06X, size=%d)\n", address, size);
|
||||
|
||||
if (size > pdata->page_size)
|
||||
@@ -211,16 +208,14 @@ static int teensy_write_page(pdata_t* pdata, uint32_t address, const uint8_t* bu
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int teensy_erase_flash(pdata_t* pdata)
|
||||
{
|
||||
static int teensy_erase_flash(struct pdata *pdata) {
|
||||
pmsg_debug("teensy_erase_flash()\n");
|
||||
|
||||
// Write a dummy page at address 0 to explicitly erase the flash.
|
||||
return teensy_write_page(pdata, 0, NULL, 0, false);
|
||||
}
|
||||
|
||||
static int teensy_reboot(pdata_t* pdata)
|
||||
{
|
||||
static int teensy_reboot(struct pdata *pdata) {
|
||||
pmsg_debug("teensy_reboot()\n");
|
||||
|
||||
// Write a dummy page at address -1 to reboot the Teensy.
|
||||
@@ -231,7 +226,7 @@ static int teensy_reboot(pdata_t* pdata)
|
||||
|
||||
static void teensy_setup(PROGRAMMER *pgm) {
|
||||
pmsg_debug("teensy_setup()\n");
|
||||
pgm->cookie = mmt_malloc(sizeof(pdata_t));
|
||||
pgm->cookie = mmt_malloc(sizeof(struct pdata));
|
||||
}
|
||||
|
||||
static void teensy_teardown(PROGRAMMER *pgm) {
|
||||
@@ -243,7 +238,7 @@ static void teensy_teardown(PROGRAMMER *pgm) {
|
||||
static int teensy_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
pmsg_debug("teensy_initialize()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
struct pdata *pdata = PDATA(pgm);
|
||||
|
||||
int result = teensy_get_bootloader_info(pdata, p);
|
||||
if (result < 0)
|
||||
@@ -265,7 +260,7 @@ static void teensy_powerup(const PROGRAMMER *pgm) {
|
||||
static void teensy_powerdown(const PROGRAMMER *pgm) {
|
||||
pmsg_debug("teensy_powerdown()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
struct pdata *pdata = PDATA(pgm);
|
||||
|
||||
if (pdata->erase_flash)
|
||||
{
|
||||
@@ -302,7 +297,7 @@ static int teensy_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, const
|
||||
return -1;
|
||||
}
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
struct pdata *pdata = PDATA(pgm);
|
||||
memcpy(mem->buf, pdata->sig_bytes, sizeof(pdata->sig_bytes));
|
||||
|
||||
return 0;
|
||||
@@ -311,7 +306,7 @@ static int teensy_read_sig_bytes(const PROGRAMMER *pgm, const AVRPART *p, const
|
||||
static int teensy_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
pmsg_debug("teensy_chip_erase()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
struct pdata *pdata = PDATA(pgm);
|
||||
|
||||
// Schedule a chip erase, either at first write or on powerdown.
|
||||
pdata->erase_flash = true;
|
||||
@@ -322,7 +317,7 @@ static int teensy_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
static int teensy_open(PROGRAMMER *pgm, const char *port) {
|
||||
pmsg_debug("teensy_open(\"%s\")\n", port);
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
struct pdata *pdata = PDATA(pgm);
|
||||
const char *bus_name = NULL;
|
||||
char* dev_name = NULL;
|
||||
|
||||
@@ -438,7 +433,7 @@ static void teensy_close(PROGRAMMER* pgm)
|
||||
{
|
||||
pmsg_debug("teensy_close()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
struct pdata *pdata = PDATA(pgm);
|
||||
if (pdata->hid_handle != NULL)
|
||||
{
|
||||
hid_close(pdata->hid_handle);
|
||||
@@ -486,7 +481,7 @@ static int teensy_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
||||
|
||||
if (mem_is_flash(mem))
|
||||
{
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
struct pdata *pdata = PDATA(pgm);
|
||||
|
||||
if (n_bytes > page_size)
|
||||
{
|
||||
@@ -537,7 +532,7 @@ static int teensy_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
||||
static int teensy_parseextparams(const PROGRAMMER *pgm, const LISTID xparams) {
|
||||
pmsg_debug("teensy_parseextparams()\n");
|
||||
|
||||
pdata_t* pdata = PDATA(pgm);
|
||||
struct pdata *pdata = PDATA(pgm);
|
||||
for (LNODEID node = lfirst(xparams); node != NULL; node = lnext(node))
|
||||
{
|
||||
const char* param = ldata(node);
|
||||
|
||||
Reference in New Issue
Block a user