Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 13:97cb32670539, committed 2019-07-25
- Comitter:
- Vkadaba
- Date:
- Thu Jul 25 06:38:45 2019 +0000
- Parent:
- 12:8f21099b8028
- Child:
- 14:266ab283b086
- Commit message:
- admw1001.c file is updated ; ; config version changed to 2.0 from 1.7
Changed in this revision
--- a/i2c0_sensirionSHT3X_config.c Wed Jul 24 08:51:31 2019 +0000
+++ b/i2c0_sensirionSHT3X_config.c Thu Jul 25 06:38:45 2019 +0000
@@ -43,7 +43,7 @@
#include "admw_config_types.h"
ADMW_CONFIG i2c0_sensirionSHT3X_config = {
- .versionId = { .major = 1, .minor = 4 },
+ .versionId = { .major = 2, .minor = 0 },
.productId = ADMW_PRODUCT_ID_ADMW1001,
.admw1001 = {
.power = {
--- a/inc/admw_api.h Wed Jul 24 08:51:31 2019 +0000
+++ b/inc/admw_api.h Thu Jul 25 06:38:45 2019 +0000
@@ -65,7 +65,13 @@
#define ADMW_MAX_CHANNELS 16
/*! A handle used in all API functions to identify the ADMW device. */
+
typedef void* ADMW_DEVICE_HANDLE;
+#define SPI_BUFFER_SIZE 100u
+
+#define SFL_READ_STATUS_HDR_SIZE 14u
+
+#define SFL_READ_STATUS_RESPONSE_SIZE 42u
/*! Supported connection types for communication with the ADMW device. */
typedef enum {
--- a/inc/admw_spi.h Wed Jul 24 08:51:31 2019 +0000
+++ b/inc/admw_spi.h Thu Jul 25 06:38:45 2019 +0000
@@ -102,6 +102,12 @@
unsigned nLength,
bool bCsHold);
+ADMW_RESULT admw_SpiReceive(
+ ADMW_SPI_HANDLE hDevice,
+ void *pTxData,
+ void *pRxData,
+ unsigned nLength,
+ bool bCsHold);
#ifdef __cplusplus
}
#endif
--- a/multichannel_continuous_config.c Wed Jul 24 08:51:31 2019 +0000
+++ b/multichannel_continuous_config.c Thu Jul 25 06:38:45 2019 +0000
@@ -42,7 +42,7 @@
#include "admw_config_types.h"
ADMW_CONFIG multichannel_continuous_config = {
- .versionId = { .major = 1, .minor = 4 },
+ .versionId = { .major = 2, .minor = 0 },
.productId = ADMW_PRODUCT_ID_ADMW1001,
.admw1001 = {
.power = {
--- a/multichannel_singlecycle_config.c Wed Jul 24 08:51:31 2019 +0000
+++ b/multichannel_singlecycle_config.c Thu Jul 25 06:38:45 2019 +0000
@@ -42,7 +42,7 @@
#include "admw_config_types.h"
ADMW_CONFIG multichannel_singlecycle_config = {
- .versionId = { .major = 1, .minor = 4 },
+ .versionId = { .major = 2, .minor = 0 },
.productId = ADMW_PRODUCT_ID_ADMW1001,
.admw1001 = {
.power = {
--- a/sensor0_typeK_cjc0_config.c Wed Jul 24 08:51:31 2019 +0000
+++ b/sensor0_typeK_cjc0_config.c Thu Jul 25 06:38:45 2019 +0000
@@ -43,7 +43,7 @@
#include "admw_config_types.h"
ADMW_CONFIG sensor0_typeK_cjc0_config = {
- .versionId = { .major = 1, .minor = 4 },
+ .versionId = { .major = 2, .minor = 0 },
.productId = ADMW_PRODUCT_ID_ADMW1001,
.admw1001 = {
.power = {
--- a/sensor1_rtd-3w-pt100_config.c Wed Jul 24 08:51:31 2019 +0000
+++ b/sensor1_rtd-3w-pt100_config.c Thu Jul 25 06:38:45 2019 +0000
@@ -43,7 +43,7 @@
#include "admw_config_types.h"
ADMW_CONFIG sensor1_rtd_3w_pt100_config = {
- .versionId = { .major = 1, .minor = 4 },
+ .versionId = { .major = 2, .minor = 0 },
.productId = ADMW_PRODUCT_ID_ADMW1001,
.admw1001 = {
.power = {
--- a/sensor2_bridge_4w_load_cell_config.c Wed Jul 24 08:51:31 2019 +0000
+++ b/sensor2_bridge_4w_load_cell_config.c Thu Jul 25 06:38:45 2019 +0000
@@ -43,7 +43,7 @@
#include "inc/admw_config_types.h"
ADMW_CONFIG default_config= {
- .versionId = { .major = 1, .minor = 7 },
+ .versionId = { .major = 2, .minor = 0 },
.productId = ADMW_PRODUCT_ID_ADMW1001,
.admw1001 = {
.power = {
--- a/sensor2_typeT_cjc0_config.c Wed Jul 24 08:51:31 2019 +0000
+++ b/sensor2_typeT_cjc0_config.c Thu Jul 25 06:38:45 2019 +0000
@@ -42,7 +42,7 @@
*/#include "admw_config_types.h"
ADMW_CONFIG sensor2_typeT_cjc0_config = {
- .versionId = { .major = 1, .minor = 4 },
+ .versionId = { .major = 2, .minor = 0 },
.productId = ADMW_PRODUCT_ID_ADMW1001,
.admw1001 = {
.power = {
--- a/sensor3_typeJ_cjc0_config.c Wed Jul 24 08:51:31 2019 +0000
+++ b/sensor3_typeJ_cjc0_config.c Thu Jul 25 06:38:45 2019 +0000
@@ -45,7 +45,7 @@
#include "admw_config_types.h"
ADMW_CONFIG sensor3_typeJ_cjc0_config = {
- .versionId = { .major = 1, .minor = 4 },
+ .versionId = { .major = 2, .minor = 0 },
.productId = ADMW_PRODUCT_ID_ADMW1001,
.admw1001 = {
.power = {
--- a/spi0_adiAdxl362_config.c Wed Jul 24 08:51:31 2019 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,91 +0,0 @@
-/*
-Copyright 2017 (c) Analog Devices, Inc.
-
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
- - Neither the name of Analog Devices, Inc. nor the names of its
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
- - The use of this software may or may not infringe the patent rights
- of one or more patent holders. This license does not release you
- from the requirement that you obtain separate licenses from these
- patent holders to use this software.
- - Use of the software either in source or binary form, must be run
- on or directly connected to an Analog Devices Inc. component.
-
-THIS SOFTWARE IS PROVIDED BY ANALOG DEVICES "AS IS" AND ANY EXPRESS OR
-IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, NON-INFRINGEMENT,
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-IN NO EVENT SHALL ANALOG DEVICES BE LIABLE FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-LIMITED TO, INTELLECTUAL PROPERTY RIGHTS, PROCUREMENT OF SUBSTITUTE GOODS OR
-SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
-OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- *****************************************************************************/
-
-/*!
- ******************************************************************************
- * @file:
- * @brief:
- *-----------------------------------------------------------------------------
- */
- #include "admw_config_types.h"
-
-ADMW_CONFIG spi0_adiAdxl362_config = {
- .versionId = { .major = 1, .minor = 4 },
- .productId = ADMW_PRODUCT_ID_ADMW1001,
- .admw1001 = {
- .power = {
- .powerMode = ADMW1001_POWER_MODE_ACTIVE,
- },
- .measurement = {
- .operatingMode = ADMW1001_OPERATING_MODE_CONTINUOUS,
- .dataReadyMode = ADMW1001_DATAREADY_PER_CYCLE,
- .cycleInterval = 1000000,
- },
- .channels = {
- [ADMW1001_CH_ID_DIG_SPI_0] = {
- /* Accelerometer X-Axis (and common settings for physical channel) */
- .enableChannel = true,
- .disablePublishing = false,
- .compensationChannel = ADMW1001_CH_ID_NONE,
- .measurementsPerCycle = 10,
- .extraSettlingTime = 10000,
- /* Optional threshold limits applied to the processed measurement results */
- .lowThreshold = -6.0,
- .highThreshold = 6.0,
- .spiChannelConfig = {
- .sensor = ADMW1001_SPI_SENSOR_ACCELEROMETER_A,
- },
- },
- [ADMW1001_CH_ID_DIG_SPI_1] = {
- /* Accelerometer Y-Axis (virtual channel) */
- .enableChannel = true,
- /* Optional threshold limits applied to the processed measurement results */
- .lowThreshold = -6.0,
- .highThreshold = 6.0,
- },
- [ADMW1001_CH_ID_DIG_SPI_2] = {
- /* Accelerometer Z-Axis (virtual channel) */
- .enableChannel = true,
- /* Optional adjustment applied to the processed measurement result */
- .offsetAdjustment = -0.2,
- /* Optional threshold limits applied to the processed measurement results */
- .lowThreshold = -1.5,
- .highThreshold = 1.5,
- },
- },
- },
-};
-
--- a/src/admw_1001.c Wed Jul 24 08:51:31 2019 +0000
+++ b/src/admw_1001.c Thu Jul 25 06:38:45 2019 +0000
@@ -54,8 +54,8 @@
#include "admw1001/admw1001_host_comms.h"
#include "crc16.h"
-#define VERSIONID_MAJOR 1
-#define VERSIONID_MINOR 4
+#define VERSIONID_MAJOR 2
+#define VERSIONID_MINOR 0
uint32_t getDataCnt = 0;
@@ -2697,3 +2697,149 @@
return ADMW_SUCCESS;
}
+ADMW_RESULT admw1001_getFirmwareStatus(
+ ADMW_DEVICE_HANDLE const hDevice,
+ bool * const bFirmwareStatus)
+{
+ bool bitCommand;
+ ADMW_RESULT eRet;
+ uint8_t pinreg = 0x1;
+
+ ADMW_DEVICE_CONTEXT *pCtx = hDevice;
+ static uint8_t DataBuffer[SPI_BUFFER_SIZE] = {0};
+ uint16_t nSize;
+
+ //Construct Read Status command
+ DataBuffer[0] = 0x07;
+ DataBuffer[1] = 0x0E; //Packet ID
+
+ DataBuffer[2] = 0x00;
+ DataBuffer[3] = 0x00; //Data words
+
+ DataBuffer[4] = 0x53;
+ DataBuffer[5] = 0x00; //Command ID
+
+ DataBuffer[6] = 0x00;
+ DataBuffer[7] = 0x00;
+ DataBuffer[8] = 0x00;
+ DataBuffer[9] = 0x00; //Address
+
+ DataBuffer[10] = 0x53;
+ DataBuffer[11] = 0x00;
+ DataBuffer[12] = 0x00;
+ DataBuffer[13] = 0x00; //Checksum
+
+ nSize = SFL_READ_STATUS_HDR_SIZE;
+
+ do
+ {
+ // Get the SFL command irq pin to check if SFL is ready to receive commands
+ // Status pin is not checked since SFL is just booted, there should not be any issue with SFL
+ eRet = admw_GetGpioState( hDevice, ADMW_GPIO_PIN_DATAREADY, &bitCommand );
+ if( eRet != ADMW_SUCCESS) {
+ return eRet;
+ }
+
+ // Command IRQ pin should be low and Status IRQ pin should be high for SFL to be in good state and ready to recieve commands
+ // pinreg == '0x00' - Error occured in SFL
+ // pinreg == '0x01' - SFL is ready to recieve commands
+ // pinreg == '0x02' - Error occured in handling any commands in SFL
+ // pinreg == '0x03' - SFL not booted
+
+ pinreg = (bitCommand);
+
+ }while(pinreg != 0x0u);
+
+ eRet = admw_SpiTransfer(pCtx->hSpi, DataBuffer, NULL,
+ nSize, false);
+ if (eRet)
+ {
+ return eRet;
+ }
+
+ //wait for command irq line to go low after sending read status header
+ wait_ms( 100 );
+
+ do
+ {
+ // Get the SFL command irq pin to check if SFL is ready to receive commands
+ // Status pin is not checked since SFL is just booted, there should not be any issue with SFL
+ eRet = admw_GetGpioState( hDevice, ADMW_GPIO_PIN_DATAREADY, &bitCommand );
+ if( eRet != ADMW_SUCCESS) {
+ return eRet;
+ }
+
+ // Command IRQ pin should be low and Status IRQ pin should be high for SFL to be in good state and ready to recieve commands
+ // pinreg == '0x00' - Error occured in SFL
+ // pinreg == '0x01' - SFL is ready to recieve commands
+ // pinreg == '0x02' - Error occured in handling any commands in SFL
+ // pinreg == '0x03' - SFL not booted
+
+ pinreg = (bitCommand);
+
+ }while(pinreg != 0x0u);
+
+ nSize = SFL_READ_STATUS_RESPONSE_SIZE;
+
+ eRet = admw_SpiReceive(pCtx->hSpi, NULL, DataBuffer,
+ nSize, false);
+
+ if (eRet)
+ {
+ return eRet;
+ }
+
+ //Verifying the application version from the response to check if firmware is present or not
+ /*
+ Flash Memory description
+ ______________
+ | Secure | 0x0000 0000
+ | Flashloader |
+ |______________| 0x0000 3BFF
+ | Security |------------------
+ | Page | 0x0000 3C00
+ | |
+ |______________| 0x0000 3FFF
+ | |------------------
+ | App Info | 0x0000 4000
+ | Page |
+ |______________| 0x0000 4800
+ | |------------------
+ | Application |
+ | Image | Application resides only in this region
+ |______________|------------------
+ | Reserved | 0x0003 FFF8
+ | for | Reserved memory region
+ | Signature | 0x0003 FFFF
+ |______________|------------------
+
+ Application version is stored in the App Info Page, the app version is updated in this region everytime the new application firmware is downloaded.
+ Here we verify if Application version is present in the Read Status response
+ If the app version bytes value is 0xFFFFFFFF then there is no firmware else there exist a firmware
+
+ Read Status Response:
+ ____________________________________________________________________________________________________________________________________
+ | | | | | |
+ |uint16_t nFlashLoaderVersion | uint16_t nStatus | uint32_t nApplicationVersion | uint32_t nApplicationHash[8] | uint16_t nChecksum |
+ |_____________________________|__________________|______________________________|______________________________|_____________________|
+
+ */
+
+ if( ((DataBuffer[4] == 0xFF) &&
+ (DataBuffer[5] == 0xFF) &&
+ (DataBuffer[6] == 0xFF) &&
+ (DataBuffer[7] == 0xFF)) ||
+ ((DataBuffer[4] == 0x00) &&
+ (DataBuffer[5] == 0x00) &&
+ (DataBuffer[6] == 0x00) &&
+ (DataBuffer[7] == 0x00)))
+ {
+ *bFirmwareStatus = false;
+ }
+ else
+ {
+ *bFirmwareStatus = true;
+ }
+
+ return eRet;
+}
--- a/src/mbed/admw_spi.cpp Wed Jul 24 08:51:31 2019 +0000
+++ b/src/mbed/admw_spi.cpp Thu Jul 25 06:38:45 2019 +0000
@@ -96,6 +96,45 @@
/*
* Execute a bi-directional data transfer on the SPI interface
*/
+ ADMW_RESULT
+admw_SpiReceive(
+ ADMW_SPI_HANDLE hDevice,
+ void *pTxData,
+ void *pRxData,
+ unsigned nLength,
+ bool bCsHold)
+{
+ SpiContext_t *pCtx = (SpiContext_t*)hDevice;
+
+ pCtx->_spi->format(ADMW_SPI_FRAME_SIZE, 1);
+
+ int rc = 0;
+
+ *(pCtx->_wakeup) = 0;
+
+ wait_us(60);
+
+ *(pCtx->_cs) = 0;
+
+ rc = pCtx->_spi->write((char*)(pTxData), pTxData ? nLength : 0,
+ (char*)(pRxData), pRxData ? nLength : 0);
+
+ if ((rc < 0) || !bCsHold)
+ *(pCtx->_cs) = 1;
+
+ *(pCtx->_wakeup) = 1;
+
+ if (rc < 0)
+ {
+ ADMW_LOG_ERROR("Failed to complete SPI transfer");
+ return ADMW_FAILURE;
+ }
+
+ pCtx->_spi->format(ADMW_SPI_FRAME_SIZE, ADMW_SPI_MODE);
+
+ return ADMW_SUCCESS;
+
+}
ADMW_RESULT
admw_SpiTransfer(
ADMW_SPI_HANDLE hDevice,