Coder Social home page Coder Social logo

physical-computation / warp-firmware Goto Github PK

View Code? Open in Web Editor NEW
4.0 4.0 199.0 16.82 MB

Firmware for the Cambridge Physical Computation Laboratory's Warp Embedded Multi-Sensor Platform.

Home Page: http://physcomp.eng.cam.ac.uk

License: BSD 3-Clause "New" or "Revised" License

Shell 0.07% CMake 0.31% C 98.18% Assembly 0.34% Batchfile 0.08% Makefile 1.02%
arm cortex-m0 embedded firmware microcontroller

warp-firmware's People

Contributors

btsouts avatar chaturatbs avatar gm662 avatar jamestimothymeech avatar janithpet avatar komagr avatar lilrabbits avatar matiasilva avatar phillipstanleymarbell avatar richardhenryhopper avatar siegfriedchao avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

warp-firmware's Issues

'z' Command changes SSSupply voltage when reading from different sensors, Change to keep SSSupply constant

  1. Remove any changes to SSSupply in the 'z' case statement.
  2. Use 'a' command and datasheets to get a list of which sensors work at which voltages.
  3. Use the list to adapt the 'z' command to only read from the sensors that work at a given supply voltage.
    Phillip could you advise a neat way to do this ? My current idea is to have a if statement for each supply voltage and use that to only print headers for + request data from sensors that operate at the current voltage. Does this sound like a good approach ?

Enhance device driver for IS25xP

Current driver for device IS25xP is not very useful. It would be helpful to expand on this implementation and provide some helper functions for reading from and writing to the flash device.

Non mathcing type for menuI2cPullupValue variable

Inside the sensor device drivers, menuI2cPullupValue variable has non-matching type declarations in different functions.

Example from devMMA8451Q.c :

WarpStatus
configureSensorMMA8451Q(uint8_t payloadF_SETUP, uint8_t payloadCTRL_REG1, uint8_t menuI2cPullupValue)

and

WarpStatus
writeSensorRegisterMMA8451Q(uint8_t deviceRegister, uint8_t payload, uint16_t menuI2cPullupValue)

CSS811 Register 0x06

Describe the bug
We currently only read 2 hex bytes from register 0x06 on the CSS811 and print them with the z command.
The datasheet suggests that there are four bytes (two for vref anf two for a negative temperature coefficient sensor) to be read and all of them are needed to calculate the temperature see page 20: https://cdn.sparkfun.com/assets/learn_tutorials/1/4/3/CCS811_Datasheet-DS000459.pdf

To reproduce
See only two hex bytes printed in: https://github.com/physical-computation/Warp-data-stream/tree/master/data

Expected behavior
All four bytes should be printed to allow temperature calculation

Replace use of magic numbers in drivers with named constants

For example, the values we use for setting the ctrl_meas register for the BME680

For example, the literal constant 0b00000001 in

numberOfConfigErrors += configureSensorBME680( 0b00000001, /* Humidity oversampling (OSRS) to 1x */
)

should be named constants (e.g., kWarpDevBME680HumidityOversampling1x or something better, to be defined in the corresponding driver header file).

First data set print error

Print error for first data set when running JLinkRTTLogger. Measurement number anomaly and possible shift of sensor readings in fields.
Firmware version:
parent e1b54ce commit 42d8caf

Sensor output values are wrong

Describe the bug
Sensor output values from the "z" command are wrong.
Some sensors always output 0. For example the HDC1000 sensor always outputs 0x00 in registers 0x00 and 0x01. Same output when looking specifically at that sensor using the "j" command.

To reproduce

  1. Run ./build.sh in build/ksdk1.1/
  2. Then run JLinkExe -device MKL03Z32XXX4 -if SWD -speed 100000 -CommanderScript and JLinkRTTClient
  3. Running the following set of commands to dump all sensor values
    b 0300
    r
    g 3000
    n
    z

Expected behavior
I got the following output
BME680 Calibration Data: 0x40, 0xFB, 0x66, 0x03, 0xFF, 0x95, 0x8C, 0x59, 0xD7, 0x58, 0xFF, 0x90, 0x1E, 0x81, 0xFF, 0x22, 0x1E, 0x00, 0x00, 0x48, 0xF9, 0x60, 0xF4, 0x1E, 0x01, 0x3F, 0x94, 0x2E, 0x00, 0x2D, 0x14, 0x78, 0x9C, 0x53, 0x65, 0xF4, 0xDD, 0xE0, 0x12, 0x23, 0x00

