Skip to content

Latest commit

 

History

History
72 lines (59 loc) · 4.41 KB

LIBRARIES.md

File metadata and controls

72 lines (59 loc) · 4.41 KB

LM-8 Libraries

Several assembly library files are included in the programs/libraries directory to provide commonly used functionality.

Math

As the name would imply, this library provides math utility functions for performing common calculations. Currently, provides subroutines for modulus, division, multiplication, and addition.

Serial

This library has subroutines for initializing the UART serial pins and printing null terminated strings out over serial. Uses Arduino pin 0 for RX and pin 1 for TX. Supports 8-bit and 16-bit string addresses.

SPI

The SPI library provides utility subroutines for initializing the SPI pins and transferring data with an SPI slave device. The SPI data transfer requires 3 wires and uses GPIO pins 4, 5, and 6. These handle communicating with a selected device, but the caller is responsible for selecting said device by setting a pin responsible for that device's chip-select line low. Since this is a "Software SPI" implementation, the performance will be much more limited than if it was hardware based, but because the clock is set by the master device, this just amounts to it being slower rather than not working at all.

SD Card

The SD library handles interacting with an SDHC or SDXC card over SPI. Only modern cards are supported to simplify the block addressing code. The library allows for easily initializing the SD card, retrieving card info, and requesting block reads. See the Bootloader program example usage. Filesystems are not supported due to the complexity, so data must be directly written to the card by means such as flashing an image generated by the Assembler with the memory flag using Etcher.

I2C

This is a "Software I2C" implementation that works at around 400 KHz and communicates with I2C slave peripherals. The SSD1306 and LCD libraries contain usage examples.

SSD1306 OLED Display

This library enables initializing and outputting to a 128x64 SSD1306 OLED display. It uses a 1 KB display buffer to enable drawing to specific pixels and then updating the display with the entire buffer. Includes subroutines for tasks like drawing converted images, sprites, and clearing the buffer with a color. Before initializing the display you must specify the I2C address of the display in the [ssd1306_address] variable. Binary monochrome images can be generated using the image_convert.py script with the -t oled parameter using a 128x64 image and will use 1 KB of ROM space each.

I2C LCD Display

This adds support for interfacing with 4 row I2C driven LCDs. It's based off of the Adafruit Arduino library, so the same basic functionality is provided. Doesn't support creating custom characters.

PCA9685 PWM Expander

The PCA9685 is an I2C controlled 12-channel PWM driver used by common Arduino PWM expander boards. The library allows using all of the basic functionality provided by the chip. See Servo Wave for an example on calculating and setting the board frequency and controlling pin duty cycles. Though the PCA9685 has 12-bit duty cycle control, only the top 8 most significant bits are used for simplicity. The library doesn't allow explicitly setting the on/off ticks for channels, instead taking just the duty cycle as a parameter, since that should cover most applications.

Graphics

This library is responsible for graphics utility subroutines corresponding to the VGA/emulator display output. Currently, only provides a software sprite drawing routine.

Utilities

Utility routines that didn't fit other categories. Has a subroutine for testing whether running in RAM or not. Provides convenience subroutines for delaying using a specified timer.

ESP-01 Modem

This library provides routines for interacting with an ESP8266/ESP32 microcontroller with a stock firmware, acting as an AT command compatible modem. Only supports interacting with a single client for simplicity. Using the modem occupies the serial port, so standard serial monitor usage is limited, though telnet is supported over the modem. Since it is using a stock firmware to act just as a simple modem over UART, I feel that it's still in the spirit of the project to use a microcontroller. See Telnet Display for example telnet communication and general modem usage.

Wii Nunchuk

This allows querying the state of Wii expansion controllers over I2C. Currently only supports the Nunchuk. A logic level converter is required to safely interact with the 3.3V Nunchuk I2C interface from the dev board's 5V I2C bus.