Serial port working.

git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11189 35acf78f-673a-0410-8e92-d51de3d6d3f4
This commit is contained in:
Giovanni Di Sirio 2017-12-26 10:51:37 +00:00
parent 8db4d4f312
commit 0714e7283d
6 changed files with 112 additions and 136 deletions

View File

@ -5,7 +5,7 @@
# Compiler options here. # Compiler options here.
ifeq ($(USE_OPT),) ifeq ($(USE_OPT),)
USE_OPT = -O0 -ggdb -fomit-frame-pointer -falign-functions=16 USE_OPT = -O2 -ggdb -fomit-frame-pointer -falign-functions=16
endif endif
# C specific options here (added to USE_OPT). # C specific options here (added to USE_OPT).
@ -111,9 +111,9 @@ include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
# Auto-build files in ./source recursively. # Auto-build files in ./source recursively.
include $(CHIBIOS)/tools/mk/autobuild.mk include $(CHIBIOS)/tools/mk/autobuild.mk
# Other files (optional). # Other files (optional).
#include $(CHIBIOS)/test/lib/test.mk include $(CHIBIOS)/test/lib/test.mk
#include $(CHIBIOS)/test/rt/rt_test.mk include $(CHIBIOS)/test/rt/rt_test.mk
#include $(CHIBIOS)/test/oslib/oslib_test.mk include $(CHIBIOS)/test/oslib/oslib_test.mk
# Define linker script file here # Define linker script file here
LDSCRIPT= $(STARTUPLD)/STM32H743xI.ld LDSCRIPT= $(STARTUPLD)/STM32H743xI.ld

View File

@ -146,7 +146,7 @@
* @brief Enables the SERIAL subsystem. * @brief Enables the SERIAL subsystem.
*/ */
#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) #if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__)
#define HAL_USE_SERIAL FALSE #define HAL_USE_SERIAL TRUE
#endif #endif
/** /**

View File

@ -16,8 +16,8 @@
#include "ch.h" #include "ch.h"
#include "hal.h" #include "hal.h"
//#include "rt_test_root.h" #include "rt_test_root.h"
//#include "oslib_test_root.h" #include "oslib_test_root.h"
/* /*
* This is a periodic thread that does absolutely nothing except flashing * This is a periodic thread that does absolutely nothing except flashing
@ -54,7 +54,7 @@ int main(void) {
/* /*
* Activates the serial driver 1 using the driver default configuration. * Activates the serial driver 1 using the driver default configuration.
*/ */
// sdStart(&SD1, NULL); sdStart(&SD3, NULL);
/* /*
* Creates the example thread. * Creates the example thread.
@ -66,12 +66,10 @@ int main(void) {
* sleeping in a loop and check the button state. * sleeping in a loop and check the button state.
*/ */
while (1) { while (1) {
#if 0 if (palReadLine(LINE_BUTTON)) {
if (palReadLine(LINE_BUTTON_USER)) { test_execute((BaseSequentialStream *)&SD3, &rt_test_suite);
test_execute((BaseSequentialStream *)&SD1, &rt_test_suite); test_execute((BaseSequentialStream *)&SD3, &oslib_test_suite);
test_execute((BaseSequentialStream *)&SD1, &oslib_test_suite);
} }
#endif
chThdSleepMilliseconds(500); chThdSleepMilliseconds(500);
} }
} }

View File

@ -332,9 +332,9 @@
/* /*
* SERIAL driver system settings. * SERIAL driver system settings.
*/ */
#define STM32_SERIAL_USE_USART1 TRUE #define STM32_SERIAL_USE_USART1 FALSE
#define STM32_SERIAL_USE_USART2 FALSE #define STM32_SERIAL_USE_USART2 FALSE
#define STM32_SERIAL_USE_USART3 FALSE #define STM32_SERIAL_USE_USART3 TRUE
#define STM32_SERIAL_USE_UART4 FALSE #define STM32_SERIAL_USE_UART4 FALSE
#define STM32_SERIAL_USE_UART5 FALSE #define STM32_SERIAL_USE_UART5 FALSE
#define STM32_SERIAL_USE_USART6 FALSE #define STM32_SERIAL_USE_USART6 FALSE

View File

