Getting Started with MitiPy and FreeRTOS
This page outlines a basic guide to getting starting using the Mitipy.
|The MitiPy FreeRTOS software build is currently under development and will be available for download in the near future.|
- Desktop PC (Windows/Linux/Mac will work)
- Micro-USB to USB Cable
- ST-LINK/V2 in-circuit debugger/programmer for STM8 and STM32 with JTAG 20 pin to SWD 10pin adaptor
- A MitiPy
- A method to power the board, either an ethernet cable with POE (Power Over Ethernet) injector, or a power supply and a wired connector for ST1
1. Download and install STM32CubeIDE (The IDE used for MitiPy FreeRTOS development, For more information on the STM32CubeIDE click HERE)
2. Download EMAC's MitiPy FreeRTOS project master branch HERE
3. Connect the ST-Link programmer to the MitiPy board for programming
- Connect the 10 pin SWD connector (small ribbon cable) to the MitiPy Board HDR3. Ensure the the painted red wire of the cable is on the same side as the arrow.Connect the other end to the adaptor, again ensuring the arrow is aligned with painted red wire. Connect the ST-Link to the adaptor with the large ribbon cable, and connect the ST-LINK to your desktop with it's provided USB cable
4. Connect your MitiPy to the Desktop using the micro-USB to USB cable. This will provide a menu through a serial terminal.
5. Apply power to the board either by POE or ST1. If using ST1 acceptable input voltages range from 8V to 32V
6. Open STM32CubeIDE and import the MitiPy FreeRTOS project
- If needed, upgrade your ST-LINK firmware by navigating to Help and selecting ST-LINK Upgrade. The ST Link upgrade window will open. Select refresh device list, and then select Open in update mode, and finally Upgrade
- To build and upload select the debug symbol (To just build select the hammer symbol).
Developing with the Mitipy
1.The baseline MitiPy FreeRTOS build has now been uploaded. Connect to the USB virtual com port on a serial terminal using Putty or TerraTerm. The USB virtual com port driver should install automatically after plugging the MitiPy to your PC. After successful installation of the driver STMMicroelectronics Virtual COM Port should be displayed as an available port. Connect to it as you would any normal serial port.
- Using a serial terminal program like Putty or Tera Term connect to the port at a baud rate of 115200.
|The USB virtual com port will adjust it's baud rate to that selected by the terminal. It has been tested to work with standard baud rate selections from 110 to 921600.|
2.After connecting the MitiPy FreeRTOS menu will be displayed. Navigate to tests for a demonstration of MitiPy functionality.
EMAC MitiPy FreeRTOS Software Description
The MitiPy_FreeRTOS project was developed using the STM32CubeIDE. It contains auto-generated program files and code along with custom files/folders provided by EMAC.
|Editing of auto-generated code blocks and files should be avoided as these portions of the project will be overwritten if the auto-code generation feature of STM32CubeIDE is used (STM32CubeMX). Instead, we recommend the user create their own custom folders in the project or just use the EMAC provided folder, MitiPy_User for project development.|
Custom EMAC folder include:
- MitiPy_Drivers provides custom written EMAC driver functions geared towards use with the MitiPy device. All functions are documented in their respective source files, hence the user should look here for function usage-rules and functionality. The functions written at a MitiPy module (COM A, COM B, SD_CARD, RS9116 radio, etc.) or individual driver level and were written with ease of use in mind.MP_FRTOS.c/h contains all FreeRTOS element declarations (Task handles, mutex handle, etc.) Here system level tasks and priorities can be adjusted if needed. MitiPy_Config.h, contains options to turn off the menu to save memory space.
- MitiPy_Tasks contains the header and source files for the MitiPy freeRTOS for all EMAC provided system tasks. Task descriptions are provided in their respective source files
- MitiPy_User is an empty project folder dedicated for use by the user.
- RS9116_1_2_1 and 'RS9116_1_2_1/examples/utilities contain driver files for the Redpine Signals RS9116 radio module.
The only folders of real importance to the user is the MitiPy_Drivers folder. In addition to containing key driver functions it also contains MP_FRTOS.c that lists system task priority, handle and size, and
Other project folders include:
- Middlewares - contains source files for the USB Virtual Com Port, fatfs (used mainly in conjuction with the sd card), and FreeRTOS.
- Drivers - contains STMicroelectronic's driver files. The user should look here for driver functionality not covered by the provide emac driver files
- Src - contains initialization functions, and main.c
- Inc - contains various include files, but the only one of primary importance FreeRTOSConfig.h file
MitiPy RTOS system-level tasks and synchronization have been provided by EMAC to ease user development.
EMAC has provided custom driver functions for the MitiPy's main peripherals. These are located under MitiPy_Drivers. See the source files for function descriptions. All of EMAC's custom functions will be prefixed by MP_ followed by the the DRIVER_NAME. Functions with the prefix MP_FRTOS utilize an RTOS element and should only be called with the scheduler running. We recommend user files be added to the MitiPy_User or that the user add their own custom folders, and not modify the project code directly. EMAC has provide custom system tasks to ease MitiPy use and jump-start user development.
ADCs - The MitiPy utilizes the STM32F407's 3 internal ADCs. Thirteen ADC pins are available to the user on HDR2. MP_ADC.c MP_FRTOS functions provide thread safe functionality through mutex control of the 3 ADC's. Aside from 'external' pin sampling this driver file also provide functions for sampling the internal temp sensor, the ram back up battery voltage, and the internal reference voltage (used for calculating the voltage from a raw read)
BATTERIES - The CuitPy has the option of being powered by an external 3.7 V 1200mah lithium ion rechargeable battery (EMAC Part#: PER-PWR0101PR0). It also has an onboard, jumper-enable 3.3V RTC-Ram Retention battery (See the MitiPy User Manual for more information. MP_BATTERIES.c contains functions for reading these battery voltages.
'BUTTONS - There are 2 buttons on the MitiPy, 1 Reset button + 1 user buttons (PB1 and PB2 respectively). PB2 is interrupt driven (rising and falling edge), hence its respective task only runs when an interrupt generated. A Callback function is provided in MP_BUTTONS.C. The user may simply edit these functions directly, to implement unique callback functionality. Button Tasks are located in MP_BUTTONS.c
CAN - CAN communication is provided through HDR4 CAN1. The CAN1 subsystem consists of the STM32407's onboard CAN1 module an external CAN tranceiver (TCAN334GDCNT). MP_CAN.c contains easy-to-use functions for message reception/transmission, and module/tranceiver mode manipulation. An example use function is also included, as well as an internal loopback test. Note CAN1 is currently configured for baud rate of 500kHz.
COM_A - COM_A consists of UART2 routed to an external RS-232 transceiver connected to the CN2 (The DB9 port). It is configured for baud rate of 115200. MP_COM_A.c provide driver functions for transceiver configuration and message transmission and reception. Two seperate mutexes are provided (MP_COM_A_RX_RecursiveMutexHandle and MP_COM_A_TX_RecursiveMutexHandle).
COM_B - COM_B consists of UART3 an RS232 transceiver and an RS422/485 transceiver. The active transceiver is user selectable, and only one can be active at a time. MP_COM_B.c provides driver functions for message transmission/receipt and transceiver selection. For thread safe usage a mutex is provided (MP_COM_B_RecursiveMutexHandle).
DACs - The STM32F407 two digital analog converter channels are available on HDR2, pins 20 and 21. Driver functions are provided MP_DAC.c.
DARLINGTON OPEN COLLECTOR DRIVERS - Eight gpios are connected and control 8 darlington pair open collector transistors. The Darlington pair transistors have superior current sinking capabilities when compared to the on-board GPIOs. (See the ULN2803A datasheet for more information). A pull-up resistor connects the Collector end of the Darlington transistor to V_HIDRV-This is left floating, but can be used by the user to enable digital toggling between GND and V_HIDRV. With V_HIDRV left unconnected the darlington transistor is used as a switch, that sinks current in the ON position. MP_DARLINGTON_OC.c provides functions for setting/resetting. Thread safe control is achieved through the use of mutexes(MP_DARLINGTON_OC_PGX_RecursiveMutexHandle). Eight indicator LEDs corresponding to the 8 darlington pairs will light up when the when in the ON position.
LEDs - Two user LEDs are present on the MitiPy board (USER_LED0 and USER_LED1) located between the ethernet jack and user push button (LD11). They are controlled through the toggling of GPIO outputs on the MCU. MP_LEDs.c contains easy to use function for the controlling the LEDs (ON, OFF, Toggle)
RNG - The STM32F407 true random number generator (RNG) is pre-initialized. The RNG generates 32 bit random numbers. MP_RNG.c contains simple 'get value' functions. The radio utilizes the RNG for certain encrpytion purposes, for this reason MP_FRTOS_GetRandomValue() should be use for thread-safe access.
RS9116 Wireless Module - The external RS9116 Wireless Module enables the development of Bluetooth Low Energy (BLE), Bluetooth (BT) and WLAN applications. In WLAN mode the RS9116 is able function as an access point or a client. The module also has the ability to operate in dual mode (WLAN +BLE). RS9116.c contains initialization functions for the radio, as well as basic use functions like connect/disconnect and sleep. Other functions and advanced usage is covered in the RS9116 documentation.
MicroSD Card - The MitiPy comes with a MicroSD slot.The MitiPy_FreeRTOS build comes with FatFs for the manipulation of files (See the FatFs documentation for more information). Demos are provided in MP_SD_CARD.c
Skywire Cellular (XBee form factor SOCKET) - Designed with the NimbleLink Skywire embedded cellular modem family in mind, the MitiPy is provisioned with an XBee socket hardware configurable to 3.3 or 3.8 Volts DC.
mDot LoRa (XBee form factor SOCKET) - Designed with the Multitech mDot Long Range LoRa Module in mind, the MitiPy is provisioned with an XBee socket jumper configurable to 3.3 or 5.0 Volts DC. MultiTech mDot is a secure, CE/FCC/RCM/GITEKI certified,Arm® Mbed™ programmable, low-power RF module, that provideslong-range, low bit rate M2M data connectivity to sensors,industrial equipment and remote appliances.The mDot is LoRaWAN® 1.0.2 compliant, providing bi-directional data communication up to 10 miles / 15 km line-of-sight and 1-3 miles / 2 km into buildings**, using sub-GHz ISM bands inNorth America, Europe, Australia and Asia Pacific (AS923). mDots bring intelligence, reduced complexity and a lower overall bill of material cost to the very edge of the network while supporting a variety of electronic interfaces to connect just about any “Thing” for years on battery power.
Ethernet - A POE 10-100 Base-T Ethernet interface provides both power and a wired network connectivity option.