summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2017-05-11 11:36:52 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2017-05-11 11:36:52 +0200
commit8665bdbf682bdff02576a6f4393f09bc56572043 (patch)
tree54b1f51c0b3e5f5dd577720a9cd54e28be19d97f
parenteabbd037f5f605a9ecf06185cd62594eb4564bce (diff)
downloadradio-controller-8665bdbf682bdff02576a6f4393f09bc56572043.tar.gz
radio-controller-8665bdbf682bdff02576a6f4393f09bc56572043.tar.bz2
radio-controller-8665bdbf682bdff02576a6f4393f09bc56572043.tar.xz
radio-controller-8665bdbf682bdff02576a6f4393f09bc56572043.zip
wip
-rw-r--r--.gdbinit2
-rw-r--r--CMakeLists.txt5
-rw-r--r--include/radio-controller.h15
-rwxr-xr-xlaunch-openocd16
-rw-r--r--openocd.cfg18
-rw-r--r--src/radio-controller.cpp20
-rw-r--r--stm32cubemx/Inc/main.h8
-rw-r--r--stm32cubemx/Src/main.c2
-rw-r--r--stm32cubemx/Src/stm32f1xx_it.c4
m---------thirdparty/mcu.cmake0
m---------thirdparty/mcucpp0
11 files changed, 71 insertions, 19 deletions
diff --git a/.gdbinit b/.gdbinit
index 3edbdf0..2d3042d 100644
--- a/.gdbinit
+++ b/.gdbinit
@@ -23,6 +23,8 @@ define run_firmware
continue
end
+set print pretty
+
target extended-remote :3333
set confirm off
file build/firmware
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4097d5a..2826974 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,8 +7,9 @@ project(radio-controller C CXX ASM)
set(CMAKE_CXX_STANDARD 14)
-add_executable(firmware src/radio-controller.cpp)
+add_executable(firmware src/radio-controller.cpp include/radio-controller.h)
target_compile_definitions(firmware PUBLIC MCUCMAKE_USING_STM32CUBEMX=1)
+target_include_directories(firmware PUBLIC include)
target_link_libraries(firmware PUBLIC gcc)
mcu_add_executable(TARGET firmware)
@@ -34,7 +35,7 @@ target_include_directories(firmware PUBLIC
)
target_sources(firmware PUBLIC
thirdparty/mcucpp/src/arm/semihosting.cpp
- thirdparty/mcucpp/src/arm/semihosting-putc.cpp
+ thirdparty/mcucpp/src/arm/semihosting-puts.cpp
thirdparty/mcucpp/src/arm/semihosting-putchar.cpp
thirdparty/mcucpp/src/generic/tinyprintf-printf.cpp
thirdparty/mcucpp/src/generic/tinyprintf-snprintf.cpp
diff --git a/include/radio-controller.h b/include/radio-controller.h
new file mode 100644
index 0000000..58f2594
--- /dev/null
+++ b/include/radio-controller.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+void main_pre_init();
+void main_post_init();
+void main_loop();
+
+void it_tim1();
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/launch-openocd b/launch-openocd
new file mode 100755
index 0000000..18b30b2
--- /dev/null
+++ b/launch-openocd
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+stlinkv2=$(lsusb -d 0483:374b | wc -l)
+olimex=$(lsusb -d 15ba:002a | wc -l)
+
+DEVICE=
+if [ $stlinkv2 -gt 0 ]
+then
+ DEVICE=stlinkv2
+elif [ $olimex -gt 0 ]
+then
+ DEVICE=olimex-arm-usb-tiny-h
+fi
+
+export DEVICE
+exec openocd -f openocd.cfg
diff --git a/openocd.cfg b/openocd.cfg
index 15a42d4..48d7292 100644
--- a/openocd.cfg
+++ b/openocd.cfg
@@ -1,5 +1,19 @@
-source [find interface/stlink-v2.cfg]
-source [find target/stm32f1x.cfg]
+if { [info exists env(DEVICE)] } {
+ set device $env(DEVICE)
+} else {
+ set device "stlink-v2"
+}
+
+switch $device {
+ "stlink-v2" {
+ source [find interface/stlink-v2.cfg]
+ }
+ "olimex-arm-usb-tiny-h" {
+ source [find interface/ftdi/olimex-arm-usb-tiny-h.cfg]
+ source [find interface/ftdi/olimex-arm-jtag-swd.cfg]
+ source [find target/stm32f1x.cfg]
+ }
+}
telnet_port disabled
tcl_port disabled
diff --git a/src/radio-controller.cpp b/src/radio-controller.cpp
index 132f581..c71aaa5 100644
--- a/src/radio-controller.cpp
+++ b/src/radio-controller.cpp
@@ -1,28 +1,40 @@
-#include "main.h"
+#include "radio-controller.h"
#include "stm32f1xx_hal.h"
-#include <cstdio>
+#include <cstring>
#include "mcu/arm/semihosting.h"
#ifdef HAL_IWDG_MODULE_ENABLED
extern IWDG_HandleTypeDef hiwdg;
#endif
+extern TIM_HandleTypeDef htim1;
+
void main_pre_init() {
-// SystemInit();
}
void main_post_init() {
semihosting::enable();
+
+ HAL_TIM_Base_Start(&htim1);
}
+static uint32_t tick_next = 0;
+
void main_loop() {
// printf("hello world!");
+ auto now = HAL_GetTick();
+
+ if (now >= tick_next) {
+ uint32_t cnt = __HAL_TIM_GET_COUNTER(&htim1);
+ printf("cnt=%lu, now=%lu\n", cnt, now);
+ tick_next += 1000;
+ }
#ifdef HAL_IWDG_MODULE_ENABLED
HAL_IWDG_Refresh(&hiwdg);
#endif
}
-void it_tim1(TIM_HandleTypeDef *htim1) {
+void it_tim1() {
;
}
diff --git a/stm32cubemx/Inc/main.h b/stm32cubemx/Inc/main.h
index 951e332..3078082 100644
--- a/stm32cubemx/Inc/main.h
+++ b/stm32cubemx/Inc/main.h
@@ -46,8 +46,6 @@
/* Includes ------------------------------------------------------------------*/
/* USER CODE BEGIN Includes */
-#include "stm32f1xx_hal_dma.h"
-#include "stm32f1xx_hal_tim.h"
/* USER CODE END Includes */
/* Private define ------------------------------------------------------------*/
@@ -58,12 +56,6 @@
extern "C" {
#endif
-void main_pre_init();
-void main_post_init();
-void main_loop();
-
-void it_tim1(TIM_HandleTypeDef *htim1);
-
#ifdef __cplusplus
}
#endif
diff --git a/stm32cubemx/Src/main.c b/stm32cubemx/Src/main.c
index 0afb615..e0e60be 100644
--- a/stm32cubemx/Src/main.c
+++ b/stm32cubemx/Src/main.c
@@ -47,7 +47,7 @@
#include "usb_device.h"
/* USER CODE BEGIN Includes */
-
+#include "radio-controller.h"
/* USER CODE END Includes */
/* Private variables ---------------------------------------------------------*/
diff --git a/stm32cubemx/Src/stm32f1xx_it.c b/stm32cubemx/Src/stm32f1xx_it.c
index a71b015..02f62b2 100644
--- a/stm32cubemx/Src/stm32f1xx_it.c
+++ b/stm32cubemx/Src/stm32f1xx_it.c
@@ -36,7 +36,7 @@
#include "stm32f1xx_it.h"
/* USER CODE BEGIN 0 */
-#include "main.h"
+#include <radio-controller.h>
/* USER CODE END 0 */
/* External variables --------------------------------------------------------*/
@@ -234,7 +234,7 @@ void USB_LP_CAN1_RX0_IRQHandler(void)
void TIM1_TRG_COM_IRQHandler(void)
{
/* USER CODE BEGIN TIM1_TRG_COM_IRQn 0 */
- it_tim1(&htim1);
+ it_tim1();
/* USER CODE END TIM1_TRG_COM_IRQn 0 */
HAL_TIM_IRQHandler(&htim1);
/* USER CODE BEGIN TIM1_TRG_COM_IRQn 1 */
diff --git a/thirdparty/mcu.cmake b/thirdparty/mcu.cmake
-Subproject f21e17eee960a18cc1c4eb7712e1c19104d1ba4
+Subproject d6454522261d34a0c7460189194a6d5716751c6
diff --git a/thirdparty/mcucpp b/thirdparty/mcucpp
-Subproject 8eb287e155802b96941627d257b086926255bd4
+Subproject 2ff0cbc23628d5712773ed820bc291f42011909