Announcement: HWA new release

Go To Last Post
23 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Everybody,

 

About 2 years ago I pushed on Github a first version of the hardware abstraction tool I named HWA. Some people here gave me some feedback that I hope I took correctly into account for this new release.

 

HWA is not Arduino, it is not a library but an abstraction tool implemented at compilation level.

 

HWA is on Github.

 

 

Some documentation and a bunch of examples are provided.

 

Feedback is welcome!

 

HWA : hardware abstraction for micro controllers, in pure standard C, without penalties.

Last Edited: Tue. May 19, 2015 - 10:28 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Moved to marketplace

 

Jim

If you want a career with a known path - become an undertaker. Dead people don't sue! - Kartman

Please Read: Code-of-Conduct

Atmel Studio6.2/AS7, DipTrace, Quartus, MPLAB user

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hello Jim, and thank you for having moved my post to a better place.

 

In fact, HWA is a free software project and there is nothing to sell. Some more details:

 

HWA is a hardware abstraction tool for microcontroller programming in C (or assembler).

This is not a library but a set of macros that allow you to write code more oriented towards the expected results than on the values ​​to be written to the registers.

A first version was released (somewhat prematurely) about three years ago. HWA has since been completely rewritten to offer generic instructions accepting lists of variable length key-value pair arguments. So the code becomes clearer and more concise. For example:

/*  Configure counter 0 (TCNT0) to count at system frequency,
 *  looping from 0 to CMAX (store in the compare unit
 *  compare0, aka OCR0A) and trigger an IRQ when overflowing
 */
hwa_config( hw_counter0,
            clock,     syshz,
            countmode, loop_up,
            bottom,    0,
            top,       compare0,
            overflow,  at_top
          );
hwa_write( hw_sub(hw_counter0, compare0), CMAX );
hwa_turn_irq( hw_counter0, overflow, on );

Right now, only ATtiny44 and ATtiny84 are supported (almost completely). ATtiny{25,45,85} and ATmega{88,168,328} which have already been tested but must be rewritten should arrive shortly. Then it should be time for STM32 for which HWA was originally designed.

An early documentation and a set of examples are provided.

If we had to make a comparison with Arduino that I have very little tested but is very well known, I would say HWA has at least the advantage of producing a code that does not suffer any penalty in terms of memory usage or execution speed. However compilation time seems noticeably longer, probably due to the work done by the preprocessor and the code optimizers.

 

 

So, don't you think it would be more appropriate to move it to the Projects section of the site or the Compilers and General Programming forum ?

 

Best regards,

 

Chris

 

HWA : hardware abstraction for micro controllers, in pure standard C, without penalties.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

So, don't you think it would be more appropriate to move it to the Projects section of the site or the Compilers and General Programming forum ?

Agree, moved.

 

Just on a personal note I wonder what libraries like this really achieve? If I'm a developer and want to make the timer in my mega168 sing and dance I guess I have three options:

 

1) read the datasheeet and learn the bare metal peripheral then set the bits and bytes to make it happen

 

2) learn a library such as yours and what all these "loop-up" and "compare0" options really mean and achieve

 

3) do the same in Arduino which is widely documented and supported so I'm likely to be able to find answers to any question I might have about their abstraction

 

What makes me choose (2) over the other options?

 

I guess one of the real deciding factors will be quality of documentation. For (1) Atmel datasheets are pretty good and generally complete (until you reach Xmega!). For (3) the arduino.cc documentation is excellent.

 

For (2) is your doxygen'd documentation accessible online or do I really have to pull the git tree and "make doc" to get to read it? To do so is probably fairly easy for a developer on Linux but there's going to be many Windows users who don't have the easy option to build Doxygen trees.

 

(Dean Camera's LUFA has the option to build the Doxygen from the tree but he always has an online copy too - 99% of the time I read the online one - I'm sure most users do)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you Cliff for moving this post and for your valuable comments.

 

1) then my source code is full of _BV(). Since that is not really self-speaking, I write comments. May be because I care about potentially readers but surely because I will soon forget what these _BV() mean.

    When I'll decide to use timer/counter1 instead of timer/counter0, I'll have to re-open the datasheet because the _BV() are not the same... And the same for the ISR.

 

3) I stopped experimenting with Arduino immediately after writing a little LED blinker: how can that require 1 KB of code? I do not taste Arduino syntax very much.

 

