Pages: [1]   Go Down
Author Topic: Porting libs from the Atmel Framework  (Read 1146 times)
0 Members and 1 Guest are viewing this topic.
Germany
Offline Offline
Full Member
***
Karma: 10
Posts: 230
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello guys,

I'm thinking about porting one or another lib from the Framework from the Due/X or the SAM3X-EK would it be reprehensible if I take the libs and put them in an Arduino user friendly muted just with an lib with an nicer frontend for the users and putting the rest what isn't in the lib itself that comes from other parts in it to make it work? So there are easy therms like .init(); and similar.

B.R.

Markus
Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8472
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm sure nobody will object to some nice new libraries smiley

Most sample code provided by vendors is pretty crap, but it does give you a leg up to do something better.

_____
Rob
Logged

Rob Gray aka the GRAYnomad www.robgray.com

Germany
Offline Offline
Full Member
***
Karma: 10
Posts: 230
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

With the received absolution from Graynomad, I make my first move with an RTC lib for the Due, there are many stuff for the RTC in the Framework and in the Arduino IDE too.

This is my first version inspired by stimmer, really small on functions but you can Set time and Get time. I make some Wrapper Calls around the functions that i found in the IDE to make it a little bit easier to use it, the other functions like Date and Alarm will follow immediately, this is only for the first view.

B.R.

Markus

* Due_RTC.rar (2.16 KB - downloaded 11 times.)
« Last Edit: December 05, 2012, 03:28:38 am by Markus_L811 » Logged

Venezuela
Offline Offline
God Member
*****
Karma: 16
Posts: 509
Ground, ground, always ground
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Excellent job and nice initiative Markus, porting some ASF libraries for Due from the 1784 ASF samples (almost 50 for Due/X), and that's what we need. Motivated people to motivate others to generate more value inside the Arduino world!
Logged

Germany
Offline Offline
Full Member
***
Karma: 10
Posts: 230
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Excellent job and nice initiative Markus, porting some ASF libraries for Due from the 1784 ASF samples (almost 50 for Due/X), and that's what we need. Motivated people to motivate others to generate more value inside the Arduino world!

Thanks,

and now with the date function

* Due_RTC.rar (1.79 KB - downloaded 17 times.)
« Last Edit: December 05, 2012, 11:34:20 am by Markus_L811 » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 32
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey Nice to see it
I was thinking of pulling the RTC in from the from the framework.
Code comment review.
There is a potential hiccup. When reading hardware registers and operating on them I always make one good local read/copy of the hardware register and then operate on the same value.  So in
Code:
int RTC_clock::get_hours()
{
return (((current_time()  & 0x00300000) >> 20) * 10 + ((current_time()  & 0x000F0000) >> 16));
}
converting from BCD to std number the "current_time()" is called twice and each time reads from the hardware registers. With the two  current_time() reads they could return different readings.
Better I would think to do
Code:
int RTC_clock::get_hours()
{
uint32_t dwTimeCurrent = current_time();
return (((dwTimeCurrent  & 0x00300000) >> 20) * 10 + (( dwTimeCurrent & 0x000F0000) >> 16));
}
« Last Edit: December 06, 2012, 01:04:19 am by neil12 » Logged

nr Bundaberg, Australia
Offline Offline
Tesla Member
***
Karma: 126
Posts: 8472
Scattered showers my arse -- Noah, 2348BC.
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I see the problem, your code is full of "evil" emoticons. Try

 return (((current_time() smiley & 0x00300000) >> 20) * 10 + ((current_time() smiley & 0x000F0000) >> 16));

or use code tags, edit the post, select the code text, and click on the # button in the toolbar at the top.

______
Rob
« Last Edit: December 05, 2012, 08:10:55 pm by Graynomad » Logged

Rob Gray aka the GRAYnomad www.robgray.com

Germany
Offline Offline
Full Member
***
Karma: 10
Posts: 230
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey Nice to see it
I was thinking of pulling the RTC in from the from the framework.
Code comment review.
There is a potential hiccup. When reading hardware registers and operating on them I always make one good local read/copy of the hardware register and then operate on the same value.  So in
Code:
int RTC_clock::get_hours()
{
return (((current_time()  & 0x00300000) >> 20) * 10 + ((current_time()  & 0x000F0000) >> 16));
}
converting from BCD to std number the "current_time()" is called twice and each time reads from the hardware registers. With the two  current_time() reads they could return different readings.
Better I would think to do
Code:
int RTC_clock::get_hours()
{
uint32_t dwTimeCurrent = current_time();
return (((dwTimeCurrent  & 0x00300000) >> 20) * 10 + (( dwTimeCurrent & 0x000F0000) >> 16));
}

Yes you are right, I will correct it, and after it I will make functions to set parts of the date seperate, but its a little bit tricky the day of the week need to be changed too. Hope I'm back soon with the alarmfunction to.

Btw. it's my first library, the last time I changed one for the Leonardo, so please be patient (I write it between work and studying) updates will follow soon.
« Last Edit: December 06, 2012, 03:16:13 am by Markus_L811 » Logged

Pages: [1]   Go Up
Jump to: