Skip to content

Commit

Permalink
Rename SPI_COUNT/etc to ESPR_SPI_COUNT to avoid conflicts with the nR…
Browse files Browse the repository at this point in the history
…F52 SDK

fix #2466
  • Loading branch information
gfwilliams committed Feb 22, 2024
1 parent e17e61b commit 1a024e2
Show file tree
Hide file tree
Showing 17 changed files with 199 additions and 199 deletions.
12 changes: 6 additions & 6 deletions scripts/build_platform_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,13 @@ def codeOutDevicePins(device, definition_name):
codeOut("");

codeOut("#define CLOCK_SPEED_MHZ "+str(board.chip["speed"]))
codeOut("#define USART_COUNT "+str(board.chip["usart"]))
codeOut("#define ESPR_USART_COUNT "+str(board.chip["usart"]))
if "spi" in board.chip:
codeOut("#define SPI_COUNT "+str(board.chip["spi"]))
codeOut("#define I2C_COUNT "+str(board.chip["i2c"]))
codeOut("#define ADC_COUNT "+str(board.chip["adc"]))
codeOut("#define DAC_COUNT "+str(board.chip["dac"]))
codeOut("#define EXTI_COUNT "+str(exti_count))
codeOut("#define ESPR_SPI_COUNT "+str(board.chip["spi"]))
codeOut("#define ESPR_I2C_COUNT "+str(board.chip["i2c"]))
codeOut("#define ESPR_ADC_COUNT "+str(board.chip["adc"]))
codeOut("#define ESPR_DAC_COUNT "+str(board.chip["dac"]))
codeOut("#define ESPR_EXTI_COUNT "+str(exti_count))
codeOut("");
codeOut("#define DEFAULT_CONSOLE_DEVICE "+board.info["default_console"]);
if "default_console_tx" in board.info:
Expand Down
24 changes: 12 additions & 12 deletions scripts/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,13 @@ def get_jsondata(is_for_document, parseArgs = True, boardObject = False):
print("BOARD "+arg[2:]);
print("Now ignore_ifdefs = False");
ignore_ifdefs = False
board = importlib.import_module(arg[2:])
board = importlib.import_module(arg[2:])
elif arg[1]=="F":
"" # -Fxxx.yy in args is filename xxx.yy, which is mandatory for build_jswrapper.py
else:
print("Unknown command-line option")
exit(1)
elif arg[-2:]==".c":
elif arg[-2:]==".c":
# C file, all good
explicit_files = True
jswraps.append(arg)
Expand All @@ -150,9 +150,9 @@ def get_jsondata(is_for_document, parseArgs = True, boardObject = False):

if board:
board.defines = defines
if "usart" in board.chip: defines.append("USART_COUNT="+str(board.chip["usart"]));
if "spi" in board.chip: defines.append("SPI_COUNT="+str(board.chip["spi"]));
if "i2c" in board.chip: defines.append("I2C_COUNT="+str(board.chip["i2c"]));
if "usart" in board.chip: defines.append("ESPR_USART_COUNT="+str(board.chip["usart"]));
if "spi" in board.chip: defines.append("ESPR_SPI_COUNT="+str(board.chip["spi"]));
if "i2c" in board.chip: defines.append("ESPR_I2C_COUNT="+str(board.chip["i2c"]));
if "USB" in board.devices: defines.append("defined(USB)=True");
else: defines.append("defined(USB)=False");
if "build" in board.info:
Expand All @@ -161,20 +161,20 @@ def get_jsondata(is_for_document, parseArgs = True, boardObject = False):
print("board.defines: " + i);
defines.append(i)
if "makefile" in board.info["build"]:
for i in board.info["build"]["makefile"]:
for i in board.info["build"]["makefile"]:
print("board.makefile: " + i);
i = i.strip()
if i.startswith("DEFINES"):
if i.startswith("DEFINES"):
defs = i[7:].strip()[2:].strip().split() # array of -Dsomething
for d in defs:
for d in defs:
if not d.startswith("-D"):
print("WARNING: expecting -Ddefine, got " + d)
defines.append(d[2:])

