Coder Social home page Coder Social logo

leddriver's Introduction

LedDriver

Build Status

A LED driver for embedded systems.

Features

  • Multiple-instance module
  • Written in C
  • Testability
  • MIT license

Assumptions and constraints

  • The implementation of LEDs is memory-mapped I/O and 8 bits
  • The I/O address is writable and readable
  • The bit value 1 is LED on and 0 is LED off
  • Dynamic memory allocation

Usage

I recommend just copying LedDriver.h and LedDriver.c into your project. Then just #include "LedDriver.h" to use the LedDriver functions.

Function Documentation

LedDriver_Create

LedDriver LedDriver_Create(uint8_t* ioAddress, uint8_t (*decoder)(int));

Create a LedDriver instance.

Note: All LEDs will be off if successfully.

Inputs:

  • ioAddress - The I/O address for LEDs.
  • decoder - The function to convert to bit from the LED number (1 to 8).

Returns the instance if created successfully, NULL if an error occurred.

LedDriver_Destroy

void LedDriver_Destroy(LedDriver* self);

Destroy a LedDriver instance.

Note: All LEDs will be off if successfully.

Inputs:

  • self - The pointer to LedDriver instance.

LedDriver_TurnOn

void LedDriver_TurnOn(LedDriver self, int ledNumber);

Turn on a LED.

Inputs:

  • self - The LedDriver instance.
  • ledNumber - The number of LED to turn on.

LedDriver_TurnOff

void LedDriver_TurnOff(LedDriver self, int ledNumber);

Turn off a LED.

Inputs:

  • self - The LedDriver instance.
  • ledNumber - The number of LED to turn off.

LedDriver_TurnAllOn

void LedDriver_TurnAllOn(LedDriver self);

Turn on all LEDs.

Inputs:

  • self - The LedDriver instance.

LedDriver_TurnAllOff

void LedDriver_TurnAllOff(LedDriver self);

Turn off all LEDs.

Inputs:

  • self - The LedDriver instance.

LedDriver_IsOn

bool LedDriver_IsOn(LedDriver self, int ledNumber);

Check if the LED is on.

Inputs:

  • self - The LedDriver instance.
  • ledNumber - The number of LED to check.

LedDriver_IsOff

bool LedDriver_IsOff(LedDriver self, int ledNumber);

Check if the LED is off.

Inputs:

  • self - The LedDriver instance.
  • ledNumber - The number of LED to check.

How to use this project

Build

$ cd LedDriver
$ mkdir build
$ cd build
$ cmake ..
$ make

Run the tests

Either using ctest or directly using bin/gtests in the build directory.

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.