2) About the learning curve, I've tried to reduce the vocabulary of HWA and to make it self-speaking as much as possible.

 

    I've decided to rename the controllers so that the same naming scheme should be reusable accross (very) different targets: timer/counter0 becomes hw_counter0, its compare unit A can be named hw_counter0_compare0, or hw_sub(hw_counter0,compare0) if you do not want your code to be tied to the counter name. If this causes trouble, it's always possible to define aliases.

 

    There are a few generic instructions: hw_read(...) hw_write(...) hwa_config(...) etc. that act on various kinds of objects (counters, pins, adc... even software-emulated hardware like the software wuart).

 

    For example, timer/counter0 is configured with hwa_config(hw_counter0, ...). If I later want to use hw_counter1 instead of hw_counter0, I'll have very few things to change in my code, maybe nothing more than the counter name.

 

    If I do not remember exactly the syntax of the instruction, HWA displays an error message telling me what is expected and most of the time I will not need to browse the documentation.

 

    The examples show all that and when different targets will be available (ATtiny85, ATmega328 soon), you'll see how it is easy to change the target.

 

I agree with you about the documentation, that is important. I tried first to include it in the repository but it does not make it browsable on Github: it displays the sources of the HTML files. So I've put the documentation on my website and there is now a link to it in the README on Github.

 

HWA : hardware abstraction for micro controllers, in pure standard C, without penalties.

Last Edited: Tue. May 19, 2015 - 03:09 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

But sadly the documentation fails (well it fails my idiot test anyway - I'm quite an idiot so I know what I'm talking about!)

 

Take this:

 

http://duparq.free.fr/hwa/atmela...

 

Now the content itself there is pretty good but I'm just thinking of how a potential user would approach this. They start here:

 

http://duparq.free.fr/hwa/index....

 

What on earth would make me read something in the left-hand index called "_c8a" ?!? If the index had listed "8bit timer/counter with 2 compare units" I might have been tempted to venture in but "_c8a" (and all those other weird and wonderful symbols) don't make much of an "index" as far as I'm concerned. I'm supposed to be reading this thing like a book that will guide me through the use of the library - not trying to decipher encrypted text.

 

While I actually think Atmel's ASF is pretty dire the thing I like about their ASF documentation:

 

http://asf.atmel.com/docs/latest/

 

Are their "quick start guides" that are available for pretty much every module. if I dig a bit here, for example is a guide to starting to use the SPI on an Xmega/AU chip:

 

http://asf.atmel.com/docs/latest...

 

I can find similar for pretty much every chip and peripheral that is supported.

Such documentation guiding the user through the use of a library like this is key.

Equally if I take the Arduino case I hopefully start here:

 

http://www.arduino.cc/en/Referen...

 

and say I want to use UART ("Serial") I move on to here:

 

http://www.arduino.cc/en/Referen...

 

and from there to specific examples like:

 

http://www.arduino.cc/en/Serial/...

 

The:

void setup(){
  Serial.begin(9600);
  Serial1.begin(38400);
  Serial2.begin(19200);
  Serial3.begin(4800);

  Serial.println("Hello Computer");
  Serial1.println("Hello Serial 1");
  Serial2.println("Hello Serial 2");
  Serial3.println("Hello Serial 3");
}

void loop() {}

tells me pretty much all I need to know to operate 4 UARTs.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've taken a look at the ASF's doc and it looks a lot like what I wanted (and I dit not get) as natural entry points for the end-user in the HWA documentation. These pages should be pointed out:

  • Using HWA that gives you exhaustive information on how to use HWA in general.
  • Atmel AVR ATtiny24 ATtiny44 ATtiny84 that gives device-specific informations with a table gathering all the objects these devices contain and a link towards the class-specific information.

 

I agree, the left side index is not sexy. The _c8a, _ad10a... symbols are the class names of the various objects a device can contain. I've nevers wanted these links to appear here but I do not know how to remove them!

 

Well, I'm not at ease with Doxygen, but I'm still trying to get something more attractive. For example, it would be great to have links towards the examples showing how to use each feature of an object.

 

HWA : hardware abstraction for micro controllers, in pure standard C, without penalties.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Documentation reorganized. Needs some more work but begins to look good.

 

HWA : hardware abstraction for micro controllers, in pure standard C, without penalties.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Ah ha - looks astronomically better - it's that kind of small detail that can be the win or lose for a project!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Files reorganized and documentation completed.

 

HWA : hardware abstraction for micro controllers, in pure standard C, without penalties.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

HWA now supports ATtinyX4, ATtinyX5, and ATmegaX8 (except the TWI that I just started).

 

HWA : hardware abstraction for micro controllers, in pure standard C, without penalties.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Partial support of ATmega32U4.

 

HWA : hardware abstraction for micro controllers, in pure standard C, without penalties.