diff --git a/libs/filesystem/fat_sd/flash_diskio.c b/libs/filesystem/fat_sd/flash_diskio.c index fe3664ae29..d1e619020a 100755 --- a/libs/filesystem/fat_sd/flash_diskio.c +++ b/libs/filesystem/fat_sd/flash_diskio.c @@ -42,7 +42,6 @@ DSTATUS disk_initialize ( { if (drv != 0) return STA_NODISK; - //jsDebug("Flash Disk Init %d",drv); return RES_OK; } @@ -76,7 +75,7 @@ DRESULT disk_read ( uint16_t size = (uint16_t)(count * FS_SECTOR_SIZE); uint32_t addr = sector * FS_SECTOR_SIZE + fs_flash_base; - jsDebug("Flash disk_read sector: %d, buff: mem: %d buff: %d len: %d", sector, addr, buff, size); + jsDebug(DBG_INFO,"Flash disk_read sector: %d, buff: mem: %d buff: %d len: %d", sector, addr, buff, size); jshFlashRead( buff, addr, size); return RES_OK; } @@ -98,7 +97,7 @@ DRESULT disk_write ( uint16_t size = (uint16_t)(count * FS_SECTOR_SIZE); uint32_t addr = sector * FS_SECTOR_SIZE + fs_flash_base; - jsDebug("Flash disk_write sector: %d, buff: mem: %d buff: %d len: %d", sector, addr, buff, size); + jsDebug(DBG_INFO,"Flash disk_write sector: %d, buff: mem: %d buff: %d len: %d", sector, addr, buff, size); jshFlashErasePage(addr); jshFlashWrite( (void *)buff, addr,size); @@ -123,7 +122,7 @@ DRESULT disk_ioctl ( switch (ctrl) { case CTRL_SYNC : /// Make sure that no pending write process res = RES_OK; - jsDebug("Flash disk_ioctl CTRL_SYNC"); + jsDebug(DBG_INFO,"Flash disk_ioctl CTRL_SYNC"); break; case GET_SECTOR_COUNT : // Get number of sectors on the disk (DWORD) diff --git a/libs/filesystem/fat_sd/flash_diskio.h b/libs/filesystem/fat_sd/flash_diskio.h index b5a43bf04f..befe304e0f 100755 --- a/libs/filesystem/fat_sd/flash_diskio.h +++ b/libs/filesystem/fat_sd/flash_diskio.h @@ -31,13 +31,3 @@ #define FS_FLASH_BASE 0x300000; uint8_t flashFatFsInit( uint32_t addr, uint16_t sectors ); - -/* -#ifndef RELEASE -#define jsDebug(fmt,...) jsWarn(fmt,##__VA_ARGS__) -#else -#define jsDebug(fmt,...) -#endif -#endif -*/ -#define jsDebug(fmt,...) diff --git a/libs/filesystem/jswrap_file.c b/libs/filesystem/jswrap_file.c index c1a5771674..33076f3ea7 100755 --- a/libs/filesystem/jswrap_file.c +++ b/libs/filesystem/jswrap_file.c @@ -649,7 +649,7 @@ int jswrap_E_flashFatFS(JsVar* options) { if (init) { if ( format ) { uint8_t res = f_mount(&jsfsFAT, "", 0); - jsDebug("Formatting Flash"); + jsDebug(DBG_INFO,"Formatting Flash"); res = f_mkfs("", 1, 0); // Super Floppy format, using all space (not partition table) if (res != FR_OK) { jsExceptionHere(JSET_INTERNALERROR, "Flash Formatting error:",res); diff --git a/libs/network/esp32/jswrap_esp32_network.c b/libs/network/esp32/jswrap_esp32_network.c index c054f8166f..8ac61186ec 100644 --- a/libs/network/esp32/jswrap_esp32_network.c +++ b/libs/network/esp32/jswrap_esp32_network.c @@ -42,12 +42,6 @@ #define UNUSED(x) (void)(x) -#ifndef RELEASE - #define jsDebug(format, ...) jsWarn(format, ## __VA_ARGS__) -#else - #define jsDebug(format, ...) do { } while(0) -#endif - static void sendWifiCompletionCB( JsVar **g_jsCallback, //!< Pointer to the global callback variable char *reason //!< NULL if successful, error string otherwise @@ -233,7 +227,7 @@ static char *wifiReasonToString(uint8_t reason) { case WIFI_REASON_UNSUPP_RSN_IE_VERSION: return "REASON_UNSUPP_RSN_IE_VERSION"; } - jsDebug( "wifiReasonToString: Unknown reason %d", reason); + jsDebug(DBG_INFO, "wifiReasonToString: Unknown reason %d", reason); return "Unknown reason"; } // End of wifiReasonToString @@ -413,7 +407,7 @@ static JsVar *getWifiModule() { static int s_retry_num = 0; static char *wifiGetEvent(uint32_t event) { - jsDebug( "wifiGetEvent: Got event: %d", event); + jsDebug(DBG_INFO,"wifiGetEvent: Got event: %d", event); switch(event) { case SYSTEM_EVENT_AP_PROBEREQRECVED: return "#onprobe_recv"; @@ -442,7 +436,7 @@ switch(event) { case SYSTEM_EVENT_WIFI_READY: break; } - jsDebug( "Unhandled wifi event type: %d", event); + jsDebug(DBG_INFO, "Unhandled wifi event type: %d", event); return NULL; } // End of wifiGetEvent @@ -488,12 +482,12 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) * * bssid * * reason */ - jsDebug("Wifi: Event(%d):SYSTEM_EVENT_%s\n",event->event_id,wifiEventToString(event->event_id)); + jsDebug(DBG_INFO,"Wifi: Event(%d):SYSTEM_EVENT_%s\n",event->event_id,wifiEventToString(event->event_id)); if (event->event_id == SYSTEM_EVENT_STA_DISCONNECTED) { if (--s_retry_num > 0 ) { esp_wifi_connect(); - jsDebug("retry to AP connect"); + jsDebug(DBG_INFO,"retry to AP connect"); return; } g_isStaConnected = false; // Flag as disconnected @@ -578,7 +572,7 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) jsvObjectSetChildAndUnLock(jsDetails, "netmask", jsvNewFromString(temp)); sprintf(temp, IPSTR, IP2STR(&event->event_info.got_ip.ip_info.gw)); jsvObjectSetChildAndUnLock(jsDetails, "gw", jsvNewFromString(temp)); - jsDebug("Wifi: About to emit connect!"); + jsDebug(DBG_INFO, "Wifi: About to emit connect!"); sendWifiEvent(event->event_id, jsDetails); // start mDNS const char * hostname; @@ -642,7 +636,7 @@ static esp_err_t event_handler(void *ctx, system_event_t *event) sendWifiCompletionCB(&g_jsAPStartedCallback, NULL); return ESP_OK; } - jsDebug("Wifi: event_handler -> NOT HANDLED EVENT: %d", event->event_id ); + jsDebug(DBG_INFO, "Wifi: event_handler -> NOT HANDLED EVENT: %d", event->event_id ); return ESP_OK; } // End of event_handler @@ -658,7 +652,7 @@ void esp32_wifi_init() { ESP_ERROR_CHECK(esp_wifi_init(&cfg)); ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM)); - jsDebug("esp32_wifi_init complete"); + jsDebug(DBG_INFO, "esp32_wifi_init complete"); } // End of esp32_wifi_init @@ -674,7 +668,7 @@ static void sendWifiCompletionCB( JsVar **g_jsCallback, //!< Pointer to the global callback variable char *reason //!< NULL if successful, error string otherwise ) { - jsDebug("sendWifiCompletionCB"); + jsDebug(DBG_INFO, "sendWifiCompletionCB"); // Check that we have a callback function. if (!jsvIsFunction(*g_jsCallback)){ return; // we have not got a function pointer: nothing to do @@ -699,7 +693,7 @@ static void sendWifiCompletionCB( * Perform a soft initialization of ESP32 networking. */ void jswrap_esp32_wifi_soft_init() { - jsDebug("jswrap_esp32_wifi_soft_init()"); + jsDebug(DBG_INFO, "jswrap_esp32_wifi_soft_init()"); JsNetwork net; networkCreate(&net, JSNETWORKTYPE_ESP32); // Set the network type to be ESP32 networkState = NETWORKSTATE_ONLINE; // Set the global state of the networking to be online @@ -724,7 +718,7 @@ void jswrap_wifi_disconnect(JsVar *jsCallback) { g_jsDisconnectCallback = jsvLockAgainSafe(jsCallback); // Call the ESP-IDF to disconnect us from the access point. - jsDebug("Disconnecting....."); + jsDebug(DBG_INFO, "Disconnecting....."); // turn off auto-connect esp_wifi_set_auto_connect(false); s_retry_num = 0; // flag so we don't attempt to reconnect @@ -758,7 +752,7 @@ void jswrap_wifi_stopAP(JsVar *jsCallback) { } err = esp_wifi_set_mode(mode); if (err != ESP_OK) { - jsDebug("jswrap_wifi_stopAP: esp_wifi_set_mode rc=%d(%s)", err,wifiErrorToString(err)); + jsDebug(DBG_INFO, "jswrap_wifi_stopAP: esp_wifi_set_mode rc=%d(%s)", err,wifiErrorToString(err)); } if (jsvIsFunction(jsCallback)) { @@ -772,7 +766,7 @@ void jswrap_wifi_connect( JsVar *jsCallback ) { -jsDebug("jswrap_wifi_connect: entry"); +jsDebug(DBG_INFO, "jswrap_wifi_connect: entry"); // Check that the ssid value isn't obviously in error. if (!jsvIsString(jsSsid)) { @@ -821,7 +815,7 @@ jsDebug("jswrap_wifi_connect: entry"); } jsvUnLock(jsPassword); } // End of we had options - jsDebug("jswrap_wifi_connect: SSID, password, Callback done"); + jsDebug(DBG_INFO, "jswrap_wifi_connect: SSID, password, Callback done"); // At this point, we have the ssid in "ssid" and the password in "password". // Perform an esp_wifi_set_mode @@ -851,7 +845,7 @@ jsDebug("jswrap_wifi_connect: entry"); jsError( "jswrap_wifi_connect: esp_wifi_set_mode: %d(%s), mode=%d", err,wifiErrorToString(err), mode); return; } - jsDebug("jswrap_wifi_connect: esi_wifi_set_mode done"); + jsDebug(DBG_INFO, "jswrap_wifi_connect: esi_wifi_set_mode done"); // Perform a an esp_wifi_set_config wifi_config_t staConfig; @@ -861,17 +855,17 @@ jsDebug("jswrap_wifi_connect: entry"); memcpy(staConfig.sta.password, password, sizeof(staConfig.sta.password)); staConfig.sta.bssid_set = false; esp_wifi_set_auto_connect(true); - jsDebug("jswrap_wifi_connect: esp_wifi_set_autoconnect done"); + jsDebug(DBG_INFO, "jswrap_wifi_connect: esp_wifi_set_autoconnect done"); err = esp_wifi_set_config(ESP_IF_WIFI_STA, &staConfig); if (err != ESP_OK) { jsError( "jswrap_wifi_connect: esp_wifi_set_config: %d(%s)", err,wifiErrorToString(err)); return; } - jsDebug("jswrap_wifi_connect: esp_wifi_set_config done"); + jsDebug(DBG_INFO, "jswrap_wifi_connect: esp_wifi_set_config done"); // Perform an esp_wifi_start - jsDebug("jswrap_wifi_connect: esp_wifi_start %s",ssid); + jsDebug(DBG_INFO, "jswrap_wifi_connect: esp_wifi_start %s",ssid); err = esp_wifi_start(); if (err != ESP_OK) { jsError( "jswrap_wifi_connect: esp_wifi_start: %d(%s)", err,wifiErrorToString(err)); @@ -1307,7 +1301,7 @@ JsVar *jswrap_wifi_getAPDetails(JsVar *jsCallback) { } // End of jswrap_wifi_getAPDetails void jswrap_wifi_save(JsVar *what) { - jsDebug("Wifi.save"); + jsDebug(DBG_INFO, "Wifi.save"); JsVar *o = jsvNewObject(); if (!o) return; @@ -1315,7 +1309,7 @@ void jswrap_wifi_save(JsVar *what) { JsVar *name = jsvNewFromString(WIFI_CONFIG_STORAGE_NAME); jswrap_storage_erase(name); jsvUnLock(name); - jsDebug("Wifi.save(clear)"); + jsDebug(DBG_INFO, "Wifi.save(clear)"); return; } @@ -1353,16 +1347,16 @@ void jswrap_wifi_save(JsVar *what) { jswrap_storage_write(name,o,0,0); jsvUnLock2(name,o); - jsDebug("Wifi.save: write completed"); + jsDebug(DBG_INFO, "Wifi.save: write completed"); } void jswrap_wifi_restore(void) { - jsDebug("jswrap_wifi_restore"); + jsDebug(DBG_INFO, "jswrap_wifi_restore"); JsVar *name = jsvNewFromString(WIFI_CONFIG_STORAGE_NAME); JsVar *o = jswrap_storage_readJSON(name, true); if (!o) { // no data - jsDebug("jswrap_wifi_restore: No data - Starting default AP"); + jsDebug(DBG_INFO, "jswrap_wifi_restore: No data - Starting default AP"); esp_wifi_start(); jsvUnLock2(name,o); return; @@ -1458,7 +1452,7 @@ void jswrap_wifi_restore(void) { return; } } else { - jsDebug( "Wifi: Both STA AND APSTA are off"); + jsDebug(DBG_INFO, "Wifi: Both STA AND APSTA are off"); } } // End of jswrap_wifi_restore @@ -1533,7 +1527,7 @@ void jswrap_wifi_setHostname( ) { char hostname[256]; jsvGetString(jsHostname, hostname, sizeof(hostname)); - jsDebug("Wifi.setHostname: %s\n", hostname); + jsDebug(DBG_INFO, "Wifi.setHostname: %s\n", hostname); tcpip_adapter_set_hostname(TCPIP_ADAPTER_IF_STA,hostname); // now update mDNS diff --git a/make/family/ESP32.make b/make/family/ESP32.make index 26da7fafd5..b4600e13b5 100755 --- a/make/family/ESP32.make +++ b/make/family/ESP32.make @@ -148,3 +148,4 @@ LDFLAGS+= -L$(ESP_APP_TEMPLATE_PATH)/build/components/bt/bluedroid/api \ -L$(ESP_APP_TEMPLATE_PATH)/build/components/bt/bluedroid/bta endif +FLASH_BAUD ?= 921600 # The flash baud rate diff --git a/make/targets/ESP32.make b/make/targets/ESP32.make index ce6399a351..46ac9f21b8 100644 --- a/make/targets/ESP32.make +++ b/make/targets/ESP32.make @@ -31,7 +31,7 @@ flash: $(PROJ_NAME).bin python $(ESP_IDF_PATH)/components/esptool_py/esptool/esptool.py \ --chip esp32 \ --port ${COMPORT} \ - --baud 921600 \ + --baud $(FLASH_BAUD) \ write_flash \ -z \ --flash_mode "dio" \ @@ -43,6 +43,6 @@ flash: $(PROJ_NAME).bin erase_flash: python $(ESP_IDF_PATH)/components/esptool_py/esptool/esptool.py \ --chip esp32 \ - --port ${COMPORT}\ - --baud 921600 \ + --port ${COMPORT} \ + --baud $(FLASH_BAUD) \ erase_flash diff --git a/src/jsutils.h b/src/jsutils.h index 54569933af..79057b2535 100755 --- a/src/jsutils.h +++ b/src/jsutils.h @@ -400,6 +400,22 @@ typedef enum { void jsAssertFail(const char *file, int line, const char *expr); +#define DBG_INFO 0 +#define DBG_VERBOSE 1 + +/* +#if defined(DEBUG) || __FILE__ == DEBUG_FILE + #define jsDebug(dbg_type, format, ...) jsiConsolePrintf("[" __FILE__ "]:" format, ## __VA_ARGS__) + #else + #define jsDebug(dbg_type, format, ...) do { } while(0) + #endif + */ +#if (defined DEBUG ) || ( defined __FILE__ == DEBUG_FILE) + #define jsDebug(dbg_type, format, ...) jsiConsolePrintf("[" __FILE__ "]:" format, ## __VA_ARGS__) +#else + #define jsDebug(dbg_type, format, ...) do { } while(0) +#endif + #ifndef USE_FLASH_MEMORY // Normal functions thet place format string in ram void jsExceptionHere(JsExceptionType type, const char *fmt, ...); diff --git a/targets/esp32/bluetooth.c b/targets/esp32/bluetooth.c index 4c5a5331cd..16e8a3bf54 100644 --- a/targets/esp32/bluetooth.c +++ b/targets/esp32/bluetooth.c @@ -41,7 +41,10 @@ void jsble_init(){ esp_err_t ret; if(ESP32_Get_NVS_Status(ESP_NETWORK_BLE)){ ret = esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT); - if(ret) {jsWarn("mem release failed:%x\n",ret); return;} + if(ret) { + jsExceptionHere(JSET_ERROR,"mem release failed:%x\n",ret); + return; + } if(initController()) return; if(initBluedroid()) return; @@ -51,7 +54,7 @@ void jsble_init(){ } else{ ret = esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT); - jsWarn("Bluetooth is disabled per ESP32.enableBLE(false)\n"); + jsWarn("Bluetooth is disabled per ESP32.enableBLE(false)\n"); } } /** Completely deinitialise the BLE stack */ @@ -96,7 +99,9 @@ uint32_t jsble_advertising_start(){ void jsble_advertising_stop(){ esp_err_t status; status = bluetooth_gap_startAdvertizing(false); - if(status) jsWarn("error in stop advertising:0X%x\n",status); + if(status){ + jsExceptionHere(JSET_ERROR,"error in stop advertising:0X%x",status); + } } /** Is BLE connected to any device at all? */ bool jsble_has_connection(){ @@ -130,7 +135,9 @@ bool jsble_check_error(uint32_t err_code){ } /// Scanning for advertisign packets uint32_t jsble_set_scanning(bool enabled, bool activeScan){ - if (activeScan) jsWarn("active scan not implemented\n"); + if (activeScan) { + jsWarn("active scan not implemented\n"); + } bluetooth_gap_setScan(enabled); return 0; } diff --git a/targets/esp32/jshardware.c b/targets/esp32/jshardware.c index 1fe985416a..6f178556cc 100644 --- a/targets/esp32/jshardware.c +++ b/targets/esp32/jshardware.c @@ -154,11 +154,6 @@ void jshInit() { if (JSHPINSTATE_I2C != 13 || JSHPINSTATE_GPIO_IN_PULLDOWN != 6 || JSHPINSTATE_MASK != 15) { jsError("JshPinState #defines have changed, please update pinStateToString()"); } - /* - jsWarn( "JSHPINSTATE_I2C %d\n",JSHPINSTATE_I2C ); - jsWarn( "JSHPINSTATE_GPIO_IN_PULLDOWN %d\n",JSHPINSTATE_GPIO_IN_PULLDOWN ); - jsWarn( "JSHPINSTATE_MASK %d\n",JSHPINSTATE_MASK ); - */ gpio_isr_register(gpio_intr_handler,NULL,0,NULL); //changed to automatic assign of interrupt // Initialize something for each of the possible pins. jshPinDefaultPullup(); diff --git a/targets/esp32/jshardwareI2c.c b/targets/esp32/jshardwareI2c.c index 8b69536406..168d3a9d73 100644 --- a/targets/esp32/jshardwareI2c.c +++ b/targets/esp32/jshardwareI2c.c @@ -40,19 +40,19 @@ static esp_err_t checkError( char * caller, esp_err_t ret ) { switch(ret) { case ESP_OK: break; case ESP_ERR_INVALID_ARG: { - jsError( "%s:, Parameter error\n", caller ); + jsExceptionHere(JSET_ERROR, "%s:, Parameter error\n", caller ); break; } case ESP_FAIL: { - jsError( "%s:, slave doesn't ACK the transfer.\n", caller ); + jsExceptionHere(JSET_ERROR, "%s: slave doesn't ACK the transfer", caller); break; } case ESP_ERR_TIMEOUT: { - jsError( "%s:, Operation timeout because the bus is busy.\n", caller ); + jsExceptionHere(JSET_ERROR, "%s:, Operation timeout because the bus is busy", caller ); break; } default: { - jsError( "%s:, unknown error code %d, \n", caller, ret ); + jsExceptionHere(JSET_ERROR, "%s:, unknown error code %d", caller, ret ); break; } } @@ -83,7 +83,7 @@ int getI2cFromDevice( IOEventFlags device ) { void jshI2CSetup(IOEventFlags device, JshI2CInfo *info) { int i2c_master_port = getI2cFromDevice(device); if (i2c_master_port == -1) { - jsError("Only I2C1 and I2C2 supported"); + jsExceptionHere(JSET_ERROR,"Only I2C1 and I2C2 supported"); return; } if(jshIsDeviceInitialised(device)){ @@ -110,13 +110,13 @@ void jshI2CSetup(IOEventFlags device, JshI2CInfo *info) { conf.master.clk_speed = info->bitrate; esp_err_t err=i2c_param_config(i2c_master_port, &conf); if ( err == ESP_ERR_INVALID_ARG ) { - jsError("jshI2CSetup: Invalid arguments"); + jsExceptionHere(JSET_ERROR,"jshI2CSetup: Invalid arguments"); return; } err=i2c_driver_install(i2c_master_port, conf.mode, 0, 0, 0); if ( err == ESP_OK ) { - jsWarn("jshI2CSetup: driver installed, sda: %d scl: %d freq: %d, \n", sda, scl, info->bitrate); - jshSetDeviceInitialised(device, true); + jsDebug(DBG_INFO, "jshI2CSetup: driver installed, sda: %d scl: %d freq: %d, \n", sda, scl, info->bitrate); + jshSetDeviceInitialised(device, true); } else { checkError("jshI2CSetup",err); } @@ -129,7 +129,7 @@ void jshI2CWrite(IOEventFlags device, bool sendStop) { int i2c_master_port = getI2cFromDevice(device); if (i2c_master_port == -1) { - jsError("Only I2C1 and I2C2 supported"); + jsExceptionHere(JSET_ERROR,"Only I2C1 and I2C2 supported"); return; } esp_err_t ret; @@ -153,8 +153,8 @@ void jshI2CRead(IOEventFlags device, } int i2c_master_port = getI2cFromDevice(device); if (i2c_master_port == -1) { - jsError("Only I2C1 and I2C2 supported"); - return; + jsExceptionHere(JSET_ERROR,"Only I2C1 and I2C2 supported"); + return; } esp_err_t ret; i2c_cmd_handle_t cmd = i2c_cmd_link_create(); diff --git a/targets/esp32/jshardwareSpi.c b/targets/esp32/jshardwareSpi.c index 3d0cd1d2ab..48c330884b 100644 --- a/targets/esp32/jshardwareSpi.c +++ b/targets/esp32/jshardwareSpi.c @@ -124,8 +124,8 @@ void jshSPISetup( .flags=flags }; if(SPIChannels[channelPnt].spi){ - SPIChannelReset(channelPnt); - jsWarn("spi was already in use, removed old assignment"); + SPIChannelReset(channelPnt); + jsDebug(DBG_INFO, "spi was already in use, removed old assignment"); } esp_err_t ret=spi_bus_initialize(SPIChannels[channelPnt].HOST, &buscfg, 1); assert(ret==ESP_OK); @@ -150,25 +150,23 @@ int jshSPISend( // Send 8 bits of data taken from "data" over the selected spi and store the returned // data for subsequent retrieval. //spiTransferBits(_spi[which_spi], (uint32_t)data, &g_lastSPIRead, 8); - esp_err_t ret; + esp_err_t ret; spi_transaction_t t; memset(&t, 0, sizeof(t)); //Zero out the transaction t.length=8; //Command is 8 bits t.tx_buffer=&data; //The data is the cmd itself // https://esp-idf.readthedocs.io/en/latest/api/spi_master.html#type-definitions // should this be a switch or always read? - t.flags=SPI_TRANS_USE_RXDATA; + t.flags=SPI_TRANS_USE_RXDATA; ret=spi_device_transmit(SPIChannels[channelPnt].spi, &t); //Transmit - blocks until result - need to change this? - assert(ret == ESP_OK); - SPIChannels[channelPnt].g_lastSPIRead=t.rx_data[0]; - + assert(ret == ESP_OK); + SPIChannels[channelPnt].g_lastSPIRead=t.rx_data[0]; } else { SPIChannels[channelPnt].g_lastSPIRead = (uint32_t)-1; } return (int)retData; } - /** * Send 16 bit data through the given SPI device. */