Measurement number, RTC->TSR, RTC->TPR, AMG8834 0, AMG8834 1, AMG8834 2, AMG8834 3, AMG8834 4, AMG8834 5, AMG8834 6, AMG8834 7, AMG8834 8, AMG8834 9, AMG8834 10, AMG8834 11, AMG8834 12, AMG8834 13, AMG8834 14, AMG8834 15, AMG8834 16, AMG8834 17, AMG8834 18, AMG8834 19, AMG8834 20, AMG8834 21, AMG8834 22, AMG8834 23, AMG8834 24, AMG8834 25, AMG8834 26, AMG8834 27, AMG8834 28, AMG8834 29, AMG8834 30, AMG8834 31, AMG8834 32, AMG8834 33, AMG8834 34, AMG8834 35, AMG8834 36, AMG8834 37, AMG8834 38, AMG8834 39, AMG8834 40, AMG8834 41, AMG8834 42, AMG8834 43, AMG8834 44, AMG8834 45, AMG8834 46, AMG8834 47, AMG8834 48, AMG8834 49, AMG8834 50, AMG8834 51, AMG8834 52, AMG8834 53, AMG8834 54, AMG8834 55, AMG8834 56, AMG8834 57, AMG8834 58, AMG8834 59, AMG8834 60, AMG8834 61, AMG8834 62, AMG8834 63, AMG8834 Temp, MMA8451 x, MMA8451 y, MMA8451 z, MAG3110 x, MAG3110 y, MAG3110 z, MAG3110 Temp, L3GD20H x, L3GD20H y, L3GD20H z, L3GD20H Temp, BME680 Press, BME680 Temp, BME680 Hum, BMX055acc x, BMX055acc y, BMX055acc z, BMX055acc Temp, BMX055mag x, BMX055mag y, BMX055mag z, BMX055mag RHALL, BMX055gyro x, BMX055gyro y, BMX055gyro z, CCS811 ECO2, CCS811 TVOC, CCS811 RAW ADC value, HDC1000 Temp, HDC1000 Hum, RTC->TSR, RTC->TPR, # Config Errors

0, 1451692821, 20372, 0, 9, 10, 14, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 8, 0, 0, 0, 0, 0, 9, 8, 0, 0, 8, 0, 0, 0, 0, 0, 4, 0, 12, 12, 12, 13, 12, 12, 12, 10, 13, 14, 13, 14, 14, 14, 14, 13, 14, 9, 14, 9, 16, 10, 16, 7, -510, 0, 0, 2, 1, 2, 0, -508, 8, 132, 694, -3938, -2083, 1879, 1737, 12, -91, -444, -137, 7, 524288, 524288, 32768, -91, 174, 995, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, -40, ----, 1451692821, 21505, 6
1, 1451692821, 24753, 0, 12, 8, 6, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 8, 0, 0, 0, 0, 0, 9, 8, 0, 0, 8, 0, 0, 0, 0, 0, 4, 0, 12, 12, 12, 13, 12, 12, 12, 10, 13, 14, 13, 14, 14, 14, 14, 13, 14, 9, 14, 9, 16, 10, 16, 7, -510, 0, 0, 2, 1, 2, 0, -508, 8, 162, 664, -3966, -2081, 1876, 1740, 12, -64, -375, -147, 7, 359136, 496256, 18242, -84, 167, 1001, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, ----, 0, 1451692821, 25883, 6
2, 1451692821, 29134, 0, 13, 12, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 8, 0, 0, 0, 0, 0, 9, 10, 0, 0, 10, 0, 0, 0, 0, 0, 4, 0, 10, 10, 11, 11, 11, 11, 10, 8, 11, 11, 11, 11, 12, 11, 12, 10, 10, 7, 11, 8, 12, 8, 11, 5, 5, 8, 8, 8, 8, 9, 7, 5, 8, 132, 688, -3930, -2082, 1874, 1751, 12, -52, -349, -146, 7, 359136, 496288, 18232, -70, 177, 997, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, -40, ----, 1451692821, 30267, 6

The sensor readings seems to be wrong and to be disagreeing with one another.
And I always see 4/6 Config Errors. Is this expected?

Screenshots and hardware pictures
MVIMG_20200203_093233
MVIMG_20200203_093220
I am using the latest version of the firmware
Selection_072

