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.
Fork of Sean_AdiSense1000_V21 by
Diff: main.cpp
- Revision:
- 35:853be4d80ff3
- Parent:
- 34:029fc3b83f78
- Child:
- 36:4aded4b4f060
--- a/main.cpp Mon Sep 24 11:39:35 2018 +0000
+++ b/main.cpp Thu Sep 27 12:14:22 2018 +0000
@@ -83,6 +83,154 @@
* START_STREAM = 0x24, //'$'
* STOP_STREAM = 0x25, //'%'
*/
+//error log
+/*
+[INFO] Resetting ADI Sense device, please wait...
+[INFO] ADI Sense device ready
+[INFO] Setting device configuration
+[INFO] Assembling LUT data
+[INFO] Setting LUT data
+[INFO] Status Summary:
+[INFO] Active Errors - RESET REQUIRED
+[INFO] Active Errors - ATTENTION REQUIRED
+[INFO] Last Error Code: 306 (0x132)
+[INFO] No diagnostics faults detected
+[INFO] Configuration completed, starting measurement cycles
+*/
+
+extern ADI_SENSE_CONNECTION connectionInfo;
+
+/*
+//normal routine for debugging
+int main()
+{
+ ADI_SENSE_RESULT res;
+ ADI_SENSE_STATUS status;
+ ADI_SENSE_DEVICE_HANDLE hDevice;
+ ADI_SENSE_MEASUREMENT_MODE eMeasurementMode = ADI_SENSE_MEASUREMENT_MODE_NORMAL;
+ bool_t bDeviceReady;
+
+
+ //Open an ADI Sense device instance.
+
+ res = adi_sense_Open(0, &connectionInfo, &hDevice);
+ if (res != ADI_SENSE_SUCCESS)
+ {
+ ADI_SENSE_LOG_ERROR("Failed to open device instance");
+ return res;
+ }
+
+
+ //Reset the given ADI Sense device....
+
+ ADI_SENSE_LOG_INFO("Resetting ADI Sense device, please wait...");
+ res = adi_sense_Reset(hDevice);
+ if (res != ADI_SENSE_SUCCESS)
+ {
+ ADI_SENSE_LOG_ERROR("Failed to reset device");
+ return res;
+ }
+
+ // ...and wait until the device is ready.
+
+ do {
+ wait_ms(100);
+ res = adi_sense_GetDeviceReadyState(hDevice, &bDeviceReady);
+ if (res != ADI_SENSE_SUCCESS)
+ {
+ ADI_SENSE_LOG_ERROR("Failed to get device ready-state");
+ return res;
+ }
+ } while (! bDeviceReady);
+ ADI_SENSE_LOG_INFO("ADI Sense device ready");
+
+
+ // Write configuration settings to the device registers.
+ // Settings are not applied until adi_sense_ApplyConfigUpdates() is called.
+
+ ADI_SENSE_LOG_INFO("Setting device configuration");
+ res = adi_sense_SetConfig(hDevice, pSelectedConfig);
+ if (res != ADI_SENSE_SUCCESS)
+ {
+ ADI_SENSE_LOG_ERROR("Failed to set device configuration");
+ return res;
+ }
+
+ unsigned lutBufferSize = ADI_SENSE_LUT_MAX_SIZE;
+ ADI_SENSE_1000_LUT *pLutBuffer = (ADI_SENSE_1000_LUT *) ::operator new (lutBufferSize);
+ if (pLutBuffer == NULL)
+ {
+ ADI_SENSE_LOG_ERROR("Failed to allocate memory for user-defined LUT data buffer");
+ return ADI_SENSE_NO_MEM;
+ }
+
+ ADI_SENSE_LOG_INFO("Assembling LUT data");
+ res = adi_sense_1000_AssembleLutData(pLutBuffer, lutBufferSize,
+ sample_lut_num_tables,
+ sample_lut_desc_list,
+ sample_lut_data_list);
+ if (res != ADI_SENSE_SUCCESS)
+ {
+ ADI_SENSE_LOG_ERROR("Failed to assemble user-defined LUT data");
+ return res;
+ }
+
+
+ // Write assembled user-defined Look-Up Table data structure to the device
+ // User-defined LUT data is not applied until adi_sense_ApplyConfigUpdates() is called.
+
+ ADI_SENSE_LOG_INFO("Setting LUT data");
+ res = adi_sense_1000_SetLutData(hDevice, pLutBuffer);
+ if (res != ADI_SENSE_SUCCESS)
+ {
+ ADI_SENSE_LOG_ERROR("Failed to set user-defined LUT data");
+ return res;
+ }
+
+ delete pLutBuffer;
+
+
+ res = adi_sense_ApplyConfigUpdates(hDevice);
+ if (res != ADI_SENSE_SUCCESS)
+ {
+ ADI_SENSE_LOG_ERROR("Failed to apply device configuration");
+ return res;
+ }
+
+ //Check device status after updating the configuration
+
+ res = adi_sense_GetStatus(hDevice, &status);
+ if (res != ADI_SENSE_SUCCESS)
+ {
+ ADI_SENSE_LOG_ERROR("Failed to retrieve device status");
+ return res;
+ }
+ if (status.deviceStatus &
+ (ADI_SENSE_DEVICE_STATUS_ERROR | ADI_SENSE_DEVICE_STATUS_ALERT))
+ {
+ utils_printStatus(&status);
+ }
+
+
+ //Kick off the measurement cycle here
+
+ ADI_SENSE_LOG_INFO("Configuration completed, starting measurement cycles");
+ utils_runMeasurement(hDevice, eMeasurementMode);
+
+
+ //Clean up and exit
+
+ res = adi_sense_Close(hDevice);
+ if (res != ADI_SENSE_SUCCESS)
+ {
+ ADI_SENSE_LOG_ERROR("Failed to close device instance");
+ return res;
+ }
+
+ return 0;
+}
+*/
+
int main( void )
{
@@ -128,14 +276,25 @@
// Check adisense has booted correctly
if( adiSense1000Active ) {
Pc_ResetSuccess( bBootLoader );
- ADI_SENSE_LOG_INFO("ADIsense boot successful 19/09/2018");
+ ADI_SENSE_LOG_INFO("ADIsense boot successful 25/09/2018");
ADI_SENSE_LOG_INFO("Firmware Version 2.1");
- ADI_SENSE_LOG_INFO("Available BLE COMMAND");
+ ADI_SENSE_LOG_INFO("\t Available BLE COMMANDS:");
ADI_SENSE_LOG_INFO("REQ_REG_PACKET_COUNT = 0x21, //'!'");
ADI_SENSE_LOG_INFO("REQ_REG_PACKETS = 0x40, //'@'");
ADI_SENSE_LOG_INFO("REQ_FIELD_NAMES = 0x23 0x0, //'#'");
ADI_SENSE_LOG_INFO("START_STREAM = 0x24, //'$'");
ADI_SENSE_LOG_INFO("STOP_STREAM = 0x25, //'percentage symbol'");
+ ADI_SENSE_LOG_INFO(" ");
+ ADI_SENSE_LOG_INFO("\t Available PC COMMANDS:");
+ ADI_SENSE_LOG_INFO("DEVICE_INFO = 'i'");
+ ADI_SENSE_LOG_INFO("FLASH_LED = 'f'");
+ ADI_SENSE_LOG_INFO("RESET = 'r'");
+ ADI_SENSE_LOG_INFO("CONFIGURE = 'c'");
+ ADI_SENSE_LOG_INFO("APPLY = 'u'");
+ ADI_SENSE_LOG_INFO("SAMPLE = 's'");
+ ADI_SENSE_LOG_INFO("START_STREAM = 'd'");
+ ADI_SENSE_LOG_INFO("STOP_STREAM = 'h'");
+ ADI_SENSE_LOG_INFO("UPDATE_FW_VERSION = 'v'");
}
else {
// Cannot continue without adi_sense module
