Skip to content

Commit 74ee970

Browse files
committed
initial commit
0 parents  commit 74ee970

File tree

7 files changed

+625
-0
lines changed

7 files changed

+625
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*.swp
2+
firmware/*
3+
build/*

Makefile

+147
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# tnx to mamalala
2+
# Changelog
3+
# Changed the variables to include the header file directory
4+
# Added global var for the XTENSA tool root
5+
#
6+
# This make file still needs some work.
7+
#
8+
#
9+
# Output directors to store intermediate compiled files
10+
# relative to the project directory
11+
BUILD_BASE = build
12+
FW_BASE = firmware
13+
14+
# Base directory for the compiler
15+
#XTENSA_TOOLS_ROOT ?= /opt/Espressif/crosstool-NG/builds/xtensa-lx106-elf/bin
16+
XTENSA_TOOLS_ROOT ?= /home/main/esp8266/esp-open-sdk/xtensa-lx106-elf/bin
17+
18+
# base directory of the ESP8266 SDK package, absolute
19+
#SDK_BASE ?= /opt/Espressif/ESP8266_SDK
20+
SDK_BASE ?= /home/main/esp8266/esp-open-sdk/sdk
21+
22+
#Esptool.py path and port
23+
ESPTOOL ?= /home/main/esp8266/esp-open-sdk/esptool/esptool.py
24+
ESPPORT ?= /dev/ttyUSB0
25+
26+
# name for the target project
27+
TARGET = app
28+
29+
# which modules (subdirectories) of the project to include in compiling
30+
MODULES = driver user softuart
31+
EXTRA_INCDIR = include /opt/Espressif/include
32+
33+
# libraries used in this project, mainly provided by the SDK
34+
LIBS = c gcc hal pp phy net80211 lwip wpa main
35+
36+
# compiler flags using during compilation of source files
37+
CFLAGS = -Os -g -O2 -Wpointer-arith -Wundef -Werror -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH
38+
39+
# linker flags used to generate the main object file
40+
LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static
41+
42+
# linker script used for the above linkier step
43+
LD_SCRIPT = eagle.app.v6.ld
44+
45+
# various paths from the SDK used in this project
46+
SDK_LIBDIR = lib
47+
SDK_LDDIR = ld
48+
SDK_INCDIR = include include/json
49+
50+
# we create two different files for uploading into the flash
51+
# these are the names and options to generate them
52+
FW_FILE_1 = 0x00000
53+
FW_FILE_1_ARGS = -bo $@ -bs .text -bs .data -bs .rodata -bc -ec
54+
FW_FILE_2 = 0x40000
55+
FW_FILE_2_ARGS = -es .irom0.text $@ -ec
56+
57+
# select which tools to use as compiler, librarian and linker
58+
CC := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
59+
AR := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-ar
60+
LD := $(XTENSA_TOOLS_ROOT)/xtensa-lx106-elf-gcc
61+
62+
63+
64+
####
65+
#### no user configurable options below here
66+
####
67+
SRC_DIR := $(MODULES)
68+
BUILD_DIR := $(addprefix $(BUILD_BASE)/,$(MODULES))
69+
70+
SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR))
71+
SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR))
72+
73+
SRC := $(foreach sdir,$(SRC_DIR),$(wildcard $(sdir)/*.c))
74+
OBJ := $(patsubst %.c,$(BUILD_BASE)/%.o,$(SRC))
75+
LIBS := $(addprefix -l,$(LIBS))
76+
APP_AR := $(addprefix $(BUILD_BASE)/,$(TARGET)_app.a)
77+
TARGET_OUT := $(addprefix $(BUILD_BASE)/,$(TARGET).out)
78+
79+
LD_SCRIPT := $(addprefix -T$(SDK_BASE)/$(SDK_LDDIR)/,$(LD_SCRIPT))
80+
81+
INCDIR := $(addprefix -I,$(SRC_DIR))
82+
EXTRA_INCDIR := $(addprefix -I,$(EXTRA_INCDIR))
83+
MODULE_INCDIR := $(addsuffix /include,$(INCDIR))
84+
85+
FW_FILE_1 := $(addprefix $(FW_BASE)/,$(FW_FILE_1).bin)
86+
FW_FILE_2 := $(addprefix $(FW_BASE)/,$(FW_FILE_2).bin)
87+
88+
V ?= $(VERBOSE)
89+
ifeq ("$(V)","1")
90+
Q :=
91+
vecho := @true
92+
else
93+
Q := @
94+
vecho := @echo
95+
endif
96+
97+
vpath %.c $(SRC_DIR)
98+
99+
define compile-objects
100+
$1/%.o: %.c
101+
$(vecho) "CC $$<"
102+
$(Q) $(CC) $(INCDIR) $(MODULE_INCDIR) $(EXTRA_INCDIR) $(SDK_INCDIR) $(CFLAGS) -c $$< -o $$@
103+
endef
104+
105+
.PHONY: all checkdirs flash clean
106+
107+
all: checkdirs $(TARGET_OUT) $(FW_FILE_1) $(FW_FILE_2)
108+
109+
$(FW_FILE_1): $(TARGET_OUT)
110+
$(vecho) "FW $@"
111+
$(ESPTOOL) elf2image $< -o $(FW_BASE)/
112+
113+
$(FW_FILE_2): $(TARGET_OUT)
114+
$(vecho) "FW $@"
115+
$(ESPTOOL) elf2image $< -o $(FW_BASE)/
116+
117+
$(TARGET_OUT): $(APP_AR)
118+
$(vecho) "LD $@"
119+
$(Q) $(LD) -L$(SDK_LIBDIR) $(LD_SCRIPT) $(LDFLAGS) -Wl,--start-group $(LIBS) $(APP_AR) -Wl,--end-group -o $@
120+
121+
$(APP_AR): $(OBJ)
122+
$(vecho) "AR $@"
123+
$(Q) $(AR) cru $@ $^
124+
125+
checkdirs: $(BUILD_DIR) $(FW_BASE)
126+
127+
$(BUILD_DIR):
128+
$(Q) mkdir -p $@
129+
130+
firmware:
131+
$(Q) mkdir -p $@
132+
133+
flash: firmware/0x00000.bin firmware/0x40000.bin
134+
-$(ESPTOOL) --baud 115200 --port $(ESPPORT) write_flash 0x00000 firmware/0x00000.bin 0x40000 firmware/0x40000.bin
135+
136+
clean:
137+
$(Q) rm -f $(APP_AR)
138+
$(Q) rm -f $(TARGET_OUT)
139+
$(Q) rm -rf $(BUILD_DIR)
140+
$(Q) rm -rf $(BUILD_BASE)
141+
142+
143+
$(Q) rm -f $(FW_FILE_1)
144+
$(Q) rm -f $(FW_FILE_2)
145+
$(Q) rm -rf $(FW_BASE)
146+
147+
$(foreach bdir,$(BUILD_DIR),$(eval $(call compile-objects,$(bdir))))

softuart/include/softuart.h

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#ifndef SOFTUART_H_
2+
#define SOFTUART_H_
3+
4+
#include "user_interface.h"
5+
6+
#define SOFTUART_MAX_RX_BUFF 64
7+
8+
#define SOFTUART_GPIO_COUNT 16
9+
10+
typedef struct softuart_pin_t {
11+
uint8_t gpio_id;
12+
uint32_t gpio_mux_name;
13+
uint8_t gpio_func;
14+
} softuart_pin_t;
15+
16+
typedef struct softuart_buffer_t {
17+
char receive_buffer[SOFTUART_MAX_RX_BUFF];
18+
uint8_t receive_buffer_tail;
19+
uint8_t receive_buffer_head;
20+
uint8_t buffer_overflow;
21+
} softuart_buffer_t;
22+
23+
typedef struct {
24+
softuart_pin_t pin_rx;
25+
softuart_pin_t pin_tx;
26+
volatile softuart_buffer_t buffer;
27+
uint16_t bit_time;
28+
} Softuart;
29+
30+
31+
BOOL Softuart_Available(Softuart *s);
32+
void Softuart_Intr_Handler(Softuart *s);
33+
34+
35+
//define mapping from pin to functio mode
36+
typedef struct {
37+
uint32_t gpio_mux_name;
38+
uint8_t gpio_func;
39+
} softuart_reg_t;
40+
41+
#endif /* SOFTUART_H_ */

0 commit comments

Comments
 (0)