code re-organized
This commit is contained in:
parent
8234b46a7d
commit
7d313f9f74
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,3 +1,3 @@
|
||||
bin/
|
||||
obj/
|
||||
|
||||
.scannerwork/
|
||||
|
25
Makefile
25
Makefile
@ -1,3 +1,4 @@
|
||||
PLATFORM ?= posix
|
||||
CROSS_COMPILE ?=
|
||||
|
||||
TARGET_FILE ?= test_c
|
||||
@ -18,9 +19,8 @@ UNIT_TEST_OBJ_DIR = $(OBJ_DIR)/$(UNIT_TEST_SRC_DIR)
|
||||
PREFIX ?= /usr
|
||||
BIN_INSTALL_DIR = $(PREFIX)/bin
|
||||
|
||||
INCLUDES := interface/
|
||||
INCLUDES += include/
|
||||
INCLUDES += include/$(ARCH)/
|
||||
INCLUDES += include/platform/$(PLATFORM)/
|
||||
INCLUDES += $(PREFIX)/include/
|
||||
INCLUDES += $(EXTRA_INC)
|
||||
|
||||
@ -39,12 +39,13 @@ C_FLAGS += -fpic
|
||||
|
||||
C_FLAGS += -O0 -ggdb3 -Wall
|
||||
CPP_FLAGS += $(addprefix -I, $(INCLUDES))
|
||||
CPP_FLAGS += -DPLATFORM=$(PLATFORM) -DPLATFORM_$(PLATFORM)
|
||||
|
||||
CHECK_FLAGS = $(addprefix -I,$(filter-out $(PREFIX)/include/,$(INCLUDES)))
|
||||
CHECK_FLAGS += --enable=all --template=gcc --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr --force
|
||||
CHECK_FLAGS += --enable=all --template=gcc --error-exitcode=1 --suppress=missingIncludeSystem --inline-suppr --force --xml --xml-version=2 2> cppcheck-report.xml
|
||||
|
||||
C_SRCS = $(wildcard $(SRC_DIR)/*.c)
|
||||
C_SRCS += $(wildcard $(SRC_DIR)/$(ARCH)/*.c)
|
||||
C_SRCS += $(wildcard $(SRC_DIR)/platform/$(PLATFORM)/*.c)
|
||||
C_OBJS = $(patsubst $(SRC_DIR)%,$(OBJ_DIR)%,$(patsubst %.c,%.o,$(C_SRCS)))
|
||||
|
||||
UNIT_TEST_SRCS = $(wildcard $(UNIT_TEST_SRC_DIR)/*.c) $(filter-out %main.c,$(CC_SRCS))
|
||||
@ -60,7 +61,7 @@ THIS_MAKEFILE := $(lastword $(MAKEFILE_LIST))
|
||||
debug:
|
||||
@echo $(C_SRCS)
|
||||
@echo $(C_OBJS)
|
||||
@echo $(ARCH)
|
||||
@echo $(PLATFORM)
|
||||
@echo $(CPP_FLAGS)
|
||||
|
||||
all: $(TARGET)
|
||||
@ -84,6 +85,12 @@ clean:
|
||||
distclean:
|
||||
rm -rf $(OBJ_DIR) $(BIN_DIR) $(COVERAGE_DIR)
|
||||
|
||||
.PHONY: check
|
||||
check: $(C_SRCS)
|
||||
echo $(C_SRCS)
|
||||
cppcheck $(CHECK_FLAGS) $(C_SRCS)
|
||||
|
||||
|
||||
.PHONY: coverage
|
||||
coverage: _cov_genhtml
|
||||
$(eval COVERAGE:=$(shell grep 'lines' .coverage.tmp | egrep -o '[0-9]+.[0-9]+%'))
|
||||
@ -110,10 +117,6 @@ build_unit_test: $(UNIT_TEST_TARGET)
|
||||
exec_unit_test: $(UNIT_TEST_TARGET)
|
||||
$(UNIT_TEST_TARGET)
|
||||
|
||||
.PHONY: check
|
||||
check: $(CC_SRCS)
|
||||
$(CHECK) $(CHECK_FLAGS) $(CC_SRCS)
|
||||
|
||||
$(UNIT_TEST_TARGET): $(UNIT_TEST_OBJS) $(THIS_MAKEFILE)
|
||||
@mkdir -p $(BIN_DIR)/$(UNIT_TEST_SRC_DIR)
|
||||
$(CC) $(C_FLAGS) $(LD_FLAGS) $(UNIT_TEST_OBJS) -o $@
|
||||
@ -124,7 +127,7 @@ $(TARGET): $(OBJS) $(THIS_MAKEFILE)
|
||||
|
||||
.PRECIOUS: $(OBJ_DIR)/%.d
|
||||
$(OBJ_DIR)/%.d: $(SRC_DIR)/%.c
|
||||
@mkdir -p $(OBJ_DIR)/$(ARCH)
|
||||
@mkdir -p $(OBJ_DIR)/platform/$(PLATFORM)
|
||||
$(CPP) -MM -MF $@ -MP -MT $(patsubst %.d,%.o,$@) $(CPP_FLAGS) $(patsubst $(OBJ_DIR)/%.d,$(SRC_DIR)/%.c,$@)
|
||||
|
||||
.PRECIOUS: $(UNIT_TEST_OBJ_DIR)/%.d
|
||||
@ -133,7 +136,7 @@ $(UNIT_TEST_OBJ_DIR)/%.d: $(UNIT_TEST_SRC_DIR)/%.c
|
||||
$(CPP) -MM -MF $@ -MP -MT $(patsubst %.d,%.o,$@) $(CPP_FLAGS) $(patsubst $(UNIT_TEST_OBJ_DIR)/%.d,$(UNIT_TEST_SRC_DIR)/%.c,$@)
|
||||
|
||||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(OBJ_DIR)/%.d
|
||||
@mkdir -p $(OBJ_DIR)/$(ARCH)
|
||||
@mkdir -p $(OBJ_DIR)/platform/$(PLATFORM)
|
||||
$(CC) -c $(CPP_FLAGS) $(C_FLAGS) $< -o $@
|
||||
|
||||
$(UNIT_TEST_OBJ_DIR)/%.o: $(UNIT_TEST_SRC_DIR)/%.c $(UNIT_TEST_OBJ_DIR)/%.d
|
||||
|
8
include/board.h
Normal file
8
include/board.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef __INCLUDE_BOARD_H__
|
||||
#define __INCLUDE_BOARD_H__
|
||||
|
||||
#ifdef PLATFORM_posix
|
||||
#include "platform/posix/board.h"
|
||||
#endif
|
||||
|
||||
#endif
|
@ -1,8 +1,8 @@
|
||||
#ifndef __BOARD_H__
|
||||
#define __BOARD_H__
|
||||
#ifndef __INCLUDE_PLATFORM_POSIX_BOARD_H__
|
||||
#define __INCLUDE_PLATFORM_POSIX_BOARD_H__
|
||||
|
||||
#include "driver.h"
|
||||
#include "posix/i2c.h"
|
||||
#include "i2c.h"
|
||||
#include "ssd1306.h"
|
||||
#include "st7789.h"
|
||||
#include "gpio.h"
|
16
sonar-project.properties
Normal file
16
sonar-project.properties
Normal file
@ -0,0 +1,16 @@
|
||||
sonar-project.properties
|
||||
|
||||
sonar.projectKey=my:test:project
|
||||
|
||||
sonar.language=c
|
||||
sonar.sources=src
|
||||
sonar.cxx.includeDirectories=include
|
||||
|
||||
# defaults to project key
|
||||
#sonar.projectName=My project
|
||||
# defaults to 'not provided'
|
||||
#sonar.projectVersion=1.0
|
||||
|
||||
sonar.sourceEncoding=UTF-8
|
||||
|
||||
sonar.host.url=https://sonar.blackfinn.de
|
@ -8,7 +8,7 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/i2c-dev.h>
|
||||
|
||||
#include "posix/i2c.h"
|
||||
#include "i2c.h"
|
||||
|
||||
int i2c_open(const struct driver *drv)
|
||||
{
|
54
src/st7789.c
54
src/st7789.c
@ -11,13 +11,6 @@ static void send_data_8bit(const struct driver *drv, uint8_t data);
|
||||
static void lcd_init(const struct driver *drv);
|
||||
static void lcd_set_windows(const struct driver *drv, uint16_t x_start, uint16_t y_start, uint16_t x_end, uint16_t y_end);
|
||||
|
||||
#if 0
|
||||
static void send_data_16bit(const struct driver *drv, uint16_t data);
|
||||
static void lcd_clear(const struct driver *drv, uint16_t color);
|
||||
static void lcd_display(const struct driver *drv, const uint16_t *image);
|
||||
static void lcd_draw_pixel(const struct driver *drv, uint16_t x, uint16_t y, uint16_t color);
|
||||
#endif
|
||||
|
||||
int st7789_open(const struct driver *drv)
|
||||
{
|
||||
assert(drv != NULL);
|
||||
@ -221,50 +214,3 @@ static void lcd_set_windows(const struct driver *drv, uint16_t x_start, uint16_t
|
||||
|
||||
send_cmd(drv, 0X2C);
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void send_data_16bit(const struct driver *drv, uint16_t data)
|
||||
{
|
||||
assert(drv != NULL);
|
||||
|
||||
struct st7789 *this = (struct st7789*)(drv->dev);
|
||||
uint8_t buf[2] = {(data >> 8) & 0xff, data & 0xff};
|
||||
drv_write(this->dc, "1", 1);
|
||||
drv_write(this->spi, (const char* )buf, 2);
|
||||
}
|
||||
|
||||
static void lcd_clear(const struct driver *drv, uint16_t color)
|
||||
{
|
||||
assert(drv != NULL);
|
||||
|
||||
struct st7789 *this = (struct st7789*)(drv->dev);
|
||||
uint16_t image[this->height * this->width];
|
||||
|
||||
color = ((color << 8) & 0xff00) | (color >> 8);
|
||||
for (uint16_t i = 0; i < this->height * this->width; i++) {
|
||||
image[i] = color;
|
||||
}
|
||||
lcd_set_windows(drv, 0, 0, this->width, this->height);
|
||||
drv_write(this->dc, "1", 1);
|
||||
for(uint16_t i = 0; i < this->height; i++) {
|
||||
drv_write(this->spi, (const char *)&image[i * this->width], this->width * 2);
|
||||
}
|
||||
}
|
||||
|
||||
static void lcd_display(const struct driver *drv, const uint16_t *image)
|
||||
{
|
||||
assert(drv != NULL);
|
||||
struct st7789 *this = (struct st7789*)(drv->dev);
|
||||
lcd_set_windows(drv, 0, 0, this->width, this->height);
|
||||
drv_write(this->dc, "1", 1);
|
||||
for (uint16_t i = 0; i < this->height; i++) {
|
||||
drv_write(this->spi, (const char *)&image[i * this->width], this->width * 2);
|
||||
}
|
||||
}
|
||||
|
||||
static void lcd_draw_pixel(const struct driver *drv, uint16_t x, uint16_t y, uint16_t color)
|
||||
{
|
||||
lcd_set_windows(drv, x, y, x + 1, y + 1);
|
||||
send_data_16bit(drv, color);
|
||||
}
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user