Make it work
This commit is contained in:
parent
2b17bb1dae
commit
340f0329fa
11 changed files with 187 additions and 125 deletions
33
.clang-format
Normal file
33
.clang-format
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
BasedOnStyle: LLVM
|
||||||
|
UseTab: Never
|
||||||
|
IndentWidth: 2
|
||||||
|
TabWidth: 2
|
||||||
|
BreakBeforeBraces: Custom
|
||||||
|
AllowShortFunctionsOnASingleLine: InlineOnly
|
||||||
|
AllowShortIfStatementsOnASingleLine: false
|
||||||
|
AllowShortLambdasOnASingleLine: true
|
||||||
|
AllowAllArgumentsOnNextLine: true
|
||||||
|
IndentCaseLabels: true
|
||||||
|
AccessModifierOffset: -2
|
||||||
|
NamespaceIndentation: None
|
||||||
|
FixNamespaceComments: false
|
||||||
|
PackConstructorInitializers: Never
|
||||||
|
AlignAfterOpenBracket: AlwaysBreak
|
||||||
|
InsertBraces: true
|
||||||
|
BraceWrapping:
|
||||||
|
AfterClass: true # false
|
||||||
|
AfterControlStatement: false
|
||||||
|
AfterEnum: true # false
|
||||||
|
AfterFunction: true # false
|
||||||
|
AfterNamespace: false
|
||||||
|
AfterObjCDeclaration: true # false
|
||||||
|
AfterStruct: true # false
|
||||||
|
AfterUnion: true # false
|
||||||
|
AfterExternBlock: false
|
||||||
|
BeforeCatch: false
|
||||||
|
BeforeElse: false
|
||||||
|
IndentBraces: false
|
||||||
|
SplitEmptyFunction: true
|
||||||
|
SplitEmptyRecord: true
|
||||||
|
SplitEmptyNamespace: true
|
||||||
|
ColumnLimit: 140
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -5,5 +5,6 @@
|
||||||
],
|
],
|
||||||
"cmake.preferredGenerators": [
|
"cmake.preferredGenerators": [
|
||||||
"Ninja"
|
"Ninja"
|
||||||
]
|
],
|
||||||
|
"sonarlint.pathToCompileCommands": "${workspaceFolder}/compile_commands.json"
|
||||||
}
|
}
|
85
Src/main.c
85
Src/main.c
|
@ -19,8 +19,8 @@
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "dma.h"
|
#include "dma.h"
|
||||||
#include "gpio.h"
|
|
||||||
#include "usart.h"
|
#include "usart.h"
|
||||||
|
#include "gpio.h"
|
||||||
|
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
|
@ -57,21 +57,15 @@ void SystemClock_Config(void);
|
||||||
|
|
||||||
/* Private user code ---------------------------------------------------------*/
|
/* Private user code ---------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN 0 */
|
/* USER CODE BEGIN 0 */
|
||||||
void SendStr(char const *str) {
|
|
||||||
while (*str) {
|
|
||||||
LL_USART_ClearFlag_TC(USART1);
|
|
||||||
LL_USART_TransmitData8(USART1, *str++);
|
|
||||||
while (!LL_USART_IsActiveFlag_TC(USART1))
|
|
||||||
;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* USER CODE END 0 */
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief The application entry point.
|
* @brief The application entry point.
|
||||||
* @retval int
|
* @retval int
|
||||||
*/
|
*/
|
||||||
int main(void) {
|
int main(void)
|
||||||
|
{
|
||||||
|
|
||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
|
|
||||||
|
@ -79,8 +73,7 @@ int main(void) {
|
||||||
|
|
||||||
/* MCU Configuration--------------------------------------------------------*/
|
/* MCU Configuration--------------------------------------------------------*/
|
||||||
|
|
||||||
/* Reset of all peripherals, Initializes the Flash interface and the Systick.
|
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
|
||||||
*/
|
|
||||||
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_AFIO);
|
LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_AFIO);
|
||||||
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
|
LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR);
|
||||||
|
|
||||||
|
@ -88,7 +81,7 @@ int main(void) {
|
||||||
NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
|
NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
|
||||||
|
|
||||||
/** NOJTAG: JTAG-DP Disabled and SW-DP Enabled
|
/** NOJTAG: JTAG-DP Disabled and SW-DP Enabled
|
||||||
*/
|
*/
|
||||||
LL_GPIO_AF_Remap_SWJ_NOJTAG();
|
LL_GPIO_AF_Remap_SWJ_NOJTAG();
|
||||||
|
|
||||||
/* USER CODE BEGIN Init */
|
/* USER CODE BEGIN Init */
|
||||||
|
@ -113,38 +106,46 @@ int main(void) {
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
/* USER CODE BEGIN WHILE */
|
/* USER CODE BEGIN WHILE */
|
||||||
app_main();
|
app_main();
|
||||||
/* USER CODE END WHILE */
|
/* USER CODE END WHILE */
|
||||||
|
|
||||||
/* USER CODE BEGIN 3 */
|
/* USER CODE BEGIN 3 */
|
||||||
/* USER CODE END 3 */
|
/* USER CODE END 3 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief System Clock Configuration
|
* @brief System Clock Configuration
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void SystemClock_Config(void) {
|
void SystemClock_Config(void)
|
||||||
|
{
|
||||||
LL_FLASH_SetLatency(LL_FLASH_LATENCY_2);
|
LL_FLASH_SetLatency(LL_FLASH_LATENCY_2);
|
||||||
while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_2) {
|
while(LL_FLASH_GetLatency()!= LL_FLASH_LATENCY_2)
|
||||||
|
{
|
||||||
}
|
}
|
||||||
LL_RCC_HSE_Enable();
|
LL_RCC_HSE_Enable();
|
||||||
|
|
||||||
/* Wait till HSE is ready */
|
/* Wait till HSE is ready */
|
||||||
while (LL_RCC_HSE_IsReady() != 1) {
|
while(LL_RCC_HSE_IsReady() != 1)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE_DIV_1, LL_RCC_PLL_MUL_9);
|
LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE_DIV_1, LL_RCC_PLL_MUL_9);
|
||||||
LL_RCC_PLL_Enable();
|
LL_RCC_PLL_Enable();
|
||||||
|
|
||||||
/* Wait till PLL is ready */
|
/* Wait till PLL is ready */
|
||||||
while (LL_RCC_PLL_IsReady() != 1) {
|
while(LL_RCC_PLL_IsReady() != 1)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
|
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
|
||||||
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_2);
|
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_2);
|
||||||
LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1);
|
LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1);
|
||||||
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL);
|
LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL);
|
||||||
|
|
||||||
/* Wait till System clock is ready */
|
/* Wait till System clock is ready */
|
||||||
while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) {
|
while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
LL_Init1msTick(72000000);
|
LL_Init1msTick(72000000);
|
||||||
LL_SetSystemCoreClock(72000000);
|
LL_SetSystemCoreClock(72000000);
|
||||||
|
@ -155,10 +156,11 @@ void SystemClock_Config(void) {
|
||||||
/* USER CODE END 4 */
|
/* USER CODE END 4 */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function is executed in case of error occurrence.
|
* @brief This function is executed in case of error occurrence.
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void Error_Handler(void) {
|
void Error_Handler(void)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN Error_Handler_Debug */
|
/* USER CODE BEGIN Error_Handler_Debug */
|
||||||
/* User can add his own implementation to report the HAL error return state */
|
/* User can add his own implementation to report the HAL error return state */
|
||||||
__disable_irq();
|
__disable_irq();
|
||||||
|
@ -167,15 +169,16 @@ void Error_Handler(void) {
|
||||||
/* USER CODE END Error_Handler_Debug */
|
/* USER CODE END Error_Handler_Debug */
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USE_FULL_ASSERT
|
#ifdef USE_FULL_ASSERT
|
||||||
/**
|
/**
|
||||||
* @brief Reports the name of the source file and the source line number
|
* @brief Reports the name of the source file and the source line number
|
||||||
* where the assert_param error has occurred.
|
* where the assert_param error has occurred.
|
||||||
* @param file: pointer to the source file name
|
* @param file: pointer to the source file name
|
||||||
* @param line: assert_param error line source number
|
* @param line: assert_param error line source number
|
||||||
* @retval None
|
* @retval None
|
||||||
*/
|
*/
|
||||||
void assert_failed(uint8_t *file, uint32_t line) {
|
void assert_failed(uint8_t *file, uint32_t line)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN 6 */
|
/* USER CODE BEGIN 6 */
|
||||||
/* User can add his own implementation to report the file name and line
|
/* User can add his own implementation to report the file name and line
|
||||||
number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file,
|
number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file,
|
||||||
|
|
|
@ -18,9 +18,8 @@
|
||||||
/* USER CODE END Header */
|
/* USER CODE END Header */
|
||||||
|
|
||||||
/* Includes ------------------------------------------------------------------*/
|
/* Includes ------------------------------------------------------------------*/
|
||||||
#include "stm32f1xx_it.h"
|
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
|
#include "stm32f1xx_it.h"
|
||||||
/* Private includes ----------------------------------------------------------*/
|
/* Private includes ----------------------------------------------------------*/
|
||||||
/* USER CODE BEGIN Includes */
|
/* USER CODE BEGIN Includes */
|
||||||
|
|
||||||
|
@ -68,9 +67,10 @@
|
||||||
/* Cortex-M3 Processor Interruption and Exception Handlers */
|
/* Cortex-M3 Processor Interruption and Exception Handlers */
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Non maskable interrupt.
|
* @brief This function handles Non maskable interrupt.
|
||||||
*/
|
*/
|
||||||
void NMI_Handler(void) {
|
void NMI_Handler(void)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
|
/* USER CODE BEGIN NonMaskableInt_IRQn 0 */
|
||||||
|
|
||||||
/* USER CODE END NonMaskableInt_IRQn 0 */
|
/* USER CODE END NonMaskableInt_IRQn 0 */
|
||||||
|
@ -81,61 +81,70 @@ void NMI_Handler(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Hard fault interrupt.
|
* @brief This function handles Hard fault interrupt.
|
||||||
*/
|
*/
|
||||||
void HardFault_Handler(void) {
|
void HardFault_Handler(void)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN HardFault_IRQn 0 */
|
/* USER CODE BEGIN HardFault_IRQn 0 */
|
||||||
|
|
||||||
/* USER CODE END HardFault_IRQn 0 */
|
/* USER CODE END HardFault_IRQn 0 */
|
||||||
while (1) {
|
while (1)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
|
/* USER CODE BEGIN W1_HardFault_IRQn 0 */
|
||||||
/* USER CODE END W1_HardFault_IRQn 0 */
|
/* USER CODE END W1_HardFault_IRQn 0 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Memory management fault.
|
* @brief This function handles Memory management fault.
|
||||||
*/
|
*/
|
||||||
void MemManage_Handler(void) {
|
void MemManage_Handler(void)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
|
/* USER CODE BEGIN MemoryManagement_IRQn 0 */
|
||||||
|
|
||||||
/* USER CODE END MemoryManagement_IRQn 0 */
|
/* USER CODE END MemoryManagement_IRQn 0 */
|
||||||
while (1) {
|
while (1)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
|
/* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
|
||||||
/* USER CODE END W1_MemoryManagement_IRQn 0 */
|
/* USER CODE END W1_MemoryManagement_IRQn 0 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Prefetch fault, memory access fault.
|
* @brief This function handles Prefetch fault, memory access fault.
|
||||||
*/
|
*/
|
||||||
void BusFault_Handler(void) {
|
void BusFault_Handler(void)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN BusFault_IRQn 0 */
|
/* USER CODE BEGIN BusFault_IRQn 0 */
|
||||||
|
|
||||||
/* USER CODE END BusFault_IRQn 0 */
|
/* USER CODE END BusFault_IRQn 0 */
|
||||||
while (1) {
|
while (1)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN W1_BusFault_IRQn 0 */
|
/* USER CODE BEGIN W1_BusFault_IRQn 0 */
|
||||||
/* USER CODE END W1_BusFault_IRQn 0 */
|
/* USER CODE END W1_BusFault_IRQn 0 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Undefined instruction or illegal state.
|
* @brief This function handles Undefined instruction or illegal state.
|
||||||
*/
|
*/
|
||||||
void UsageFault_Handler(void) {
|
void UsageFault_Handler(void)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN UsageFault_IRQn 0 */
|
/* USER CODE BEGIN UsageFault_IRQn 0 */
|
||||||
|
|
||||||
/* USER CODE END UsageFault_IRQn 0 */
|
/* USER CODE END UsageFault_IRQn 0 */
|
||||||
while (1) {
|
while (1)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN W1_UsageFault_IRQn 0 */
|
/* USER CODE BEGIN W1_UsageFault_IRQn 0 */
|
||||||
/* USER CODE END W1_UsageFault_IRQn 0 */
|
/* USER CODE END W1_UsageFault_IRQn 0 */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles System service call via SWI instruction.
|
* @brief This function handles System service call via SWI instruction.
|
||||||
*/
|
*/
|
||||||
void SVC_Handler(void) {
|
void SVC_Handler(void)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN SVCall_IRQn 0 */
|
/* USER CODE BEGIN SVCall_IRQn 0 */
|
||||||
|
|
||||||
/* USER CODE END SVCall_IRQn 0 */
|
/* USER CODE END SVCall_IRQn 0 */
|
||||||
|
@ -145,9 +154,10 @@ void SVC_Handler(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Debug monitor.
|
* @brief This function handles Debug monitor.
|
||||||
*/
|
*/
|
||||||
void DebugMon_Handler(void) {
|
void DebugMon_Handler(void)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
|
/* USER CODE BEGIN DebugMonitor_IRQn 0 */
|
||||||
|
|
||||||
/* USER CODE END DebugMonitor_IRQn 0 */
|
/* USER CODE END DebugMonitor_IRQn 0 */
|
||||||
|
@ -157,9 +167,10 @@ void DebugMon_Handler(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles Pendable request for system service.
|
* @brief This function handles Pendable request for system service.
|
||||||
*/
|
*/
|
||||||
void PendSV_Handler(void) {
|
void PendSV_Handler(void)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN PendSV_IRQn 0 */
|
/* USER CODE BEGIN PendSV_IRQn 0 */
|
||||||
|
|
||||||
/* USER CODE END PendSV_IRQn 0 */
|
/* USER CODE END PendSV_IRQn 0 */
|
||||||
|
@ -169,9 +180,10 @@ void PendSV_Handler(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles System tick timer.
|
* @brief This function handles System tick timer.
|
||||||
*/
|
*/
|
||||||
void SysTick_Handler(void) {
|
void SysTick_Handler(void)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN SysTick_IRQn 0 */
|
/* USER CODE BEGIN SysTick_IRQn 0 */
|
||||||
|
|
||||||
/* USER CODE END SysTick_IRQn 0 */
|
/* USER CODE END SysTick_IRQn 0 */
|
||||||
|
@ -189,9 +201,10 @@ void SysTick_Handler(void) {
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles DMA1 channel4 global interrupt.
|
* @brief This function handles DMA1 channel4 global interrupt.
|
||||||
*/
|
*/
|
||||||
void DMA1_Channel4_IRQHandler(void) {
|
void DMA1_Channel4_IRQHandler(void)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN DMA1_Channel4_IRQn 0 */
|
/* USER CODE BEGIN DMA1_Channel4_IRQn 0 */
|
||||||
dma1_channel4_irq_handler();
|
dma1_channel4_irq_handler();
|
||||||
/* USER CODE END DMA1_Channel4_IRQn 0 */
|
/* USER CODE END DMA1_Channel4_IRQn 0 */
|
||||||
|
@ -201,9 +214,10 @@ void DMA1_Channel4_IRQHandler(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles DMA1 channel5 global interrupt.
|
* @brief This function handles DMA1 channel5 global interrupt.
|
||||||
*/
|
*/
|
||||||
void DMA1_Channel5_IRQHandler(void) {
|
void DMA1_Channel5_IRQHandler(void)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN DMA1_Channel5_IRQn 0 */
|
/* USER CODE BEGIN DMA1_Channel5_IRQn 0 */
|
||||||
dma1_channel5_irq_handler();
|
dma1_channel5_irq_handler();
|
||||||
/* USER CODE END DMA1_Channel5_IRQn 0 */
|
/* USER CODE END DMA1_Channel5_IRQn 0 */
|
||||||
|
@ -213,11 +227,12 @@ void DMA1_Channel5_IRQHandler(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles USART1 global interrupt.
|
* @brief This function handles USART1 global interrupt.
|
||||||
*/
|
*/
|
||||||
void USART1_IRQHandler(void) {
|
void USART1_IRQHandler(void)
|
||||||
|
{
|
||||||
/* USER CODE BEGIN USART1_IRQn 0 */
|
/* USER CODE BEGIN USART1_IRQn 0 */
|
||||||
|
usart1_irq_handler();
|
||||||
/* USER CODE END USART1_IRQn 0 */
|
/* USER CODE END USART1_IRQn 0 */
|
||||||
/* USER CODE BEGIN USART1_IRQn 1 */
|
/* USER CODE BEGIN USART1_IRQn 1 */
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ extern "C" {
|
||||||
|
|
||||||
void dma1_channel4_irq_handler();
|
void dma1_channel4_irq_handler();
|
||||||
void dma1_channel5_irq_handler();
|
void dma1_channel5_irq_handler();
|
||||||
|
void usart1_irq_handler();
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,8 @@
|
||||||
|
|
||||||
#include <f1ll/console_handler.h>
|
#include <f1ll/console_handler.h>
|
||||||
|
|
||||||
void app_main() {
|
void app_main()
|
||||||
|
{
|
||||||
f1ll::console_handler::init(USART1, DMA1, LL_DMA_CHANNEL_5, LL_DMA_CHANNEL_4);
|
f1ll::console_handler::init(USART1, DMA1, LL_DMA_CHANNEL_5, LL_DMA_CHANNEL_4);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
|
@ -2,10 +2,17 @@
|
||||||
|
|
||||||
#include <f1ll/console_handler.h>
|
#include <f1ll/console_handler.h>
|
||||||
|
|
||||||
void dma1_channel4_irq_handler() {
|
void dma1_channel4_irq_handler()
|
||||||
|
{
|
||||||
f1ll::console_handler::instance().tx_dma_isr();
|
f1ll::console_handler::instance().tx_dma_isr();
|
||||||
}
|
}
|
||||||
|
|
||||||
void dma1_channel5_irq_handler() {
|
void dma1_channel5_irq_handler()
|
||||||
|
{
|
||||||
f1ll::console_handler::instance().rx_dma_isr();
|
f1ll::console_handler::instance().rx_dma_isr();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void usart1_irq_handler()
|
||||||
|
{
|
||||||
|
f1ll::console_handler::instance().usart_isr();
|
||||||
|
}
|
|
@ -13,15 +13,15 @@
|
||||||
|
|
||||||
namespace f1ll {
|
namespace f1ll {
|
||||||
|
|
||||||
class console_handler : public usart_core, public singleton<console_handler> {
|
class console_handler : public usart_core, public singleton<console_handler>
|
||||||
|
{
|
||||||
friend class singleton<console_handler>;
|
friend class singleton<console_handler>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void print(char const *s);
|
void print(char const *s);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
console_handler(USART_TypeDef *usart, DMA_TypeDef *dma, uint32_t channelRx,
|
console_handler(USART_TypeDef *usart, DMA_TypeDef *dma, uint32_t channelRx, uint32_t channelTx);
|
||||||
uint32_t channelTx);
|
|
||||||
|
|
||||||
// LL_UsartCore pure virtual function implementations
|
// LL_UsartCore pure virtual function implementations
|
||||||
virtual void receiver_idle(void);
|
virtual void receiver_idle(void);
|
||||||
|
|
|
@ -11,39 +11,38 @@
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <platform/dma_ll.h>
|
#include <platform/dma_ll.h>
|
||||||
|
|
||||||
namespace f1ll
|
namespace f1ll {
|
||||||
|
|
||||||
|
class dma_helper
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
dma_helper(DMA_TypeDef *dma, uint32_t channel);
|
||||||
|
dma_helper(dma_helper const &base) = default;
|
||||||
|
|
||||||
class dma_helper
|
inline DMA_TypeDef *get_dma() const { return m_dma; }
|
||||||
{
|
inline uint32_t get_channel() const { return m_channel; }
|
||||||
public:
|
inline volatile uint32_t *get_is_reg() const { return m_is_reg; }
|
||||||
dma_helper(DMA_TypeDef *dma, uint32_t channel);
|
inline volatile uint32_t *get_ifc_reg() const { return m_ifc_reg; }
|
||||||
dma_helper(dma_helper const &base) = default;
|
inline uint32_t get_te_mask() const { return m_te_masks[m_channel - 1]; }
|
||||||
|
inline uint32_t get_ht_mask() const { return m_ht_masks[m_channel - 1]; }
|
||||||
|
inline uint32_t get_tc_mask() const { return m_tc_masks[m_channel - 1]; }
|
||||||
|
inline uint32_t get_gi_mask() const { return m_gi_masks[m_channel - 1]; }
|
||||||
|
|
||||||
inline DMA_TypeDef *get_dma() const { return m_dma; }
|
inline bool is_enabled_it_te() { return LL_DMA_IsEnabledIT_TE(m_dma, m_channel) != 0; }
|
||||||
inline uint32_t get_channel() const { return m_channel; }
|
inline bool is_enabled_it_ht() { return LL_DMA_IsEnabledIT_HT(m_dma, m_channel) != 0; }
|
||||||
inline volatile uint32_t *get_is_reg() const { return m_is_reg; }
|
inline bool is_enabled_it_tc() { return LL_DMA_IsEnabledIT_TC(m_dma, m_channel) != 0; }
|
||||||
inline volatile uint32_t *get_ifc_reg() const { return m_ifc_reg; }
|
|
||||||
inline uint32_t get_te_mask() const { return m_te_masks[m_channel - 1]; }
|
|
||||||
inline uint32_t get_ht_mask() const { return m_ht_masks[m_channel - 1]; }
|
|
||||||
inline uint32_t get_tc_mask() const { return m_tc_masks[m_channel - 1]; }
|
|
||||||
inline uint32_t get_gi_mask() const { return m_gi_masks[m_channel - 1]; }
|
|
||||||
|
|
||||||
inline bool is_enabled_it_te() { return LL_DMA_IsEnabledIT_TE(m_dma, m_channel) != 0; }
|
private:
|
||||||
inline bool is_enabled_it_ht() { return LL_DMA_IsEnabledIT_HT(m_dma, m_channel) != 0; }
|
DMA_TypeDef *m_dma;
|
||||||
inline bool is_enabled_it_tc() { return LL_DMA_IsEnabledIT_TC(m_dma, m_channel) != 0; }
|
uint32_t m_channel;
|
||||||
|
volatile uint32_t *m_is_reg;
|
||||||
|
volatile uint32_t *m_ifc_reg;
|
||||||
|
|
||||||
private:
|
static const uint32_t m_te_masks[7];
|
||||||
DMA_TypeDef *m_dma;
|
static const uint32_t m_ht_masks[7];
|
||||||
uint32_t m_channel;
|
static const uint32_t m_tc_masks[7];
|
||||||
volatile uint32_t *m_is_reg;
|
static const uint32_t m_gi_masks[7];
|
||||||
volatile uint32_t *m_ifc_reg;
|
};
|
||||||
|
|
||||||
static const uint32_t m_te_masks[7];
|
|
||||||
static const uint32_t m_ht_masks[7];
|
|
||||||
static const uint32_t m_tc_masks[7];
|
|
||||||
static const uint32_t m_gi_masks[7];
|
|
||||||
};
|
|
||||||
|
|
||||||
} /* namespace f4ll */
|
} /* namespace f4ll */
|
||||||
|
|
||||||
|
|
|
@ -3,10 +3,12 @@
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
template <typename T> class singleton {
|
template <typename T> class singleton
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
static T &instance() { return *m_instance; }
|
static T &instance() { return *m_instance; }
|
||||||
template <typename... args_t> static T &init(args_t &&...args) {
|
template <typename... args_t> static T &init(args_t &&...args)
|
||||||
|
{
|
||||||
static T instance{std::forward<args_t>(args)...};
|
static T instance{std::forward<args_t>(args)...};
|
||||||
m_instance = &instance;
|
m_instance = &instance;
|
||||||
return instance;
|
return instance;
|
||||||
|
|
|
@ -13,7 +13,8 @@
|
||||||
|
|
||||||
namespace f1ll {
|
namespace f1ll {
|
||||||
|
|
||||||
class usart_core {
|
class usart_core
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
static inline void usart_irq(usart_core *_this) { _this->usart_isr(); }
|
static inline void usart_irq(usart_core *_this) { _this->usart_isr(); }
|
||||||
static inline void rx_dma_irq(usart_core *_this) { _this->rx_dma_isr(); }
|
static inline void rx_dma_irq(usart_core *_this) { _this->rx_dma_isr(); }
|
||||||
|
@ -23,8 +24,7 @@ public:
|
||||||
void setup_receive(void *buffer, uint16_t length);
|
void setup_receive(void *buffer, uint16_t length);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
usart_core(USART_TypeDef *usart, DMA_TypeDef *dma, uint32_t channel_rx,
|
usart_core(USART_TypeDef *usart, DMA_TypeDef *dma, uint32_t channel_rx, uint32_t stream_tx);
|
||||||
uint32_t stream_tx);
|
|
||||||
|
|
||||||
USART_TypeDef *m_usart;
|
USART_TypeDef *m_usart;
|
||||||
dma_helper m_rxDma;
|
dma_helper m_rxDma;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue