Vybhav Kadaba
/
EV-PRO-MW1001_Development_updateFW
Bumped Mbed FW version to 01.20.0080
Diff: src/admw_1001.c
- Revision:
- 64:e8670e971e22
- Parent:
- 63:2655a04c00f5
- Child:
- 65:d91e1d63153d
--- a/src/admw_1001.c Tue Apr 14 06:43:47 2020 +0000 +++ b/src/admw_1001.c Tue Apr 14 07:04:24 2020 +0000 @@ -53,7 +53,6 @@ #include "admw1001/admw1001_lut_data.h" #include "admw1001/admw1001_host_comms.h" #include "inc/mbedVersion.h" -#include "crc16.h" #define VERSIONID_MAJOR 2 #define VERSIONID_MINOR 0 @@ -752,46 +751,19 @@ return ADMW_SUCCESS; } -ADMW_RESULT admw1001_Write_Debug_Register( - ADMW_DEVICE_HANDLE hDevice, - uint16_t nAddress, - void *pData, - unsigned nLength) +ADMW_RESULT admw_GetDeviceReadyState( + ADMW_DEVICE_HANDLE const hDevice, + bool * const bReady) { - ADMW_RESULT eRet; - ADMW_DEVICE_CONTEXT *pCtx = hDevice; - uint16_t command = ADMW1001_HOST_COMMS_DEBUG_WRITE_CMD | - (nAddress & ADMW1001_HOST_COMMS_ADR_MASK); - uint8_t commandData[2] = { - command >> 8, - command & 0xFF - }; - uint8_t commandResponse[2]; + ADMW_SPI_Chip_Type_t chipTypeReg; - do { - eRet = admw_SpiTransfer(pCtx->hSpi, commandData, commandResponse, - sizeof(command), false); - if (eRet) { - ADMW_LOG_ERROR("Failed to send write command for register %u", - nAddress); - return eRet; - } - wait_ms(100); - //admw_TimeDelayUsec(ADMW1001_HOST_COMMS_XFER_DELAY); - } while ((commandResponse[0] != ADMW1001_HOST_COMMS_CMD_RESP_0) || - (commandResponse[1] != ADMW1001_HOST_COMMS_CMD_RESP_1)); - - eRet = admw_SpiTransfer(pCtx->hSpi, pData, NULL, nLength, false); - if (eRet) { - ADMW_LOG_ERROR("Failed to write data (%dB) to register %u", - nLength, nAddress); - return eRet; - } - - admw_TimeDelayUsec(ADMW1001_HOST_COMMS_XFER_DELAY); + READ_REG_U8(hDevice, chipTypeReg.VALUE8, SPI_CHIP_TYPE); + /* If we read this register successfully, assume the device is ready */ + *bReady = (chipTypeReg.VALUE8 == REG_SPI_CHIP_TYPE_RESET); return ADMW_SUCCESS; } + ADMW_RESULT admw1001_ReadRegister( ADMW_DEVICE_HANDLE hDevice, uint16_t nAddress, @@ -833,59 +805,6 @@ return ADMW_SUCCESS; } -ADMW_RESULT admw1001_Read_Debug_Register( - ADMW_DEVICE_HANDLE hDevice, - uint16_t nAddress, - void *pData, - unsigned nLength) -{ - ADMW_RESULT eRet; - ADMW_DEVICE_CONTEXT *pCtx = hDevice; - uint16_t command = ADMW1001_HOST_COMMS_DEBUG_READ_CMD | - (nAddress & ADMW1001_HOST_COMMS_ADR_MASK); - uint8_t commandData[2] = { - command >> 8, - command & 0xFF - }; - uint8_t commandResponse[2]; - - do { - eRet = admw_SpiTransfer(pCtx->hSpi, commandData, commandResponse, - sizeof(command), false); - if (eRet) { - ADMW_LOG_ERROR("Failed to send read command for register %u", - nAddress); - return eRet; - } - - admw_TimeDelayUsec(ADMW1001_HOST_COMMS_XFER_DELAY); - } while ((commandResponse[0] != ADMW1001_HOST_COMMS_CMD_RESP_0) || - (commandResponse[1] != ADMW1001_HOST_COMMS_CMD_RESP_1)); - - eRet = admw_SpiTransfer(pCtx->hSpi, NULL, pData, nLength, false); - if (eRet) { - ADMW_LOG_ERROR("Failed to read data (%uB) from register %u", - nLength, nAddress); - return eRet; - } - - admw_TimeDelayUsec(ADMW1001_HOST_COMMS_XFER_DELAY); - - return ADMW_SUCCESS; -} -ADMW_RESULT admw_GetDeviceReadyState( - ADMW_DEVICE_HANDLE const hDevice, - bool * const bReady) -{ - ADMW_SPI_Chip_Type_t chipTypeReg; - - READ_REG_U8(hDevice, chipTypeReg.VALUE8, SPI_CHIP_TYPE); - /* If we read this register successfully, assume the device is ready */ - *bReady = (chipTypeReg.VALUE8 == REG_SPI_CHIP_TYPE_RESET); - - return ADMW_SUCCESS; -} - ADMW_RESULT admw1001_GetDataReadyModeInfo( ADMW_DEVICE_HANDLE const hDevice, ADMW_MEASUREMENT_MODE const eMeasurementMode,