One of my second year classes, Microcontrollers I, centred on the understanding of, and design with, general purpose microcontrollers. The course specifically used the TI MSP430F5529 microcontroller and its corresponding development board. A big part of the course was writing software libraries for the sub-systems of the MSP430. The design process for these libraries was generally straight forward. The libraries of code grew out of the data sheets supplied by TI on the sub-systems themselves. Much of the code is 'first draft' in state, but I hope to revisit these libraries when I have more time to create polished works. Below is a listing of libraries I wrote to moderate completion. These libraries were designed for the MSP430F5529 microcontroller specifically, but are likely to work with other chips in the same family, and most MSP430's with a little attention and modification.
The ADC12 Module gives access to a high-precision 12-bit analog to digital converter. Channels can be sampled in independent single shot mode, or a combination of multiple channels repeating or otherwise. The ADC precision can be specified as 8-, 10, or 12-bit width. Sample and hold circuitry can be configured for a variable length of hold time before sampling. Sampling can be triggered by interrupts from timers, input or by the program itself. There are many references to choose from.
HC-SR04 Ultrasonic Ranger Module
This ultrasonic ranger module is a simple to use device for measuring distances between the device and the nearest obstacle. Given a short duration pulse at the input, the HC-SR04 uses pulses of high frequency sound and their echo to gauge the distance to something in front of it. It works best with hard surfaces between 10 cm and 200 cm roughly.
HD44780 Hitachi LCD
The HD44780 is a nearly ubiquitous chipset for dealing with common 16x2 and 20x4 character displays. It is not an I/O efficient platform, utilizing an 8-bit parallel data bus with three address/command lines, but makes up for its appetite in simplicity of use and character ROM.
4x4 Matrix Keypad
Nearly unworthy of an entire library itself, this is an implementation of how to interface with a simple matrix keypad. Rows and columns are used to determine the intersection of a button press.
PCD8544 a.k.a. Nokia 5110 LCD
48 rows and 84 columns of SPI interfacing, LCD agility. The PCD8544 controller is responsible for the addressing and control of the pixel-level functionality. This display gives more control over the detail of what you intend to display, but trades off that access with a steeper difficulty and lack of character ROM.
tdelay and micro_delay Libraries
tdelay is a library solely consisting of delay functions I've written myself for some reason or another. It's not good. I'm not even sure why you're here. Sometimes other libraries reference this one.
micro_delay.asm is an assembly implementation of a delay routine to waste as precisely as possible one microsecond of time. This is bare metal stuff and suffers from the granularity of cycle time. Work will be done to eliminate this monstrosity of assembly.
Timers are useful things for more than just counting time. Timers give rise to Pulse Width Modulation, Servo control, Real Time Clocks, and more. The following libraries are sub-system specific modules for use the timers on the MSP430F5529.
Serial - SPI
SPI is a synchronous serial peripheral interface designed for simple, fast communication on few conductors. SPI is a near second in popularity to the I2C technology. SPI is even used for another library here, the PCD8544 LCD controller.
Serial - UART
Due to its utter simplicity of design, useful back-compatibility, USB prevalence, and relatively easy operation fundamentals, asynchronous serial UART is still a popular technology.
An archive of all the available libraries from above in one archive.