Therefore we round up the sample rate requested by user.We’ll also consider 1 Hz as the default option. The sample rate given by user is understood as at least this much. Signature for configuration function Sample rate Typedef ruuvi_driver_status_t (*ruuvi_driver_sensor_dsp_fp)(uint8_t* dsp_function, * RUUVI_DRIVER_ERROR_INVALID_PARAM if parameter is invalid for any reason. * RUUVI_DRIVER_ERROR_NOT_IMPLEMENTED if sensor supports given DSP, but * RUUVI_DRIVER_ERROR_NOT_SUPPORTED if sensor doesn't support given DSP * RUUVI_DRIVER_ERROR_NULL if either parameter is NULL Can be a combination of several functions. * DSP functions are run on the sensor HW, not in the platform FW. * Modifies input parameters to actual values written on the sensor. * Takes DSP function and a DSP parameter as input, configured value or error code as output. * Configure sensor digital signal processing. Typedef ruuvi_driver_status_t (*ruuvi_driver_sensor_setup_fp)(uint8_t* parameter) * RUUVI_DRIVER_ERROR_NOT_IMPLEMENTED if the sensor could support parameter, but it's not implemented in fw. * RUUVI_DRIVER_ERROR_NOT_SUPPORTED if sensor cannot support given parameter * RUUVI_DRIVER_ERROR_NULL if parameter is NULL * parameter value to write to sensor configuration. * The function will modify the pointed data to the actual value which was written The configuration function signatures are defined in ruuvi_driver_sensor.h, let’s implement them with the above low-level functions. We’ll implement those rates as custom values to the sensor. Additionally the standard sensor configuration format supports only sample rates in range of 1 … 200 Hz, whereas TMP117 supports rates of 1/4, 1/8 and 1/16 Hz. We’ll return a warning if the user tries to set the oversampling to higher ratio than what is supported by current sample rate or vice versa. Only digital signal processing ( DSP) supported by TMP117 is oversampling. Sample rate can be configured through conversion cycle time in continuous mode. M_timestamp = RUUVI_DRIVER_UINT64_INVALID Ruuvi_driver_sensor_uninitialize(sensor) Ruuvi_driver_status_t err_code = RUUVI_DRIVER_SUCCESS Ruuvi_driver_status_t ruuvi_interface_i2c_tmp117_read(const uint8_t dev_id, const uint8_t reg_addr, * reg_val pointer to 16-bit data to be received. * reg_addr TMP117 register address to read. * Binds Ruuvi Interface I2C functions for TMP117 Return ruuvi_interface_i2c_write_blocking(dev_id, command, sizeof(command), true) Ruuvi_driver_status_t ruuvi_interface_i2c_tmp117_write(const uint8_t dev_id, const uint8_t reg_addr, * RUUVI_DRIVER_ERROR_TIMEOUT if device does not respond on bus * reg_addr TMP117 register address to write. You’ll find the section in the rightmost green box of architecture diagram. interfaces/i2c/ruuvi_interface_i2c_tmp117.hĪnd place the functionality there. To keep the project structure clean we’ll create new files: /interfaces/i2c/ruuvi_interface_i2c_tmp117.c The work even further simplified by the TMP117 register structure which has fixed size read/write commands. Most of the heavy lifting is already done, we’ll simply add calls to Ruuvi I2C libraries which in turn will call the underlying Software Development Kit ( SDK). To actually get the data from sensor, we’ll need to implement the I2C write and read functions. Where "NameOfMCU" is the name of the MCU family used, CMSIS should be there in case you are using any ARM, "NameOfDirectory" is the name of your custom directory (you can add several).Īlso, get the debug build working first, before switching to release build.Be sure to compile the project on Debug settings and on right board. Under "user include directories" you should have something like this: $(DeviceIncludePath) Then in the properties window, check settings (this is a bit different in different versions of CrossWorks, might have to right click and pick properties in older versions). In the project, click on the project name itself in "project explorer". In case some needed lib is missing here, you will get very weird errors. Grab your specific target MCU as well as any specific boards or libraries you'll be using. Download & install all relevant libs from inside the IDE, under Tools -> Packages -> Install packages.In CrossWorks, you have to do the following: For now I simply included the header and C-File in the project directory. The file seems to be included since it shows up in the dependencies. Right now trying to call a function of a included header file. I haven't used Segger Studio specifically, but it seems to be the CrossWorks IDE underneath. I am just starting out with Segger Embedded Studio.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |