Tuesday, January 13, 2015

1 Wire Interface library .. design suggestions ?

Well well, hello there again. It has been quite some time, unfortunately the schools started again, so I won't have much time to post. I'll try to make this a quick one.
I once said I should write a 1 wire library, to avoid rewriting code, and make coding more fun and productive .. and whatever. So, I have got the finished "thermometer" project with 3x8 segment displays. And I should admit, it work's quite nice indeed :)
In the process of designing the library, the most important part was choosing the way of how it all will come together. For instance, in my design I chose to have several rather "repeating" functions, but they would shorten the time of writing, and they would be more comfortable, so heck whatever. In that design I had..
Simple functions
  • one_wire_reset - the reset presence pulse thingy
  • one_wire_read - read one byte
  • one_wire_write - write one byte
And some advanced functions
  • one_wire_receive - to receive given amount of bytes into an array
  • one_wire_send_data - send bytes from given array
  • one_wire_send_package - send reset/presence, ROM command, and function command, with arguments
  • one_wire_send - send reset/presence, ROM command and function command, but without arguments
So far this was all the ideas I had in my mind. Btw, I'd appreciate any ideas or comments about the design.. The library is under WTFPL, and kindof made to be easy configurable. The only things that needs to be changed are _1_WIRE_PORT_L and _1_WIRE_PORT_N, which correspond to which PORT's which bit is going to be used as 1 wire interface. Whatsoever, it's easy enough to figure out. And here is the link to the library, the test can be found in this blog's bitbucket's repository. And that was all for today, so long!