Coder Social home page Coder Social logo

z13z4ck / hwa Goto Github PK

View Code? Open in Web Editor NEW

This project forked from duparq/hwa

0.0 2.0 0.0 45.99 MB

A set of C-preprocessor macros providing a thickless hardware abstraction layer for various microcontrollers allowing concise, highly readable source code, and top performance binary code.

Home Page: http://duparq.free.fr/hwa/index.html

License: Other

Makefile 3.96% C 60.17% Shell 0.63% Python 34.14% C++ 1.02% CSS 0.07% HTML 0.02%

hwa's Introduction

HWA

HWA is a set of C-preprocessor definitions designed to help developers write hardware-related code that:

  • is concise and easy to read,
  • produces efficient binary code,
  • simplifies the process of porting the code to a different target.

To achieve these goals, HWA provides:

  • a set of objects that represent the hardware,

  • generic instructions that accept various types and various numbers of mandatory and optionnal arguments, that put the focus on the expected result rather than on the values to be written in registers,

  • an error-checking mechanism that tries to produce messages that help the developer to solve the problems,

  • a transactional processing mechanism that allows further optimization of the machine code.

There is actually no penalty in using HWA, either in terms of size, execution speed or memory used. Because it is not a library, using HWA does not affect negatively the efficiency of the binary code produced as HWA helps the compiler's optimizers produce a binary that is at least as efficient as if the developer had written smart accesses to hardware registers himself.

Any C compiler compatible with the C11 standard should be able to compile the source code.

As the C-preprocessor can be used to parse assembler source, a few features of HWA can be used for assembler programming. The implementation of a @ref atmelavr_swuarta "software UART for Atmel AVR microcontrollers" (see atmel/avr/swuarta/) and a @ref atmelavr_diabolo "bootloader" (see atmel/avr/examples/diabolo) are examples of such a usage.

Here is an example of how to use a watchdog interrupt to make a LED blink with an Atmel AVR ATtiny44A-PU:

//  Load HWA definitions for the target device
//
#include <hwa/attiny44a_pu.h>


//  We can use pin numbers as the device name tells HWA the package
//
#define PIN_LED      HW_PIN(7)


//  Service watchdog IRQ
//
HW_ISR( watchdog0 )
{
  //  Blink the LED
  //
  hw( toggle, PIN_LED );
}


int main ( )
{
  //  Create a HWA context preloaded with RESET values to
  //  collect the hardware configuration
  //
  hwa_begin_from_reset();

  //  Configure the LED pin
  //
  hwa( configure, PIN_LED, direction, output );

  //  Configure the watchdog to trigger an IRQ every 250ms
  //
  hwa( configure, watchdog0,
       timeout,   250ms,
       action,    irq );

  //  Configure the core to enter idle mode when asked to sleep
  //
  hwa( configure,  core0,
       sleep,      enabled,
       sleep_mode, idle );

  //  Write this configuration into the hardware
  //
  hwa_commit();

  //  Enable interrupts
  //
  hw_enable_interrupts();

  //  Sleep between interrupts
  //
  for(;;)
    hw_sleep();

  return 0 ;
}

Several other example projects are provided in the vendor/architecture/examples/ directories (e.g. atmel/avr/examples/).

Each examples/ directory contains a README.md file that explains how to compile the examples.

Documentation

A ready-made documentation is available here. Start with the @ref using page.

Building the documentation from sources requires Doxygen and Gnu Make. Run make in the HWA base directory and open the doxygen/html/index.html page.

Status

WARNING! The development of HWA is very chaotic and this project is subject to heavy changes of the code base.

Supported devices

  • HWA supports almost fully Atmel AVR ATtinyX4, ATtinyX5, and ATmegaX8.

  • ST's STM32F103 is the device that initiated the writing of HWA. The code is being rewritten.

  • Support of ATmega32U4 and Espressif's ESP8266 has been started but needs to be rewritten.

Organization of the code

The base source code of HWA is in the hwa/ directory.

Device-related sources are stored in vendor/architecture/ directories (atmel/avr/, st/stm32/, espressif/, ...) where are stored classes/, devices/, and examples/ directories.

Hosting

HWA is hosted on Github.

Feedback

Feedbacks will be greatly appreciated. For any bug report, question or suggestion, please use my gmail address (duparq) and put HWA in the object.

License

HWA is free software. See the @ref license "license" page for license information.


hwa's People

Contributors

duparq avatar

Watchers

James Cloos avatar Aziz 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.