Over the last two days I worked on the embedded software for the HydroPWNics Hardware. As mentioned before the hardware is based on FreeScale ARM Cortex M0+ microcontrollers, the Kinetis MKL05Z16VFK4 and MKV10Z16VFM7. To develop and program for these FreeScale MCUs I am using the new FreeScale IDE Kinetis Design Studio. I worked on developing basic hardware libraries to control the hardware peripherals on the microcontrollers, this is he first step before writing an application specific firmware. The process this time around was very different from what I'm used to, it will all be explained in the rest of the post!
Kinetis Design Studio is an eclipse based IDE, (its the expected IDE really, Ti has their own, NXP has their own, etc) it combines the standard Eclipse C/C++ layout with a an array of tools/plugins specific for FreeScale Kinetis ARM Cortex development. KDS is a free tool and uses the GNU ARM GCC toolchain for building projects. In addition to the standard features of the Eclipse-ARM-Cortex-IDE (my generic term for these sorts of IDEs they are mostlty the same) KDS has a neat tool called Processor Expert. Processor Expert is a nifty graphical interface with lots of menu options and a physical representation of the MCU you are using. With Processor Expert you can configure the microcontroller and code libraries for ther peripherals and pins you are using in your happlication with simple context menus. After you configure everything how you like for your application Processor Expert will auto generate logical device drivers for all the hardware peripherals/GPIO you chose in the in configuration!
After playing around with Kinetis Design Studio for a while and Processor Expert, I figured out how to use them correctly and set out to created custom libraries for the HydroPWNics hardware. I started by making charts of the pinouts of the microcontrollers on the PCBs in google docs spreadsheets. The chart shows the physical pin, port name, the function the pin needs to be set to, the function on the PCB, and a note (typically which Kinetis component being used for code generation).For easy viewing I screencapped the documents and the legend below:
Pinout Map Legend
Module Hub Pinout Mapping
Digital Sensor Module Pinout Mapping
Analog Sensor Module Pinout Mapping
MKL05 Processor Expert : This is the Processor Expert View in Kinetis Design Studio, this is for the MKL05 series MCU being used on the sensor modules, you can see that the graphic is the 24 VQFN package being used on the sensor module boards.
MKV10 Processor Expert: Processor Expert view for the MKV10 series MCU being used on the Module hub. This screenshot shows a bit more, it was taken after I finished the configuration. I didn't say much before but configuration is carried out by selecting "Components" that represent a type of code that can be generated for a given function. The options are usually a logical device driver (simple register level driver code), basic init code (just configuring peripheral registers and nothing else), or a high level application device driver. Once components are chosen they are added to the component list for the project. Components after being added need to be configured, this usually amounts to baudrates or clock divisers for serial or timers and pin mapping for peripherals. Configuration is simple and Processor Expert notifies you of conflicts if component configurations are using the same resources or pins. Once configuration is complete code can be generated with the click of a button.
I mentioned earlier how this process has been different than I'm used to, well traditionally a library would have to be written at the register level, by digging through the datasheet. Sometimes a manufacture has a prewritten library that just needs to be compiled but this time there was the Processor Expert feature. I guess this is the new way of doing things and its kind of awesome really, this feature has saved me a lot of time and I look forward to spending more time on the application code than hardware drivers!
The software sources for all the firmware can be found in the HydroPWNicsFirmware github repository here: https://github.com/adamjvr/HydroPWNicsFirmware This is only a start so far, a lot has to be done in the coming weeks but I feel that what got done for this post is a good start given that I don't have any hardware in hand yet. PCBs should be coming in the next few days and I will be ordering components and development hardware soon, stay tuned for more to follow on the embedded software and more of HydroPWNics!