You can use the Swift programming language — well established on Apple devices — on an MCU. We will have a look at the SwiftIO board, integrating an ARM Cortex-M7 Processor and 32-MB RAM.

The MadMachine SwiftIO is a development board in a BeagleBone Black form factor. What makes the board appealing to me is the fact that we have a set of interesting hardware combined with a uncommon software framework. Code can be written in Swift, a programming language well established on Apple devices.

The SwiftIO Hardware

While Swift targets the Apple hardware, the SwiftIO board (Figure 1) from MadMachine will bring the Swift language to the embedded world.

MadMachine SwiftIO board
Figure 1: MadMachine SwiftIO board.

The core components used on the board are:
 

  • NXP i.MX RT1052 Crossover Processor with Arm® Cortex®-M7 core running at 600 MHz
  • 8 MB external QSPI flash
  • 32 MB SDRAM
  • MicroSD card slot, supporting standard and high capacity SD cards

With the i.MX RT1052 the board gets a beefy MCU in its center, whose features can be seen in Figure 2.
 
Figure 2: i.MX RT1052 overview (Source: NXP).

Additionally, the board offers:
 

  • 46 GPIO (general-purpose I/O)
  • 12 ADC channels (12 bit)
  • 14 PWM channels
  • 4 UART
  • 2 CAN (CAN 2.0B)
  • 2 I²C (3.4 MHz max clock)
  • 2D graphic engine
  • RGB display output (1366 x 768 WXGA max)
  • Camera input (CSI 8,16,24 Bit)
 

This is not a complete list of features, but it give you a good idea about the hardware you get. Even the package is compact in size. You get a board, USB cable, a set of stickers and the SwiftIO board with an SD-Card inserted (Figure 3). Everything you need to get started.

A SwiftIO board and more are in the box
Figure 3: What comes inside the box.

The IDE for SwiftIO

When it comes to software development, MadMachine supplies you with an IDE for SwiftIO. This IDE can be downloaded at the website and will basically look like what you see in Figure 4. The IDE is available for Windows and macOS, which is good news for our Apple users.

MadMachine IDE
Figure 4: MadMachine IDE.

If you don’t like the IDE, you can use the provided CLI tools for this board or team those up with XCode or Visual Studio Code for your next project. MadMachines provides a tutorial on how to use the CLI tool.

No Need to Reflash, You Just Need to Copy

The board includes inside the attached SPI flash a bootloader that will copy your application into the SDRAM at boot and execute it from the SDRAM. This makes reprogramming the board easy. The onboard programmer allows writing your code to the attached microSD Card by showing up as mass storage device. Also, you can simply remove the SD card and write your new firmware directly on it.

The SwiftIO Framework

The software got my attention. The SwiftIO framework can be seen in Figure 5 and makes use of the Zephyr RTOS underneath. Access to all the low-level hardware — like GPIOs , analog functions, PWM, I²C and so on — is abstracted, so it should be easy to write our own software without having to deal with all the details of the i.MX 1052 MCU. Also, this takes care of the SDRAM access and initialization as for the SPI flash setup.

Software stack
Figure 5: Software stack (Source: MadMachine.io).

For the programming language used for this board, Swift is commonly used on Apple systems and mostly found in the Apple ecosystem. Swift is not limited to Apple systems and can be used to develop applications also for Linux and since the recent past also Windows. As Swift is a programming language that offers modern elements and concepts having it available on a MCU makes a perfect addition to extend your Swift knowledge.

If you’re wondering what SwiftIO code looks like, Listing 1 demonstrates how to make an LED blink.

Blink demo app
Listing 1: Blink Demo Application.

Listing 2 demonstrates how to use PWM to control the brightness of an LED. More advanced examples are already included, so you can start exploring SwiftIO.

PWM demo app
Listing 2: PWM Demo Application.

Support and Further Documentation

For this board you can easily get support, just go to the MadMachines Discord server and ask your questions in the appropriate chats. As with any platform, use friendly and polite wording; nobody wants trolls around. Even deeper technical questions can be asked. Also, if you miss any documents, asking for it may help.

Final Thoughts

If you are looking for an Arduino-compatible board or something that can be used with C/C++ out of the box, this one is not for you. Also, the board comes at a higher price than most of your usual development boards. If you consider that you have a support, development can be done on all major operating systems and you can use a modern programming language — with a board that works very well out of the box — it is on you to determine your priorities.


Questions or Comments

Do you have technical questions or comments about this article? Email the author at mathias.claussen@elektor.com or contact Elektor at editor@elektor.com.