Skip to content

Commit c0afff8

Browse files
agattidpgeorge
authored andcommitted
pic16bit: Make it build with recent XC16 versions.
The PIC16 port didn't catch up with the other ports, so it required a bit of work to make it build with the latest version of XC16. Signed-off-by: Alessandro Gatti <a.gatti@frob.it>
1 parent 785c92d commit c0afff8

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

ports/pic16bit/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ QSTR_DEFS = qstrdefsport.h
77
include $(TOP)/py/py.mk
88
include $(TOP)/extmod/extmod.mk
99

10-
XCVERSION ?= 1.35
10+
XCVERSION ?= 2.10
1111
XC16 ?= /opt/microchip/xc16/v$(XCVERSION)
1212
CROSS_COMPILE ?= $(XC16)/bin/xc16-
1313

@@ -31,7 +31,7 @@ CFLAGS += -O1 -DNDEBUG
3131
endif
3232

3333
LDFLAGS += --heap=0 -nostdlib -T $(XC16)/support/$(PARTFAMILY)/gld/p$(PART).gld -Map=$@.map --cref -p$(PART)
34-
LIBS += -L$(XC16)/lib -L$(XC16)/lib/$(PARTFAMILY) -lc -lm -lpic30
34+
LIBS += -L$(XC16)/lib -L$(XC16)/lib/$(PARTFAMILY) -lc99-elf -lm-elf -lc99-pic30-elf
3535

3636
SRC_C = \
3737
main.c \

ports/pic16bit/mpconfigport.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,3 @@ typedef int mp_off_t;
9393
#define MICROPY_MPHALPORT_H "pic16bit_mphal.h"
9494
#define MICROPY_HW_BOARD_NAME "dsPICSK"
9595
#define MICROPY_HW_MCU_NAME "dsPIC33"
96-
97-
// XC16 toolchain doesn't seem to define these
98-
typedef int intptr_t;
99-
typedef unsigned int uintptr_t;

py/misc.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,18 @@ static inline bool mp_check(bool value) {
380380

381381
// mp_int_t can be larger than long, i.e. Windows 64-bit, nan-box variants
382382
static inline uint32_t mp_clz_mpi(mp_int_t x) {
383+
#ifdef __XC16__
384+
mp_uint_t mask = MP_OBJ_WORD_MSBIT_HIGH;
385+
mp_uint_t zeroes = 0;
386+
while (mask != 0) {
387+
if (mask & (mp_uint_t)x) {
388+
break;
389+
}
390+
zeroes++;
391+
mask >>= 1;
392+
}
393+
return zeroes;
394+
#else
383395
MP_STATIC_ASSERT(sizeof(mp_int_t) == sizeof(long long)
384396
|| sizeof(mp_int_t) == sizeof(long));
385397

@@ -389,6 +401,7 @@ static inline uint32_t mp_clz_mpi(mp_int_t x) {
389401
} else {
390402
return mp_clzll((unsigned long long)x);
391403
}
404+
#endif
392405
}
393406

394407
#endif // MICROPY_INCLUDED_PY_MISC_H

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy