Code Monkey home page Code Monkey logo

dallas-ds1620-c's Introduction

C DS1620 Library

Build Status Coverage Status

Fork of original library by jpmulligan.

Copyright (C) 2010 John P. Mulligan. All rights reserved.

Forked by Nikolay Nerovny, BMSTU, 2018.

This is an C library for use with the Dallas Semiconductor DS1620 Digital Thermometer and Thermostat. Uses 3-wire serial communication.

Latest version of library:

https://github.com/bsail/dallas-ds1620-c

Development

For developers looking to extend, bug fix, build, and test this library with dependencies and test infrastructure included in the source tree.

Setup Environment - Ubuntu 16.04/18.04

sudo apt install build-essential git ruby gcov lcov
sudo gem install ceedling

Get Code

mkdir ds1620
git clone https://github.com/bsail/dallas-ds1620-c ds1620
ceedling upgrade ds1620
cd ds1620

For a proper integration of this library one should describe the callbacks to access I/O ports for communication with device. The example implementation of callbacks is given below:

static void clock_low_callback(void)
{
  bit_clear(PORTK, 7);
}

static void clock_high_callback(void)
{
  bit_set(PORTK, 7);
}

static void reset_low_callback(void)
{
  /* In this example we assume that there are two devices with different reset lines;
   * ds1620_current_device is a local variable
   */
  if (ds1620_current_device == 1)
    bit_clear(PORTK, 4);
  else
    bit_clear(PORTK, 5);
}

static void reset_high_callback(void)
{
  /* In this example we assume that there are two devices with different reset lines;
   * ds1620_current_device is a local variable
   */
  if (ds1620_current_device == 1)
    bit_set(PORTK, 4);
  else
    bit_set(PORTK, 5);
}

static void dq_set_callback(uint8_t bit)
{
  if (bit)
    bit_set(PORTK, 6);
  else
    bit_clear(PORTK, 6);
}

static uint8_t dq_get_callback(void)
{
  return bit_check(PORTK, 6);
}

static void dq_set_output_callback(void)
{
  bit_set(DDRK, 6);
}

static void dq_set_input_callback(void)
{
  bit_clear(DDRK, 6);
}

static void setup_ports_callback(void)
{
  bit_set(DDRK, 4); /* Reset line for ds1620 #1 */
  bit_set(DDRK, 5); /* Reset line for ds1620 #0 */
  bit_set(DDRK, 6); /* Data line */
  bit_set(DDRK, 7); /* Clock line */
}

static void delay_callback(unsigned long delay_ms)
{
  some_fancy_delay_function(delay_ms);
}

Tests

Unit Tests

Build & Run Unit Tests

ceedling test:all

Generate LCOV coverage report (build/lcov/index.html)

ceedling lcov

You may use and create additional tasks for Ceedling build system. Please refer to the documentation in the vendor/ceedling/docs.

Project Structure

Source Directories

  • /src - library source directory

    • ds1620.h - main header
    • ds1620.c - main implementation
    • ds1620_send_command.h - header of command interface
    • ds1620_send_command.c - implementation of command interface
    • ds1620_receive_data.h - header for data receive subroutine
    • ds1620_receive_data.c - implementation of data receive subroutine
    • ds1620_send_data.h - header for data send subroutine
    • ds1620_send_data.c - implementation of data send subroutine
    • ds1620_reset.h - header for reset functions
    • ds1620_reset.c - implementation of reset functions
  • /test

    • test_ds1620.c - Unity test file for ds1620.c module (use ceedling test:ds1620 to run tests only in this source file)
    • test_ds1620_send_command.c - Unity test file for ds1620_send_command.c module (use ceedling test:ds1620_send_command to run tests only in this source file)
    • test_ds1620_receive_data.c - Unity test file for ds1620_receive_data.c module (use ceedling test:ds1620_receive_data to run tests only in this source file)
    • test_ds1620_send_data.c - Unity test file for ds1620_send_data.c module (use ceedling test:ds1620_send_data to run tests only in this source file)
    • test_ds1620_reset.c - Unity test file for ds1620_reset.c module (use ceedling test:ds1620_reset to run tests only in this source file)
  • /

    • COPYING - GNU General Public License version 3
    • COPYING.LESSER - GNU Lesser General Public License version 3
    • README.md - this file
    • project.yml - Ceedling project file including parameters of test compiler and linker
    • .gitignore - definitions of files and directories to be ignored by git
    • .travis.yml - configuration file for Travis CI
    • Gemfile - list of required gems
    • rakefile.rb - additional configuration of build system

Third Party Source Directories

  • /vendor - Ceedling source with documentation and plugins

Build Directories

  • /build - Ceedling library build directory

dallas-ds1620-c's People

Contributors

jpmulligan avatar locutus3009 avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.