Giter VIP home page Giter VIP logo

si7210-driver's Introduction

Si7210 Hall-effect sensor driver API

A portable driver written in C for Silicon Lab's Si7210 hall-effect sensor.

Introduction

This package contains the Si7210 sensor driver. The driver includes si7210.c, si7210.h, and si7210_defs.h files.

Integration details

  • Integrate si7210.c, si7210.h, and si7210_defs.h files into the project
  • Include the si7210.h file in your code like below.
#include "si7210.h"

File information

  • si7210_defs.h : This header file contains definitions used by both the user and driver APIs.
  • si7210.h : This header file contains the declarations of the driver APIs.
  • lmt01.c : This source file contains the definitions of the driver APIs.

Supported interfaces

  • I2C

User Guide

Initialising the device

To intialise the device, the user must create a device structure. The user can do this by creating an instance of the structure si7210_dev. The user must then fill in the various parameters as shown below to initialise the device. THe usermust then choose the particular settings they wish to use, by filling in the 'settings' member of the device struct.

si7210_status rslt = SI7210_OK;

struct si7210_dev dev = {
    .dev_id   = SI7210_ADDRESS_0;
    .read     = usr_i2c_read;
    .write    = usr_i2c_write;
    .delay_ms = usr_delay_ms;
    .callback = callback;
};

if((rslt = si7210_init(&dev) != SI7210_OK)
    return rslt;

dev.settings.range        = SI7210_20mT;
dev.settings.compensation = SI7210_COMPENSATION_TEMP_NEO;
dev.settings.output_pin   = SI7210_OUTPUT_PIN_HIGH;
 
if((rslt = si7210_set_sensor_settings(&dev)) != SI7210_OK)
    return rslt;

if(rslt == SI7210_OK)
{
    float field;
    float temperature;

    /* Obtain field strength reading from device */
    si7210_get_field_strength(&dev, &field_strength);

    /* Obtain a temperature reading from the device */
    si7210_get_temperature(&dev, &temperature);

    printf("Field: %fmT\tTemperature: %f*C", field, temperature);
}

Templates for function pointers

si7210_status usr_i2c_read(uint8_t dev_id, uint8_t reg_addr, uint8_t *data, uint16_t len)
{
    si7210_status rslt = SI7210_OK;

    /* User implemented I2C read function */

    return rslt;
}

si7210_status usr_i2c_write(uint8_t dev_id, uint8_t reg_addr, uint8_t *data, uint16_t len)
{
    si7210_status rslt = SI7210_OK;

    /* User implemented I2C write function */

    return rslt;
}

void usr_delay_ms(uint32_t period_ms)
{
    /* User implemented delay (ms) function */
}

si7210-driver's People

Contributors

farly7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

si7210-driver's Issues

example code does not compile

Hi FARLY7
thanks for the great work on the si7210 sensor....
I tried to use your lib and implemented the example code provided on your git web page in Arduino.
Unfortunately i do not get it to compile.
Do you have a running excample how to use and correctly initialise your lib?
Best regards

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.