summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2023-06-05 15:41:35 +0700
committerhathach <[email protected]>2023-06-05 15:41:45 +0700
commitf6a45a7aab42264fc9c270150549cd4c4a54292e (patch)
treed6494edada746ceb4ffd541d2aa5f407a86639a9
parentc7686f8d5e98660137ef176d35bc8a82f63675f3 (diff)
clean up
-rw-r--r--.idea/runConfigurations/stm32g474_jlink.xml10
-rw-r--r--hw/bsp/board.c11
-rw-r--r--hw/bsp/family_support.cmake17
-rw-r--r--hw/bsp/stm32g4/family.c50
-rw-r--r--src/CMakeLists.txt4
5 files changed, 55 insertions, 37 deletions
diff --git a/.idea/runConfigurations/stm32g474_jlink.xml b/.idea/runConfigurations/stm32g474_jlink.xml
new file mode 100644
index 000000000..45a755da4
--- /dev/null
+++ b/.idea/runConfigurations/stm32g474_jlink.xml
@@ -0,0 +1,10 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="stm32g474 jlink" type="com.jetbrains.cidr.embedded.customgdbserver.type" factoryName="com.jetbrains.cidr.embedded.customgdbserver.factory" PROGRAM_PARAMS="-device &quot;stm32g474re&quot; -if swd -speed 100000 -port 25321 -swoport 25322 -TelnetPort 25323 -nogui -singlerun" REDIRECT_INPUT="false" ELEVATE="false" USE_EXTERNAL_CONSOLE="false" PASS_PARENT_ENVS_2="true" PROJECT_NAME="cdc_msc" TARGET_NAME="cdc_msc" CONFIG_NAME="b_g474e_dpow1" version="1" RUN_TARGET_PROJECT_NAME="cdc_msc" RUN_TARGET_NAME="cdc_msc">
+ <custom-gdb-server version="1" gdb-connect="tcp::25321" executable="/usr/bin/JLinkGDBServer" warmup-ms="0" download-type="UPDATED_ONLY" reset-cmd="monitor reset" reset-type="AFTER_DOWNLOAD">
+ <debugger kind="GDB" isBundled="true" />
+ </custom-gdb-server>
+ <method v="2">
+ <option name="CLION.COMPOUND.BUILD" enabled="true" />
+ </method>
+ </configuration>
+</component> \ No newline at end of file
diff --git a/hw/bsp/board.c b/hw/bsp/board.c
index 66ffcb199..3f62547a0 100644
--- a/hw/bsp/board.c
+++ b/hw/bsp/board.c
@@ -39,7 +39,7 @@
#define sys_read _read
#endif
-#if defined(LOGGER_RTT)
+#if defined(LOGGER_RTT) || defined(LOGGER_rtt)
// Logging with RTT
// If using SES IDE, use the Syscalls/SEGGER_RTT_Syscalls_SES.c instead
@@ -62,7 +62,7 @@ TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count)
#endif
-#elif defined(LOGGER_SWO)
+#elif defined(LOGGER_SWO) || defined(LOGGER_swo)
// Logging with SWO for ARM Cortex
#include "board_mcu.h"
@@ -71,11 +71,12 @@ TU_ATTR_USED int sys_write (int fhdl, const void *buf, size_t count)
{
(void) fhdl;
uint8_t const* buf8 = (uint8_t const*) buf;
- for(size_t i=0; i<count; i++)
- {
+
+ for(size_t i=0; i<count; i++) {
ITM_SendChar(buf8[i]);
}
- return count;
+
+ return (int) count;
}
TU_ATTR_USED int sys_read (int fhdl, char *buf, size_t count)
diff --git a/hw/bsp/family_support.cmake b/hw/bsp/family_support.cmake
index fdcd9a983..2c0ee95d6 100644
--- a/hw/bsp/family_support.cmake
+++ b/hw/bsp/family_support.cmake
@@ -115,6 +115,12 @@ function(family_configure_common TARGET)
"LINKER:-Map=$<TARGET_FILE:${TARGET}>.map"
)
endif()
+
+ # LOGGER
+ if (DEFINED LOGGER)
+ target_compile_definitions(${TARGET} PUBLIC LOGGER_${LOGGER})
+ endif ()
+
endfunction()
@@ -136,12 +142,11 @@ function(family_add_tinyusb TARGET OPT_MCU)
set(TINYUSB_TARGET_PREFIX ${TARGET}-)
add_library(${TARGET}-tinyusb_config INTERFACE)
- target_include_directories(${TARGET}-tinyusb_config INTERFACE
- ${CMAKE_CURRENT_SOURCE_DIR}/src
- )
- target_compile_definitions(${TARGET}-tinyusb_config INTERFACE
- CFG_TUSB_MCU=${OPT_MCU}
- )
+ target_include_directories(${TARGET}-tinyusb_config INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src)
+ target_compile_definitions(${TARGET}-tinyusb_config INTERFACE CFG_TUSB_MCU=${OPT_MCU})
+ if (DEFINED LOG)
+ target_compile_definitions(${TARGET}-tinyusb_config INTERFACE CFG_TUSB_DEBUG=${LOG})
+ endif()
# tinyusb's CMakeList.txt
add_subdirectory(${TOP}/src ${CMAKE_CURRENT_BINARY_DIR}/tinyusb)
diff --git a/hw/bsp/stm32g4/family.c b/hw/bsp/stm32g4/family.c
index 3b490e9b3..19ba415bc 100644
--- a/hw/bsp/stm32g4/family.c
+++ b/hw/bsp/stm32g4/family.c
@@ -79,32 +79,35 @@ void board_init(void)
NVIC_SetPriority(USBWakeUp_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY);
#endif
- GPIO_InitTypeDef GPIO_InitStruct;
+ GPIO_InitTypeDef gpio_init;
// LED
- GPIO_InitStruct.Pin = LED_PIN;
- GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
- GPIO_InitStruct.Pull = GPIO_PULLUP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
+ memset(&gpio_init, 0, sizeof(gpio_init));
+ gpio_init.Pin = LED_PIN;
+ gpio_init.Mode = GPIO_MODE_OUTPUT_PP;
+ gpio_init.Pull = GPIO_PULLUP;
+ gpio_init.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(LED_PORT, &gpio_init);
board_led_write(false);
// Button
- GPIO_InitStruct.Pin = BUTTON_PIN;
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
- GPIO_InitStruct.Pull = BUTTON_STATE_ACTIVE ? GPIO_PULLDOWN : GPIO_PULLUP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
+ memset(&gpio_init, 0, sizeof(gpio_init));
+ gpio_init.Pin = BUTTON_PIN;
+ gpio_init.Mode = GPIO_MODE_INPUT;
+ gpio_init.Pull = BUTTON_STATE_ACTIVE ? GPIO_PULLDOWN : GPIO_PULLUP;
+ gpio_init.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(BUTTON_PORT, &gpio_init);
#ifdef UART_DEV
// UART
- GPIO_InitStruct.Pin = UART_TX_PIN | UART_RX_PIN;
- GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
- GPIO_InitStruct.Pull = GPIO_PULLUP;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- GPIO_InitStruct.Alternate = UART_GPIO_AF;
- HAL_GPIO_Init(UART_GPIO_PORT, &GPIO_InitStruct);
+ memset(&gpio_init, 0, sizeof(gpio_init));
+ gpio_init.Pin = UART_TX_PIN | UART_RX_PIN;
+ gpio_init.Mode = GPIO_MODE_AF_PP;
+ gpio_init.Pull = GPIO_PULLUP;
+ gpio_init.Speed = GPIO_SPEED_FREQ_HIGH;
+ gpio_init.Alternate = UART_GPIO_AF;
+ HAL_GPIO_Init(UART_GPIO_PORT, &gpio_init);
UartHandle = (UART_HandleTypeDef){
.Instance = UART_DEV,
@@ -121,15 +124,18 @@ void board_init(void)
// USB Pins TODO double check USB clock and pin setup
// Configure USB DM and DP pins. This is optional, and maintained only for user guidance.
- GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
- GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
- GPIO_InitStruct.Pull = GPIO_NOPULL;
- GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
- HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
+ memset(&gpio_init, 0, sizeof(gpio_init));
+ gpio_init.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
+ gpio_init.Mode = GPIO_MODE_INPUT;
+ gpio_init.Pull = GPIO_NOPULL;
+ gpio_init.Speed = GPIO_SPEED_FREQ_HIGH;
+ HAL_GPIO_Init(GPIOA, &gpio_init);
__HAL_RCC_USB_CLK_ENABLE();
board_vbus_sense_init();
+
+ // USB PD
}
//--------------------------------------------------------------------+
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 09f41c9ab..3dbd72d61 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -98,7 +98,3 @@ endif()
target_link_libraries(${TINYUSB_TARGET} PUBLIC
${TINYUSB_CONFIG_TARGET}
)
-
-# export target name
-# set(TINYUSB_TARGET ${TINYUSB_TARGET} PARENT_SCOPE)
-# set(TINYUSB_CONFIG_TARGET ${TINYUSB_CONFIG_TARGET} PARENT_SCOPE)