![]() |
ucglib_xmega_hal
3.0
Xmega Hardware Abstraction Layer for Ucglib
|
This is the Xmega Hardware Abstraction Layer for the C implementation of the ucglib library from Oli Kraus
The C implementation of the ucglib library can be found at https://github.com/olikraus/ucglib/tree/master/csrc
This HAL contains four c- and h-files:
ucglib_xmega_hal.c | Functions for the HAL |
ucglib_xmega.h | Prototypes and definitions of the HAL including the ucg.h with the extra hook |
ucg.h | An adjusted ucg.h with a extra hook for printing facilities |
main_test_hal.c | An example for a 1.8 inch TFT LCD Module |
The struct ucg_t
in the adjusted ucg.h
has an extra field at the end on the struct:
* #ifdef __AVR_XMEGA__ * void *xmega_hook; // added pointer for print hook * #endif
This HAL also contains a precompiled library for the ATxmega256a3u:
ucglib_xmega.a | All precompiled functions of ucglib and all precompiled functions of the HAL |
ucglib_xmega.h | Prototypes and definitions of the HAL including the ucg.h with the extra hook |
main_test_library.c | An example for a 1.8 inch TFT LCD Module |
You can use the precompiled library
The examples uses the 32 MHz clock. So you need clock.c and clock.h from http://dolman-wim.nl/xmega/libraries/index.php
#
define
's to define the connections.These are the steps for using ucglib with a Xmega
* Display Xmega * VCC 3V3 * GND GND * CS D4 (SS) * RESET D3 * A0 (DC or CD) D2 * SDA D5 (MOSI) * SCK D7 (SCK) * LED (BLK) D1 * D6 (MISO) not connected
These are the steps for using the precompiled atxmega256a3u library
* Display Xmega * VCC 3V3 * GND GND * CS D4 (SS) * RESET D3 * A0 (DC or CD) D2 * SDA D5 (MOSI) * SCK D7 (SCK) * LED (BLK) D1 * D6 (MISO) not connected
These are the steps for building a precompiled static library
This HAL uses for the serial communication SPI or bit banging. With SPI the display must connected to one of the SPI's of the Xmega. With bit banging all connections are available
The test uses this 1.8 inch TFT LCD Module:
![]() |
The configuration for using SPI of port D. Declare an array of pins for the non-SPI connections
* pin_t connectArraySPI[] = { * { UCG_XMEGA_PIN_RST, &PORTD, PIN3_bp }, // RST * { UCG_XMEGA_PIN_CD, &PORTD, PIN2_bp }, // CD * { UCG_XMEGA_PIN_BLK, &PORTD, PIN1_bp }, // BLK * { UCG_XMEGA_PIN_NULL } * };
Call the connect function before you call ucg_Init
:
* ucg_connectXmega(&SPID, connectArraySPI, 0);
The configuration for bit banging Declare an array all connections
* pin_t connectArrayBBcompatibelSPID[] = { * { UCG_XMEGA_PIN_SCK, &PORTD, PIN7_bp }, // SCK * { UCG_XMEGA_PIN_SDA, &PORTD, PIN5_bp }, // SDA * { UCG_XMEGA_PIN_CS, &PORTD, PIN4_bp }, // CS * { UCG_XMEGA_PIN_RST, &PORTD, PIN3_bp }, // RST * { UCG_XMEGA_PIN_CD, &PORTD, PIN2_bp }, // CD * { UCG_XMEGA_PIN_NULL } * };
Call the connect function before you call ucg_Init
:
* ucg_connectXmega(NULL, connectArrayBBcompatibelSPID, 0);
The BLK connection of the display can be connected to the Xmega or external to VCC. If the third parameter in the function ucg_connectXmega()
is 1 the pin of the Xmega that is connected to BLK will be disabled. This makes it possible to make a tight connection between the Xmega an the display on a breadboard.
![]() |
The connections are listed here:
* Display Xmega/power * VCC 3V3 * GND GND * CS D0 * RESET D1 * A0 (DC or CD) D2 * SDA D3 * SCK D4 * LED (BLK) D5 (Disabled), connect LED direct to 3V3 or 5V
From version 2.1 a function ucg_BitmapPrint() is added. This function prints a bitmap to the display. The bitmap is an array with rgb-pixels. The size of the array may not exceed the 32K limit. Pictures larger than 32K must be split in smaller blocks.
Two examples can be found in the folder examples.
A non-AVR program to split a PNG file in multiple arrays can be found in the folder gcc.
This library is free software. You can redistribute it and/or modify it. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY.