Skip to content

Commit 5a38f84

Browse files
committed
Add XC8 v2+ suppport. (signal11#26)
2 parents deffafa + 44c6e94 commit 5a38f84

File tree

10 files changed

+45
-10
lines changed

10 files changed

+45
-10
lines changed

host_test/control_transfer_in.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ int main(int argc, char **argv)
6565
if (libusb_init(NULL))
6666
return -1;
6767

68-
handle = libusb_open_device_with_vid_pid(NULL, 0xa0a0, 0x0001);
68+
handle = libusb_open_device_with_vid_pid(NULL, 0xa0a0, 0x0003);
6969
if (!handle) {
7070
perror("libusb_open failed: ");
7171
return 1;

host_test/control_transfer_out.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ int main(int argc, char **argv)
6464
if (libusb_init(NULL))
6565
return -1;
6666

67-
handle = libusb_open_device_with_vid_pid(NULL, 0xa0a0, 0x0001);
67+
handle = libusb_open_device_with_vid_pid(NULL, 0xa0a0, 0x0003);
6868
if (!handle) {
6969
perror("libusb_open failed: ");
7070
return 1;

host_test/test.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ int main(int argc, char **argv)
6666
if (libusb_init(NULL))
6767
return -1;
6868

69-
handle = libusb_open_device_with_vid_pid(NULL, 0xa0a0, 0x0001);
69+
handle = libusb_open_device_with_vid_pid(NULL, 0xa0a0, 0x0003);
7070
if (!handle) {
7171
perror("libusb_open failed: ");
7272
return 1;

usb/include/usb_cdc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
#if defined(__XC16__) || defined(__XC32__)
4343
#pragma pack(push, 1)
4444
#elif __XC8
45+
#if __XC8_VERSION >= 2000
46+
// This is needed, even though the XC8 manual says its unnecessary
47+
#pragma pack(push, 1)
48+
#endif
4549
#else
4650
#error "Compiler not supported"
4751
#endif

usb/include/usb_ch9.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
#if defined(__XC16__) || defined(__XC32__)
4242
#pragma pack(push, 1)
4343
#elif __XC8
44+
#if __XC8_VERSION >= 2000
45+
// This is needed, even though the XC8 manual says its unnecessary
46+
#pragma pack(push, 1)
47+
#endif
4448
#else
4549
#error "Compiler not supported"
4650
#endif

usb/include/usb_hid.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
#if defined(__XC16__) || defined(__XC32__)
4343
#pragma pack(push, 1)
4444
#elif __XC8
45+
#if __XC8_VERSION >= 2000
46+
// This is needed, even though the XC8 manual says its unnecessary
47+
#pragma pack(push, 1)
48+
#endif
4549
#else
4650
#error "Compiler not supported"
4751
#endif

usb/include/usb_microsoft.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
#if defined(__XC16__) || defined(__XC32__)
4242
#pragma pack(push, 1)
4343
#elif __XC8
44+
#if __XC8_VERSION >= 2000
45+
// This is needed, even though the XC8 manual says its unnecessary
46+
#pragma pack(push, 1)
47+
#endif
4448
#else
4549
#error "Compiler not supported"
4650
#endif

usb/include/usb_msc.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@
4242
#if defined(__XC16__) || defined(__XC32__)
4343
#pragma pack(push, 1)
4444
#elif __XC8
45+
#if __XC8_VERSION >= 2000
46+
// This is needed, even though the XC8 manual says its unnecessary
47+
#pragma pack(push, 1)
48+
#endif
4549
#else
4650
#error "Compiler not supported"
4751
#endif

usb/src/usb_hal.h

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626

2727
#ifndef USB_HAL_H__
28-
#define UAB_HAL_H__
28+
#define USB_HAL_H__
2929

3030
#ifdef _PIC14E
3131
#define NEEDS_PULL /* Whether to pull up D+/D- with SFR_PULL_EN. */
@@ -288,7 +288,14 @@ struct buffer_descriptor {
288288
#if defined(_18F46J50) || defined(_18F87J50)
289289
#define BD_ADDR 0x400
290290
//#undef BUFFER_ADDR
291-
#else
291+
#endif
292+
293+
#ifdef _18F2455
294+
#define BD_ADDR 0x400
295+
#define BUFFER_ADDR 0x500
296+
#endif
297+
298+
#ifndef BD_ADDR
292299
#error "CPU not supported yet"
293300
#endif
294301

@@ -306,11 +313,19 @@ struct buffer_descriptor {
306313
#elif defined __XC8
307314
#define memcpy_from_rom(x,y,z) memcpy(x,y,z)
308315
#define FAR
309-
#define BD_ATTR_TAG @##BD_ADDR
316+
#if __XC8_VERSION >= 2000
317+
// XC8 discontinued the @addr notation and replaced it with __at()
318+
#define AT_ADDR(X) __at(X)
319+
#else
320+
#define AT_ADDR(X) @X
321+
#endif
322+
323+
#define BD_ATTR_TAG AT_ADDR(BD_ADDR)
324+
310325
#ifdef BUFFER_ADDR
311-
#define XC8_BUFFER_ADDR_TAG @##BUFFER_ADDR
326+
#define XC8_BUFFER_ADDR_TAG AT_ADDR(BUFFER_ADDR)
312327
#else
313-
#define XC8_BUFFER_ADDR_TAG
328+
#define XC8_BUFFER_ADDR_TAG
314329
#endif
315330
#endif
316331

usb/src/usb_hid.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ uint8_t process_hid_setup_request(const struct setup_packet *setup)
9191
if (len < 0)
9292
return -1;
9393

94-
usb_send_data_stage((void*) desc, min(len, setup->wLength), NULL, NULL);
94+
usb_send_data_stage((void*) desc, MIN(len, setup->wLength), NULL, NULL);
9595
return 0;
9696
}
9797

@@ -112,7 +112,7 @@ uint8_t process_hid_setup_request(const struct setup_packet *setup)
112112
if (len < 0)
113113
return -1;
114114

115-
usb_send_data_stage((void*)desc, min(len, setup->wLength), callback, context);
115+
usb_send_data_stage((void*)desc, MIN(len, setup->wLength), callback, context);
116116
return 0;
117117
}
118118
#endif

0 commit comments

Comments
 (0)