Instructions/pointers to port a library to STM32duino

Please do not post requests
Post Reply
stanleyseow
Posts: 46
Joined: Sun Sep 27, 2015 3:26 am
Location: Kuala Lumpur, Malaysia
Contact:

Instructions/pointers to port a library to STM32duino

Post by stanleyseow » Sat May 14, 2016 5:43 am

Everyone here have different background with different levels of programming skills/experience ... some are really good whereas some are just hobbyists or just users of those ported libraries...

Can anyone point me to where to start if I wanted to port an Arduino library to the stm32duino ?? ( nothing specifics at the moment, just curious on how it was done by the contributors here ... )

All I was "aware" was that I have to read the datasheets in details and datasheets are something NOT easy to understand for me ... :-)

Any examples on how a previous library was ported would be a good way to learn by example ...

Thanks ...
Stanley
9W2SVT / N5SVT

racemaniac
Posts: 522
Joined: Sat Nov 07, 2015 9:09 am

Re: Instructions/pointers to port a library to STM32duino

Post by racemaniac » Sat May 14, 2016 6:03 am

What do you expect in instructions?
I think the project has got pretty good arduino compatibility, but there are some differences ofcourse. It will highly depend on the library and what it uses.

zmemw16
Posts: 1422
Joined: Wed Jul 08, 2015 2:09 pm
Location: St Annes, Lancs,UK

Re: Instructions/pointers to port a library to STM32duino

Post by zmemw16 » Sat May 14, 2016 9:49 am

i'd look at one of these Arduino_STM32/STM32F1/libraries : OLED_I2C, Adafruit_SSD1306, Adafruit_ILI9341_STM & Adafruit_GFX_AS against the Adafruit sources on Github

learn to read output from diff or find graphical diff e.g. tkdiff

figure out why its changed :)

areas for attention, #include's, #define's, #if's also bit operations on ports, stuff using timers, i2c, spi

stephen

stanleyseow
Posts: 46
Joined: Sun Sep 27, 2015 3:26 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Instructions/pointers to port a library to STM32duino

Post by stanleyseow » Wed May 25, 2016 1:45 pm

Thanks for the tips on diff and #defines/#ifdef , I totally forgotten about this command ...

I guess my questions was too generic and was also given generic replies as well..

Specifically, I would like to port a DAC (generating APRS audio out) code from teensy/others to the stm32duino..
https://github.com/rvnash/aprs_teensy31

Teensy was on the ARM Cortex-M4 72 MHz whereas STM32F103 was a ARM Cortex-M3 ....
Stanley
9W2SVT / N5SVT

ozolive
Posts: 6
Joined: Thu Oct 06, 2016 11:09 am

Re: Instructions/pointers to port a library to STM32duino

Post by ozolive » Fri Oct 21, 2016 9:44 am

I had a quick look at this lib and i see it uses a lot of the ambiguous type "int", and maybe others.

You should try replacing those as explained in this thread: http://www.stm32duino.com/viewtopic.php?f=13&t=1479

It might continue to fail, but could as well ends up more near to working ;)

User avatar
iwalpola
Posts: 24
Joined: Tue Jun 21, 2016 1:08 pm
Location: Silchar, India
Contact:

Re: Instructions/pointers to port a library to STM32duino

Post by iwalpola » Tue Jan 31, 2017 8:10 am

Hi,

I did some porting a while back, and I was porting an 8-bit parallel LCD code. Basically what I changed was the way that data was written to the GPIOs, and the rest of the library was not hardware-specific. Let me explain...

The library I was porting (Adafruit ILI9341 8 bit parallel) had some functions for drawing lines and rectangles and pixels, and these functions were calling a few (one or two) functions for writing and reading data to/from the GPIOs. I had to change only the functions that dealt with GPIOs, since ths is what is different between arduino and STM32.

Specifically you want to
1) look into the pin names, and change them to STM32 pin names.
2) digitalread() and digitalwrite() will work, but if the code uses bit operations to write and read and set the mode of pins, you must replace them with STM32 registers.

Here are some references:
Git commit history during porting (you can see all the changes I made step by step): https://github.com/iwalpola/Adafruit_IL ... its/master
Guide to STM32 GPIO registers: http://www.stm32duino.com/viewtopic.php ... 500#p15500

User avatar
BennehBoy
Posts: 420
Joined: Thu Jan 05, 2017 8:21 pm
Location: Yorkshire
Contact:

Re: Instructions/pointers to port a library to STM32duino

Post by BennehBoy » Tue Jan 31, 2017 10:18 am

I saw elsewhere on the forum Roger mentioning that sometimes definitions don't get brought in correctly.

I was hacking about with this ELM327 OBDII library last night -> https://github.com/irvined1982/arduino-ELM327

The example header stipulates 3 definitions that must be made:

Code: Select all

	#define ELM_TIMEOUT 9000
	#define ELM_BAUD_RATE 9600
	#define ELM_PORT Serial
The library itself then checks if these are defined and if not defines them with the above defaults.

Where I'm going with this is that if I locally defined these in my code prior to including the library, then the library definitions override my local definitions.

I can't figure out why this would be.

I edited the library header file in the end to use Serial3 and this got things working.
-------------------------------------
https://github.com/BennehBoy

Post Reply