Using freing code samples in port demo

yuriwolchkov wrote on Friday, November 20, 2009:

Good day.

I have ported the FreeRTOS for the MSP430F5438 mcu and toolchain Code Composer Essentials. Now I’m working on demo application for my port. There is several tasks already working on my development board (MSP-EXP430F5438). It is FlashTasks, IntegerMathTasks, PolledQueueTasks and the task, that checks that all the other tasks are still operating as expected, and that no errors have been detected.

There is only 2 leds on my devboard, but it have an I2C  LCD. So, I thought that I should use it in demos to my port. Writing my own drivers to this LCD will take too much time end efforts, so I decided to use the TI’s demo files, that contains this driver already. But this code isn’t effective, in particular for using in RTOS, because it contains constructs such:

    for(int i=0; i<pack_length; i++)
        while (isI2Cbusy);

Therefore I have a dilemma. At the beginning of my work on port I intended to use TI’s files as is, but now I forced to edit them. And what about programming notation used in the FreeRTOS? Should I rewrite all this sample code from TI with this notation? (there is a lot of code should to be rewritten, and it will take a lot of my time)

Another approach is in creating some process, that will call original functions from TI’s samples. But it seems to me isn’t very good, because this functions throw out a lot of mcu’s cycles.

So what should I do to create an adequate port for my mcu, toolchain, end devboard in current situation?

davedoors wrote on Friday, November 20, 2009:

You could change the busy wait loop to instead block on a binary semaphore and have the I2C generate an interrupt when it has finished its transfer. That way you will not waste CPU cycles polling the I2C.

Alternatively, and very simply, if your design allows it you could just run the task that uses the I2C at the idle priority so more important tasks will always pre-empt it. That will allow you to use the code without modification.

yuriwolchkov wrote on Friday, November 20, 2009:

Thank you for the reply, davedoors. But the main question isn’t how to avoid I2C polling, but what should I do with coding notation (for example naming conventions), and should I to rewrite this TI’s files whith it notation, if I want to publish my port.