summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/pic16bit/Makefile4
-rw-r--r--ports/pic16bit/mpconfigport.h4
-rw-r--r--py/misc.h13
3 files changed, 15 insertions, 6 deletions
diff --git a/ports/pic16bit/Makefile b/ports/pic16bit/Makefile
index 6d061514f..dda48fa3c 100644
--- a/ports/pic16bit/Makefile
+++ b/ports/pic16bit/Makefile
@@ -7,7 +7,7 @@ QSTR_DEFS = qstrdefsport.h
include $(TOP)/py/py.mk
include $(TOP)/extmod/extmod.mk
-XCVERSION ?= 1.35
+XCVERSION ?= 2.10
XC16 ?= /opt/microchip/xc16/v$(XCVERSION)
CROSS_COMPILE ?= $(XC16)/bin/xc16-
@@ -31,7 +31,7 @@ CFLAGS += -O1 -DNDEBUG
endif
LDFLAGS += --heap=0 -nostdlib -T $(XC16)/support/$(PARTFAMILY)/gld/p$(PART).gld -Map=$@.map --cref -p$(PART)
-LIBS += -L$(XC16)/lib -L$(XC16)/lib/$(PARTFAMILY) -lc -lm -lpic30
+LIBS += -L$(XC16)/lib -L$(XC16)/lib/$(PARTFAMILY) -lc99-elf -lm-elf -lc99-pic30-elf
SRC_C = \
main.c \
diff --git a/ports/pic16bit/mpconfigport.h b/ports/pic16bit/mpconfigport.h
index a2d607fb2..d80f7edb9 100644
--- a/ports/pic16bit/mpconfigport.h
+++ b/ports/pic16bit/mpconfigport.h
@@ -93,7 +93,3 @@ typedef int mp_off_t;
#define MICROPY_MPHALPORT_H "pic16bit_mphal.h"
#define MICROPY_HW_BOARD_NAME "dsPICSK"
#define MICROPY_HW_MCU_NAME "dsPIC33"
-
-// XC16 toolchain doesn't seem to define these
-typedef int intptr_t;
-typedef unsigned int uintptr_t;
diff --git a/py/misc.h b/py/misc.h
index 96b13c151..8ac80bb7b 100644
--- a/py/misc.h
+++ b/py/misc.h
@@ -380,6 +380,18 @@ static inline bool mp_check(bool value) {
// mp_int_t can be larger than long, i.e. Windows 64-bit, nan-box variants
static inline uint32_t mp_clz_mpi(mp_int_t x) {
+ #ifdef __XC16__
+ mp_uint_t mask = MP_OBJ_WORD_MSBIT_HIGH;
+ mp_uint_t zeroes = 0;
+ while (mask != 0) {
+ if (mask & (mp_uint_t)x) {
+ break;
+ }
+ zeroes++;
+ mask >>= 1;
+ }
+ return zeroes;
+ #else
MP_STATIC_ASSERT(sizeof(mp_int_t) == sizeof(long long)
|| sizeof(mp_int_t) == sizeof(long));
@@ -389,6 +401,7 @@ static inline uint32_t mp_clz_mpi(mp_int_t x) {
} else {
return mp_clzll((unsigned long long)x);
}
+ #endif
}
#endif // MICROPY_INCLUDED_PY_MISC_H