diff options
author | Joel Bodenmann <joel@embedded.pro> | 2017-02-18 16:34:15 +0100 |
---|---|---|
committer | Joel Bodenmann <joel@embedded.pro> | 2017-02-18 16:34:15 +0100 |
commit | 170869dea9a544335d2b0d98bb74eddc2afdc7e6 (patch) | |
tree | de35d2ba304bd813858d73f29b137e178f0e3295 /boards/base/Altera-MAX10-Neek | |
parent | d3e995549655106a24d1089add89c1f674aa5d60 (diff) | |
download | uGFX-170869dea9a544335d2b0d98bb74eddc2afdc7e6.tar.gz uGFX-170869dea9a544335d2b0d98bb74eddc2afdc7e6.tar.bz2 uGFX-170869dea9a544335d2b0d98bb74eddc2afdc7e6.zip |
Added complete support for Altera Terasic MAX10 NEEK board
Diffstat (limited to 'boards/base/Altera-MAX10-Neek')
-rw-r--r-- | boards/base/Altera-MAX10-Neek/board.mk | 3 | ||||
-rw-r--r-- | boards/base/Altera-MAX10-Neek/board_alteraframereader.h | 30 | ||||
-rw-r--r-- | boards/base/Altera-MAX10-Neek/board_framebuffer.h | 62 | ||||
-rw-r--r-- | boards/base/Altera-MAX10-Neek/gmouse_lld_FT5316_board.h | 106 | ||||
-rw-r--r-- | boards/base/Altera-MAX10-Neek/readme.txt | 3 |
5 files changed, 140 insertions, 64 deletions
diff --git a/boards/base/Altera-MAX10-Neek/board.mk b/boards/base/Altera-MAX10-Neek/board.mk index bc0d4652..9e8a0d90 100644 --- a/boards/base/Altera-MAX10-Neek/board.mk +++ b/boards/base/Altera-MAX10-Neek/board.mk @@ -3,4 +3,5 @@ GFXSRC += GFXDEFS += GFXLIBS += -include $(GFXLIB)/drivers/gdisp/framebuffer/driver.mk +include $(GFXLIB)/drivers/gdisp/alteraframereader/driver.mk +include $(GFXLIB)/drivers/ginput/touch/FT5316/driver.mk diff --git a/boards/base/Altera-MAX10-Neek/board_alteraframereader.h b/boards/base/Altera-MAX10-Neek/board_alteraframereader.h new file mode 100644 index 00000000..af6dca82 --- /dev/null +++ b/boards/base/Altera-MAX10-Neek/board_alteraframereader.h @@ -0,0 +1,30 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +#define SCREEN_WIDTH 800 +#define SCREEN_HEIGHT 480 +#define FRAMEREADER_BASE ALT_VIP_VFR_0_BASE + +#if GDISP_NEED_CONTROL + static void board_backlight(GDisplay* g, uint8_t percent) + { + (void) g; + (void) percent; + } + + static void board_contrast(GDisplay* g, uint8_t percent) + { + (void) g; + (void) percent; + } + + static void board_power(GDisplay* g, powermode_t pwr) + { + (void) g; + (void) pwr; + } +#endif diff --git a/boards/base/Altera-MAX10-Neek/board_framebuffer.h b/boards/base/Altera-MAX10-Neek/board_framebuffer.h deleted file mode 100644 index 4943b187..00000000 --- a/boards/base/Altera-MAX10-Neek/board_framebuffer.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * This file is subject to the terms of the GFX License. If a copy of - * the license was not distributed with this file, you can obtain one at: - * - * http://ugfx.org/license.html - */ -#include <system.h> -#include <io.h> - -#define SCREEN_WIDTH 800 -#define SCREEN_HEIGHT 480 -#define GDISP_LLD_PIXELFORMAT GDISP_PIXELFORMAT_RGB888 - -#ifdef GDISP_DRIVER_VMT - - static void board_init(GDisplay* g, fbInfo* fbi) - { - g->g.Width = SCREEN_WIDTH; - g->g.Height = SCREEN_HEIGHT; - g->g.Backlight = 100; - g->g.Contrast = 50; - fbi->linelen = g->g.Width * sizeof(LLDCOLOR_TYPE); // bytes per row - fbi->pixels = gfxAlloc(SCREEN_WIDTH * SCREEN_HEIGHT * sizeof(LLDCOLOR_TYPE)); // pointer to the memory frame buffer - if (!fbi->pixels) { - gfxHalt("Couldn't allocate memory for framebuffer\r\n"); - } - - // Let the framebuffer reader know where to find the framebuffer - IOWR(FRAMEBUFFER_READER_BASE, 0, (alt_u32*)fbi->pixels); - - // Make sure the MSB is set so we bypass the data cache - fbi->pixels = (void*)((char*)fbi->pixels + 0x80000000); - } - - #if GDISP_HARDWARE_FLUSH - static void board_flush(GDisplay* g) - { - (void) g; - } - #endif - - #if GDISP_NEED_CONTROL - static void board_backlight(GDisplay* g, uint8_t percent) - { - (void) g; - (void) percent; - } - - static void board_contrast(GDisplay* g, uint8_t percent) - { - (void) g; - (void) percent; - } - - static void board_power(GDisplay* g, powermode_t pwr) - { - (void) g; - (void) pwr; - } - #endif - -#endif /* GDISP_LLD_BOARD_IMPLEMENTATION */ diff --git a/boards/base/Altera-MAX10-Neek/gmouse_lld_FT5316_board.h b/boards/base/Altera-MAX10-Neek/gmouse_lld_FT5316_board.h new file mode 100644 index 00000000..0987f369 --- /dev/null +++ b/boards/base/Altera-MAX10-Neek/gmouse_lld_FT5316_board.h @@ -0,0 +1,106 @@ +/* + * This file is subject to the terms of the GFX License. If a copy of + * the license was not distributed with this file, you can obtain one at: + * + * http://ugfx.org/license.html + */ + +#ifndef _GINPUT_LLD_MOUSE_BOARD_H +#define _GINPUT_LLD_MOUSE_BOARD_H + +#include <stdio.h> +#include <system.h> +#include "i2c_opencores.h" + +#define FT5316_I2C_SLAVE_ADDRESS 0x38 + +// Resolution and Accuracy Settings +#define GMOUSE_FT5316_PEN_CALIBRATE_ERROR 8 +#define GMOUSE_FT5316_PEN_CLICK_ERROR 6 +#define GMOUSE_FT5316_PEN_MOVE_ERROR 4 +#define GMOUSE_FT5316_FINGER_CALIBRATE_ERROR 14 +#define GMOUSE_FT5316_FINGER_CLICK_ERROR 18 +#define GMOUSE_FT5316_FINGER_MOVE_ERROR 14 + +// How much extra data to allocate at the end of the GMouse structure for the board's use +#define GMOUSE_FT5316_BOARD_DATA_SIZE 0 + +// Set this to TRUE if you want self-calibration. +// NOTE: This is not as accurate as real calibration. +// It requires the orientation of the touch panel to match the display. +// It requires the active area of the touch panel to exactly match the display size. +#define GMOUSE_FT5316_SELF_CALIBRATE TRUE + +static unsigned int device_write(unsigned char device_address, unsigned char sub_address, unsigned char wdata) +{ + I2C_start(I2C_OPENCORES_0_BASE, device_address, 0); // Device address in write mode + I2C_write(I2C_OPENCORES_0_BASE, sub_address, 0); // Set sub address to read register + I2C_write(I2C_OPENCORES_0_BASE, wdata, 1); // Set write register + + return 1; +} + +static unsigned int device_read(unsigned char device_address, unsigned char sub_address) +{ + unsigned int rdata; + + I2C_start(I2C_OPENCORES_0_BASE, device_address, 0); // Device address in write mode + rdata = I2C_write(I2C_OPENCORES_0_BASE, sub_address, 0); // Set sub address to read register. + I2C_start(I2C_OPENCORES_0_BASE, device_address, 1); // Send start again but this time in read mode + rdata = I2C_read(I2C_OPENCORES_0_BASE, 1); // Read the register and send stop + + return rdata; +} + +static unsigned int device_read_16(unsigned char device_address, unsigned char sub_address) +{ + unsigned int rdata_l; + unsigned int rdata_h; + + I2C_start(I2C_OPENCORES_0_BASE, device_address, 0); // Eccelerometer address in write mode + rdata_l = I2C_write(I2C_OPENCORES_0_BASE, sub_address, 0); // Set sub address to read register. + I2C_start(I2C_OPENCORES_0_BASE, device_address, 1); // Send start again but this time in read mode + rdata_l = I2C_read(I2C_OPENCORES_0_BASE, 0); // Read the register and MACK + rdata_h = I2C_read(I2C_OPENCORES_0_BASE, 1); // Read the next register and send stop + + return (0xFFFF & ((rdata_h << 8) | rdata_l)); +} + +static bool_t init_board(GMouse* m, unsigned instance) +{ + (void)m; + (void)instance; + + I2C_init(I2C_OPENCORES_0_BASE, 50000000, 400000); + + return TRUE; +} + +static void write_reg(GMouse* m, uint8_t reg, uint8_t val) +{ + (void)m; + + device_write(FT5316_I2C_SLAVE_ADDRESS, reg, val); +} + +static uint8_t read_byte(GMouse* m, uint8_t reg) +{ + (void)m; + uint8_t ret = 0; + + ret = (uint8_t)device_read(FT5316_I2C_SLAVE_ADDRESS, reg); + + return ret; +} + +static uint16_t read_word(GMouse* m, uint8_t reg) +{ + (void)m; + uint16_t ret = 0; + + ret = (uint16_t)device_read(FT5316_I2C_SLAVE_ADDRESS, reg); + + return ret; +} + +#endif /* _GINPUT_LLD_MOUSE_BOARD_H */ diff --git a/boards/base/Altera-MAX10-Neek/readme.txt b/boards/base/Altera-MAX10-Neek/readme.txt index 1a043097..979b422e 100644 --- a/boards/base/Altera-MAX10-Neek/readme.txt +++ b/boards/base/Altera-MAX10-Neek/readme.txt @@ -6,4 +6,5 @@ In order to use this board file, the following things are needed: data cache if the MSB is set. On this board uGFX currently supports: - - GDISP via the framebuffer driver + - GDISP via the altraframereader driver + - GINPUT via the FT5316 mouse/touchscreen driver |