more hacks
This commit is contained in:
parent
8366bbe163
commit
451f477729
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@ bin/
|
|||||||
generated.*.ld
|
generated.*.ld
|
||||||
.idea
|
.idea
|
||||||
build
|
build
|
||||||
|
STM32F103xx.svd
|
||||||
|
@ -6,28 +6,32 @@ set(CMAKE_C_STANDARD 99)
|
|||||||
|
|
||||||
add_compile_options(
|
add_compile_options(
|
||||||
-Wall
|
-Wall
|
||||||
-Wextra
|
-Wextra -Wshadow -Wno-unused-variable -Wimplicit-function-declaration
|
||||||
-Wconversion
|
-Wredundant-decls -Wstrict-prototypes -Wmissing-prototypes
|
||||||
-Wsign-conversion
|
|
||||||
-ggdb3
|
-ggdb3
|
||||||
-Os
|
-O0
|
||||||
|
)
|
||||||
|
|
||||||
|
add_link_options(
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
add_compile_definitions(
|
add_compile_definitions(
|
||||||
STM32F1
|
STM32F1
|
||||||
|
STM32F103C8T6
|
||||||
DEBUG
|
DEBUG
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(dht_test main.c)
|
add_executable(dht_test main.c)
|
||||||
|
|
||||||
set_target_properties(dht_test PROPERTIES
|
set_target_properties(dht_test PROPERTIES SUFFIX .elf)
|
||||||
SUFFIX .elf
|
|
||||||
)
|
|
||||||
|
|
||||||
target_include_directories(dht_test PRIVATE
|
|
||||||
${LIBOPENCM3_DIR}/include
|
|
||||||
RTT
|
|
||||||
)
|
|
||||||
|
|
||||||
add_custom_target(libopencm3 make TARGETS=stm32/f1 -j8 WORKING_DIRECTORY ${LIBOPENCM3_DIR})
|
add_custom_target(libopencm3 make TARGETS=stm32/f1 -j8 WORKING_DIRECTORY ${LIBOPENCM3_DIR})
|
||||||
link_directories(${LIBOPENCM3_DIR}/lib)
|
#link_directories(${LIBOPENCM3_DIR}/lib)
|
||||||
|
target_link_libraries(dht_test PUBLIC ${LIBOPENCM3_DIR}/lib/libopencm3_stm32f1.a)
|
||||||
|
|
||||||
|
add_subdirectory(RTT)
|
||||||
|
target_link_libraries(dht_test PUBLIC RTT)
|
||||||
|
|
||||||
|
target_include_directories(dht_test PUBLIC
|
||||||
|
RTT ${LIBOPENCM3_DIR}/include
|
||||||
|
)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": 2,
|
"version": 3,
|
||||||
"cmakeMinimumRequired": {
|
"cmakeMinimumRequired": {
|
||||||
"major": 3,
|
"major": 3,
|
||||||
"minor": 19,
|
"minor": 19,
|
||||||
@ -11,7 +11,8 @@
|
|||||||
"displayName": "Default Config",
|
"displayName": "Default Config",
|
||||||
"description": "Default build using Ninja generator",
|
"description": "Default build using Ninja generator",
|
||||||
"generator": "Ninja",
|
"generator": "Ninja",
|
||||||
"binaryDir": "${sourceDir}/build/default"
|
"binaryDir": "${sourceDir}/build",
|
||||||
|
"toolchainFile": "toolchain-STM32F1.cmake"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"buildPresets": [
|
"buildPresets": [
|
||||||
|
21
README.md
21
README.md
@ -1,7 +1,22 @@
|
|||||||
## Build
|
## Build
|
||||||
|
|
||||||
0. git submodule update --init (This is only needed once)
|
First time:
|
||||||
1. make -C libopencm3 # (Only needed once)
|
|
||||||
2. make
|
0. `git submodule update --init`
|
||||||
|
1. `make -C libopencm3`
|
||||||
|
2. `cmake -S . --preset=default`
|
||||||
|
|
||||||
|
or older cmake:
|
||||||
|
|
||||||
|
2. `cmake -S . -B build -DCMAKE_TOOLCHAIN_FILE=toolchain-STM32F1.cmake`
|
||||||
|
|
||||||
|
And then to build an `.elf`
|
||||||
|
|
||||||
|
0. `cmake --build build --verbose`
|
||||||
|
|
||||||
|
|
||||||
|
## RTT debug console
|
||||||
|
|
||||||
|
run this while `openocd` is running
|
||||||
|
|
||||||
|
while true; do telnet localhost 9090; sleep 1; done
|
||||||
|
8
RTT/CMakeLists.txt
Normal file
8
RTT/CMakeLists.txt
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
add_library(RTT
|
||||||
|
SEGGER_RTT.c
|
||||||
|
SEGGER_RTT_printf.c
|
||||||
|
SEGGER_RTT_Syscalls_GCC.c
|
||||||
|
)
|
||||||
|
target_include_directories(RTT
|
||||||
|
INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
)
|
24
main.c
24
main.c
@ -26,6 +26,8 @@
|
|||||||
|
|
||||||
#include <SEGGER_RTT.h>
|
#include <SEGGER_RTT.h>
|
||||||
|
|
||||||
|
#define puts(s) SEGGER_RTT_WriteString(0, s);SEGGER_RTT_WriteString(0,"\n")
|
||||||
|
|
||||||
#define DHT_PORT GPIOB
|
#define DHT_PORT GPIOB
|
||||||
#define DHT_PIN GPIO0
|
#define DHT_PIN GPIO0
|
||||||
|
|
||||||
@ -197,7 +199,7 @@ static void dht_start(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Parse received DHT11 bit timing data from g_dht_vals and print out pretty values
|
// Parse received DHT11 bit timing data from g_dht_vals and print out pretty values
|
||||||
static void dht_parse_data(){
|
static void dht_parse_data(void) {
|
||||||
int8_t data[5] = {0};
|
int8_t data[5] = {0};
|
||||||
uint8_t checksum = 0;
|
uint8_t checksum = 0;
|
||||||
int data_index = 0;
|
int data_index = 0;
|
||||||
@ -231,16 +233,16 @@ static void dht_parse_data(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Just toggle the data pin, used only for debugging
|
// Just toggle the data pin, used only for debugging
|
||||||
static void dht_start_signal(void)
|
//static void dht_start_signal(void)
|
||||||
{
|
//{
|
||||||
gpio_set_mode(DHT_PORT, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, DHT_PIN);
|
// gpio_set_mode(DHT_PORT, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, DHT_PIN);
|
||||||
gpio_clear(DHT_PORT, DHT_PIN);
|
// gpio_clear(DHT_PORT, DHT_PIN);
|
||||||
delay(100000);
|
// delay(100000);
|
||||||
//delay(30000);
|
// //delay(30000);
|
||||||
gpio_set(DHT_PORT, DHT_PIN);
|
// gpio_set(DHT_PORT, DHT_PIN);
|
||||||
delay(100);
|
// delay(100);
|
||||||
gpio_set_mode(DHT_PORT, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, DHT_PIN);
|
// gpio_set_mode(DHT_PORT, GPIO_MODE_INPUT, GPIO_CNF_INPUT_PULL_UPDOWN, DHT_PIN);
|
||||||
}
|
//}
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
|
@ -3,14 +3,12 @@ set(CMAKE_SYSTEM_VERSION Cortex-M3-STM32F1)
|
|||||||
|
|
||||||
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
|
set(CMAKE_C_COMPILER arm-none-eabi-gcc)
|
||||||
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
|
set(CMAKE_CXX_COMPILER arm-none-eabi-g++)
|
||||||
|
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
|
||||||
|
|
||||||
|
set(ARM_OPTIONS -mcpu=cortex-m3 -mthumb -msoft-float)
|
||||||
set(ARM_OPTIONS -mcpu=cortex-m4 -mfloat-abi=soft --specs=nano.specs)
|
|
||||||
|
|
||||||
add_compile_options(
|
add_compile_options(
|
||||||
${ARM_OPTIONS}
|
${ARM_OPTIONS}
|
||||||
-fmessage-length=0
|
|
||||||
-funsigned-char
|
|
||||||
-ffunction-sections
|
-ffunction-sections
|
||||||
-fdata-sections
|
-fdata-sections
|
||||||
-MMD
|
-MMD
|
||||||
@ -20,12 +18,21 @@ add_compile_options(
|
|||||||
|
|
||||||
add_link_options(
|
add_link_options(
|
||||||
${ARM_OPTIONS}
|
${ARM_OPTIONS}
|
||||||
--specs=rdimon.specs
|
-specs=nano.specs
|
||||||
-u_printf_float
|
-specs=nosys.specs # puts does not work.....
|
||||||
-u_scanf_float
|
#-specs=rdimon.specs
|
||||||
|
LINKER:-lc
|
||||||
|
LINKER:-lgcc
|
||||||
|
LINKER:-lnosys
|
||||||
|
#-specs=nano.specs
|
||||||
|
#-u_printf_float
|
||||||
|
#-u_scanf_float
|
||||||
-nostartfiles
|
-nostartfiles
|
||||||
|
#-Wl,--start-group -lc -lgcc -lnosys -Wl,--end-group
|
||||||
LINKER:--gc-sections
|
LINKER:--gc-sections
|
||||||
LINKER:--build-id
|
LINKER:--build-id
|
||||||
|
LINKER:-Map=${CMAKE_PROJECT_NAME}.map
|
||||||
|
-T${CMAKE_SOURCE_DIR}/generated.STM32F103C8T6.ld
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user