if len(defines)>1:
print("Got #DEFINES:")
for d in defines: print(" "+d)

githash = get_git_hash()
if len(githash)==0: githash="master"

Expand Down Expand Up @@ -262,13 +262,13 @@ def get_jsondata(is_for_document, parseArgs = True, boardObject = False):
if not key in ["type","class","name","patch"]:
print("Copying "+key+" --- "+jsondata[key])
targetjsondata[key] = jsondata[key]
drop = True
drop = True
if not drop:
jsondatas.append(jsondata)
except ValueError as e:
sys.stderr.write( "JSON PARSE FAILED for " + jsonstring + " - "+ str(e) + "\n")
exc_obj = sys.exc_info()
print(''.join(traceback.format_exception(exc_obj)))
print(''.join(traceback.format_exception(exc_obj)))
exit(1)
except Exception as e:
sys.stderr.write( "JSON PARSE FAILED for " + jsonstring + " - "+str(e) + "\n" )
Expand Down Expand Up @@ -307,7 +307,7 @@ def get_jsondata(is_for_document, parseArgs = True, boardObject = False):
"include" : "platform_config.h"
})

jsondatas = sorted(jsondatas, key=lambda j: j["sortorder"] if "sortorder" in j else 0)
jsondatas = sorted(jsondatas, key=lambda j: j["sortorder"] if "sortorder" in j else 0)

return jsondatas