Host OS (please complete the following information):

  • OS: Ubuntu 18.04.3
  • Browser: Chrome
  • Version (e.g., 22).
  • J-Link Commander V6.56a

You local changes (please complete the following information):

  • Output of git diff.
    diff --git a/tools/scripts/jlink.commands b/tools/scripts/jlink.commands
    index e0d59ab..d449d69 100644
    --- a/tools/scripts/jlink.commands
    +++ b/tools/scripts/jlink.commands
    @@ -1,5 +1,5 @@
    exec EnableRemarks
    unlock kinetis
    -loadfile /build/ksdk1.1/work/demos/Warp/armgcc/Warp/release/Warp.srec
    +loadfile /home/vimuth/projects/warp/Warp-firmware/build/ksdk1.1/work/demos/Warp/armgcc/Warp/release/Warp.srec
    r
    go
    \ No newline at end of file

  • Output of git remote -v.
    origin [email protected]:physical-computation/Warp-firmware.git (fetch)
    origin [email protected]:physical-computation/Warp-firmware.git (push)

Additional context
I have set the switches for "Power from USB and Sensors Enabled" as in - https://github.com/physical-computation/Warp-hardware/tree/master/revB
all switches in S3 is set to off

I2C pull up resistance variables - type, name, configuration

Describe the bug
Variables for I2C pull up resistance appear in various places with different type and semantics.

Variable menuI2cPullupValue in main functions is uint16_t and intended to be the I2C resistance value in Ohms.

Variable pullupValue in configureI2Cpins function is uint8_t and corresponds to the tap positions of the ISL23425 DCPs.

Required changes

  1. There are currently two ISL23425 DCPs which are configured with the same tap position value using configureI2Cpins function. We should modify the function to be able to take two values.
  2. A similar approach for menuI2cPullupValue, since there are two DCPs.
  3. We should add a function to map the menuI2cPullupValue Ohms value to ISL23425 DCP tap position.

Warp menu switch cases `R`, `F`, `P` are missing `break`

Describe the bug
The switch statement of the Warp menu is missing the break command at the end of the case block for cases R, F, and P. This results in the execution of code in cases below the active one in a waterfall manner.

To reproduce
Steps to reproduce the behavior:

  1. Start firmware
  2. Press "R" at Warp menu.

Expected behavior
The firmware should not execute code outside the selected case.

Host OS (please complete the following information):

  • OS: Linux 5.15.6-arch2-1 x86_64 GNU/Linux

The initXXXX functions where XXXX is the name of a sensor are defined with two arguments but are passed three

Describe the bug
When editing config.h such that
#define WARP_BUILD_ENABLE_DEVBMX055 1
or
#define WARP_BUILD_ENABLE_DEVHDC1000 1

you get compiler errors that state that you are trying to call a function that takes two arguments with three arguments.
To reproduce
set #define WARP_BUILD_ENABLE_DEVBMX055 1
or
#define WARP_BUILD_ENABLE_DEVHDC1000 1
and then compile with make warp

Expected behavior
Compiler errors complaining about calling a function with more arguments than it is defined to have.

Incorrect bme680 calibration register address

This doesn't actually seem to cause any problems though I suspect if compiled in debug mode this would cause crashes due to trying to write to unallocated memory. I just spotted this when looking at the code.

The number of bme680 calibration constants:

kWarpSizesBME680CalibrationValuesCount = 41,
is not consistent with the range of addresses it attempts to read from:
kWarpSensorConfigurationRegisterBME680CalibrationRegion1Start = 0x89,
kWarpSensorConfigurationRegisterBME680CalibrationRegion1End = 0xA2,
kWarpSensorConfigurationRegisterBME680CalibrationRegion2Start = 0xE1,
kWarpSensorConfigurationRegisterBME680CalibrationRegion2End = 0xF2,

These constants are used here:

for ( reg = kWarpSensorConfigurationRegisterBME680CalibrationRegion1Start;
reg < kWarpSensorConfigurationRegisterBME680CalibrationRegion1End;
reg++)
{
status4 |= readSensorRegisterBME680(reg, 1 /* numberOfBytes */);
deviceBME680CalibrationValues[index++] = deviceBME680State.i2cBuffer[0];
}
for ( reg = kWarpSensorConfigurationRegisterBME680CalibrationRegion2Start;
reg < kWarpSensorConfigurationRegisterBME680CalibrationRegion2End;
reg++)
{
status4 |= readSensorRegisterBME680(reg, 1 /* numberOfBytes */);
deviceBME680CalibrationValues[index++] = deviceBME680State.i2cBuffer[0];
}
and this declaration is relavent
volatile uint8_t deviceBME680CalibrationValues[kWarpSizesBME680CalibrationValuesCount];