@ -2280,6 +2280,104 @@
#endif #endif
#endif #endif
#if (STM32_USART16SEL == STM32_USART16SEL_PCLK2) || defined(__DOXYGEN__)
/**
* @brief USART1 clock.
*/
#define STM32_USART1CLK STM32_PCLK2
/**
* @brief USART6 clock.
*/
#define STM32_USART6CLK STM32_PCLK2
#elif STM32_USART1SEL == STM32_USART16SEL_PLL2_Q_CK
#define STM32_USART1CLK STM32_PLL2_Q_CK
#define STM32_USART6CLK STM32_PLL2_Q_CK
#elif STM32_USART16SEL == STM32_USART16SEL_PLL3_Q_CK
#define STM32_USART1CLK STM32_PLL3_Q_CK
#define STM32_USART6CLK STM32_PLL3_Q_CK
#elif STM32_USART16SEL == STM32_USART16SEL_HSI_KER_CK
#define STM32_USART1CLK STM32_HSICLK
#define STM32_USART6CLK STM32_HSICLK
#elif STM32_USART16SEL == STM32_USART16SEL_CSI_KER_CK
#define STM32_USART1CLK STM32_CSICLK
#define STM32_USART6CLK STM32_CSICLK
#elif STM32_USART16SEL == STM32_USART16SEL_LSE_CK
#define STM32_USART1CLK STM32_LSECLK
#define STM32_USART6CLK STM32_LSECLK
#else
#error "invalid source selected for STM32_USART16SEL clock"
#endif
#if (STM32_USART234578SEL == STM32_USART234578SEL_PCLK1) || defined(__DOXYGEN__)
/**
* @brief USART2 clock.
*/
#define STM32_USART2CLK STM32_PCLK1
/**
* @brief USART3 clock.
*/
#define STM32_USART3CLK STM32_PCLK1
/**
* @brief USART4 clock.
*/
#define STM32_USART4CLK STM32_PCLK1
/**
* @brief USART5 clock.
*/
#define STM32_USART5CLK STM32_PCLK1
/**
* @brief USART7 clock.
*/
#define STM32_USART7CLK STM32_PCLK1
/**
* @brief USART8 clock.
*/
#define STM32_USART8CLK STM32_PCLK2
#elif STM32_USART234578SEL == STM32_USART234578SEL_PLL2_Q_CK
#define STM32_USART2CLK STM32_PLL2_Q_CK
#define STM32_USART3CLK STM32_PLL2_Q_CK
#define STM32_USART4CLK STM32_PLL2_Q_CK
#define STM32_USART5CLK STM32_PLL2_Q_CK
#define STM32_USART7CLK STM32_PLL2_Q_CK
#define STM32_USART8CLK STM32_PLL2_Q_CK
#elif STM32_USART234578SEL == STM32_USART234578SEL_PLL3_Q_CK
#define STM32_USART2CLK STM32_PLL3_Q_CK
#define STM32_USART3CLK STM32_PLL3_Q_CK
#define STM32_USART4CLK STM32_PLL3_Q_CK
#define STM32_USART5CLK STM32_PLL3_Q_CK
#define STM32_USART7CLK STM32_PLL3_Q_CK
#define STM32_USART8CLK STM32_PLL3_Q_CK
#elif STM32_USART234578SEL == STM32_USART234578SEL_HSI_KER_CK
#define STM32_USART2CLK STM32_HSICLK
#define STM32_USART3CLK STM32_HSICLK
#define STM32_USART4CLK STM32_HSICLK
#define STM32_USART5CLK STM32_HSICLK
#define STM32_USART7CLK STM32_HSICLK
#define STM32_USART8CLK STM32_HSICLK
#elif STM32_USART234578SEL == STM32_USART234578SEL_CSI_KER_CK
#define STM32_USART2CLK STM32_CSICLK
#define STM32_USART3CLK STM32_CSICLK
#define STM32_USART4CLK STM32_CSICLK
#define STM32_USART5CLK STM32_CSICLK
#define STM32_USART7CLK STM32_CSICLK
#define STM32_USART8CLK STM32_CSICLK
#elif STM32_USART234578SEL == STM32_USART234578SEL_LSE_CK
#define STM32_USART2CLK STM32_LSECLK
#define STM32_USART3CLK STM32_LSECLK
#define STM32_USART4CLK STM32_LSECLK
#define STM32_USART6CLK STM32_LSECLK
#define STM32_USART7CLK STM32_LSECLK
#define STM32_USART8CLK STM32_LSECLK
#else
#error "invalid source selected for STM32_USART234578SEL clock"
#endif
@ -2303,126 +2401,6 @@
#if 0 #if 0
/**
* @brief USART1 frequency.
*/
#if (STM32_USART1SEL == STM32_USART1SEL_PCLK2) || defined(__DOXYGEN__)
#define STM32_USART1CLK STM32_PCLK2
#elif STM32_USART1SEL == STM32_USART1SEL_SYSCLK
#define STM32_USART1CLK STM32_SYSCLK
#elif STM32_USART1SEL == STM32_USART1SEL_HSI
#define STM32_USART1CLK STM32_HSICLK
#elif STM32_USART1SEL == STM32_USART1SEL_LSE
#define STM32_USART1CLK STM32_LSECLK
#else
#error "invalid source selected for USART1 clock"
#endif
/**
* @brief USART2 frequency.
*/
#if (STM32_USART2SEL == STM32_USART2SEL_PCLK1) || defined(__DOXYGEN__)
#define STM32_USART2CLK STM32_PCLK1
#elif STM32_USART2SEL == STM32_USART2SEL_SYSCLK
#define STM32_USART2CLK STM32_SYSCLK
#elif STM32_USART2SEL == STM32_USART2SEL_HSI
#define STM32_USART2CLK STM32_HSICLK
#elif STM32_USART2SEL == STM32_USART2SEL_LSE
#define STM32_USART2CLK STM32_LSECLK
#else
#error "invalid source selected for USART2 clock"
#endif
/**
* @brief USART3 frequency.
*/
#if (STM32_USART3SEL == STM32_USART3SEL_PCLK1) || defined(__DOXYGEN__)
#define STM32_USART3CLK STM32_PCLK1
#elif STM32_USART3SEL == STM32_USART3SEL_SYSCLK
#define STM32_USART3CLK STM32_SYSCLK
#elif STM32_USART3SEL == STM32_USART3SEL_HSI
#define STM32_USART3CLK STM32_HSICLK
#elif STM32_USART3SEL == STM32_USART3SEL_LSE
#define STM32_USART3CLK STM32_LSECLK
#else
#error "invalid source selected for USART3 clock"
#endif
/**
* @brief UART4 frequency.
*/
#if (STM32_UART4SEL == STM32_UART4SEL_PCLK1) || defined(__DOXYGEN__)
#define STM32_UART4CLK STM32_PCLK1
#elif STM32_UART4SEL == STM32_UART4SEL_SYSCLK
#define STM32_UART4CLK STM32_SYSCLK
#elif STM32_UART4SEL == STM32_UART4SEL_HSI
#define STM32_UART4CLK STM32_HSICLK
#elif STM32_UART4SEL == STM32_UART4SEL_LSE
#define STM32_UART4CLK STM32_LSECLK
#else
#error "invalid source selected for UART4 clock"
#endif
/**
* @brief UART5 frequency.
*/
#if (STM32_UART5SEL == STM32_UART5SEL_PCLK1) || defined(__DOXYGEN__)
#define STM32_UART5CLK STM32_PCLK1
#elif STM32_UART5SEL == STM32_UART5SEL_SYSCLK
#define STM32_UART5CLK STM32_SYSCLK
#elif STM32_UART5SEL == STM32_UART5SEL_HSI
#define STM32_UART5CLK STM32_HSICLK
#elif STM32_UART5SEL == STM32_UART5SEL_LSE
#define STM32_UART5CLK STM32_LSECLK
#else
#error "invalid source selected for UART5 clock"
#endif
/**
* @brief USART6 frequency.
*/
#if (STM32_USART6SEL == STM32_USART6SEL_PCLK2) || defined(__DOXYGEN__)
#define STM32_USART6CLK STM32_PCLK2
#elif STM32_USART6SEL == STM32_USART6SEL_SYSCLK
#define STM32_USART6CLK STM32_SYSCLK
#elif STM32_USART6SEL == STM32_USART6SEL_HSI
#define STM32_USART6CLK STM32_HSICLK
#elif STM32_USART6SEL == STM32_USART6SEL_LSE
#define STM32_USART6CLK STM32_LSECLK
#else
#error "invalid source selected for USART6 clock"
#endif
/**
* @brief UART7 frequency.
*/
#if (STM32_UART7SEL == STM32_UART7SEL_PCLK1) || defined(__DOXYGEN__)
#define STM32_UART7CLK STM32_PCLK1
#elif STM32_UART7SEL == STM32_UART7SEL_SYSCLK
#define STM32_UART7CLK STM32_SYSCLK
#elif STM32_UART7SEL == STM32_UART7SEL_HSI
#define STM32_UART7CLK STM32_HSICLK
#elif STM32_UART7SEL == STM32_UART7SEL_LSE
#define STM32_UART7CLK STM32_LSECLK
#else
#error "invalid source selected for UART7 clock"
#endif
/**
* @brief UART8 frequency.
*/
#if (STM32_UART8SEL == STM32_UART8SEL_PCLK1) || defined(__DOXYGEN__)
#define STM32_UART8CLK STM32_PCLK1
#elif STM32_UART8SEL == STM32_UART8SEL_SYSCLK
#define STM32_UART8CLK STM32_SYSCLK
#elif STM32_UART8SEL == STM32_UART8SEL_HSI
#define STM32_UART8CLK STM32_HSICLK
#elif STM32_UART8SEL == STM32_UART8SEL_LSE
#define STM32_UART8CLK STM32_LSECLK
#else
#error "invalid source selected for UART8 clock"
#endif
/** /**
* @brief I2C1 frequency. * @brief I2C1 frequency.
*/ */