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
Revision 36:4aded4b4f060, committed 2018-10-25
- Comitter:
- nfathurr
- Date:
- Thu Oct 25 08:59:30 2018 +0000
- Parent:
- 35:853be4d80ff3
- Commit message:
- modified output into one line
Changed in this revision
--- a/common/utils.c Thu Sep 27 12:14:22 2018 +0000 +++ b/common/utils.c Thu Oct 25 08:59:30 2018 +0000 @@ -136,6 +136,35 @@ } } +/* ===ALTERNATE FUNCTION FOR PRINTING RESULT ===*/ +void utils_printSamples_2( + ADI_SENSE_DATA_SAMPLE *pSampleBuffer, + uint32_t nNumSamples, + ADI_SENSE_MEASUREMENT_MODE eMeasurementMode) +{ +// bool fftMode = (eMeasurementMode == ADI_SENSE_MEASUREMENT_MODE_FFT); + + ADI_SENSE_LOG_INFO("#%.5f#%.5f#%.5f#%.5f#%.5f#%.5f#%.5f#%.5f#%.5f", + //temp + pSampleBuffer[0].processedValue, + //lc1 + pSampleBuffer[1].processedValue, + //lc2 + pSampleBuffer[2].processedValue, + //lc3 + pSampleBuffer[3].processedValue, + //lc4 + pSampleBuffer[4].processedValue, + //humidity + pSampleBuffer[5].processedValue, + //AccX + pSampleBuffer[6].processedValue, + //AccY + pSampleBuffer[7].processedValue, + //AccZ + pSampleBuffer[8].processedValue); +} + static void gpioCallbackFn(ADI_SENSE_GPIO_PIN ePinId, void * pArg) { volatile bool_t *pbFlag = (volatile bool_t *)pArg; @@ -315,7 +344,7 @@ * subsequent samples may be missed if not retrieved promptly when * the next DATAREADY assertion occurs. */ - utils_printSamples(pSampleBuffer, nReturned, eMeasurementMode); + utils_printSamples_2(pSampleBuffer, nReturned, eMeasurementMode); nSampleCount += nReturned; }
--- a/inc/pc_interface/pc_interface.h Thu Sep 27 12:14:22 2018 +0000 +++ b/inc/pc_interface/pc_interface.h Thu Oct 25 08:59:30 2018 +0000 @@ -16,8 +16,8 @@ #include "string.h" #include "adi_sense_api.h" #include "adi_sense_1000/adi_sense_1000_api.h" -#include "pc_interface/pc_serial.h" -#include "pc_interface/pc_conversions.h" +#include "pc_serial.h" +#include "pc_conversions.h" #include "myproswift_periph.h" #include "core_cm4.h" #include "myproswift_error_codes.h"
--- a/inc/pc_interface/pc_serial.h Thu Sep 27 12:14:22 2018 +0000 +++ b/inc/pc_interface/pc_serial.h Thu Oct 25 08:59:30 2018 +0000 @@ -3,7 +3,7 @@ #include "mbed.h" #include "stdarg.h" -#include "inc/communications.h" +#include "communications.h" /* Definitions
--- a/main.cpp Thu Sep 27 12:14:22 2018 +0000 +++ b/main.cpp Thu Oct 25 08:59:30 2018 +0000 @@ -100,7 +100,7 @@ extern ADI_SENSE_CONNECTION connectionInfo; -/* + //normal routine for debugging int main() { @@ -212,8 +212,7 @@ } - //Kick off the measurement cycle here - + //Kick off the measurement cycle here ADI_SENSE_LOG_INFO("Configuration completed, starting measurement cycles"); utils_runMeasurement(hDevice, eMeasurementMode); @@ -228,94 +227,4 @@ } return 0; -} -*/ - - -int main( void ) -{ - int ret = 1; - bool bleActive; - - // Indicate device is booting - Led_Boot(); - - // Check if device needs to enter bootloader function, this is set via a PC command - // Flag is stored in RTC registers that persist while vbat is powered - bool_t bBootLoader = Rcc_ReadBackupReg( BOOTLOADER_FLAG_BACKUP_REG ) == 1 ? true : false; - - if( bBootLoader ) { - - // Let user know device is entering bootloader mode - Pc_ResetSuccess( bBootLoader ); - - // Jump to bootloader - Bootloader_Init(); - } - - // Otherwise, boot main program - - // Boot the adisense1000 to a known state - ret = Adisense1000_Boot(); - bool adiSense1000Active = !ret; - -#ifdef BL652 - //boot BLE device - ret = Bl652_Boot(); - if (ret == 0) { - ADI_SENSE_LOG_INFO("BLE Boot success.."); - } else { - ADI_SENSE_LOG_INFO("BLE Boot unsuccessful.."); - } -#endif - - // Set if ble is present or not - // If not, the PC interface can still be initialised - bleActive = !ret; - - // Check adisense has booted correctly - if( adiSense1000Active ) { - Pc_ResetSuccess( bBootLoader ); - ADI_SENSE_LOG_INFO("ADIsense boot successful 25/09/2018"); - ADI_SENSE_LOG_INFO("Firmware Version 2.1"); - 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 - exit( 1 ); - } - - // Set led on to indicate boot has completed - - ADI_SENSE_LOG_INFO("Set LED Idle..."); - Led_Idle(); - - // Begin main program - ADI_SENSE_LOG_INFO("Begin main program..."); - while(1) { - // Read in a command and handle appropriately - ret = MyProSwift_Command( bleActive ); - if( ret != 0 ) { - // Errors should be handled at lower levels, using reponse codes - // to the appropriate active interface - // exit(1); - } - } -} - +} \ No newline at end of file
--- a/smartcushion_adisense_config.c Thu Sep 27 12:14:22 2018 +0000 +++ b/smartcushion_adisense_config.c Thu Oct 25 08:59:30 2018 +0000 @@ -32,7 +32,7 @@ .disablePublishing = false, .compensationChannel = ADI_SENSE_1000_CHANNEL_ID_NONE, .measurementsPerCycle = 1, - .extraSettlingTime = 0.0000, + .extraSettlingTime = 1000, .measurementUnit = ADI_SENSE_1000_MEASUREMENT_UNIT_CELSIUS, .adcChannelConfig = { .sensor = ADI_SENSE_1000_ADC_SENSOR_RTD_2WIRE_PT100_DEF_L1, @@ -42,10 +42,10 @@ .diodeRatio = ADI_SENSE_1000_ADC_EXC_CURRENT_IOUT_DIODE_DEFAULT //.swapOption = ADI_SENSE_1000_ADC_EXC_CURRENT_SWAP_NONE, }, .filter = { - .type = ADI_SENSE_1000_ADC_FILTER_FIR_25SPS, - .fs = 0, - //.type = ADI_SENSE_1000_ADC_FILTER_SINC4, - //.fs = 1920, + //.type = ADI_SENSE_1000_ADC_FILTER_FIR_25SPS, +// .fs = 0, + .type = ADI_SENSE_1000_ADC_FILTER_SINC4, + .fs = 1920, }, .reference = { .type = ADI_SENSE_1000_ADC_REFERENCE_RESISTOR_INTERNAL_1, @@ -60,6 +60,7 @@ .disablePublishing = false, .compensationChannel = ADI_SENSE_1000_CHANNEL_ID_NONE, .measurementsPerCycle = 1, + .offsetAdjustment = -1, .extraSettlingTime = 20000, .adcChannelConfig = { @@ -108,6 +109,7 @@ .disablePublishing = false, .compensationChannel = ADI_SENSE_1000_CHANNEL_ID_NONE, .measurementsPerCycle = 1, + .offsetAdjustment = -0.7, .extraSettlingTime = 20000, .adcChannelConfig = { @@ -168,29 +170,26 @@ .disablePublishing = false, .compensationChannel = ADI_SENSE_1000_CHANNEL_ID_NONE, .measurementsPerCycle = 1, - .extraSettlingTime = 100, - .offsetAdjustment = +0.07, + .extraSettlingTime = 10000, + .offsetAdjustment = 0.07, /* Optional threshold limits applied to the processed measurement results */ .lowThreshold = -2.0, .highThreshold = 2.0, .spiChannelConfig = { - //.sensor = ADI_SENSE_1000_SPI_SENSOR_ACCELEROMETER_A_ADV_L1, - //ADI_SENSE_1000_SPI_SENSOR_ACCELEROMETER_ADI_ADXL362, .sensor = ADI_SENSE_1000_SPI_SENSOR_ACCELEROMETER_A_DEF_L1, - .configurationCommand = { - .command = { 0x0A, 0x2C, 0x83 }, /* +/-8G range 0x03, default 0x83 for +/-2G */ - .commandLength = 3, - }, }, }, [ADI_SENSE_1000_CHANNEL_ID_SPI_1] = { /* Accelerometer Y-Axis (virtual channel) */ .enableChannel = true, - .offsetAdjustment = 0, + .offsetAdjustment = 0, /* Optional threshold limits applied to the processed measurement results */ .lowThreshold = -2.0, .highThreshold = 2.0, + .spiChannelConfig = { + .sensor = ADI_SENSE_1000_SPI_SENSOR_ACCELEROMETER_A_DEF_L1, + }, }, [ADI_SENSE_1000_CHANNEL_ID_SPI_2] = { @@ -201,6 +200,9 @@ /* Optional threshold limits applied to the processed measurement results */ .lowThreshold = -2, .highThreshold = 2, + .spiChannelConfig = { + .sensor = ADI_SENSE_1000_SPI_SENSOR_ACCELEROMETER_A_DEF_L1, + }, },
--- a/src/ble_interface/ble_interface.cpp Thu Sep 27 12:14:22 2018 +0000 +++ b/src/ble_interface/ble_interface.cpp Thu Oct 25 08:59:30 2018 +0000 @@ -142,7 +142,8 @@ channel_info.measurementName = "Load cell"; } - else if( channel.spiChannelConfig.sensor == ADI_SENSE_1000_SPI_SENSOR_ACCELEROMETER_A_ADV_L1 ) { + else if( channel.spiChannelConfig.sensor >= ADI_SENSE_1000_SPI_SENSOR_PRESSURE_A_DEF_L1 && channel.spiChannelConfig.sensor <= ADI_SENSE_1000_SPI_SENSOR_ACCELEROMETER_B_ADV_L2 ) { + //ADI_SENSE_1000_SPI_SENSOR_PRESSURE_A_DEF_L1 channel_info.measurementTypeId = ACCELEROMETER; channel_info.measurementName = "Accelerometer"; } @@ -440,8 +441,10 @@ } delete pLutBuffer; + adi_sense_ApplyConfigUpdates( hDevice ); + ADI_SENSE_LOG_INFO("ApplyConfig update applied"); //get information about the adisense data ready mode adi_sense_1000_GetDataReadyModeInfo(hDevice, @@ -705,6 +708,7 @@ delete pLutBuffer; adi_sense_ApplyConfigUpdates( hDevice ); + ADI_SENSE_LOG_INFO("ApplyConfigUpdates"); //get information about the adisense data ready mode adi_sense_1000_GetDataReadyModeInfo(hDevice, @@ -714,6 +718,7 @@ &nSamplesPerDataready, &nSamplesPerCycle, &nBytesPerSample ); + ADI_SENSE_LOG_INFO("GetDataReadyMode"); //allocate a buffer to store the samples retreived on each DATAREADY pulse pSampleBuffer = new ADI_SENSE_DATA_SAMPLE[nSamplesPerDataready]; if( pSampleBuffer == NULL ) {
--- a/src/myproswift_eval.cpp Thu Sep 27 12:14:22 2018 +0000 +++ b/src/myproswift_eval.cpp Thu Oct 25 08:59:30 2018 +0000 @@ -1,7 +1,5 @@ #include "myproswift_eval.h" - - #include "mbed.h" #include "pc_interface.h" #include "ble_interface.h" @@ -24,6 +22,7 @@ volatile bool bPcMessageFlag = 0; ret = Pc_SetupReadLineCb( msgBuffer, MSG_BUFFER_MAX_SIZE, &bPcMessageFlag ); if( ret != 0 ) { +// ADI_SENSE_LOG_INFO("PC Message Read Unsuccesful!"); return ret; } @@ -33,7 +32,7 @@ //read first byte ret = Bl652_SetupReadCb( bleBuffer, 1, &bBleMessageReceived ); if( ret != 0 ) { - ADI_SENSE_LOG_INFO("Ble Message Read Unsuccesful!"); +// ADI_SENSE_LOG_INFO("Ble Message Read Unsuccesful!"); return ret; } } @@ -59,9 +58,9 @@ //handle message based on which interface it was received from if( bBleMessageReceived ) { //parse and handle command - ADI_SENSE_LOG_INFO("BLE Message Received!"); +// ADI_SENSE_LOG_INFO("BLE Message Received!"); ret = Ble_ParseCommand( bleBuffer ); - ADI_SENSE_LOG_INFO("BLE Command Parsed!"); +// ADI_SENSE_LOG_INFO("BLE Command Parsed!"); if(ret != 0) { //all ble side error handled within function as responses return ret; @@ -70,9 +69,9 @@ else if(bPcMessageFlag) { //parse and handle command - ADI_SENSE_LOG_INFO("PC Message Received!"); +// ADI_SENSE_LOG_INFO("PC Message Received!"); ret = Pc_ParseCommand( msgBuffer ); - ADI_SENSE_LOG_INFO("PC Command Parsed!"); +// ADI_SENSE_LOG_INFO("PC Command Parsed!"); if( ret != 0 ) { //all pc side error handled within function as responses return ret;
--- a/src/myproswift_periph.cpp Thu Sep 27 12:14:22 2018 +0000 +++ b/src/myproswift_periph.cpp Thu Oct 25 08:59:30 2018 +0000 @@ -53,13 +53,9 @@ .datareadyPin = SENSE_DREADY_PIN, }, .log = { - /* - * #define PC_UART_TX_PIN PA_11 - * #define PC_UART_RX_PIN PA_12 - */ - .txPin = PA_11, - .rxPin = PA_12, - .baudRate = 115200, + .txPin = PC_UART_TX_PIN, + .rxPin = PC_UART_RX_PIN, + .baudRate = PC_UART_BAUDRATE, .disableLogs = false, }, }; @@ -78,6 +74,8 @@ Serial bleSerialDevice(BLE_SERIAL_TX, BLE_SERIAL_RX, BLE_BAUD_RATE); +//Serial bleSerialDevice(PC_UART_TX_PIN, PC_UART_RX_PIN, PC_UART_BAUDRATE); + #ifdef BL652 DigitalOut bleMode0(BLE_MODE_0_PIN, 0); DigitalOut bleMode1(BLE_MODE_1_PIN, 0);
--- a/src/pc_interface/pc_interface.cpp Thu Sep 27 12:14:22 2018 +0000 +++ b/src/pc_interface/pc_interface.cpp Thu Oct 25 08:59:30 2018 +0000 @@ -27,7 +27,7 @@ int Pc_ResetSuccess(bool_t bBootLoader) { char status[3]; - //char hello_pc[] = "hello pc!\r\n"; + char hello_pc[] = "pc reset ok!\r\n"; if(bBootLoader) { //format error code into chars @@ -44,7 +44,7 @@ Pc_Write(status, strlen(status)); Pc_Write(delimBuf, sizeof(delimBuf)); //Pc_Write(hello_pc, 11); - //Pc_Write(hello_pc, strlen(hello_pc)); + Pc_Write(hello_pc, strlen(hello_pc)); return 0; }