Skip to content
zhu48 edited this page May 12, 2017 · 13 revisions

LauncPadLMC Mini-RTOS

The LaunchPadLMC Mini-RTOS is a bare-bones Real-Time Operating System for the Tiva C LaunchPad, targeting the University of Wisconsin at Madison's NASA Robotic Mining Competition robot.

Project

The project is developed using the Keil uVision Integrated Development Environment mainly because classes here at UW Madison use uVision to teach embedded programming. Anybody seeking to use a different IDE should be aware that the project uses Texas Instruments' driverlib.

Texas Instruments Drivers

Learning to directly manipulate register values has merit, but massively slows down development time. Therefore, we use the driver library published by Texas Instruments to handle direct register read/write.

Texas Instruments Driver Library
http://www.ti.com/tool/SW-TM4C

Additional Documentation
http://www.ti.com/tool/Ek-TM4C123Gxl

Documentation on how to use this library is available at the link or in the docs/ directory in this repository. The code for the driver is also included in the repository under the driverlib/ directory.

Real-Time Operating System

The RTOS is new and fully custom, and therefore feature-sparse. It is only intended to target the M4C123GH6PM on the Tiva C LaunchPad, and it exists for the sole purpose of driving UW Madison's Robotic Mining Competition robot. The RTOS includes almost no safety checks and offers a primitive API. This Wiki will constantly be updated as more details about the API as they become more set in stone.

This repository also includes a collection of tasks tailored to the UW Madison RMC robot.

There is no intention of implementing memory protection, task priority, and privilege control for this year's competition.

Scheduler

The scheduler is a round-robin scheduler which runs every millisecond. On every scheduling run, the scheduler runs every task whose interval timer has run down, as well as every task for which an event has triggered.

The scheduler provides concurrency through the yield() call, and a simple context switching mechanism. Each task has a statically allocated stack space in memory, but no part of memory is protected from corruption. The scheduler will preempt tasks that overrun their allotted time slot, guaranteeing that all tasks that need to run in a scheduling cycle will run. The scheduler allocates an equal share of CPU time to each task, and reassigns unused CPU time to other tasks.

Events

This RTOS supports callbacks for two events, UART events and Quadrature Encoder events. Even though the RTOS supports callbacks for UART events, the kernel manages all UART Tx and Rx interrupts, as well as all transmit and receive buffers and hardware FIFOs. User tasks should not attempt to interact with UART hardware FIFOs.

Tasks

This repository includes four user tasks.

blinky.c The Blinky task periodically toggles the LaunchPad's user LED to indicate everything is okay. It also optionally prints debug information to USB UART.

ctrlLoop.c The Control Loop task uses a PID loop to control PWM generators 0 and 1 in PWM peripheral 0.

SerialReader.c The Serial Reader task decodes Serial commands sent to the LaunchPad over USB UART. It currently only supports wheel speed commands.

radio.c The Radio task controls UART radio modules. Intended targets are the HM-10 and the BTM-05 BLE modules, but this task is in early development.

Debug

Currently, the kernel provides two ways to print out to USB UART. These are the printlit() and kprintf() functions, defined in LMCterminal.h and implemented in LMCterminal.c.

printlit() takes a string literal as input, and prints out out to USB UART.

kprintf() takes parameters exactly like stdio printf(), but only %c, %i, %d, and %l are supported. %l also acts like stdio printf()'s %ll, taking an uint64_t.

Clone this wiki locally