These for loops read from 42 different memory locations and write the contents to an array of length 41.

I believe the fix is to set this:

kWarpSensorConfigurationRegisterBME680CalibrationRegion2End = 0xF2,
to 0xf1.

Hopefully I haven't just completely misunderstood something here.

KSDK v1.1 API function static i2c_status_t I2C_DRV_MasterReceive() not properly handling block read

For sensors such as MAG3110, if we would like to use its burst mode (with auto increment, multiple bytes read), the master by the end of the read should send a NAK to the slave. See MAG3110 datasheet page 12 diagram as an example.

However the API function i2c_status_t I2C_DRV_MasterReceive() does not handle this situation, i.e. no NAK is sent by the master when doing a block read.

A possible fix could be as follows, at line 778 and onwards in fsl_i2c_master_driver.c

        /* Dummy read to trigger receive of next byte in interrupt. */
        I2C_HAL_ReadByte(baseAddr);
        SEGGER_RTT_printf(0, "\r\n\trxSize is %d.\n\n", rxSize);

        while((rxSize--))
        {
            /* Wait for the transfer to finish.*/
            I2C_DRV_MasterWait(instance, timeout_ms);
            SEGGER_RTT_printf(0, "\r\n\trxSize is %d.\n\n", rxSize);
            if (rxSize == 0)
            {
                I2C_HAL_SendStop(baseAddr);
            }
            if (rxSize == 1)
            {
                I2C_HAL_SendNak(baseAddr);
            }
        }

This gives a correct i2c ACK and NACK behaviour, however it would not return kStatus_I2C_Success after the change has been made.

See KSDK API v2.0 as this version takes care of the rxSize value and sends the needed NAK at the end of the receiving operation, in fsl_i2c.c.

status_t I2C_MasterReadBlocking(I2C_Type *base, uint8_t *rxBuff, size_t rxSize)
{
    status_t result = kStatus_Success;
    volatile uint8_t dummy = 0;

    /* Add this to avoid build warning. */
    dummy++;

    /* Wait until the data register is ready for transmit. */
    while (!(base->S & kI2C_TransferCompleteFlag))
    {
    }

    /* Clear the IICIF flag. */
    base->S = kI2C_IntPendingFlag;

    /* Setup the I2C peripheral to receive data. */
    base->C1 &= ~(I2C_C1_TX_MASK | I2C_C1_TXAK_MASK);

    /* If rxSize equals 1, configure to send NAK. */
    if (rxSize == 1)
    {
        /* Issue NACK on read. */
        base->C1 |= I2C_C1_TXAK_MASK;
    }

    /* Do dummy read. */
    dummy = base->D;

    while ((rxSize--))
    {
        /* Wait until data transfer complete. */
        while (!(base->S & kI2C_IntPendingFlag))
        {
        }

        /* Clear the IICIF flag. */
        base->S = kI2C_IntPendingFlag;

        /* Single byte use case. */
        if (rxSize == 0)
        {
            /* Read the final byte. */
            result = I2C_MasterStop(base);
        }

        if (rxSize == 1)
        {
            /* Issue NACK on read. */
            base->C1 |= I2C_C1_TXAK_MASK;
        }

        /* Read from the data register. */
        *rxBuff++ = base->D;
    }

    return result;
}

Add self-test function for flash driver

Add a function that will test the flash (and driver) by writing to it and reading back. (Potentially other operations, too.)

Perhaps it would make sense to organize this as a separate build of the firmware that a definition in config.h controls. E.g., WARP_BUILD_ENABLE_SELFTEST. This way the self-test code will not take up important space in production builds.

`z` command incorrectly converts most sensor register values across the sensor types.

z command incorrectly converts most sensor register values across the sensor types.

For example,

readSensorRegisterValueCombined = ((readSensorRegisterValueMSB & 0xFF)<<8) + (readSensorRegisterValueLSB & 0xFF);

When the magnetometer data sheet register map is:
Screen Shot 2019-03-14 at 18 45 08

So the conversion for the hall sensor data should be:

readSensorRegisterValueCombined = ((readSensorRegisterValueMSB & 0xFF) << 6) | (readSensorRegisterValueLSB >> 2);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.