Expand Down
44 changes: 22 additions & 22 deletions src/jsdevices.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void jshResetDevices() {
unsigned int i;
// Reset list of pins that were set manually
jshResetPinStateIsManual();

// setup flow control
for (i=0;i<JSHSERIALDEVICESTATUSES;i++) {
#ifdef USB
Expand Down Expand Up @@ -334,13 +334,13 @@ void jshTransmitFlushDevice(IOEventFlags device) {
jsiSetBusy(BUSY_TRANSMIT, true);
bool deviceHasData = false;
do {
deviceHasData = false;
deviceHasData = false;
// Check TX queue to see if there is any data to send
unsigned char tempTail = txTail;
while (txHead != tempTail) {
if (IOEVENTFLAGS_GETTYPE(txBuffer[tempTail].flags) == device) {
deviceHasData = true;
break;
break;
}
tempTail = (unsigned char)((tempTail+1)&TXBUFFERMASK);
}
Expand Down Expand Up @@ -617,40 +617,40 @@ const char *jshGetDeviceString(
#ifdef USE_TERMINAL
case EV_TERMINAL: return "Terminal";
#endif
#if USART_COUNT>=1
#if ESPR_USART_COUNT>=1
case EV_SERIAL1: return "Serial1";
#endif
#if USART_COUNT>=2
#if ESPR_USART_COUNT>=2
case EV_SERIAL2: return "Serial2";
#endif
#if USART_COUNT>=3
#if ESPR_USART_COUNT>=3
case EV_SERIAL3: return "Serial3";
#endif
#if USART_COUNT>=4
#if ESPR_USART_COUNT>=4
case EV_SERIAL4: return "Serial4";
#endif
#if USART_COUNT>=5
#if ESPR_USART_COUNT>=5
case EV_SERIAL5: return "Serial5";
#endif
#if USART_COUNT>=6
#if ESPR_USART_COUNT>=6
case EV_SERIAL6: return "Serial6";
#endif
#if SPI_COUNT>=1
#if ESPR_SPI_COUNT>=1
case EV_SPI1: return "SPI1";
#endif
#if SPI_COUNT>=2
#if ESPR_SPI_COUNT>=2
case EV_SPI2: return "SPI2";
#endif
#if SPI_COUNT>=3
#if ESPR_SPI_COUNT>=3
case EV_SPI3: return "SPI3";
#endif
#if I2C_COUNT>=1
#if ESPR_I2C_COUNT>=1
case EV_I2C1: return "I2C1";
#endif
#if I2C_COUNT>=2
#if ESPR_I2C_COUNT>=2
case EV_I2C2: return "I2C2";
#endif
#if I2C_COUNT>=3
#if ESPR_I2C_COUNT>=3
case EV_I2C3: return "I2C3";
#endif
default: return "";
Expand Down Expand Up @@ -687,22 +687,22 @@ IOEventFlags jshFromDeviceString(
#endif
}
else if (device[0]=='S') {
#if USART_COUNT>0
#if ESPR_USART_COUNT>0
if (device[1]=='e' && device[2]=='r' && device[3]=='i' && device[4]=='a' && device[5]=='l' &&
device[6]>='1' && (device[6]-'1')<USART_COUNT &&
device[6]>='1' && (device[6]-'1')<ESPR_USART_COUNT &&
device[7]==0)
return EV_SERIAL1+device[6]-'1';
#endif
#if SPI_COUNT>0
#if ESPR_SPI_COUNT>0
if (device[1]=='P' && device[2]=='I' &&
device[3]>='1' && (device[3]-'1')<SPI_COUNT &&
device[3]>='1' && (device[3]-'1')<ESPR_SPI_COUNT &&
device[4]==0)
return EV_SPI1+device[3]-'1';
#endif
}
#if I2C_COUNT>0
#if ESPR_I2C_COUNT>0
else if (device[0]=='I' && device[1]=='2' && device[2]=='C' &&
device[3]>='1' && (device[3]-'1')<I2C_COUNT &&
device[3]>='1' && (device[3]-'1')<ESPR_I2C_COUNT &&
device[4]==0)
return EV_I2C1+device[3]-'1';
#endif
Expand Down Expand Up @@ -764,7 +764,7 @@ void jshSetFlowControlEnabled(IOEventFlags device, bool software, Pin pinCTS) {
(*deviceState) |= SDS_FLOW_CONTROL_XON_XOFF;
else
(*deviceState) &= ~SDS_FLOW_CONTROL_XON_XOFF;

jshSerialDeviceCTSPins[devIdx] = PIN_UNDEFINED;
if (jshIsPinValid(pinCTS)) {
jshPinSetState(pinCTS, JSHPINSTATE_GPIO_OUT);
Expand Down
48 changes: 24 additions & 24 deletions src/jsdevices.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ typedef enum {
// device type
EV_NONE,
EV_EXTI0, ///< External Interrupt
EV_EXTI_MAX = EV_EXTI0 + EXTI_COUNT - 1,
EV_EXTI_MAX = EV_EXTI0 + ESPR_EXTI_COUNT - 1,
EV_SERIAL_START,
EV_LOOPBACKA = EV_SERIAL_START,
EV_LOOPBACKB,
Expand All @@ -55,28 +55,28 @@ typedef enum {
#ifdef BLUETOOTH
EV_BLUETOOTH, ///< Bluetooth LE
#endif
#if USART_COUNT>=1
#if ESPR_USART_COUNT>=1
EV_SERIAL1, // Used for IO for UARTS
#endif
#if USART_COUNT>=2
#if ESPR_USART_COUNT>=2
EV_SERIAL2,
#endif
#if USART_COUNT>=3
#if ESPR_USART_COUNT>=3
EV_SERIAL3,
#endif
#if USART_COUNT>=4
#if ESPR_USART_COUNT>=4
EV_SERIAL4,
#endif
#if USART_COUNT>=5
#if ESPR_USART_COUNT>=5
EV_SERIAL5,
#endif
#if USART_COUNT>=6
#if ESPR_USART_COUNT>=6
EV_SERIAL6,
#endif
#if USART_COUNT>=1
EV_SERIAL_MAX = EV_SERIAL1 + USART_COUNT - 1,
#if ESPR_USART_COUNT>=1
EV_SERIAL_MAX = EV_SERIAL1 + ESPR_USART_COUNT - 1,
EV_SERIAL1_STATUS, // Used to store serial status info
EV_SERIAL_STATUS_MAX = EV_SERIAL1_STATUS + USART_COUNT - 1,
EV_SERIAL_STATUS_MAX = EV_SERIAL1_STATUS + ESPR_USART_COUNT - 1,
#else
_EV_SERIAL_MAX_PLUS_ONE,
EV_SERIAL_MAX = _EV_SERIAL_MAX_PLUS_ONE-1,
Expand All @@ -88,29 +88,29 @@ typedef enum {
#ifdef BANGLEJS
EV_BANGLEJS, // sent whenever Bangle.js-specific data needs to be queued
#endif
#if SPI_COUNT>=1
#if ESPR_SPI_COUNT>=1
EV_SPI1, ///< SPI Devices
#endif
#if SPI_COUNT>=2
#if ESPR_SPI_COUNT>=2
EV_SPI2,
#endif
#if SPI_COUNT>=3
#if ESPR_SPI_COUNT>=3
EV_SPI3,
#endif
#if SPI_COUNT>=1
EV_SPI_MAX = EV_SPI1 + SPI_COUNT - 1,
#if ESPR_SPI_COUNT>=1
EV_SPI_MAX = EV_SPI1 + ESPR_SPI_COUNT - 1,
#endif
#if I2C_COUNT>=1
#if ESPR_I2C_COUNT>=1
EV_I2C1, ///< I2C Devices
#endif
#if I2C_COUNT>=2
#if ESPR_I2C_COUNT>=2
EV_I2C2,
#endif
#if I2C_COUNT>=3
#if ESPR_I2C_COUNT>=3
EV_I2C3,
#endif
#if I2C_COUNT>=1
EV_I2C_MAX = EV_I2C1 + I2C_COUNT - 1,
#if ESPR_I2C_COUNT>=1
EV_I2C_MAX = EV_I2C1 + ESPR_I2C_COUNT - 1,
#endif
EV_DEVICE_MAX,
// EV_DEVICE_MAX should not be >64 - see DEVICE_INITIALISED_FLAGS
Expand All @@ -137,7 +137,7 @@ typedef enum {
/// If DEVICE_HAS_DEVICE_STATE, this is the index where device state is stored
#define TO_SERIAL_DEVICE_STATE(X) ((X)-EV_SERIAL_DEVICE_STATE_START)

#if USART_COUNT>=1
#if ESPR_USART_COUNT>=1
/// Return true if the device is a USART (hardware serial)
#define DEVICE_IS_USART(X) (((X)>=EV_SERIAL1) && ((X)<=EV_SERIAL_MAX))
#define DEVICE_IS_USART_STATUS(X) (((X)>=EV_SERIAL1_STATUS) && ((X)<=EV_SERIAL_STATUS_MAX))
Expand All @@ -147,19 +147,19 @@ typedef enum {
#endif

// Return true if the device is an SPI.
#if SPI_COUNT>=1
#if ESPR_SPI_COUNT>=1
#define DEVICE_IS_SPI(X) (((X)>=EV_SPI1) && ((X)<=EV_SPI_MAX))
#else
#define DEVICE_IS_SPI(X) (false)
#endif
#if I2C_COUNT>=1
#if ESPR_I2C_COUNT>=1
#define DEVICE_IS_I2C(X) (((X)>=EV_I2C1) && ((X)<=EV_I2C_MAX))
#else
#define DEVICE_IS_I2C(X) (false)
#endif
#define DEVICE_IS_EXTI(X) (((X)>=EV_EXTI0) && ((X)<=EV_EXTI_MAX))

#if USART_COUNT>=1
#if ESPR_USART_COUNT>=1
#define IOEVENTFLAGS_SERIAL_TO_SERIAL_STATUS(X) ((X) + EV_SERIAL1_STATUS - EV_SERIAL1)
#define IOEVENTFLAGS_SERIAL_STATUS_TO_SERIAL(X) ((X) + EV_SERIAL1 - EV_SERIAL1_STATUS)
#endif
Expand Down
8 changes: 4 additions & 4 deletions src/jsinteractive.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,11 +656,11 @@ void jsiDumpHardwareInitialisation(vcbprintf_callback user_callback, void *user_
jsiDumpSerialInitialisation(user_callback, user_data, "USB", humanReadableDump);
#endif
int i;
for (i=0;i<USART_COUNT;i++)
for (i=0;i<ESPR_USART_COUNT;i++)
jsiDumpSerialInitialisation(user_callback, user_data, jshGetDeviceString(EV_SERIAL1+i), humanReadableDump);
for (i=0;i<SPI_COUNT;i++)
for (i=0;i<ESPR_SPI_COUNT;i++)
jsiDumpDeviceInitialisation(user_callback, user_data, jshGetDeviceString(EV_SPI1+i));
for (i=0;i<I2C_COUNT;i++)
for (i=0;i<ESPR_I2C_COUNT;i++)
jsiDumpDeviceInitialisation(user_callback, user_data, jshGetDeviceString(EV_I2C1+i));
// pins
Pin pin;
Expand Down Expand Up @@ -1935,7 +1935,7 @@ void jsiIdle() {
maxEvents -= jsiHandleIOEventForSerial(usartClass, &event);
}
jsvUnLock(usartClass);
#if USART_COUNT>0
#if ESPR_USART_COUNT>0
} else if (DEVICE_IS_USART_STATUS(eventType)) {
// ------------------------------------------------------------------------ SERIAL STATUS CALLBACK
JsVar *usartClass = jsvSkipNameAndUnLock(jsiGetClassNameFromDevice(IOEVENTFLAGS_GETTYPE(IOEVENTFLAGS_SERIAL_STATUS_TO_SERIAL(event.flags))));
Expand Down
12 changes: 6 additions & 6 deletions src/jspin.c
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,15 @@ void jshPinOutput(

// Convert an event type flag into a jshPinFunction for an actual hardware device
JshPinFunction jshGetPinFunctionFromDevice(IOEventFlags device) {
#if USART_COUNT>0
#if ESPR_USART_COUNT>0
if (DEVICE_IS_USART(device))
return JSH_USART1 + ((device - EV_SERIAL1)<<JSH_SHIFT_TYPE);
#endif
#if SPI_COUNT>0
#if ESPR_SPI_COUNT>0
if (DEVICE_IS_SPI(device))
return JSH_SPI1 + ((device - EV_SPI1)<<JSH_SHIFT_TYPE);
#endif
#if I2C_COUNT>0
#if ESPR_I2C_COUNT>0
if (DEVICE_IS_I2C(device))
return JSH_I2C1 + ((device - EV_I2C1)<<JSH_SHIFT_TYPE);
#endif
Expand All @@ -290,15 +290,15 @@ JshPinFunction jshGetPinFunctionFromDevice(IOEventFlags device) {

// Convert a jshPinFunction to an event type flag
IOEventFlags jshGetFromDevicePinFunction(JshPinFunction func) {
#if USART_COUNT>0
#if ESPR_USART_COUNT>0
if (JSH_PINFUNCTION_IS_USART(func))
return EV_SERIAL1 + ((func - JSH_USART1) >> JSH_SHIFT_TYPE);
#endif
#if SPI_COUNT>0
#if ESPR_SPI_COUNT>0
if (JSH_PINFUNCTION_IS_SPI(func))
return EV_SPI1 + ((func - JSH_SPI1) >> JSH_SHIFT_TYPE);
#endif
#if I2C_COUNT>0
#if ESPR_I2C_COUNT>0
if (JSH_PINFUNCTION_IS_I2C(func))
return EV_I2C1 + ((func - JSH_I2C1) >> JSH_SHIFT_TYPE);
#endif
Expand Down
Loading

0 comments on commit 1a024e2

Please sign in to comment.