├── Src
├── syscalls.c
├── D6Board.cpp
├── dma.c
├── stm32f1xx_hal_msp.c
├── gpio.c
├── debouncedButton.cpp
├── adc.c
├── usart.c
├── Command.cpp
├── tim.c
├── ADF4351.cpp
├── spi.c
├── Serial.cpp
├── stm32f1xx_it.c
├── main.c
└── Loop.cpp
├── Documentation
└── ADF4351_SCHDOC.pdf
├── Documents
└── Photos
│ └── D6_and_STLinkV2.jpg
├── .gitignore
├── README.md
├── tests
└── D6_blinkTest
│ ├── debug.mak
│ ├── release.mak
│ ├── LEDBlink.cpp
│ ├── D6_blinkTest.sln
│ ├── stm32.mak
│ ├── stm32.xml
│ ├── D6_blinkTest-Release.vgdbsettings
│ ├── D6_blinkTest-Debug.vgdbsettings
│ └── stm32f1xx_hal_conf.h
├── debug.mak
├── release.mak
├── Inc
├── Loop.h
├── Command.h
├── gpio.h
├── dma.h
├── usart.h
├── adc.h
├── spi.h
├── tim.h
├── debouncedButton.h
├── Serial.h
├── D6Board.h
├── stm32f1xx_it.h
├── main.h
├── ADF4351.h
├── stm32f1xx_hal_conf.h
└── eeprom.h
├── D6_firmware.sln
├── stm32.mak
├── stm32.xml
├── STM32F103C8_FLASH.ld
├── D6_firmware-Debug.vgdbsettings
├── D6_firmware-Release.vgdbsettings
├── D6_firmware.ioc
└── startup
└── startup_stm32f103xb.s
/Src/syscalls.c:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joseluu/D6_firmware/HEAD/Src/syscalls.c
--------------------------------------------------------------------------------
/Documentation/ADF4351_SCHDOC.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joseluu/D6_firmware/HEAD/Documentation/ADF4351_SCHDOC.pdf
--------------------------------------------------------------------------------
/Documents/Photos/D6_and_STLinkV2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/joseluu/D6_firmware/HEAD/Documents/Photos/D6_and_STLinkV2.jpg
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | .vs
2 | CodeDB
3 | Debug/
4 | Release/
5 | Src/Backup
6 | Inc/Backup
7 | .mxproject
8 | VisualGDBCache
9 | *.VC.db
10 | *.old
11 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # D6_firmware
2 |
3 | This is an alternate firmware for the D6 spectrum analyzer with tracking source
4 |
5 | D6 board can also be used with the ADI PLL test software ADF435x (use the modified version in the ADF435x repo)
6 |
7 | discussions en francais sur le sujet, voir ici: https://gitter.im/D6_firmware/D6_en_fran%C3%A7ais
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/tests/D6_blinkTest/debug.mak:
--------------------------------------------------------------------------------
1 | #Generated by VisualGDB (http://visualgdb.com)
2 | #DO NOT EDIT THIS FILE MANUALLY UNLESS YOU ABSOLUTELY NEED TO
3 | #USE VISUALGDB PROJECT PROPERTIES DIALOG INSTEAD
4 |
5 | BINARYDIR := Debug
6 |
7 | #Additional flags
8 | PREPROCESSOR_MACROS := DEBUG=1
9 | INCLUDE_DIRS :=
10 | LIBRARY_DIRS :=
11 | LIBRARY_NAMES :=
12 | ADDITIONAL_LINKER_INPUTS :=
13 | MACOS_FRAMEWORKS :=
14 | LINUX_PACKAGES :=
15 |
16 | CFLAGS := -ggdb -ffunction-sections -O0
17 | CXXFLAGS := -ggdb -ffunction-sections -fno-exceptions -fno-rtti -O0
18 | ASFLAGS :=
19 | LDFLAGS := -Wl,-gc-sections
20 | COMMONFLAGS :=
21 | LINKER_SCRIPT :=
22 |
23 | START_GROUP := -Wl,--start-group
24 | END_GROUP := -Wl,--end-group
25 |
26 | #Additional options detected from testing the toolchain
27 | USE_DEL_TO_CLEAN := 1
28 | CP_NOT_AVAILABLE := 1
29 |
30 | ADDITIONAL_MAKE_FILES := stm32.mak
31 | GENERATE_BIN_FILE := 1
32 | GENERATE_IHEX_FILE := 0
33 |
--------------------------------------------------------------------------------
/debug.mak:
--------------------------------------------------------------------------------
1 | #Generated by VisualGDB (http://visualgdb.com)
2 | #DO NOT EDIT THIS FILE MANUALLY UNLESS YOU ABSOLUTELY NEED TO
3 | #USE VISUALGDB PROJECT PROPERTIES DIALOG INSTEAD
4 |
5 | BINARYDIR := Debug
6 |
7 | #Additional flags
8 | PREPROCESSOR_MACROS := DEBUG=1
9 | INCLUDE_DIRS := Inc
10 | LIBRARY_DIRS :=
11 | LIBRARY_NAMES :=
12 | ADDITIONAL_LINKER_INPUTS :=
13 | MACOS_FRAMEWORKS :=
14 | LINUX_PACKAGES :=
15 |
16 | CFLAGS := -ggdb -ffunction-sections -O0
17 | CXXFLAGS := -ggdb -ffunction-sections -fno-exceptions -fno-rtti -O0
18 | ASFLAGS :=
19 | LDFLAGS := -Wl,-gc-sections
20 | COMMONFLAGS :=
21 | LINKER_SCRIPT :=
22 |
23 | START_GROUP := -Wl,--start-group
24 | END_GROUP := -Wl,--end-group
25 |
26 | #Additional options detected from testing the toolchain
27 | USE_DEL_TO_CLEAN := 1
28 | CP_NOT_AVAILABLE := 1
29 |
30 | ADDITIONAL_MAKE_FILES := stm32.mak
31 | GENERATE_BIN_FILE := 1
32 | GENERATE_IHEX_FILE := 1
33 | GENERATE_MAP_FILE :=0
34 |
--------------------------------------------------------------------------------
/tests/D6_blinkTest/release.mak:
--------------------------------------------------------------------------------
1 | #Generated by VisualGDB (http://visualgdb.com)
2 | #DO NOT EDIT THIS FILE MANUALLY UNLESS YOU ABSOLUTELY NEED TO
3 | #USE VISUALGDB PROJECT PROPERTIES DIALOG INSTEAD
4 |
5 | BINARYDIR := Release
6 |
7 | #Additional flags
8 | PREPROCESSOR_MACROS := NDEBUG=1 RELEASE=1
9 | INCLUDE_DIRS :=
10 | LIBRARY_DIRS :=
11 | LIBRARY_NAMES :=
12 | ADDITIONAL_LINKER_INPUTS :=
13 | MACOS_FRAMEWORKS :=
14 | LINUX_PACKAGES :=
15 |
16 | CFLAGS := -ggdb -ffunction-sections -O3
17 | CXXFLAGS := -ggdb -ffunction-sections -fno-exceptions -fno-rtti -O3
18 | ASFLAGS :=
19 | LDFLAGS := -Wl,-gc-sections
20 | COMMONFLAGS :=
21 | LINKER_SCRIPT :=
22 |
23 | START_GROUP := -Wl,--start-group
24 | END_GROUP := -Wl,--end-group
25 |
26 | #Additional options detected from testing the toolchain
27 | USE_DEL_TO_CLEAN := 1
28 | CP_NOT_AVAILABLE := 1
29 |
30 | ADDITIONAL_MAKE_FILES := stm32.mak
31 | GENERATE_BIN_FILE := 1
32 | GENERATE_IHEX_FILE := 0
33 |
--------------------------------------------------------------------------------
/release.mak:
--------------------------------------------------------------------------------
1 | #Generated by VisualGDB (http://visualgdb.com)
2 | #DO NOT EDIT THIS FILE MANUALLY UNLESS YOU ABSOLUTELY NEED TO
3 | #USE VISUALGDB PROJECT PROPERTIES DIALOG INSTEAD
4 |
5 | BINARYDIR := Release
6 |
7 | #Additional flags
8 | PREPROCESSOR_MACROS := NDEBUG=1 RELEASE=1
9 | INCLUDE_DIRS := Inc
10 | LIBRARY_DIRS :=
11 | LIBRARY_NAMES :=
12 | ADDITIONAL_LINKER_INPUTS :=
13 | MACOS_FRAMEWORKS :=
14 | LINUX_PACKAGES :=
15 |
16 | CFLAGS := -ggdb -ffunction-sections -O3
17 | CXXFLAGS := -ggdb -ffunction-sections -fno-exceptions -fno-rtti -O3
18 | ASFLAGS :=
19 | LDFLAGS := -Wl,-gc-sections
20 | COMMONFLAGS :=
21 | LINKER_SCRIPT :=
22 |
23 | START_GROUP := -Wl,--start-group
24 | END_GROUP := -Wl,--end-group
25 |
26 | #Additional options detected from testing the toolchain
27 | USE_DEL_TO_CLEAN := 1
28 | CP_NOT_AVAILABLE := 1
29 |
30 | ADDITIONAL_MAKE_FILES := stm32.mak
31 | GENERATE_BIN_FILE := 1
32 | GENERATE_IHEX_FILE := 1
33 | GENERATE_MAP_FILE := 0
34 |
--------------------------------------------------------------------------------
/Inc/Loop.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C)
2 | * 2019 Jose Luu
3 | * additional authors:
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, version 3.
8 | *
9 | * This program is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #pragma once
19 | #ifndef _LOOP_H
20 | #define _LOOP_H
21 |
22 | void sendChar(char c);
23 |
24 | #ifdef __cplusplus
25 | extern "C" {
26 | #endif
27 |
28 | void initializeListener();
29 | void doListen(void);
30 |
31 |
32 | #ifdef __cplusplus
33 | }
34 | #endif
35 |
36 |
37 | #endif
38 |
--------------------------------------------------------------------------------
/tests/D6_blinkTest/LEDBlink.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #ifdef __cplusplus
5 | extern "C"
6 | #endif
7 | void SysTick_Handler(void)
8 | {
9 | HAL_IncTick();
10 | HAL_SYSTICK_IRQHandler();
11 | }
12 |
13 | int main(void)
14 | {
15 | HAL_Init();
16 |
17 | __GPIOA_CLK_ENABLE();
18 | __GPIOB_CLK_ENABLE();
19 | GPIO_InitTypeDef GPIO_InitStructure;
20 |
21 | GPIO_InitStructure.Pin = GPIO_PIN_11;
22 |
23 | GPIO_InitStructure.Mode = GPIO_MODE_OUTPUT_PP;
24 | GPIO_InitStructure.Speed = GPIO_SPEED_HIGH;
25 | GPIO_InitStructure.Pull = GPIO_NOPULL;
26 | HAL_GPIO_Init(GPIOA, &GPIO_InitStructure);
27 | GPIO_InitStructure.Pin = GPIO_PIN_1;
28 | HAL_GPIO_Init(GPIOB, &GPIO_InitStructure);
29 |
30 | for (;;)
31 | {
32 | HAL_GPIO_WritePin(GPIOA, GPIO_PIN_11, GPIO_PIN_SET);
33 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_RESET);
34 | HAL_Delay(50);
35 | HAL_GPIO_WritePin(GPIOA, GPIO_PIN_11, GPIO_PIN_RESET);
36 | HAL_GPIO_WritePin(GPIOB, GPIO_PIN_1, GPIO_PIN_SET);
37 | HAL_Delay(50);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/D6_firmware.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "D6_firmware", "D6_firmware.vcxproj", "{ADEEBCB4-D74D-4DDC-95D7-70605ED71C41}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x86 = Debug|x86
11 | Release|x86 = Release|x86
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {ADEEBCB4-D74D-4DDC-95D7-70605ED71C41}.Debug|x64.ActiveCfg = Debug|Win32
15 | {ADEEBCB4-D74D-4DDC-95D7-70605ED71C41}.Debug|x86.ActiveCfg = Debug|Win32
16 | {ADEEBCB4-D74D-4DDC-95D7-70605ED71C41}.Debug|x86.Build.0 = Debug|Win32
17 | {ADEEBCB4-D74D-4DDC-95D7-70605ED71C41}.Release|x64.ActiveCfg = Release|Win32
18 | {ADEEBCB4-D74D-4DDC-95D7-70605ED71C41}.Release|x86.ActiveCfg = Release|Win32
19 | {ADEEBCB4-D74D-4DDC-95D7-70605ED71C41}.Release|x86.Build.0 = Release|Win32
20 | EndGlobalSection
21 | GlobalSection(SolutionProperties) = preSolution
22 | HideSolutionNode = FALSE
23 | EndGlobalSection
24 | EndGlobal
25 |
--------------------------------------------------------------------------------
/tests/D6_blinkTest/D6_blinkTest.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "D6_blinkTest", "D6_blinkTest.vcxproj", "{407440C7-5711-43B3-89E7-96E21EBFA2BD}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x86 = Debug|x86
11 | Release|x86 = Release|x86
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {407440C7-5711-43B3-89E7-96E21EBFA2BD}.Debug|x64.ActiveCfg = Debug|Win32
15 | {407440C7-5711-43B3-89E7-96E21EBFA2BD}.Debug|x86.ActiveCfg = Debug|Win32
16 | {407440C7-5711-43B3-89E7-96E21EBFA2BD}.Debug|x86.Build.0 = Debug|Win32
17 | {407440C7-5711-43B3-89E7-96E21EBFA2BD}.Release|x64.ActiveCfg = Release|Win32
18 | {407440C7-5711-43B3-89E7-96E21EBFA2BD}.Release|x86.ActiveCfg = Release|Win32
19 | {407440C7-5711-43B3-89E7-96E21EBFA2BD}.Release|x86.Build.0 = Release|Win32
20 | EndGlobalSection
21 | GlobalSection(SolutionProperties) = preSolution
22 | HideSolutionNode = FALSE
23 | EndGlobalSection
24 | EndGlobal
25 |
--------------------------------------------------------------------------------
/Src/D6Board.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright (C)
2 | * 2019 Jose Luu
3 | * additional authors:
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, version 3.
8 | *
9 | * This program is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "gpio.h"
19 | #include "main.h"
20 | #include "D6Board.h"
21 |
22 |
23 | void ledD2(bool stateOn) // the tracking generator "on" led
24 | {
25 | HAL_GPIO_WritePin(D2_GPIO_Port, D2_Pin, stateOn ? GPIO_PIN_SET : GPIO_PIN_RESET);
26 | }
27 |
28 | bool buttonPressed(void)
29 | {
30 | return (HAL_GPIO_ReadPin(SW_GPIO_Port, SW_Pin) == GPIO_PIN_SET);
31 | }
32 |
33 |
34 | void sendSingleRegister(WhichADF indexADF, unsigned long reg)
35 | {
36 | sendADF4351(indexADF, reg);
37 | }
--------------------------------------------------------------------------------
/Inc/Command.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C)
2 | * 2019 Jose Luu
3 | * additional authors:
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, version 3.
8 | *
9 | * This program is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #pragma once
19 | #ifndef _COMMAND_H
20 | #define _COMMAND_H
21 |
22 | #define FIRMWARE_VERSION 6
23 |
24 | #define FIRMWARE_ENGINEERING_VARIANT 0
25 |
26 | void doInteractive(char c);
27 | void doNWT(unsigned char c);
28 | void doAD(char c);
29 | void enableTracking(bool newState);
30 |
31 | typedef struct {
32 | char code;
33 | long long frequency;
34 | long long step;
35 | long long count;
36 | long long delay;
37 | long long audio;
38 | unsigned char which;
39 | unsigned long r;
40 | } Command;
41 |
42 | void analyzerStandbyLedOn(bool standbyState);
43 | void executeButtonAction(bool pushedButton);
44 | void executeCommand(Command command);
45 |
46 |
47 | #endif
48 |
--------------------------------------------------------------------------------
/stm32.mak:
--------------------------------------------------------------------------------
1 | #This file is generated by VisualGDB.
2 | #It contains GCC settings automatically derived from the board support package (BSP).
3 | #DO NOT EDIT MANUALLY. THE FILE WILL BE OVERWRITTEN.
4 | #Use VisualGDB Project Properties dialog or modify Makefile or per-configuration .mak files instead.
5 |
6 | #In order to build this project manually (outside VisualGDB), please provide TOOLCHAIN_ROOT, BSP_ROOT, EFP_BASE and TESTFW_BASE variables via Environment or Make command line
7 | #Embedded toolchain
8 | CC := $(TOOLCHAIN_ROOT)/bin/arm-eabi-gcc.exe
9 | CXX := $(TOOLCHAIN_ROOT)/bin/arm-eabi-g++.exe
10 | LD := $(CXX)
11 | AR := $(TOOLCHAIN_ROOT)/bin/arm-eabi-ar.exe
12 | OBJCOPY := $(TOOLCHAIN_ROOT)/bin/arm-eabi-objcopy.exe
13 |
14 | #Additional flags
15 | PREPROCESSOR_MACROS += ARM_MATH_CM3 flash_layout STM32F103C8 USE_HAL_LEGACY STM32F103xB
16 | INCLUDE_DIRS += . $(BSP_ROOT)/STM32F1xxxx/STM32F1xx_HAL_Driver/Inc $(BSP_ROOT)/STM32F1xxxx/STM32F1xx_HAL_Driver/Inc/Legacy $(BSP_ROOT)/STM32F1xxxx/CMSIS_HAL/Device/ST/STM32F1xx/Include $(BSP_ROOT)/STM32F1xxxx/CMSIS_HAL/Include $(BSP_ROOT)/STM32F1xxxx/CMSIS_HAL/Core/Include
17 | LIBRARY_DIRS +=
18 | LIBRARY_NAMES +=
19 | ADDITIONAL_LINKER_INPUTS +=
20 | MACOS_FRAMEWORKS +=
21 | LINUX_PACKAGES +=
22 |
23 | CFLAGS +=
24 | CXXFLAGS +=
25 | ASFLAGS +=
26 | LDFLAGS += --specs=nano.specs --specs=nosys.specs
27 | COMMONFLAGS += -mcpu=cortex-m3 -mthumb
28 | LINKER_SCRIPT := $(BSP_ROOT)/STM32F1xxxx/LinkerScripts/STM32F103C8_flash.lds
29 |
30 |
--------------------------------------------------------------------------------
/tests/D6_blinkTest/stm32.mak:
--------------------------------------------------------------------------------
1 | #This file is generated by VisualGDB.
2 | #It contains GCC settings automatically derived from the board support package (BSP).
3 | #DO NOT EDIT MANUALLY. THE FILE WILL BE OVERWRITTEN.
4 | #Use VisualGDB Project Properties dialog or modify Makefile or per-configuration .mak files instead.
5 |
6 | #VisualGDB provides BSP_ROOT and TOOLCHAIN_ROOT via environment when running Make. The line below will only be active if GNU Make is started manually.
7 | BSP_ROOT ?= $(LOCALAPPDATA)/VisualGDB/EmbeddedBSPs/arm-eabi/com.sysprogs.arm.stm32
8 | EFP_BASE ?= $(LOCALAPPDATA)/VisualGDB/EmbeddedEFPs
9 | TESTFW_BASE ?= $(LOCALAPPDATA)/VisualGDB/TestFrameworks
10 | TOOLCHAIN_ROOT ?= C:/SysGCC/arm-eabi
11 | #Embedded toolchain
12 | CC := $(TOOLCHAIN_ROOT)/bin/arm-eabi-gcc.exe
13 | CXX := $(TOOLCHAIN_ROOT)/bin/arm-eabi-g++.exe
14 | LD := $(CXX)
15 | AR := $(TOOLCHAIN_ROOT)/bin/arm-eabi-ar.exe
16 | OBJCOPY := $(TOOLCHAIN_ROOT)/bin/arm-eabi-objcopy.exe
17 |
18 | #Additional flags
19 | PREPROCESSOR_MACROS += ARM_MATH_CM3 flash_layout STM32F103C8 STM32F103xB USE_HAL_LEGACY
20 | INCLUDE_DIRS += . $(BSP_ROOT)/STM32F1xxxx/STM32F1xx_HAL_Driver/Inc $(BSP_ROOT)/STM32F1xxxx/STM32F1xx_HAL_Driver/Inc/Legacy $(BSP_ROOT)/STM32F1xxxx/CMSIS_HAL/Device/ST/STM32F1xx/Include $(BSP_ROOT)/STM32F1xxxx/CMSIS_HAL/Include
21 | LIBRARY_DIRS +=
22 | LIBRARY_NAMES +=
23 | ADDITIONAL_LINKER_INPUTS +=
24 | MACOS_FRAMEWORKS +=
25 | LINUX_PACKAGES +=
26 |
27 | CFLAGS +=
28 | CXXFLAGS +=
29 | ASFLAGS +=
30 | LDFLAGS += --specs=nano.specs --specs=nosys.specs
31 | COMMONFLAGS += -mcpu=cortex-m3 -mthumb
32 | LINKER_SCRIPT := $(BSP_ROOT)/STM32F1xxxx/LinkerScripts/STM32F103C8_flash.lds
33 |
34 |
--------------------------------------------------------------------------------
/Inc/gpio.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : gpio.h
4 | * Description : This file contains all the functions prototypes for
5 | * the gpio
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2019 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Define to prevent recursive inclusion -------------------------------------*/
21 | #ifndef __gpio_H
22 | #define __gpio_H
23 | #ifdef __cplusplus
24 | extern "C" {
25 | #endif
26 |
27 | /* Includes ------------------------------------------------------------------*/
28 | #include "main.h"
29 |
30 | /* USER CODE BEGIN Includes */
31 |
32 | /* USER CODE END Includes */
33 |
34 | /* USER CODE BEGIN Private defines */
35 |
36 | /* USER CODE END Private defines */
37 |
38 | void MX_GPIO_Init(void);
39 |
40 | /* USER CODE BEGIN Prototypes */
41 |
42 | /* USER CODE END Prototypes */
43 |
44 | #ifdef __cplusplus
45 | }
46 | #endif
47 | #endif /*__ pinoutConfig_H */
48 |
49 | /**
50 | * @}
51 | */
52 |
53 | /**
54 | * @}
55 | */
56 |
57 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
58 |
--------------------------------------------------------------------------------
/Inc/dma.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : dma.h
4 | * Description : This file contains all the function prototypes for
5 | * the dma.c file
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2019 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* Define to prevent recursive inclusion -------------------------------------*/
20 | #ifndef __dma_H
21 | #define __dma_H
22 |
23 | #ifdef __cplusplus
24 | extern "C" {
25 | #endif
26 |
27 | /* Includes ------------------------------------------------------------------*/
28 | #include "main.h"
29 |
30 | /* DMA memory to memory transfer handles -------------------------------------*/
31 |
32 | /* USER CODE BEGIN Includes */
33 |
34 | /* USER CODE END Includes */
35 |
36 | /* USER CODE BEGIN Private defines */
37 |
38 | /* USER CODE END Private defines */
39 |
40 | void MX_DMA_Init(void);
41 |
42 | /* USER CODE BEGIN Prototypes */
43 |
44 | /* USER CODE END Prototypes */
45 |
46 | #ifdef __cplusplus
47 | }
48 | #endif
49 |
50 | #endif /* __dma_H */
51 |
52 | /**
53 | * @}
54 | */
55 |
56 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
57 |
--------------------------------------------------------------------------------
/Inc/usart.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : USART.h
4 | * Description : This file provides code for the configuration
5 | * of the USART instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2019 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* Define to prevent recursive inclusion -------------------------------------*/
20 | #ifndef __usart_H
21 | #define __usart_H
22 | #ifdef __cplusplus
23 | extern "C" {
24 | #endif
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "main.h"
28 |
29 | /* USER CODE BEGIN Includes */
30 |
31 | /* USER CODE END Includes */
32 |
33 | extern UART_HandleTypeDef huart1;
34 |
35 | /* USER CODE BEGIN Private defines */
36 |
37 | /* USER CODE END Private defines */
38 |
39 | void MX_USART1_UART_Init(void);
40 |
41 | /* USER CODE BEGIN Prototypes */
42 |
43 | /* USER CODE END Prototypes */
44 |
45 | #ifdef __cplusplus
46 | }
47 | #endif
48 | #endif /*__ usart_H */
49 |
50 | /**
51 | * @}
52 | */
53 |
54 | /**
55 | * @}
56 | */
57 |
58 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
59 |
--------------------------------------------------------------------------------
/tests/D6_blinkTest/stm32.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | com.visualgdb.arm-eabi
4 | com.sysprogs.arm.stm32
5 | 2018.12R2
6 | STM32F103C8
7 | STM32F1xxxx/DeviceDefinitions/stm32f103xb.xml
8 |
9 |
10 |
11 | com.sysprogs.bspoptions.primary_memory
12 | flash
13 |
14 |
15 | com.sysprogs.mcuoptions.ignore_startup_file
16 |
17 |
18 |
19 | com.sysprogs.toolchainoptions.arm.libctype
20 | --specs=nano.specs
21 |
22 |
23 | com.sysprogs.toolchainoptions.arm.libnosys
24 | --specs=nosys.specs
25 |
26 |
27 |
28 | Device-specific files
29 | stm32.mak
30 |
31 | com.sysprogs.arm.stm32.hal
32 |
33 |
34 |
35 |
36 | com.sysprogs.bspoptions.stm32.hal_legacy
37 | USE_HAL_LEGACY
38 |
39 |
40 | com.sysprogs.stm32.legacy_hal_src
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/Inc/adc.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : ADC.h
4 | * Description : This file provides code for the configuration
5 | * of the ADC instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2019 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* Define to prevent recursive inclusion -------------------------------------*/
20 | #ifndef __adc_H
21 | #define __adc_H
22 | #ifdef __cplusplus
23 | extern "C" {
24 | #endif
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "main.h"
28 |
29 | /* USER CODE BEGIN Includes */
30 | #include
31 |
32 | /* USER CODE END Includes */
33 |
34 | extern ADC_HandleTypeDef hadc1;
35 |
36 | /* USER CODE BEGIN Private defines */
37 |
38 | /* USER CODE END Private defines */
39 |
40 | void MX_ADC1_Init(void);
41 |
42 | /* USER CODE BEGIN Prototypes */
43 |
44 | bool getADCMeasurement(short * val);
45 | bool getADCMeasurementN(short * val, int n);
46 | /* USER CODE END Prototypes */
47 |
48 | #ifdef __cplusplus
49 | }
50 | #endif
51 | #endif /*__ adc_H */
52 |
53 | /**
54 | * @}
55 | */
56 |
57 | /**
58 | * @}
59 | */
60 |
61 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
62 |
--------------------------------------------------------------------------------
/Inc/spi.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : SPI.h
4 | * Description : This file provides code for the configuration
5 | * of the SPI instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2019 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* Define to prevent recursive inclusion -------------------------------------*/
20 | #ifndef __spi_H
21 | #define __spi_H
22 | #ifdef __cplusplus
23 | extern "C" {
24 | #endif
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "main.h"
28 |
29 | /* USER CODE BEGIN Includes */
30 |
31 | /* USER CODE END Includes */
32 |
33 | extern SPI_HandleTypeDef hspi1;
34 | extern SPI_HandleTypeDef hspi2;
35 |
36 | /* USER CODE BEGIN Private defines */
37 |
38 | /* USER CODE END Private defines */
39 |
40 | void MX_SPI1_Init(void);
41 | void MX_SPI2_Init(void);
42 |
43 | /* USER CODE BEGIN Prototypes */
44 | void sendSPI1(unsigned long dataLong);
45 | void sendSPI2(unsigned long dataLong);
46 | /* USER CODE END Prototypes */
47 |
48 | #ifdef __cplusplus
49 | }
50 | #endif
51 | #endif /*__ spi_H */
52 |
53 | /**
54 | * @}
55 | */
56 |
57 | /**
58 | * @}
59 | */
60 |
61 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
62 |
--------------------------------------------------------------------------------
/Inc/tim.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : TIM.h
4 | * Description : This file provides code for the configuration
5 | * of the TIM instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2019 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* Define to prevent recursive inclusion -------------------------------------*/
20 | #ifndef __tim_H
21 | #define __tim_H
22 | #ifdef __cplusplus
23 | extern "C" {
24 | #endif
25 |
26 | /* Includes ------------------------------------------------------------------*/
27 | #include "main.h"
28 |
29 | /* USER CODE BEGIN Includes */
30 | #include
31 | /* USER CODE END Includes */
32 |
33 | extern TIM_HandleTypeDef htim3;
34 |
35 | /* USER CODE BEGIN Private defines */
36 |
37 | /* USER CODE END Private defines */
38 |
39 | void MX_TIM3_Init(void);
40 |
41 | void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
42 |
43 | /* USER CODE BEGIN Prototypes */
44 | void blinkD1(bool newState);
45 | /* USER CODE END Prototypes */
46 |
47 | #ifdef __cplusplus
48 | }
49 | #endif
50 | #endif /*__ tim_H */
51 |
52 | /**
53 | * @}
54 | */
55 |
56 | /**
57 | * @}
58 | */
59 |
60 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
61 |
--------------------------------------------------------------------------------
/Src/dma.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : dma.c
4 | * Description : This file provides code for the configuration
5 | * of all the requested memory to memory DMA transfers.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2019 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* Includes ------------------------------------------------------------------*/
20 | #include "dma.h"
21 |
22 | /* USER CODE BEGIN 0 */
23 |
24 | /* USER CODE END 0 */
25 |
26 | /*----------------------------------------------------------------------------*/
27 | /* Configure DMA */
28 | /*----------------------------------------------------------------------------*/
29 |
30 | /* USER CODE BEGIN 1 */
31 |
32 | /* USER CODE END 1 */
33 |
34 | /**
35 | * Enable DMA controller clock
36 | */
37 | void MX_DMA_Init(void)
38 | {
39 | /* DMA controller clock enable */
40 | __HAL_RCC_DMA1_CLK_ENABLE();
41 |
42 | /* DMA interrupt init */
43 | /* DMA1_Channel5_IRQn interrupt configuration */
44 | HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 0, 0);
45 | HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn);
46 |
47 | }
48 |
49 | /* USER CODE BEGIN 2 */
50 |
51 | /* USER CODE END 2 */
52 |
53 | /**
54 | * @}
55 | */
56 |
57 | /**
58 | * @}
59 | */
60 |
61 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
62 |
--------------------------------------------------------------------------------
/stm32.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | com.visualgdb.arm-eabi
4 |
5 | 7.2.0
6 | 8.0.1
7 | 3
8 |
9 | com.sysprogs.arm.stm32
10 | 2019.06
11 | STM32F103C8
12 | STM32F1xxxx/DeviceDefinitions/stm32f103xb.xml
13 |
14 |
15 |
16 | com.sysprogs.bspoptions.primary_memory
17 | flash
18 |
19 |
20 | com.sysprogs.mcuoptions.ignore_startup_file
21 |
22 |
23 |
24 | com.sysprogs.toolchainoptions.arm.libctype
25 | --specs=nano.specs
26 |
27 |
28 | com.sysprogs.toolchainoptions.arm.libnosys
29 | --specs=nosys.specs
30 |
31 |
32 |
33 | Device-specific files
34 | stm32.mak
35 |
36 | com.sysprogs.arm.stm32.hal
37 | com.sysprogs.arm.stm32.STM32F1_ll
38 |
39 |
40 |
41 |
42 | com.sysprogs.bspoptions.stm32.hal_legacy
43 | USE_HAL_LEGACY
44 |
45 |
46 | com.sysprogs.stm32.legacy_hal_src
47 |
48 |
49 |
50 | com.sysprogs.bspoptions.stm32.ll_driver
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/Inc/debouncedButton.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C)
2 | * 2019 Jose Luu
3 | * additional authors:
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, version 3.
8 | *
9 | * This program is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #pragma once
19 | #ifndef _DEBOUNCEDBUTTON_H
20 | #define _DEBOUNCEDBUTTON_H
21 | #include "gpio.h"
22 |
23 | #define MAX_DEBOUNCED_BUTTONS 1
24 |
25 | #ifndef __cplusplus
26 | // C interface
27 | #include
28 |
29 | void DebouncedButton_SysTick_Handler(); //insert call to this function in the SysTick_Handler function
30 | bool DebouncedButton_buttonState(int index, bool * changed);
31 | int DebouncedButton_addNewButton(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin);
32 | #else
33 | class DebouncedButton
34 | {
35 | GPIO_TypeDef *GPIOx;
36 | uint16_t GPIO_Pin;
37 | int buttonPressed_0;
38 | int buttonPressed_1;
39 | int debounceThreshold = 10;
40 | bool buttonPressConfirmed;
41 | bool buttonPressChanged;
42 |
43 | void buttonSysTick_Handler();
44 | bool readButtonPress();
45 |
46 | public:
47 | static int addButton(DebouncedButton * button);
48 | static DebouncedButton * allButtons[MAX_DEBOUNCED_BUTTONS];
49 | static int debouncedButtonCount;
50 | static void SysTick_Handler();
51 |
52 | bool buttonState(bool * changed);
53 |
54 | DebouncedButton(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, int debounceThreshold = 50)
55 | : GPIOx(GPIOx)
56 | , GPIO_Pin(GPIO_Pin)
57 | , debounceThreshold(debounceThreshold)
58 | , buttonPressed_0(0)
59 | , buttonPressed_1(0)
60 | , buttonPressConfirmed(false)
61 | , buttonPressChanged(false)
62 | {
63 | }
64 | };
65 | #endif
66 |
67 |
68 | #endif
--------------------------------------------------------------------------------
/Inc/Serial.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C)
2 | * 2019 Jose Luu
3 | * additional authors:
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, version 3.
8 | *
9 | * This program is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #pragma once
19 | #ifndef SERIAL_H
20 | #define SERIAL_H
21 |
22 | #include "usart.h"
23 |
24 |
25 | #ifdef Error_Handler
26 | #undef Error_Handler
27 | #endif // Error_Handler
28 |
29 | class SerialOutput {
30 | public:
31 | SerialOutput(UART_HandleTypeDef * pHandle, char * driverBuffer, unsigned int size);
32 | bool puts(const char * str);
33 | bool putch(char c);
34 | bool putsNonBlocking(const char * str);
35 | void doOutputIT();
36 |
37 | static SerialOutput * channel_1;
38 | static SerialOutput * channel_2;
39 | static SerialOutput * channel_3;
40 |
41 | char * driverBuffer;
42 | unsigned int driverBufferSize;
43 | bool busy;
44 | UART_HandleTypeDef *pHandle;
45 | };
46 |
47 |
48 | class SerialInput {
49 | public:
50 | SerialInput(UART_HandleTypeDef * pHandle, char * buffer, unsigned int size);
51 | void initialize(SerialOutput * echoChannel = NULL);
52 | void doInputIT();
53 | bool fgetc(unsigned char & c); // non blocking
54 | char * fgets(char * str, int size);
55 | bool isCharAvailable();
56 | char * fgetsNonBlocking(char * str, int size);
57 |
58 | static SerialInput * channel_1;
59 | static SerialInput * channel_2;
60 | static SerialInput * channel_3;
61 |
62 | SerialOutput * echo;
63 | uint8_t rxBuffer; // used by DMA
64 | char inputBuffer[2];
65 | bool eol;
66 | bool textMode;
67 | unsigned int overrun;
68 | unsigned int nChars;
69 | char * driverBuffer;
70 | char * driverBufferNextChar;
71 | unsigned int driverBufferSize;
72 | SerialInput * serialObject;
73 | UART_HandleTypeDef *pHandle;
74 | };
75 |
76 |
77 | #endif
78 |
79 |
--------------------------------------------------------------------------------
/Inc/D6Board.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C)
2 | * 2019 Jose Luu
3 | * additional authors:
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, version 3.
8 | *
9 | * This program is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #pragma once
19 | #ifndef _D6CONFIGURATION_H
20 | #define _D6CONFIGURATION_H
21 |
22 |
23 | #define REFERENCE 25000000 // 25 MHz local reference
24 | #define MODULUS_VALUE 3125 // must be less than 4096 (12 bits)
25 | #define CHANNEL_SPACING (REFERENCE/MODULUS_VALUE)
26 |
27 | typedef enum {
28 | eTracking = 0,
29 | eAnalyzer
30 | } WhichADF;
31 |
32 | #include "ADF4351.h"
33 |
34 | //R1
35 | #define R1 ((MODULUS_VALUE & MOD_VALUE_MASK) << MOD_VALUE_SHIFT) | PHASE_VALUE_DEFAULT | PRESCALER8_9 | R1_ADDRESS
36 |
37 | //R2
38 | #define R_COUNTER 1 // PFD=REFERENCE (25Mhz)
39 | #define R2 PD_POLARITY_POS | LOCK_DETECT_PRECISION_10NS | DOUBLE_BUFFERING_ENABLE | CHARGE_CURRENT_2_5MA | (R_COUNTER << R_COUNTER_SHIFT ) | R2_ADDRESS
40 |
41 | //R3
42 | #define CLOCK_DIVIDER 150 << CLOCK_DIVIDER_VALUE_SHIFT
43 | #define R3 CLOCK_DIVIDER | R3_ADDRESS
44 |
45 | //R4
46 | #define BS_CLOCK 200 << BAND_SELECT_CLOCK_DIVIDER_SHIFT
47 | #define R4 RF_OUTPUT_MINUS4dBm | RF_OUTPUT_ENABLE | BS_CLOCK | FEEDBACK_FUNDAMENTAL | R4_ADDRESS // no AUX output
48 |
49 | //R5
50 | #define R5 R5_RESERVED | DIGITAL_LOCK_DETECT_PIN | R5_ADDRESS
51 |
52 |
53 | #ifdef __cplusplus
54 | bool frequencySetup(WhichADF indexADF, unsigned long long frequency, unsigned int level, unsigned int & range, bool forceRange);
55 | void sendSingleRegister(WhichADF indexADF, unsigned long reg);
56 | void sendADF4351(WhichADF indexADF, unsigned long reg);
57 | void ADF4351Off(WhichADF indexADF);
58 | #endif
59 |
60 | #ifdef __cplusplus
61 | extern "C" {
62 | #endif
63 |
64 | void ledD1(bool stateOn);
65 | void ledD2(bool stateOn);
66 | void probeSPI(WhichADF indexADF);
67 |
68 | #ifdef __cplusplus
69 | }
70 | #endif
71 |
72 |
73 |
74 |
75 |
76 | #endif
--------------------------------------------------------------------------------
/Inc/stm32f1xx_it.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file stm32f1xx_it.h
5 | * @brief This file contains the headers of the interrupt handlers.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2019 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* USER CODE END Header */
20 |
21 | /* Define to prevent recursive inclusion -------------------------------------*/
22 | #ifndef __STM32F1xx_IT_H
23 | #define __STM32F1xx_IT_H
24 |
25 | #ifdef __cplusplus
26 | extern "C" {
27 | #endif
28 |
29 | /* Private includes ----------------------------------------------------------*/
30 | /* USER CODE BEGIN Includes */
31 |
32 | /* USER CODE END Includes */
33 |
34 | /* Exported types ------------------------------------------------------------*/
35 | /* USER CODE BEGIN ET */
36 |
37 | /* USER CODE END ET */
38 |
39 | /* Exported constants --------------------------------------------------------*/
40 | /* USER CODE BEGIN EC */
41 |
42 | /* USER CODE END EC */
43 |
44 | /* Exported macro ------------------------------------------------------------*/
45 | /* USER CODE BEGIN EM */
46 |
47 | /* USER CODE END EM */
48 |
49 | /* Exported functions prototypes ---------------------------------------------*/
50 | void NMI_Handler(void);
51 | void HardFault_Handler(void);
52 | void MemManage_Handler(void);
53 | void BusFault_Handler(void);
54 | void UsageFault_Handler(void);
55 | void SVC_Handler(void);
56 | void DebugMon_Handler(void);
57 | void PendSV_Handler(void);
58 | void SysTick_Handler(void);
59 | void DMA1_Channel5_IRQHandler(void);
60 | void ADC1_2_IRQHandler(void);
61 | void USART1_IRQHandler(void);
62 | /* USER CODE BEGIN EFP */
63 |
64 | /* USER CODE END EFP */
65 |
66 | #ifdef __cplusplus
67 | }
68 | #endif
69 |
70 | #endif /* __STM32F1xx_IT_H */
71 |
72 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
73 |
--------------------------------------------------------------------------------
/Src/stm32f1xx_hal_msp.c:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * File Name : stm32f1xx_hal_msp.c
5 | * Description : This file provides code for the MSP Initialization
6 | * and de-Initialization codes.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2019 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under BSD 3-Clause license,
14 | * the "License"; You may not use this file except in compliance with the
15 | * License. You may obtain a copy of the License at:
16 | * opensource.org/licenses/BSD-3-Clause
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Includes ------------------------------------------------------------------*/
23 | #include "main.h"
24 | /* USER CODE BEGIN Includes */
25 |
26 | /* USER CODE END Includes */
27 |
28 | /* Private typedef -----------------------------------------------------------*/
29 | /* USER CODE BEGIN TD */
30 |
31 | /* USER CODE END TD */
32 |
33 | /* Private define ------------------------------------------------------------*/
34 | /* USER CODE BEGIN Define */
35 |
36 | /* USER CODE END Define */
37 |
38 | /* Private macro -------------------------------------------------------------*/
39 | /* USER CODE BEGIN Macro */
40 |
41 | /* USER CODE END Macro */
42 |
43 | /* Private variables ---------------------------------------------------------*/
44 | /* USER CODE BEGIN PV */
45 |
46 | /* USER CODE END PV */
47 |
48 | /* Private function prototypes -----------------------------------------------*/
49 | /* USER CODE BEGIN PFP */
50 |
51 | /* USER CODE END PFP */
52 |
53 | /* External functions --------------------------------------------------------*/
54 | /* USER CODE BEGIN ExternalFunctions */
55 |
56 | /* USER CODE END ExternalFunctions */
57 |
58 | /* USER CODE BEGIN 0 */
59 |
60 | /* USER CODE END 0 */
61 | /**
62 | * Initializes the Global MSP.
63 | */
64 | void HAL_MspInit(void)
65 | {
66 | /* USER CODE BEGIN MspInit 0 */
67 |
68 | /* USER CODE END MspInit 0 */
69 |
70 | __HAL_RCC_AFIO_CLK_ENABLE();
71 | __HAL_RCC_PWR_CLK_ENABLE();
72 |
73 | /* System interrupt init*/
74 |
75 | /** NOJTAG: JTAG-DP Disabled and SW-DP Enabled
76 | */
77 | __HAL_AFIO_REMAP_SWJ_NOJTAG();
78 |
79 | /* USER CODE BEGIN MspInit 1 */
80 |
81 | /* USER CODE END MspInit 1 */
82 | }
83 |
84 | /* USER CODE BEGIN 1 */
85 |
86 | /* USER CODE END 1 */
87 |
88 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
89 |
--------------------------------------------------------------------------------
/Inc/main.h:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file : main.h
5 | * @brief : Header for main.c file.
6 | * This file contains the common defines of the application.
7 | ******************************************************************************
8 | * @attention
9 | *
10 | * © Copyright (c) 2019 STMicroelectronics.
11 | * All rights reserved.
12 | *
13 | * This software component is licensed by ST under BSD 3-Clause license,
14 | * the "License"; You may not use this file except in compliance with the
15 | * License. You may obtain a copy of the License at:
16 | * opensource.org/licenses/BSD-3-Clause
17 | *
18 | ******************************************************************************
19 | */
20 | /* USER CODE END Header */
21 |
22 | /* Define to prevent recursive inclusion -------------------------------------*/
23 | #ifndef __MAIN_H
24 | #define __MAIN_H
25 |
26 | #ifdef __cplusplus
27 | extern "C" {
28 | #endif
29 |
30 | /* Includes ------------------------------------------------------------------*/
31 | #include "stm32f1xx_hal.h"
32 |
33 | /* Private includes ----------------------------------------------------------*/
34 | /* USER CODE BEGIN Includes */
35 |
36 | /* USER CODE END Includes */
37 |
38 | /* Exported types ------------------------------------------------------------*/
39 | /* USER CODE BEGIN ET */
40 |
41 | /* USER CODE END ET */
42 |
43 | /* Exported constants --------------------------------------------------------*/
44 | /* USER CODE BEGIN EC */
45 |
46 | /* USER CODE END EC */
47 |
48 | /* Exported macro ------------------------------------------------------------*/
49 | /* USER CODE BEGIN EM */
50 |
51 | #define ACTIVE_UART huart1
52 | #define ACTIVE_CHANNEL channel_1
53 |
54 | /* USER CODE END EM */
55 |
56 | /* Exported functions prototypes ---------------------------------------------*/
57 | void Error_Handler(void);
58 |
59 | /* USER CODE BEGIN EFP */
60 | void start_us_DWT(int slot);
61 | unsigned int get_us_DWT(int slot);
62 | void delay_us_DWT(unsigned long uSec);
63 | /* USER CODE END EFP */
64 |
65 | /* Private defines -----------------------------------------------------------*/
66 | #define AD8307_EN_Pin GPIO_PIN_15
67 | #define AD8307_EN_GPIO_Port GPIOC
68 | #define ADC_Pin GPIO_PIN_3
69 | #define ADC_GPIO_Port GPIOA
70 | #define LEA_Pin GPIO_PIN_4
71 | #define LEA_GPIO_Port GPIOA
72 | #define D1_Pin GPIO_PIN_1
73 | #define D1_GPIO_Port GPIOB
74 | #define LE_Pin GPIO_PIN_12
75 | #define LE_GPIO_Port GPIOB
76 | #define D2_Pin GPIO_PIN_11
77 | #define D2_GPIO_Port GPIOA
78 | #define SW_Pin GPIO_PIN_12
79 | #define SW_GPIO_Port GPIOA
80 | #define T_Pin GPIO_PIN_6
81 | #define T_GPIO_Port GPIOB
82 | #define R_Pin GPIO_PIN_7
83 | #define R_GPIO_Port GPIOB
84 | /* USER CODE BEGIN Private defines */
85 | void Error_Handler(void);
86 | /* USER CODE END Private defines */
87 |
88 | #ifdef __cplusplus
89 | }
90 | #endif
91 |
92 | #endif /* __MAIN_H */
93 |
94 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
95 |
--------------------------------------------------------------------------------
/Src/gpio.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : gpio.c
4 | * Description : This file provides code for the configuration
5 | * of all used GPIO pins.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2019 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "gpio.h"
22 | /* USER CODE BEGIN 0 */
23 |
24 | /* USER CODE END 0 */
25 |
26 | /*----------------------------------------------------------------------------*/
27 | /* Configure GPIO */
28 | /*----------------------------------------------------------------------------*/
29 | /* USER CODE BEGIN 1 */
30 |
31 | /* USER CODE END 1 */
32 |
33 | /** Configure pins as
34 | * Analog
35 | * Input
36 | * Output
37 | * EVENT_OUT
38 | * EXTI
39 | PA3 ------> ADCx_IN3
40 | */
41 | void MX_GPIO_Init(void)
42 | {
43 |
44 | GPIO_InitTypeDef GPIO_InitStruct = {0};
45 |
46 | /* GPIO Ports Clock Enable */
47 | __HAL_RCC_GPIOC_CLK_ENABLE();
48 | __HAL_RCC_GPIOD_CLK_ENABLE();
49 | __HAL_RCC_GPIOA_CLK_ENABLE();
50 | __HAL_RCC_GPIOB_CLK_ENABLE();
51 |
52 | /*Configure GPIO pin Output Level */
53 | HAL_GPIO_WritePin(GPIOA, LEA_Pin|D2_Pin, GPIO_PIN_RESET);
54 |
55 | /*Configure GPIO pin Output Level */
56 | HAL_GPIO_WritePin(LE_GPIO_Port, LE_Pin, GPIO_PIN_RESET);
57 |
58 | /*Configure GPIO pin : PtPin */
59 | GPIO_InitStruct.Pin = AD8307_EN_Pin;
60 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
61 | GPIO_InitStruct.Pull = GPIO_PULLUP;
62 | HAL_GPIO_Init(AD8307_EN_GPIO_Port, &GPIO_InitStruct);
63 |
64 | /*Configure GPIO pin : PtPin */
65 | GPIO_InitStruct.Pin = ADC_Pin;
66 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
67 | HAL_GPIO_Init(ADC_GPIO_Port, &GPIO_InitStruct);
68 |
69 | /*Configure GPIO pins : PAPin PAPin */
70 | GPIO_InitStruct.Pin = LEA_Pin|D2_Pin;
71 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
72 | GPIO_InitStruct.Pull = GPIO_NOPULL;
73 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
74 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
75 |
76 | /*Configure GPIO pin : PtPin */
77 | GPIO_InitStruct.Pin = LE_Pin;
78 | GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
79 | GPIO_InitStruct.Pull = GPIO_NOPULL;
80 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
81 | HAL_GPIO_Init(LE_GPIO_Port, &GPIO_InitStruct);
82 |
83 | /*Configure GPIO pin : PtPin */
84 | GPIO_InitStruct.Pin = SW_Pin;
85 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
86 | GPIO_InitStruct.Pull = GPIO_NOPULL;
87 | HAL_GPIO_Init(SW_GPIO_Port, &GPIO_InitStruct);
88 |
89 | }
90 |
91 | /* USER CODE BEGIN 2 */
92 |
93 | /* USER CODE END 2 */
94 |
95 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
96 |
--------------------------------------------------------------------------------
/Src/debouncedButton.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright (C)
2 | * 2019 Jose Luu
3 | * additional authors:
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, version 3.
8 | *
9 | * This program is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "debouncedButton.h"
19 |
20 | DebouncedButton * DebouncedButton::allButtons[MAX_DEBOUNCED_BUTTONS];
21 | int DebouncedButton::debouncedButtonCount;
22 |
23 | bool DebouncedButton::readButtonPress()
24 | {
25 | return (HAL_GPIO_ReadPin(GPIOx, GPIO_Pin) == GPIO_PIN_RESET); // pressing the button means a zero
26 | }
27 |
28 | void DebouncedButton::buttonSysTick_Handler()
29 | {
30 | bool buttonPressed = readButtonPress();
31 | static int buttonPressed_0;
32 | static int buttonPressed_1;
33 | const int debounceThreshold = 10;
34 |
35 | if (buttonPressed) {
36 | if (!buttonPressConfirmed)
37 | {
38 | buttonPressed_0 = 0;
39 | buttonPressed_1++;
40 | if (buttonPressed_1 > debounceThreshold) {
41 | buttonPressed_1 = debounceThreshold + 1;
42 | if (!buttonPressConfirmed) {
43 | buttonPressChanged = true;
44 | }
45 | buttonPressConfirmed = true;
46 | }
47 | }
48 | } else {
49 | if (buttonPressConfirmed)
50 | {
51 | buttonPressed_0++;
52 | buttonPressed_1 = 0;
53 | if (buttonPressed_0 > debounceThreshold) {
54 | buttonPressed_0 = debounceThreshold + 1;
55 | if (buttonPressConfirmed) {
56 | buttonPressChanged = true;
57 | }
58 | buttonPressConfirmed = false;
59 | }
60 | }
61 | }
62 | }
63 |
64 | bool DebouncedButton::buttonState(bool * changed)
65 | {
66 | * changed = buttonPressChanged;
67 | buttonPressChanged = false; // only happens once
68 | return buttonPressConfirmed;
69 | }
70 |
71 | int DebouncedButton::addButton(DebouncedButton * button)
72 | {
73 | int value=-1;
74 | if (debouncedButtonCount < MAX_DEBOUNCED_BUTTONS)
75 | {
76 | value = DebouncedButton::debouncedButtonCount;
77 | DebouncedButton::allButtons[value] = button;
78 | DebouncedButton::debouncedButtonCount++;
79 | } else {
80 | Error_Handler();
81 | }
82 | return value;
83 | }
84 |
85 | void DebouncedButton::SysTick_Handler()
86 | {
87 | for (int i = 0; i < DebouncedButton::debouncedButtonCount;i++)
88 | {
89 | DebouncedButton::allButtons[i]->buttonSysTick_Handler();
90 | }
91 | }
92 |
93 | // C interface implementation
94 | extern "C" {
95 | void DebouncedButton_SysTick_Handler()
96 | {
97 | DebouncedButton::SysTick_Handler();
98 | }
99 |
100 | bool DebouncedButton_buttonState(int index, bool * changed)
101 | {
102 | DebouncedButton::allButtons[index]->buttonState(changed);
103 | }
104 |
105 | int DebouncedButton_addNewButton(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
106 | {
107 | DebouncedButton * button = new DebouncedButton(GPIOx, GPIO_Pin);
108 | return DebouncedButton::addButton(button);
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/Src/adc.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : ADC.c
4 | * Description : This file provides code for the configuration
5 | * of the ADC instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2019 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "adc.h"
22 |
23 | /* USER CODE BEGIN 0 */
24 |
25 | /* USER CODE END 0 */
26 |
27 | ADC_HandleTypeDef hadc1;
28 |
29 | /* ADC1 init function */
30 | void MX_ADC1_Init(void)
31 | {
32 | ADC_ChannelConfTypeDef sConfig = {0};
33 |
34 | /** Common config
35 | */
36 | hadc1.Instance = ADC1;
37 | hadc1.Init.ScanConvMode = ADC_SCAN_DISABLE;
38 | hadc1.Init.ContinuousConvMode = ENABLE;
39 | hadc1.Init.DiscontinuousConvMode = DISABLE;
40 | hadc1.Init.ExternalTrigConv = ADC_SOFTWARE_START;
41 | hadc1.Init.DataAlign = ADC_DATAALIGN_RIGHT;
42 | hadc1.Init.NbrOfConversion = 1;
43 | if (HAL_ADC_Init(&hadc1) != HAL_OK)
44 | {
45 | Error_Handler();
46 | }
47 | /** Configure Regular Channel
48 | */
49 | sConfig.Channel = ADC_CHANNEL_3;
50 | sConfig.Rank = ADC_REGULAR_RANK_1;
51 | sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5;
52 | if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
53 | {
54 | Error_Handler();
55 | }
56 |
57 | }
58 |
59 | void HAL_ADC_MspInit(ADC_HandleTypeDef* adcHandle)
60 | {
61 |
62 | GPIO_InitTypeDef GPIO_InitStruct = {0};
63 | if(adcHandle->Instance==ADC1)
64 | {
65 | /* USER CODE BEGIN ADC1_MspInit 0 */
66 |
67 | /* USER CODE END ADC1_MspInit 0 */
68 | /* ADC1 clock enable */
69 | __HAL_RCC_ADC1_CLK_ENABLE();
70 |
71 | __HAL_RCC_GPIOA_CLK_ENABLE();
72 | /**ADC1 GPIO Configuration
73 | PA3 ------> ADC1_IN3
74 | */
75 | GPIO_InitStruct.Pin = ADC_Pin;
76 | GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
77 | HAL_GPIO_Init(ADC_GPIO_Port, &GPIO_InitStruct);
78 |
79 | /* ADC1 interrupt Init */
80 | HAL_NVIC_SetPriority(ADC1_2_IRQn, 0, 0);
81 | HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
82 | /* USER CODE BEGIN ADC1_MspInit 1 */
83 |
84 | /* USER CODE END ADC1_MspInit 1 */
85 | }
86 | }
87 |
88 | void HAL_ADC_MspDeInit(ADC_HandleTypeDef* adcHandle)
89 | {
90 |
91 | if(adcHandle->Instance==ADC1)
92 | {
93 | /* USER CODE BEGIN ADC1_MspDeInit 0 */
94 |
95 | /* USER CODE END ADC1_MspDeInit 0 */
96 | /* Peripheral clock disable */
97 | __HAL_RCC_ADC1_CLK_DISABLE();
98 |
99 | /**ADC1 GPIO Configuration
100 | PA3 ------> ADC1_IN3
101 | */
102 | HAL_GPIO_DeInit(ADC_GPIO_Port, ADC_Pin);
103 |
104 | /* ADC1 interrupt Deinit */
105 | HAL_NVIC_DisableIRQ(ADC1_2_IRQn);
106 | /* USER CODE BEGIN ADC1_MspDeInit 1 */
107 |
108 | /* USER CODE END ADC1_MspDeInit 1 */
109 | }
110 | }
111 |
112 | /* USER CODE BEGIN 1 */
113 |
114 | short g_ADCValue;
115 | unsigned long g_MeasurementNumber;
116 |
117 | bool getADCMeasurement(short * val)
118 | {
119 | bool bValue = false;
120 | HAL_ADC_Start(&hadc1);
121 | if(HAL_ADC_PollForConversion(&hadc1, 1000000) == HAL_OK)
122 | {
123 | g_ADCValue = HAL_ADC_GetValue(&hadc1);
124 | g_MeasurementNumber++;
125 | *val = g_ADCValue;
126 | bValue= true;
127 | }
128 | HAL_ADC_Stop(&hadc1);
129 | return bValue;
130 | }
131 | bool getADCMeasurementN(short * val,int n)
132 | {
133 | g_ADCValue = 0;
134 | bool bValue = false;
135 | for (int i=0;i© Copyright (c) 2019 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "usart.h"
22 |
23 | /* USER CODE BEGIN 0 */
24 |
25 | /* USER CODE END 0 */
26 |
27 | UART_HandleTypeDef huart1;
28 | DMA_HandleTypeDef hdma_usart1_rx;
29 |
30 | /* USART1 init function */
31 |
32 | void MX_USART1_UART_Init(void)
33 | {
34 |
35 | huart1.Instance = USART1;
36 | huart1.Init.BaudRate = 57600;
37 | huart1.Init.WordLength = UART_WORDLENGTH_8B;
38 | huart1.Init.StopBits = UART_STOPBITS_1;
39 | huart1.Init.Parity = UART_PARITY_NONE;
40 | huart1.Init.Mode = UART_MODE_TX_RX;
41 | huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
42 | huart1.Init.OverSampling = UART_OVERSAMPLING_16;
43 | if (HAL_UART_Init(&huart1) != HAL_OK)
44 | {
45 | Error_Handler();
46 | }
47 |
48 | }
49 |
50 | void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
51 | {
52 |
53 | GPIO_InitTypeDef GPIO_InitStruct = {0};
54 | if(uartHandle->Instance==USART1)
55 | {
56 | /* USER CODE BEGIN USART1_MspInit 0 */
57 |
58 | /* USER CODE END USART1_MspInit 0 */
59 | /* USART1 clock enable */
60 | __HAL_RCC_USART1_CLK_ENABLE();
61 |
62 | __HAL_RCC_GPIOB_CLK_ENABLE();
63 | /**USART1 GPIO Configuration
64 | PB6 ------> USART1_TX
65 | PB7 ------> USART1_RX
66 | */
67 | GPIO_InitStruct.Pin = T_Pin;
68 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
69 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
70 | HAL_GPIO_Init(T_GPIO_Port, &GPIO_InitStruct);
71 |
72 | GPIO_InitStruct.Pin = R_Pin;
73 | GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
74 | GPIO_InitStruct.Pull = GPIO_NOPULL;
75 | HAL_GPIO_Init(R_GPIO_Port, &GPIO_InitStruct);
76 |
77 | __HAL_AFIO_REMAP_USART1_ENABLE();
78 |
79 | /* USART1 DMA Init */
80 | /* USART1_RX Init */
81 | hdma_usart1_rx.Instance = DMA1_Channel5;
82 | hdma_usart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
83 | hdma_usart1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
84 | hdma_usart1_rx.Init.MemInc = DMA_MINC_ENABLE;
85 | hdma_usart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
86 | hdma_usart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
87 | hdma_usart1_rx.Init.Mode = DMA_CIRCULAR;
88 | hdma_usart1_rx.Init.Priority = DMA_PRIORITY_LOW;
89 | if (HAL_DMA_Init(&hdma_usart1_rx) != HAL_OK)
90 | {
91 | Error_Handler();
92 | }
93 |
94 | __HAL_LINKDMA(uartHandle,hdmarx,hdma_usart1_rx);
95 |
96 | /* USART1 interrupt Init */
97 | HAL_NVIC_SetPriority(USART1_IRQn, 0, 0);
98 | HAL_NVIC_EnableIRQ(USART1_IRQn);
99 | /* USER CODE BEGIN USART1_MspInit 1 */
100 |
101 | /* USER CODE END USART1_MspInit 1 */
102 | }
103 | }
104 |
105 | void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
106 | {
107 |
108 | if(uartHandle->Instance==USART1)
109 | {
110 | /* USER CODE BEGIN USART1_MspDeInit 0 */
111 |
112 | /* USER CODE END USART1_MspDeInit 0 */
113 | /* Peripheral clock disable */
114 | __HAL_RCC_USART1_CLK_DISABLE();
115 |
116 | /**USART1 GPIO Configuration
117 | PB6 ------> USART1_TX
118 | PB7 ------> USART1_RX
119 | */
120 | HAL_GPIO_DeInit(GPIOB, T_Pin|R_Pin);
121 |
122 | /* USART1 DMA DeInit */
123 | HAL_DMA_DeInit(uartHandle->hdmarx);
124 |
125 | /* USART1 interrupt Deinit */
126 | HAL_NVIC_DisableIRQ(USART1_IRQn);
127 | /* USER CODE BEGIN USART1_MspDeInit 1 */
128 |
129 | /* USER CODE END USART1_MspDeInit 1 */
130 | }
131 | }
132 |
133 | /* USER CODE BEGIN 1 */
134 |
135 | /* USER CODE END 1 */
136 |
137 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
138 |
--------------------------------------------------------------------------------
/Src/Command.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright (C)
2 | * 2019 Jose Luu
3 | * additional authors:
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, version 3.
8 | *
9 | * This program is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include
19 | #include "adc.h"
20 | #include "main.h"
21 | #include "tim.h"
22 | #include "D6Board.h"
23 | #include "Loop.h"
24 | #include "Serial.h"
25 | #include "Command.h"
26 |
27 | #define STR(s) #s
28 | char firmwareVersion[] = "D6 Simple Spectrum firmware by Jose F1FGV Version " STR(FIRMWARE_VERSION);
29 |
30 | static unsigned long delayFactor = 100;
31 | static long analyzerOffset = 128000;
32 | static bool trackingGeneratorEnabled = false;
33 |
34 | void analyzerStandbyLedOn(bool newState)
35 | {
36 | blinkD1(newState);
37 | }
38 |
39 | void enableTracking(bool newState)
40 | {
41 | trackingGeneratorEnabled = newState;
42 | ledD2(newState);
43 | if (!newState)
44 | {
45 | ADF4351Off(eTracking);
46 | }
47 | }
48 |
49 | bool isTrackingEnabled()
50 | {
51 | return trackingGeneratorEnabled;
52 | }
53 |
54 | void setDelayFactor(unsigned long newDelayFactor)
55 | {
56 | delayFactor = newDelayFactor;
57 | }
58 | unsigned long getDelayFactor(void)
59 | {
60 | return delayFactor;
61 | }
62 | void setAnalyzerOffet(long newAnalyzerOffset)
63 | {
64 | analyzerOffset = newAnalyzerOffset;
65 | }
66 | long getAnalyzerOffset(void)
67 | {
68 | return analyzerOffset;
69 | }
70 | void sendStatus()
71 | {
72 | sendChar(FIRMWARE_VERSION);
73 | sendChar(FIRMWARE_ENGINEERING_VARIANT);
74 | sendChar(0xFF);
75 | sendChar(0xFF);
76 | }
77 |
78 | void sendMeasurement()
79 | {
80 | short value = 0;
81 | char cValue[2] = { 0, 0 };
82 | if (getADCMeasurement(&value)) {
83 | // value /= 4 ; // use 10 bits
84 | memcpy(cValue, &value, 2);
85 | sendChar(cValue[0]);
86 | sendChar(cValue[1]);
87 | sendChar(cValue[0]);
88 | sendChar(cValue[1]);
89 | }
90 | }
91 |
92 | void executeButtonAction(bool pushedButton)
93 | {
94 | if (pushedButton) {
95 | enableTracking(!isTrackingEnabled());
96 | }
97 | }
98 |
99 | void executeCommand(Command command)
100 | {
101 | unsigned int range;
102 |
103 | switch(command.code)
104 | {
105 | case 'f':
106 | #ifdef DEBUG_SPI
107 | while (true)
108 | {
109 | ledD1(true);
110 | probeSPI(eTracking);
111 | probeSPI(eAnalyzer);
112 | ledD1(false);
113 | delay_us_DWT(10);
114 | }
115 | #else
116 | if (isTrackingEnabled()) {
117 | if (frequencySetup(eTracking, command.frequency, 4, range, false)) {
118 | analyzerStandbyLedOn(!frequencySetup(eAnalyzer, command.frequency + analyzerOffset, 4, range, true));
119 | } else {
120 | analyzerStandbyLedOn(true);
121 | ADF4351Off(eAnalyzer);
122 | }
123 | } else {
124 | analyzerStandbyLedOn(!frequencySetup(eAnalyzer, command.frequency + analyzerOffset, 4, range, false));
125 | }
126 | #endif
127 | break;
128 | case 'a':
129 | case 'b':
130 | case 'c':
131 | case 'd':
132 | case 'w':
133 | case 'x':
134 | int i;
135 | for (i=0;iFLASH
57 |
58 | /* The program code and other data goes into FLASH */
59 | .text :
60 | {
61 | . = ALIGN(4);
62 | *(.text) /* .text sections (code) */
63 | *(.text*) /* .text* sections (code) */
64 | *(.glue_7) /* glue arm to thumb code */
65 | *(.glue_7t) /* glue thumb to arm code */
66 | *(.eh_frame)
67 |
68 | KEEP (*(.init))
69 | KEEP (*(.fini))
70 |
71 | . = ALIGN(4);
72 | _etext = .; /* define a global symbols at end of code */
73 | } >FLASH
74 |
75 | /* Constant data goes into FLASH */
76 | .rodata :
77 | {
78 | . = ALIGN(4);
79 | *(.rodata) /* .rodata sections (constants, strings, etc.) */
80 | *(.rodata*) /* .rodata* sections (constants, strings, etc.) */
81 | . = ALIGN(4);
82 | } >FLASH
83 |
84 | .ARM.extab : { *(.ARM.extab* .gnu.linkonce.armextab.*) } >FLASH
85 | .ARM : {
86 | __exidx_start = .;
87 | *(.ARM.exidx*)
88 | __exidx_end = .;
89 | } >FLASH
90 |
91 | .preinit_array :
92 | {
93 | PROVIDE_HIDDEN (__preinit_array_start = .);
94 | KEEP (*(.preinit_array*))
95 | PROVIDE_HIDDEN (__preinit_array_end = .);
96 | } >FLASH
97 | .init_array :
98 | {
99 | PROVIDE_HIDDEN (__init_array_start = .);
100 | KEEP (*(SORT(.init_array.*)))
101 | KEEP (*(.init_array*))
102 | PROVIDE_HIDDEN (__init_array_end = .);
103 | } >FLASH
104 | .fini_array :
105 | {
106 | PROVIDE_HIDDEN (__fini_array_start = .);
107 | KEEP (*(SORT(.fini_array.*)))
108 | KEEP (*(.fini_array*))
109 | PROVIDE_HIDDEN (__fini_array_end = .);
110 | } >FLASH
111 |
112 | /* used by the startup to initialize data */
113 | _sidata = LOADADDR(.data);
114 |
115 | /* Initialized data sections goes into RAM, load LMA copy after code */
116 | .data :
117 | {
118 | . = ALIGN(4);
119 | _sdata = .; /* create a global symbol at data start */
120 | *(.data) /* .data sections */
121 | *(.data*) /* .data* sections */
122 |
123 | . = ALIGN(4);
124 | _edata = .; /* define a global symbol at data end */
125 | } >RAM AT> FLASH
126 |
127 |
128 | /* Uninitialized data section */
129 | . = ALIGN(4);
130 | .bss :
131 | {
132 | /* This is used by the startup in order to initialize the .bss secion */
133 | _sbss = .; /* define a global symbol at bss start */
134 | __bss_start__ = _sbss;
135 | *(.bss)
136 | *(.bss*)
137 | *(COMMON)
138 |
139 | . = ALIGN(4);
140 | _ebss = .; /* define a global symbol at bss end */
141 | __bss_end__ = _ebss;
142 | } >RAM
143 |
144 | /* User_heap_stack section, used to check that there is enough RAM left */
145 | ._user_heap_stack :
146 | {
147 | . = ALIGN(4);
148 | PROVIDE ( end = . );
149 | PROVIDE ( _end = . );
150 | . = . + _Min_Heap_Size;
151 | . = . + _Min_Stack_Size;
152 | . = ALIGN(4);
153 | } >RAM
154 |
155 |
156 |
157 | /* Remove information from the standard libraries */
158 | /DISCARD/ :
159 | {
160 | libc.a ( * )
161 | libm.a ( * )
162 | libgcc.a ( * )
163 | }
164 |
165 | .ARM.attributes 0 : { *(.ARM.attributes) }
166 | }
167 |
168 |
169 |
--------------------------------------------------------------------------------
/Src/tim.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : TIM.c
4 | * Description : This file provides code for the configuration
5 | * of the TIM instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2019 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "tim.h"
22 |
23 | /* USER CODE BEGIN 0 */
24 | #include
25 | /* USER CODE END 0 */
26 |
27 | TIM_HandleTypeDef htim3;
28 |
29 | /* TIM3 init function */
30 | void MX_TIM3_Init(void)
31 | {
32 | TIM_ClockConfigTypeDef sClockSourceConfig = {0};
33 | TIM_MasterConfigTypeDef sMasterConfig = {0};
34 | TIM_OC_InitTypeDef sConfigOC = {0};
35 |
36 | htim3.Instance = TIM3;
37 | htim3.Init.Prescaler = 18000;
38 | htim3.Init.CounterMode = TIM_COUNTERMODE_UP;
39 | htim3.Init.Period = 2000;
40 | htim3.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
41 | htim3.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
42 | if (HAL_TIM_Base_Init(&htim3) != HAL_OK)
43 | {
44 | Error_Handler();
45 | }
46 | sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
47 | if (HAL_TIM_ConfigClockSource(&htim3, &sClockSourceConfig) != HAL_OK)
48 | {
49 | Error_Handler();
50 | }
51 | if (HAL_TIM_PWM_Init(&htim3) != HAL_OK)
52 | {
53 | Error_Handler();
54 | }
55 | sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
56 | sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
57 | if (HAL_TIMEx_MasterConfigSynchronization(&htim3, &sMasterConfig) != HAL_OK)
58 | {
59 | Error_Handler();
60 | }
61 | sConfigOC.OCMode = TIM_OCMODE_PWM1;
62 | sConfigOC.Pulse = 1000;
63 | sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
64 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
65 | if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_4) != HAL_OK)
66 | {
67 | Error_Handler();
68 | }
69 | HAL_TIM_MspPostInit(&htim3);
70 |
71 | }
72 |
73 | void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
74 | {
75 |
76 | if(tim_baseHandle->Instance==TIM3)
77 | {
78 | /* USER CODE BEGIN TIM3_MspInit 0 */
79 |
80 | /* USER CODE END TIM3_MspInit 0 */
81 | /* TIM3 clock enable */
82 | __HAL_RCC_TIM3_CLK_ENABLE();
83 | /* USER CODE BEGIN TIM3_MspInit 1 */
84 |
85 | /* USER CODE END TIM3_MspInit 1 */
86 | }
87 | }
88 | void HAL_TIM_MspPostInit(TIM_HandleTypeDef* timHandle)
89 | {
90 |
91 | GPIO_InitTypeDef GPIO_InitStruct = {0};
92 | if(timHandle->Instance==TIM3)
93 | {
94 | /* USER CODE BEGIN TIM3_MspPostInit 0 */
95 |
96 | /* USER CODE END TIM3_MspPostInit 0 */
97 |
98 | __HAL_RCC_GPIOB_CLK_ENABLE();
99 | /**TIM3 GPIO Configuration
100 | PB1 ------> TIM3_CH4
101 | */
102 | GPIO_InitStruct.Pin = D1_Pin;
103 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
104 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
105 | HAL_GPIO_Init(D1_GPIO_Port, &GPIO_InitStruct);
106 |
107 | /* USER CODE BEGIN TIM3_MspPostInit 1 */
108 |
109 | /* USER CODE END TIM3_MspPostInit 1 */
110 | }
111 |
112 | }
113 |
114 | void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
115 | {
116 |
117 | if(tim_baseHandle->Instance==TIM3)
118 | {
119 | /* USER CODE BEGIN TIM3_MspDeInit 0 */
120 |
121 | /* USER CODE END TIM3_MspDeInit 0 */
122 | /* Peripheral clock disable */
123 | __HAL_RCC_TIM3_CLK_DISABLE();
124 | /* USER CODE BEGIN TIM3_MspDeInit 1 */
125 |
126 | /* USER CODE END TIM3_MspDeInit 1 */
127 | }
128 | }
129 |
130 | /* USER CODE BEGIN 1 */
131 | void reconfigureToForceOutput()
132 | {
133 | TIM_OC_InitTypeDef sConfigOC = { 0 };
134 |
135 | sConfigOC.OCMode = TIM_OCMODE_FORCED_ACTIVE;
136 | sConfigOC.Pulse = 0;
137 | sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
138 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
139 | if (HAL_TIM_OC_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_4) != HAL_OK) {
140 | Error_Handler();
141 | }
142 | }
143 | void reconfigureToBlink()
144 | {
145 | TIM_OC_InitTypeDef sConfigOC = { 0 };
146 |
147 | sConfigOC.OCMode = TIM_OCMODE_PWM1;
148 | sConfigOC.Pulse = 1000;
149 | sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
150 | sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
151 | if (HAL_TIM_PWM_ConfigChannel(&htim3, &sConfigOC, TIM_CHANNEL_4) != HAL_OK) {
152 | Error_Handler();
153 | }
154 | }
155 | void blinkD1(bool newState)
156 | {
157 | if (newState)
158 | {
159 | HAL_TIM_OC_Stop(&htim3, TIM_CHANNEL_4);
160 | reconfigureToBlink();
161 | HAL_TIM_PWM_Start(&htim3, TIM_CHANNEL_4);
162 | }
163 | else
164 | {
165 | HAL_TIM_PWM_Stop(&htim3, TIM_CHANNEL_4);
166 | reconfigureToForceOutput();
167 | HAL_TIM_OC_Start(&htim3, TIM_CHANNEL_4);
168 | }
169 | }
170 | /* USER CODE END 1 */
171 |
172 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
173 |
--------------------------------------------------------------------------------
/Src/ADF4351.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright (C)
2 | * 2019 Jose Luu
3 | * additional authors:
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, version 3.
8 | *
9 | * This program is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include "memory.h"
19 | #include "spi.h"
20 | #include "D6Board.h"
21 | #include "Command.h"
22 | #include "main.h"
23 | #include "ADF4351.h"
24 |
25 | #define ADF_COUNT 2
26 | #define ADF_REGISTER_COUNT 6
27 |
28 | static unsigned long Register_Set[ADF_COUNT][ADF_REGISTER_COUNT];
29 | static unsigned long Register_SetPrevious[ADF_COUNT][ADF_REGISTER_COUNT];
30 |
31 | void ADF4351Off(WhichADF indexADF);
32 |
33 |
34 | void loadEnable(WhichADF indexADF, bool low)
35 | {
36 | switch (indexADF)
37 | {
38 | case eTracking:
39 | HAL_GPIO_WritePin(LE_GPIO_Port,
40 | LE_Pin,
41 | (low ? GPIO_PIN_RESET : GPIO_PIN_SET));
42 | break;
43 | case eAnalyzer:
44 | HAL_GPIO_WritePin(LEA_GPIO_Port,
45 | LEA_Pin,
46 | (low ? GPIO_PIN_RESET : GPIO_PIN_SET));
47 | break;
48 | }
49 | }
50 | void sendADF4351(WhichADF indexADF, unsigned long reg)
51 | {
52 | loadEnable(indexADF, true);
53 | switch(indexADF)
54 | {
55 | case eTracking:
56 | sendSPI2(reg);
57 | break;
58 | case eAnalyzer:
59 | sendSPI1(reg);
60 | break;
61 | }
62 | loadEnable(indexADF, false);
63 | }
64 |
65 | void writeADFRegisters(WhichADF indexADF, unsigned long registerSet[])
66 | {
67 | // _SYNC(1); // measure time to write to ADF
68 | for (int i = ADF_REGISTER_COUNT-1; i >= 0; i--)
69 | {
70 | bool mustWrite = false;
71 | if (mustWrite || (registerSet[i] != Register_SetPrevious[indexADF][i]))
72 | {
73 | unsigned long Reg_Buf;
74 | mustWrite = true; // we must finish up to register 0 once we start writing into registers
75 | Reg_Buf = registerSet[i];
76 | sendADF4351(indexADF,Reg_Buf);
77 | Register_SetPrevious[indexADF][i] = registerSet[i];// remember value so that we can skip it next time
78 | }
79 | }
80 | // _SYNC(0);
81 | }
82 |
83 |
84 | void frequencySetupInternal(WhichADF indexADF, unsigned long long internalVCOFrequency, unsigned int rangeFrequency, unsigned int level)
85 | {
86 | unsigned long intDivider = internalVCOFrequency / REFERENCE; // see fig 25 page 15 of ADF4341 document
87 | unsigned long frac = internalVCOFrequency / CHANNEL_SPACING % MODULUS_VALUE;
88 |
89 | unsigned long registerSet[6];
90 |
91 | registerSet[0] = ((intDivider & INT_VALUE_MASK) << INT_VALUE_SHIFT) |
92 | ((frac & FRAC_VALUE_MASK) << FRAC_VALUE_SHIFT);
93 | registerSet[1] = R1;
94 | registerSet[2] = R2;
95 | registerSet[3] = R3;
96 | registerSet[4] = R4;
97 | registerSet[4] |= ((rangeFrequency & RF_DIVIDER_SELECT_MASK) << RF_DIVIDER_SELECT_SHIFT);
98 | switch (level)
99 | {
100 | case 0: // RF will be completely off
101 | registerSet[4] &= (~RF_OUTPUT_ENABLE);
102 | break;
103 | default:
104 | case 1:
105 | registerSet[4] |= RF_OUTPUT_MINUS4dBm;
106 | break;
107 | case 2:
108 | registerSet[4] |= RF_OUTPUT_MINUS1dBm;
109 | break;
110 | case 3:
111 | registerSet[4] |= RF_OUTPUT_2dBm;
112 | break;
113 | case 4:
114 | registerSet[4] |= RF_OUTPUT_5dBm;
115 | break;
116 | }
117 | registerSet[5] = R5;
118 | writeADFRegisters(indexADF, registerSet);
119 | }
120 |
121 | bool frequencySetup(WhichADF indexADF, unsigned long long frequency, unsigned int level, unsigned int &range, bool forceRange)
122 | {
123 | unsigned long long VCOfrequency = frequency;
124 | if (VCOfrequency > ADF_MAX_FREQUENCY)
125 | {
126 | ADF4351Off(indexADF);
127 | return false;
128 | }
129 | if (forceRange)
130 | {
131 | VCOfrequency = frequency << range;
132 | if (VCOfrequency< ADF_MIN_FREQUENCY || VCOfrequency > ADF_MAX_FREQUENCY)
133 | {
134 | return false;
135 | }
136 | frequencySetupInternal(indexADF, VCOfrequency, range, level);
137 | return true;
138 | }
139 | for (range = 0; range < ADF_RANGE_COUNT; range++)
140 | {
141 | if (VCOfrequency >= ADF_LOW_FREQUENCY)
142 | {
143 | frequencySetupInternal(indexADF, VCOfrequency, range, level);
144 | return true;
145 | }
146 | VCOfrequency *= 2;
147 | }
148 | if (VCOfrequency/2 >= ADF_MIN_FREQUENCY){ // we try the extended value
149 | range--;
150 | frequencySetupInternal(indexADF, VCOfrequency/2, range, level);
151 | return true;
152 | }
153 | ADF4351Off(indexADF);
154 | return false;
155 | }
156 |
157 | void ADF4351Off(WhichADF indexADF)
158 | {
159 | unsigned long registerSet[6];
160 |
161 | registerSet[0] = 0;
162 | registerSet[1] = R1;
163 | registerSet[2] = R2;
164 | registerSet[3] = R3;
165 | registerSet[4] = R4 | VCO_POWERED_DOWN;
166 | registerSet[5] = R5;
167 | writeADFRegisters(indexADF, registerSet);
168 | }
169 |
170 | void probeSPI(WhichADF indexADF) // write arbitrary patterns to check SPI
171 | {
172 | unsigned long registerSet[6];
173 | registerSet[0] = 0x55555501;
174 | registerSet[1] = 0x55550101;
175 | registerSet[2] = 0x55010101;
176 | registerSet[3] = 0xAAAAAA55;
177 | registerSet[4] = 0xAAAA0101;
178 | registerSet[5] = 0x80880088;
179 | writeADFRegisters(indexADF, ®isterSet[0]);
180 | }
--------------------------------------------------------------------------------
/Src/spi.c:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * File Name : SPI.c
4 | * Description : This file provides code for the configuration
5 | * of the SPI instances.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2019 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "spi.h"
22 |
23 | /* USER CODE BEGIN 0 */
24 | #include "memory.h"
25 | /* USER CODE END 0 */
26 |
27 | SPI_HandleTypeDef hspi1;
28 | SPI_HandleTypeDef hspi2;
29 |
30 | /* SPI1 init function */
31 | void MX_SPI1_Init(void)
32 | {
33 |
34 | hspi1.Instance = SPI1;
35 | hspi1.Init.Mode = SPI_MODE_MASTER;
36 | hspi1.Init.Direction = SPI_DIRECTION_2LINES;
37 | hspi1.Init.DataSize = SPI_DATASIZE_8BIT;
38 | hspi1.Init.CLKPolarity = SPI_POLARITY_LOW;
39 | hspi1.Init.CLKPhase = SPI_PHASE_1EDGE;
40 | hspi1.Init.NSS = SPI_NSS_SOFT;
41 | hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
42 | hspi1.Init.FirstBit = SPI_FIRSTBIT_MSB;
43 | hspi1.Init.TIMode = SPI_TIMODE_DISABLE;
44 | hspi1.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
45 | hspi1.Init.CRCPolynomial = 10;
46 | if (HAL_SPI_Init(&hspi1) != HAL_OK)
47 | {
48 | Error_Handler();
49 | }
50 |
51 | }
52 | /* SPI2 init function */
53 | void MX_SPI2_Init(void)
54 | {
55 |
56 | hspi2.Instance = SPI2;
57 | hspi2.Init.Mode = SPI_MODE_MASTER;
58 | hspi2.Init.Direction = SPI_DIRECTION_2LINES;
59 | hspi2.Init.DataSize = SPI_DATASIZE_8BIT;
60 | hspi2.Init.CLKPolarity = SPI_POLARITY_LOW;
61 | hspi2.Init.CLKPhase = SPI_PHASE_1EDGE;
62 | hspi2.Init.NSS = SPI_NSS_SOFT;
63 | hspi2.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_8;
64 | hspi2.Init.FirstBit = SPI_FIRSTBIT_MSB;
65 | hspi2.Init.TIMode = SPI_TIMODE_DISABLE;
66 | hspi2.Init.CRCCalculation = SPI_CRCCALCULATION_DISABLE;
67 | hspi2.Init.CRCPolynomial = 10;
68 | if (HAL_SPI_Init(&hspi2) != HAL_OK)
69 | {
70 | Error_Handler();
71 | }
72 |
73 | }
74 |
75 | void HAL_SPI_MspInit(SPI_HandleTypeDef* spiHandle)
76 | {
77 |
78 | GPIO_InitTypeDef GPIO_InitStruct = {0};
79 | if(spiHandle->Instance==SPI1)
80 | {
81 | /* USER CODE BEGIN SPI1_MspInit 0 */
82 |
83 | /* USER CODE END SPI1_MspInit 0 */
84 | /* SPI1 clock enable */
85 | __HAL_RCC_SPI1_CLK_ENABLE();
86 |
87 | __HAL_RCC_GPIOA_CLK_ENABLE();
88 | /**SPI1 GPIO Configuration
89 | PA5 ------> SPI1_SCK
90 | PA7 ------> SPI1_MOSI
91 | */
92 | GPIO_InitStruct.Pin = GPIO_PIN_5|GPIO_PIN_7;
93 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
94 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
95 | HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
96 |
97 | /* USER CODE BEGIN SPI1_MspInit 1 */
98 |
99 | /* USER CODE END SPI1_MspInit 1 */
100 | }
101 | else if(spiHandle->Instance==SPI2)
102 | {
103 | /* USER CODE BEGIN SPI2_MspInit 0 */
104 |
105 | /* USER CODE END SPI2_MspInit 0 */
106 | /* SPI2 clock enable */
107 | __HAL_RCC_SPI2_CLK_ENABLE();
108 |
109 | __HAL_RCC_GPIOB_CLK_ENABLE();
110 | /**SPI2 GPIO Configuration
111 | PB13 ------> SPI2_SCK
112 | PB15 ------> SPI2_MOSI
113 | */
114 | GPIO_InitStruct.Pin = GPIO_PIN_13|GPIO_PIN_15;
115 | GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
116 | GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
117 | HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
118 |
119 | /* USER CODE BEGIN SPI2_MspInit 1 */
120 |
121 | /* USER CODE END SPI2_MspInit 1 */
122 | }
123 | }
124 |
125 | void HAL_SPI_MspDeInit(SPI_HandleTypeDef* spiHandle)
126 | {
127 |
128 | if(spiHandle->Instance==SPI1)
129 | {
130 | /* USER CODE BEGIN SPI1_MspDeInit 0 */
131 |
132 | /* USER CODE END SPI1_MspDeInit 0 */
133 | /* Peripheral clock disable */
134 | __HAL_RCC_SPI1_CLK_DISABLE();
135 |
136 | /**SPI1 GPIO Configuration
137 | PA5 ------> SPI1_SCK
138 | PA7 ------> SPI1_MOSI
139 | */
140 | HAL_GPIO_DeInit(GPIOA, GPIO_PIN_5|GPIO_PIN_7);
141 |
142 | /* USER CODE BEGIN SPI1_MspDeInit 1 */
143 |
144 | /* USER CODE END SPI1_MspDeInit 1 */
145 | }
146 | else if(spiHandle->Instance==SPI2)
147 | {
148 | /* USER CODE BEGIN SPI2_MspDeInit 0 */
149 |
150 | /* USER CODE END SPI2_MspDeInit 0 */
151 | /* Peripheral clock disable */
152 | __HAL_RCC_SPI2_CLK_DISABLE();
153 |
154 | /**SPI2 GPIO Configuration
155 | PB13 ------> SPI2_SCK
156 | PB15 ------> SPI2_MOSI
157 | */
158 | HAL_GPIO_DeInit(GPIOB, GPIO_PIN_13|GPIO_PIN_15);
159 |
160 | /* USER CODE BEGIN SPI2_MspDeInit 1 */
161 |
162 | /* USER CODE END SPI2_MspDeInit 1 */
163 | }
164 | }
165 |
166 | /* USER CODE BEGIN 1 */
167 | // changes
168 | // SPI_DIRECTION_1LINE
169 | // crc 7
170 | void sendSPI1(unsigned long dataLong)
171 | {
172 | uint8_t data[4];
173 | memcpy(data, &dataLong, 4);
174 | for (int i = 3; i>=0; i--) // 4 bytes MSB first
175 | {
176 | HAL_SPI_Transmit(&hspi1, &data[i], 1, 0);
177 | }
178 | }
179 | void sendSPI2(unsigned long dataLong)
180 | {
181 | uint8_t data[4];
182 | memcpy(data, &dataLong, 4);
183 | for (int i=3; i>=0;i--) // 4 bytes MSB first
184 | {
185 | HAL_SPI_Transmit(&hspi2, &data[i], 1, 0);
186 | }
187 | }
188 |
189 | /* USER CODE END 1 */
190 |
191 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
192 |
--------------------------------------------------------------------------------
/tests/D6_blinkTest/D6_blinkTest-Release.vgdbsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 | Release
4 |
5 |
6 |
7 | MinGWUnixSlash
8 |
9 | $(ProjectDir)
10 | stm32.xml
11 |
12 |
13 | Makefile
14 | Release
15 | $(LocalMultiThreadedBuildFlags)
16 |
17 | false
18 | cmd.exe
19 | /c "$(TOOLCHAIN_ROOT)\bin\make.exe"
20 | $(BuildDir)
21 |
22 |
23 |
24 | LANG
25 | en_US.UTF-8
26 |
27 |
28 | PATH
29 | $(TOOLCHAIN_ROOT)\bin;%PATH%
30 |
31 |
32 |
33 |
34 |
35 | true
36 |
37 |
38 |
39 |
40 |
41 | false
42 | false
43 | false
44 | false
45 | false
46 | false
47 | false
48 | false
49 | false
50 |
51 | false
52 | false
53 | false
54 | false
55 | false
56 | false
57 | true
58 | false
59 | None
60 | false
61 | false
62 | main
63 | true
64 | false
65 | false
66 | false
67 |
68 | com.sysprogs.arm.openocd
69 |
70 |
71 |
72 | com.sysprogs.arm.openocd.interface
73 |
74 |
75 |
76 | com.sysprogs.arm.openocd.cpu
77 |
78 |
79 |
80 | com.sysprogs.arm.openocd.chip
81 |
82 |
83 |
84 | com.sysprogs.arm.openocd.board
85 |
86 |
87 |
88 | com.sysprogs.arm.openocd.target
89 | target/stm32f1x.cfg
90 |
91 |
92 | com.sysprogs.arm.openocd.extraargs
93 | -c init -c "reset init"
94 |
95 |
96 | com.sysprogs.arm.openocd.initargs
97 |
98 |
99 |
100 | com.sysprogs.arm.openocd.commands.halt
101 | mon halt
102 |
103 |
104 | com.sysprogs.arm.openocd.commands.program
105 | load
106 |
107 |
108 | com.sysprogs.arm.openocd.commands.autoprogram
109 |
110 |
111 |
112 | com.sysprogs.arm.openocd.commands.reset
113 | mon reset init
114 |
115 |
116 | com.sysprogs.arm.openocd.commands.resetafter
117 |
118 |
119 |
120 | com.sysprogs.arm.openocd.quicksetup.enabled
121 | 1
122 |
123 |
124 | com.sysprogs.arm.openocd.delay
125 | 0
126 |
127 |
128 | com.sysprogs.arm.openocd.transport
129 |
130 |
131 |
132 |
133 | true
134 | Auto
135 | false
136 | false
137 | true
138 | false
139 |
140 | _estack
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 | Default
154 |
155 |
156 |
157 | true
158 |
159 |
160 |
161 | Unknown
162 |
163 | true
164 |
165 |
166 |
--------------------------------------------------------------------------------
/Src/Serial.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright (C)
2 | * 2019 Jose Luu
3 | * additional authors:
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, version 3.
8 | *
9 | * This program is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include
19 | #include "main.h"
20 | #include "Serial.h"
21 |
22 | SerialInput * SerialInput::ACTIVE_CHANNEL = NULL;
23 | SerialOutput * SerialOutput::ACTIVE_CHANNEL = NULL;
24 |
25 | void SerialInput::initialize(SerialOutput * echoChannel)
26 | {
27 | if (HAL_UART_Receive_DMA(&huart1, &rxBuffer, 1) != HAL_OK) {
28 | Error_Handler();
29 | }
30 | echo = echoChannel;
31 | }
32 |
33 | SerialInput::SerialInput(UART_HandleTypeDef * pHandle, char * buffer, unsigned int size)
34 | : pHandle(pHandle)
35 | , driverBuffer (buffer)
36 | , driverBufferSize (size)
37 | {
38 | driverBufferNextChar = buffer;
39 | nChars = 0;
40 | eol = false;
41 | textMode = false;
42 | overrun = 0;
43 | inputBuffer[0] = 0;
44 | inputBuffer[1] = 0;
45 |
46 | if (pHandle == &ACTIVE_UART) {
47 | SerialInput::ACTIVE_CHANNEL = this;
48 | } else {
49 | Error_Handler();
50 | }
51 | }
52 |
53 | // append terminating 0, returns the newline and clip to size characters
54 | char * SerialInput::fgets(char * str, int size)
55 | {
56 | while (!eol && ((driverBufferNextChar - driverBuffer) < size)) {
57 | HAL_Delay(1);
58 | }
59 | return fgetsNonBlocking(str, size);
60 | }
61 |
62 | bool SerialInput::isCharAvailable()
63 | {
64 | return driverBufferNextChar != driverBuffer;
65 | }
66 |
67 | bool SerialInput::fgetc(unsigned char & c) // non blocking
68 | {
69 | if ((driverBufferNextChar - driverBuffer) < 1)
70 | {
71 | return false;
72 | }
73 | const int sizeUseful = 1; // read one character
74 | c = driverBuffer[0];
75 | strncpy(driverBuffer, &driverBuffer[1], nChars - sizeUseful);
76 | nChars -= sizeUseful;
77 | driverBufferNextChar = &driverBuffer[nChars];
78 | return true;
79 | }
80 | char * SerialInput::fgetsNonBlocking(char * str, int size)
81 | {
82 | while (!eol && ((driverBufferNextChar - driverBuffer) < size-1)) {
83 | return NULL;
84 | }
85 | int sizeUseful;
86 | if ((driverBufferNextChar - driverBuffer) >= size-1) {
87 | sizeUseful = size - 1;
88 | strncpy(str, driverBuffer, sizeUseful); //toto: verify chars are not lost
89 | str[sizeUseful] = 0;
90 | strncpy(driverBuffer, &driverBuffer[sizeUseful], nChars - sizeUseful);
91 | nChars -= sizeUseful;
92 | driverBufferNextChar = &driverBuffer[nChars];
93 | goto cleanup;
94 | } else {
95 | sizeUseful = driverBufferNextChar - driverBuffer;
96 | memcpy(str, driverBuffer, sizeUseful);
97 | str[sizeUseful] = 0;
98 | driverBufferNextChar = driverBuffer;
99 | nChars = 0;
100 | }
101 | cleanup:
102 | overrun = 0;
103 | eol = false;
104 | return str;
105 | }
106 |
107 | void SerialInput::doInputIT(void)
108 | {
109 | unsigned char c = rxBuffer;
110 | if (echo) {
111 | echo->putch(c);
112 | if (c == '\r') {
113 | echo->putch('\n');
114 | }
115 | }
116 | if ((driverBufferNextChar - driverBuffer) >= driverBufferSize) {
117 | overrun++;
118 | } else {
119 | if (textMode) {
120 | if (c == '\n') {
121 | eol = true;
122 | }
123 | if (c == '\r') {
124 | c = '\n';
125 | eol = true;
126 | }
127 | if (c == 127 || c == 8) {
128 | // handle backspace and delete (only when echoing ?)
129 | if(nChars > 0)
130 | {
131 | driverBufferNextChar--;
132 | nChars--;
133 | }
134 | } else {
135 | *driverBufferNextChar++ = c;
136 | nChars++;
137 | }
138 | }
139 | else
140 | {
141 | *driverBufferNextChar++ = c;
142 | nChars++;
143 | }
144 | }
145 | #if 0
146 | HAL_StatusTypeDef status;
147 | status = HAL_UART_Receive_IT(pHandle, (uint8_t *)inputBuffer, 1);
148 | if (status == HAL_BUSY)
149 | {
150 | Error_Handler();
151 | }
152 | #endif
153 | }
154 | void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle)
155 | {
156 | SerialInput * serialObject;
157 | if (UartHandle == &ACTIVE_UART) {
158 | serialObject = SerialInput::ACTIVE_CHANNEL;
159 | } else {
160 | Error_Handler();
161 | }
162 | __HAL_UART_FLUSH_DRREGISTER(UartHandle); // Clear the buffer to prevent overrun
163 | serialObject->doInputIT();
164 | }
165 |
166 | SerialOutput::SerialOutput(UART_HandleTypeDef * pHandle, char * driverBuffer, unsigned int size)
167 | : pHandle(pHandle)
168 | , driverBuffer(driverBuffer)
169 | , driverBufferSize(size)
170 | {
171 | busy = false;
172 | if (pHandle == &ACTIVE_UART) {
173 | SerialOutput::ACTIVE_CHANNEL = this;
174 | } else {
175 | Error_Handler();
176 | }
177 | }
178 |
179 | bool SerialOutput::puts(const char * str)
180 | {
181 | int statusTransmit;
182 | busy = true;
183 | if (strlen(str) >= driverBufferSize) {
184 | }
185 | statusTransmit = HAL_UART_Transmit(pHandle, (uint8_t*)str, strlen(str), 1000);
186 | busy = false;
187 | return statusTransmit;
188 | }
189 |
190 | bool SerialOutput::putch(char c)
191 | {
192 | int statusTransmit;
193 | busy = true;
194 | do
195 | {
196 | statusTransmit = HAL_UART_Transmit(pHandle, (uint8_t*)&c, 1, 10);
197 | }
198 | while (statusTransmit == HAL_BUSY);
199 | busy = false;
200 | return statusTransmit;
201 | }
202 |
203 |
204 | bool SerialOutput::putsNonBlocking(const char * str)
205 | {
206 | int statusTransmit;
207 | if (busy) {
208 | return false;
209 | }
210 | busy = true;
211 | int len = strlen(str);
212 | // if (strlen(str) >= driverBufferSize) {
213 | // }
214 |
215 | statusTransmit = HAL_UART_Transmit_IT(pHandle, (uint8_t*) str, len);
216 | return statusTransmit;
217 | }
218 |
219 | void SerialOutput::doOutputIT()
220 | {
221 | busy = false;
222 | }
223 |
224 | void HAL_UART_TxCpltCallback(UART_HandleTypeDef *UartHandle)
225 | {
226 | SerialOutput * serialObject;
227 | if (UartHandle == &ACTIVE_UART) {
228 | serialObject = SerialOutput::ACTIVE_CHANNEL;
229 | } else {
230 | Error_Handler();
231 | }
232 | serialObject->doOutputIT();
233 | }
234 |
235 | void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
236 | {
237 | // HAL_UART_ERROR_NONE = 0x00, /*!< No error */
238 | // HAL_UART_ERROR_PE = 0x01, /*!< Parity error */
239 | // HAL_UART_ERROR_NE = 0x02, /*!< Noise error */
240 | // HAL_UART_ERROR_FE = 0x04, /*!< frame error */
241 | // HAL_UART_ERROR_ORE = 0x08, /*!< Overrun error */
242 | // HAL_UART_ERROR_DMA = 0x10, /*!< DMA transfer error */
243 | // HAL_UART_ERROR_BUSY = 0x20 /*!< Busy Error */
244 | static int nLastError = huart->ErrorCode;
245 | Error_Handler();
246 | }
247 |
248 |
--------------------------------------------------------------------------------
/Inc/ADF4351.h:
--------------------------------------------------------------------------------
1 | /* Copyright (C)
2 | * 2019 Jose Luu
3 | * additional authors:
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, version 3.
8 | *
9 | * This program is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #pragma once
19 | #ifndef _ADF4351_H
20 | #define _ADF4351_H
21 |
22 |
23 | // do not include this file: include boardspecific file D6Board.h
24 | // ADF4351 constants
25 |
26 | #define ADF_MAX_FREQUENCY 4500000000LL
27 | #define ADF_HIGH_FREQUENCY 4400000000LL
28 | #define ADF_LOW_FREQUENCY 2200000000LL
29 | #define ADF_MIN_FREQUENCY 2048000000LL
30 | #define ADF_RANGE_COUNT 7
31 |
32 | //R0
33 | #define INT_VALUE_SHIFT 15
34 | #define INT_VALUE_MASK 0xFFFF
35 |
36 | #define FRAC_VALUE_SHIFT 3
37 | #define FRAC_VALUE_MASK 0xFFF
38 |
39 | #define R0_ADDRESS 0
40 |
41 | //R1
42 | #define PHASE_ADJUST_ON 0x10000000 //disables VCO band selection, use only for fixed frequency application
43 | #define PHASE_ADJUST_OFF 0x00000000 //
44 |
45 | #define PRESCALER8_9 0x08000000 //N must be >=75
46 | #define PRESCALER4_5 0x00000000 //when used: max frequency: 3.6GHz N must be >=23
47 |
48 | #define PHASE_VALUE_SHIFT 15 //can be used to optimize fractional spurs
49 | #define PHASE_VALUE_MASK 0xFFF // 12 bits
50 | #define PHASE_VALUE_DEFAULT 0x8000 // (1 not shifted) use this value when not using it
51 |
52 | #define MOD_VALUE_SHIFT 3
53 | #define MOD_VALUE_MASK 0xFFF // 12 bits
54 |
55 | #define R1_ADDRESS 1
56 |
57 | //R2
58 | #define LOW_SPUR 0x60000000 //dither fractional mode when using wide (> RFout/10) bandwith for fast lock
59 | #define LOW_NOISE 0x00000000 //improve phase noise, must also use narrow bandwidth filter
60 |
61 | #define MUXOUT_LOCK 0x18000000
62 | #define MUXOUT_DL 0x18000000 //OUTPUT DIGITAL LOCK DETECT
63 | #define MUXOUT_AL 0x14000000 //OUTPUT ANALOG LOCK DETECT
64 | #define MUXOUT_N 0x10000000 //OUTPUT N-DIVIDER if used, VCO band selection does not operate properly
65 | #define MUXOUT_R 0x0C000000 //OUTPUT R_COUNTER
66 | #define MUXOUT_L 0x08000000 //OUTPUT LOW
67 | #define MUXOUT_H 0x04000000 //OUTPUT HIGH
68 | #define MUXOUT_TS 0x00000000 //OUTPUT THREE STATE
69 |
70 | #define REF_DOUB_ENABLE 0x02000000 //if used with wide bandwidth and low spur must have 50% duty cycle
71 | #define REF_DOUB_DISABLE 0x00000000
72 |
73 | #define REF_DIV2_ENABLE 0x01000000 //useful for cycle slip reduction
74 | #define REF_DIV2_DISABLE 0x00000000
75 |
76 | #define R_COUNTER_SHIFT 14
77 | #define R_COUNTER_MASK 0x3FF // 10 bits
78 |
79 | #define DOUBLE_BUFFERING_ENABLE 0x00002000 //for the RF DIVIDER setting in R4 to wait for R0
80 | #define DOUBLE_BUFFERING_DISABLE 0x00000000
81 |
82 | #define CHARGE_CURRENT_5MA 0x00001E00 //5mA (5.1k) value depends on loop filter design
83 | #define CHARGE_CURRENT_2_5MA 0x00000E00 //2.5mA (5.1k) value depends on loop filter design
84 | #define CHARGE_CURRENT_1MA 0x00000600 //1.25mA (5.1k)
85 | #define CHARGE_PUMP_CURRENT_SHIFT 9
86 | #define CHARGE_PUMP_CURRENT_MASK 0xF // CP_CURRENT=(value+1)*312.5uA -> larger current increases loop bandwidth
87 |
88 | #define LOCK_DEtECT_FUNCTION_5CYCLES 0x00000100 //use with integer mode
89 | #define LOCK_DEtECT_FUNCTION_40CYCLES 0x00000000 //use with frac mode
90 |
91 | #define LOCK_DETECT_PRECISION_6NS 0x00000080 //comparison window size for digital lock detector
92 | #define LOCK_DETECT_PRECISION_10NS 0x00000000 //must use for fractional
93 |
94 | #define PD_POLARITY_POS 0x00000040 //use this value when a passive loop filter is used
95 | #define PD_POLARITY_NEG 0x00000000 //use when inverting amplifier in loop
96 |
97 | #define POWER_DOWN_ENABLE 0x00000020 //software power down
98 | #define POWER_DOWN_DISABLE 0x00000000 //normal value when active
99 |
100 | #define CP_THREE_STATE_ENABLE 0x00000010 //charge pump in three state mode
101 | #define CP_THREE_STATE_DISABLE 0x00000000 //normal value when active
102 |
103 | #define COUNTER_RESET_ENABLE 0x00000008 //keep R and N in reset value
104 | #define COUNTER_RESET_DISABLE 0x00000000 //normal value when active
105 |
106 | #define R2_ADDRESS 2
107 |
108 | //R3
109 | #define BAND_SELECT_CLOCK_HIGH 0x00800000 //Max PFD/BSclock_div < 500KHz
110 | #define BAND_SELECT_CLOCK_LOW 0x00000000 //Max PFD/BSClock div < 125KHz
111 |
112 | #define ANTIBACKLASH_PLUSE_WIDTH_3 0x00400000 //3ns INT-N
113 | #define ANTIBACKLASH_PLUSE_WIDTH_6 0x00000000 //6ns FRAC-N
114 |
115 | #define CHARGE_CANCELATION_ENABLE 0x00200000 //reduces PFD spurs in INT mode
116 | #define CHARGE_CANCELATION_DISABLE 0x00000000 // FRAC MODE
117 |
118 | #define CYCLE_SLIP_ENABLE 0x00040000 //Improves lock time when using narrow bandwidth filter PFD must have a 50% duty cycle
119 | #define CYCLE_SLIP_DISABLE 0x00000000
120 |
121 | #define R3_RESERVED 0x00018000
122 |
123 | #define CLOCK_DIVIDER_OFF 0x00000000
124 | #define RESYNC_ENABLE 0x00010000
125 | #define FAST_LOCK_ENABLE 0x00008000
126 |
127 | #define CLOCK_DIVIDER_VALUE_SHIFT 3 // for phase resync and fast lock, determines time in wide bandwidth mode
128 | #define CLOCK_DIVIDER_VALUE_MASK 0xFFF
129 |
130 | #define R3_ADDRESS 3
131 |
132 | //R4
133 | #define FEEDBACK_FUNDAMENTAL 0x00800000
134 | #define FEEDBACK_DIVIDED 0x00000000
135 |
136 | #define RF_DIVIDER_SELECT_SHIFT 20
137 | #define RF_DIVIDER_SELECT_MASK 0x3F
138 |
139 | #define BAND_SELECT_CLOCK_DIVIDER_SHIFT 12 //divide output of R counter to feed band select logic
140 | #define BAND_SELECT_CLOCK_DIVIDER_MASK 0xFF //band select logic freq must be < 125KHz OR < 500 KHz if band select clock high
141 |
142 | #define VCO_POWERED_DOWN 0x00000800
143 | #define VCO_POWERED_UP 0x00000000
144 |
145 | #define MUTE_TILL_LOCK_DETECT_ENABLE 0x00000400 //RFout is muted until lock detect
146 | #define MUTE_TILL_LOCK_DETECT_DISABLE 0x00000000
147 |
148 | #define AUX_FUNDAMENTAL_OUTPUT 0x00000200
149 | #define AUX_DIVIDED_OUTPUT 0x00000000
150 |
151 | #define AUX_OUTPUT_ENABLE 0x00000100
152 | #define AUX_OUTPUT_DISABLE 0x00000000
153 |
154 | #define AUX_OUTPUT_5dBm 0x000000C0
155 | #define AUX_OUTPUT_2dBm 0x00000080
156 | #define AUX_OUTPUT_MINUS1dBm 0x00000040
157 | #define AUX_OUTPUT_MINUS4dBm 0x00000000
158 |
159 | #define RF_OUTPUT_ENABLE 0x00000020
160 | #define RF_OUTPUT_DISABLE 0x00000000
161 |
162 | #define RF_OUTPUT_5dBm 0x00000018
163 | #define RF_OUTPUT_2dBm 0x00000010
164 | #define RF_OUTPUT_MINUS1dBm 0x00000008
165 | #define RF_OUTPUT_MINUS4dBm 0x00000000
166 |
167 | #define R4_ADDRESS 4
168 |
169 | //R5
170 | #define HIGH_LOCK_DETECT_PIN 0x00C00000
171 | #define DIGITAL_LOCK_DETECT_PIN 0x00400000
172 | #define LOW_LOCK_DETECT_PIN 0x00000000
173 | #define R5_RESERVED 0x180000
174 | #define R5_ADDRESS 5
175 |
176 | #endif
177 |
--------------------------------------------------------------------------------
/tests/D6_blinkTest/D6_blinkTest-Debug.vgdbsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 | Debug
4 |
5 |
6 |
7 | MinGWUnixSlash
8 |
9 | $(ProjectDir)
10 | stm32.xml
11 |
12 |
13 | Makefile
14 | Debug
15 | $(LocalMultiThreadedBuildFlags)
16 |
17 | false
18 | cmd.exe
19 | /c "$(TOOLCHAIN_ROOT)\bin\make.exe"
20 | $(BuildDir)
21 |
22 |
23 |
24 | LANG
25 | en_US.UTF-8
26 |
27 |
28 | PATH
29 | $(TOOLCHAIN_ROOT)\bin;%PATH%
30 |
31 |
32 |
33 |
34 |
35 | true
36 |
37 |
38 |
39 |
40 |
41 | false
42 | false
43 | false
44 | false
45 | false
46 | false
47 | false
48 | false
49 | false
50 |
51 | false
52 | false
53 | false
54 | false
55 | false
56 | false
57 | true
58 | false
59 | None
60 | false
61 | false
62 | main
63 | true
64 | false
65 | false
66 | false
67 |
68 | com.sysprogs.arm.openocd
69 |
70 |
71 |
72 | com.sysprogs.arm.openocd.interface
73 | interface/stlink-v2-1.cfg
74 |
75 |
76 | com.sysprogs.arm.openocd.cpu
77 |
78 |
79 |
80 | com.sysprogs.arm.openocd.chip
81 |
82 |
83 |
84 | com.sysprogs.arm.openocd.board
85 |
86 |
87 |
88 | com.sysprogs.arm.openocd.target
89 | target/stm32f1x.cfg
90 |
91 |
92 | com.sysprogs.arm.openocd.extraargs
93 | -c init -c "reset init"
94 |
95 |
96 | com.sysprogs.arm.openocd.initargs
97 |
98 |
99 |
100 | com.sysprogs.arm.openocd.commands.halt
101 | mon halt
102 |
103 |
104 | com.sysprogs.arm.openocd.commands.program
105 | load
106 |
107 |
108 | com.sysprogs.arm.openocd.commands.autoprogram
109 |
110 |
111 |
112 | com.sysprogs.arm.openocd.commands.reset
113 | mon reset init
114 |
115 |
116 | com.sysprogs.arm.openocd.commands.resetafter
117 |
118 |
119 |
120 | com.sysprogs.arm.openocd.quicksetup.enabled
121 | 1
122 |
123 |
124 | com.sysprogs.arm.openocd.delay
125 | 0
126 |
127 |
128 | com.sysprogs.arm.openocd.transport
129 |
130 |
131 |
132 | com.sysprogs.arm.openocd.quicksetup.interface
133 | stlink-v2-1
134 |
135 |
136 |
137 | true
138 | Auto
139 | false
140 | false
141 | true
142 | false
143 |
144 | _estack
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 | Default
158 |
159 |
160 |
161 | true
162 |
163 |
164 |
165 |
166 | Unknown
167 |
168 | true
169 |
170 |
171 |
--------------------------------------------------------------------------------
/D6_firmware-Debug.vgdbsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 | Debug
4 |
5 |
6 |
7 | MinGWUnixSlash
8 |
9 | $(ProjectDir)
10 | stm32.xml
11 |
12 |
13 | Makefile
14 | Debug
15 | $(LocalMultiThreadedBuildFlags)
16 |
17 | false
18 |
19 | BuildMachine
20 | BuiltinShortcut
21 |
22 | cmd.exe
23 | /c "$(TOOLCHAIN_ROOT)\bin\make.exe"
24 | $(BuildDir)
25 |
26 |
27 |
28 | LANG
29 | en_US.UTF-8
30 |
31 |
32 | PATH
33 | $(TOOLCHAIN_ROOT)\bin;%PATH%
34 |
35 |
36 |
37 |
38 |
39 | true
40 |
41 |
42 |
43 |
44 |
45 | false
46 | false
47 | false
48 | false
49 | false
50 | false
51 | false
52 | false
53 | false
54 |
55 | false
56 | false
57 | false
58 | false
59 | false
60 | false
61 | true
62 | false
63 | None
64 | false
65 | false
66 | main
67 | true
68 | false
69 | false
70 | false
71 |
72 | com.sysprogs.arm.openocd
73 |
74 |
75 |
76 | com.sysprogs.arm.openocd.interface
77 | interface/stlink-v2.cfg
78 |
79 |
80 | com.sysprogs.arm.openocd.cpu
81 |
82 |
83 |
84 | com.sysprogs.arm.openocd.chip
85 |
86 |
87 |
88 | com.sysprogs.arm.openocd.board
89 |
90 |
91 |
92 | com.sysprogs.arm.openocd.target
93 | target/stm32f1x.cfg
94 |
95 |
96 | com.sysprogs.arm.openocd.extraargs
97 | -c init -c "reset init"
98 |
99 |
100 | com.sysprogs.arm.openocd.initargs
101 |
102 |
103 |
104 | com.sysprogs.arm.openocd.commands.halt
105 | mon halt
106 |
107 |
108 | com.sysprogs.arm.openocd.commands.program
109 | load
110 |
111 |
112 | com.sysprogs.arm.openocd.commands.autoprogram
113 |
114 |
115 |
116 | com.sysprogs.arm.openocd.commands.reset
117 | mon reset init
118 |
119 |
120 | com.sysprogs.arm.openocd.commands.resetafter
121 |
122 |
123 |
124 | com.sysprogs.arm.openocd.quicksetup.enabled
125 | 1
126 |
127 |
128 | com.sysprogs.arm.openocd.delay
129 | 0
130 |
131 |
132 | com.sysprogs.arm.openocd.transport
133 |
134 |
135 |
136 | com.sysprogs.arm.openocd.quicksetup.interface
137 | stlink-v2
138 |
139 |
140 |
141 | true
142 | Disabled
143 | false
144 | false
145 | true
146 | false
147 |
148 | _estack
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 | Default
162 |
163 |
164 |
165 | true
166 |
167 |
168 |
169 |
170 | Unknown
171 |
172 | true
173 |
174 |
175 |
--------------------------------------------------------------------------------
/Src/stm32f1xx_it.c:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /**
3 | ******************************************************************************
4 | * @file stm32f1xx_it.c
5 | * @brief Interrupt Service Routines.
6 | ******************************************************************************
7 | * @attention
8 | *
9 | * © Copyright (c) 2019 STMicroelectronics.
10 | * All rights reserved.
11 | *
12 | * This software component is licensed by ST under BSD 3-Clause license,
13 | * the "License"; You may not use this file except in compliance with the
14 | * License. You may obtain a copy of the License at:
15 | * opensource.org/licenses/BSD-3-Clause
16 | *
17 | ******************************************************************************
18 | */
19 | /* USER CODE END Header */
20 |
21 | /* Includes ------------------------------------------------------------------*/
22 | #include "main.h"
23 | #include "stm32f1xx_it.h"
24 | /* Private includes ----------------------------------------------------------*/
25 | /* USER CODE BEGIN Includes */
26 | #include "debouncedButton.h"
27 | /* USER CODE END Includes */
28 |
29 | /* Private typedef -----------------------------------------------------------*/
30 | /* USER CODE BEGIN TD */
31 |
32 | /* USER CODE END TD */
33 |
34 | /* Private define ------------------------------------------------------------*/
35 | /* USER CODE BEGIN PD */
36 |
37 | /* USER CODE END PD */
38 |
39 | /* Private macro -------------------------------------------------------------*/
40 | /* USER CODE BEGIN PM */
41 |
42 | /* USER CODE END PM */
43 |
44 | /* Private variables ---------------------------------------------------------*/
45 | /* USER CODE BEGIN PV */
46 | static volatile bool buttonPressConfirmed;
47 | static volatile bool buttonPressChanged;
48 |
49 | /* USER CODE END PV */
50 |
51 | /* Private function prototypes -----------------------------------------------*/
52 | /* USER CODE BEGIN PFP */
53 |
54 | /* USER CODE END PFP */
55 |
56 | /* Private user code ---------------------------------------------------------*/
57 | /* USER CODE BEGIN 0 */
58 |
59 | /* USER CODE END 0 */
60 |
61 | /* External variables --------------------------------------------------------*/
62 | extern ADC_HandleTypeDef hadc1;
63 | extern DMA_HandleTypeDef hdma_usart1_rx;
64 | extern UART_HandleTypeDef huart1;
65 | /* USER CODE BEGIN EV */
66 |
67 | /* USER CODE END EV */
68 |
69 | /******************************************************************************/
70 | /* Cortex-M3 Processor Interruption and Exception Handlers */
71 | /******************************************************************************/
72 | /**
73 | * @brief This function handles Non maskable interrupt.
74 | */
75 | void NMI_Handler(void)
76 | {
77 | /* USER CODE BEGIN NonMaskableInt_IRQn 0 */
78 |
79 | /* USER CODE END NonMaskableInt_IRQn 0 */
80 | /* USER CODE BEGIN NonMaskableInt_IRQn 1 */
81 |
82 | /* USER CODE END NonMaskableInt_IRQn 1 */
83 | }
84 |
85 | /**
86 | * @brief This function handles Hard fault interrupt.
87 | */
88 | void HardFault_Handler(void)
89 | {
90 | /* USER CODE BEGIN HardFault_IRQn 0 */
91 |
92 | /* USER CODE END HardFault_IRQn 0 */
93 | while (1)
94 | {
95 | /* USER CODE BEGIN W1_HardFault_IRQn 0 */
96 | /* USER CODE END W1_HardFault_IRQn 0 */
97 | }
98 | }
99 |
100 | /**
101 | * @brief This function handles Memory management fault.
102 | */
103 | void MemManage_Handler(void)
104 | {
105 | /* USER CODE BEGIN MemoryManagement_IRQn 0 */
106 |
107 | /* USER CODE END MemoryManagement_IRQn 0 */
108 | while (1)
109 | {
110 | /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */
111 | /* USER CODE END W1_MemoryManagement_IRQn 0 */
112 | }
113 | }
114 |
115 | /**
116 | * @brief This function handles Prefetch fault, memory access fault.
117 | */
118 | void BusFault_Handler(void)
119 | {
120 | /* USER CODE BEGIN BusFault_IRQn 0 */
121 |
122 | /* USER CODE END BusFault_IRQn 0 */
123 | while (1)
124 | {
125 | /* USER CODE BEGIN W1_BusFault_IRQn 0 */
126 | /* USER CODE END W1_BusFault_IRQn 0 */
127 | }
128 | }
129 |
130 | /**
131 | * @brief This function handles Undefined instruction or illegal state.
132 | */
133 | void UsageFault_Handler(void)
134 | {
135 | /* USER CODE BEGIN UsageFault_IRQn 0 */
136 |
137 | /* USER CODE END UsageFault_IRQn 0 */
138 | while (1)
139 | {
140 | /* USER CODE BEGIN W1_UsageFault_IRQn 0 */
141 | /* USER CODE END W1_UsageFault_IRQn 0 */
142 | }
143 | }
144 |
145 | /**
146 | * @brief This function handles System service call via SWI instruction.
147 | */
148 | void SVC_Handler(void)
149 | {
150 | /* USER CODE BEGIN SVCall_IRQn 0 */
151 |
152 | /* USER CODE END SVCall_IRQn 0 */
153 | /* USER CODE BEGIN SVCall_IRQn 1 */
154 |
155 | /* USER CODE END SVCall_IRQn 1 */
156 | }
157 |
158 | /**
159 | * @brief This function handles Debug monitor.
160 | */
161 | void DebugMon_Handler(void)
162 | {
163 | /* USER CODE BEGIN DebugMonitor_IRQn 0 */
164 |
165 | /* USER CODE END DebugMonitor_IRQn 0 */
166 | /* USER CODE BEGIN DebugMonitor_IRQn 1 */
167 |
168 | /* USER CODE END DebugMonitor_IRQn 1 */
169 | }
170 |
171 | /**
172 | * @brief This function handles Pendable request for system service.
173 | */
174 | void PendSV_Handler(void)
175 | {
176 | /* USER CODE BEGIN PendSV_IRQn 0 */
177 |
178 | /* USER CODE END PendSV_IRQn 0 */
179 | /* USER CODE BEGIN PendSV_IRQn 1 */
180 |
181 | /* USER CODE END PendSV_IRQn 1 */
182 | }
183 |
184 | /**
185 | * @brief This function handles System tick timer.
186 | */
187 | void SysTick_Handler(void)
188 | {
189 | /* USER CODE BEGIN SysTick_IRQn 0 */
190 | DebouncedButton_SysTick_Handler();
191 |
192 | /* USER CODE END SysTick_IRQn 0 */
193 | HAL_IncTick();
194 | /* USER CODE BEGIN SysTick_IRQn 1 */
195 |
196 | /* USER CODE END SysTick_IRQn 1 */
197 | }
198 |
199 | /******************************************************************************/
200 | /* STM32F1xx Peripheral Interrupt Handlers */
201 | /* Add here the Interrupt Handlers for the used peripherals. */
202 | /* For the available peripheral interrupt handler names, */
203 | /* please refer to the startup file (startup_stm32f1xx.s). */
204 | /******************************************************************************/
205 |
206 | /**
207 | * @brief This function handles DMA1 channel5 global interrupt.
208 | */
209 | void DMA1_Channel5_IRQHandler(void)
210 | {
211 | /* USER CODE BEGIN DMA1_Channel5_IRQn 0 */
212 |
213 | /* USER CODE END DMA1_Channel5_IRQn 0 */
214 | HAL_DMA_IRQHandler(&hdma_usart1_rx);
215 | /* USER CODE BEGIN DMA1_Channel5_IRQn 1 */
216 |
217 | /* USER CODE END DMA1_Channel5_IRQn 1 */
218 | }
219 |
220 | /**
221 | * @brief This function handles ADC1 and ADC2 global interrupts.
222 | */
223 | void ADC1_2_IRQHandler(void)
224 | {
225 | /* USER CODE BEGIN ADC1_2_IRQn 0 */
226 |
227 | /* USER CODE END ADC1_2_IRQn 0 */
228 | HAL_ADC_IRQHandler(&hadc1);
229 | /* USER CODE BEGIN ADC1_2_IRQn 1 */
230 |
231 | /* USER CODE END ADC1_2_IRQn 1 */
232 | }
233 |
234 | /**
235 | * @brief This function handles USART1 global interrupt.
236 | */
237 | void USART1_IRQHandler(void)
238 | {
239 | /* USER CODE BEGIN USART1_IRQn 0 */
240 |
241 | /* USER CODE END USART1_IRQn 0 */
242 | HAL_UART_IRQHandler(&huart1);
243 | /* USER CODE BEGIN USART1_IRQn 1 */
244 |
245 | /* USER CODE END USART1_IRQn 1 */
246 | }
247 |
248 | /* USER CODE BEGIN 1 */
249 |
250 | /* USER CODE END 1 */
251 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
252 |
--------------------------------------------------------------------------------
/D6_firmware-Release.vgdbsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 | Release
4 |
5 |
6 |
7 | MinGWUnixSlash
8 |
9 | $(ProjectDir)
10 | false
11 | stm32.xml
12 |
13 |
14 |
15 | com.visualgdb.arm-eabi
16 |
17 | 7.2.0
18 | 8.0.1
19 | 3
20 |
21 |
22 | Makefile
23 | Release
24 | $(LocalMultiThreadedBuildFlags)
25 |
26 | false
27 | $(ToolchainMake)
28 | $(ToolchainMakeArgs)
29 | $(BuildDir)
30 |
31 |
32 | true
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | Default
46 |
47 |
48 |
49 | true
50 |
51 |
52 |
53 |
54 | Unknown
55 |
56 | true
57 | false
58 |
59 |
60 |
61 |
62 | false
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | false
72 | false
73 | false
74 | false
75 | false
76 | false
77 | false
78 | false
79 | false
80 |
81 | false
82 | false
83 | false
84 | false
85 | false
86 | false
87 | true
88 | false
89 | None
90 | false
91 | false
92 | main
93 | true
94 | false
95 | false
96 | false
97 | 0
98 |
99 |
100 | com.sysprogs.arm.openocd
101 |
102 |
103 |
104 | com.sysprogs.arm.openocd.interface
105 | interface/stlink-v2.cfg
106 |
107 |
108 | com.sysprogs.arm.openocd.cpu
109 |
110 |
111 |
112 | com.sysprogs.arm.openocd.chip
113 |
114 |
115 |
116 | com.sysprogs.arm.openocd.board
117 |
118 |
119 |
120 | com.sysprogs.arm.openocd.target
121 | target/stm32f1x.cfg
122 |
123 |
124 | com.sysprogs.arm.openocd.extraargs
125 | -c init -c "reset init"
126 |
127 |
128 | com.sysprogs.arm.openocd.initargs
129 |
130 |
131 |
132 | com.sysprogs.arm.openocd.commands.halt
133 | mon halt
134 |
135 |
136 | com.sysprogs.arm.openocd.commands.program
137 | load
138 |
139 |
140 | com.sysprogs.arm.openocd.commands.autoprogram
141 |
142 |
143 |
144 | com.sysprogs.arm.openocd.commands.reset
145 | mon reset init
146 |
147 |
148 | com.sysprogs.arm.openocd.commands.resetafter
149 |
150 |
151 |
152 | com.sysprogs.arm.openocd.quicksetup.enabled
153 | 1
154 |
155 |
156 | com.sysprogs.arm.openocd.delay
157 | 0
158 |
159 |
160 | com.sysprogs.arm.openocd.transport
161 |
162 |
163 |
164 | com.sysprogs.arm.openocd.quicksetup.interface
165 | stlink-v2
166 |
167 |
168 |
169 |
170 | true
171 | Auto
172 | 0
173 | false
174 | false
175 | true
176 | false
177 | false
178 |
179 | _estack
180 | 0
181 | false
182 | true
183 |
184 |
--------------------------------------------------------------------------------
/Src/main.c:
--------------------------------------------------------------------------------
1 | /* USER CODE BEGIN Header */
2 | /* Copyright (C)
3 | * 2019 Jose Luu
4 | * additional authors:
5 | *
6 | * This program is free software: you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation, version 3.
9 | *
10 | * This program is distributed in the hope that it will be useful, but
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 | * General Public License for more details.
14 | *
15 | * You should have received a copy of the GNU General Public License
16 | * along with this program. If not, see .
17 | */
18 | /* USER CODE END Header */
19 |
20 | /* Includes ------------------------------------------------------------------*/
21 | #include "main.h"
22 | #include "adc.h"
23 | #include "dma.h"
24 | #include "spi.h"
25 | #include "tim.h"
26 | #include "usart.h"
27 | #include "gpio.h"
28 |
29 | /* Private includes ----------------------------------------------------------*/
30 | /* USER CODE BEGIN Includes */
31 | #include "D6Board.h"
32 | #include "Loop.h"
33 | #include "eeprom.h"
34 | /* USER CODE END Includes */
35 |
36 | /* Private typedef -----------------------------------------------------------*/
37 | /* USER CODE BEGIN PTD */
38 |
39 | /* USER CODE END PTD */
40 |
41 | /* Private define ------------------------------------------------------------*/
42 | /* USER CODE BEGIN PD */
43 |
44 | /* USER CODE END PD */
45 |
46 | /* Private macro -------------------------------------------------------------*/
47 | /* USER CODE BEGIN PM */
48 |
49 | /* USER CODE END PM */
50 |
51 | /* Private variables ---------------------------------------------------------*/
52 |
53 | /* USER CODE BEGIN PV */
54 | /* Private variables ---------------------------------------------------------*/
55 | uint16_t VirtAddVarTab[NB_OF_VAR] = { 0x5555, 0x6666, 0x7777 };
56 | uint16_t VarDataTab[NB_OF_VAR] = { 0, 0, 0 };
57 | /* USER CODE END PV */
58 |
59 | /* Private function prototypes -----------------------------------------------*/
60 | void SystemClock_Config(void);
61 | /* USER CODE BEGIN PFP */
62 | /* Private function prototypes -----------------------------------------------*/
63 |
64 | /* USER CODE END PFP */
65 |
66 | /* Private user code ---------------------------------------------------------*/
67 | /* USER CODE BEGIN 0 */
68 | // precise timing functions
69 | #define SLOTS 4
70 | static volatile uint32_t start[4];
71 |
72 | void start_us_DWT(int slot)
73 | {
74 | if (slot < SLOTS) {
75 | start[slot] = DWT->CYCCNT;
76 | }
77 | }
78 |
79 | unsigned int get_us_DWT(int slot)
80 | {
81 | if (slot < SLOTS) {
82 | unsigned long long val;
83 | if (DWT->CYCCNT < start[slot]) {
84 | val = (DWT->CYCCNT - start[slot]) + (1LL << 32);
85 | } else {
86 | val = (DWT->CYCCNT - start[slot]);
87 | }
88 | return val * 1000000L / SystemCoreClock;
89 | }
90 | return 0xFFFFFFFF;
91 | }
92 |
93 | void delay_us_DWT(unsigned long uSec)
94 | {
95 | volatile uint32_t cycles = (SystemCoreClock / 1000000L)*uSec;
96 | volatile uint32_t start = DWT->CYCCNT;
97 | do {
98 | } while (DWT->CYCCNT - start < cycles);
99 | }
100 |
101 | /* USER CODE END 0 */
102 |
103 | /**
104 | * @brief The application entry point.
105 | * @retval int
106 | */
107 | int main(void)
108 | {
109 | /* USER CODE BEGIN 1 */
110 |
111 | /* USER CODE END 1 */
112 |
113 | /* MCU Configuration--------------------------------------------------------*/
114 |
115 | /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
116 | HAL_Init();
117 |
118 | /* USER CODE BEGIN Init */
119 | CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;
120 | DWT->CYCCNT = 0;
121 | // Enable hi resolution counter
122 | DWT->CTRL &= ~0x00000001;
123 | DWT->CTRL |= 0x00000001;
124 | /* USER CODE END Init */
125 |
126 | /* Configure the system clock */
127 | SystemClock_Config();
128 |
129 | /* USER CODE BEGIN SysInit */
130 | /* Unlock the Flash Program Erase controller */
131 | HAL_FLASH_Unlock();
132 | /* EEPROM Init */
133 | EE_Init();
134 | /* USER CODE END SysInit */
135 |
136 | /* Initialize all configured peripherals */
137 | MX_GPIO_Init();
138 | MX_DMA_Init();
139 | MX_USART1_UART_Init();
140 | MX_SPI1_Init();
141 | MX_SPI2_Init();
142 | MX_ADC1_Init();
143 | MX_TIM3_Init();
144 | /* USER CODE BEGIN 2 */
145 | initializeListener();
146 | blinkD1(true);
147 | /* USER CODE END 2 */
148 |
149 | /* Infinite loop */
150 | /* USER CODE BEGIN WHILE */
151 | while (1)
152 | {
153 | /* USER CODE END WHILE */
154 |
155 | /* USER CODE BEGIN 3 */
156 | doListen();
157 | }
158 | /* USER CODE END 3 */
159 | }
160 |
161 | /**
162 | * @brief System Clock Configuration
163 | * @retval None
164 | */
165 | void SystemClock_Config(void)
166 | {
167 | RCC_OscInitTypeDef RCC_OscInitStruct = {0};
168 | RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
169 | RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
170 |
171 | /** Initializes the CPU, AHB and APB busses clocks
172 | */
173 | RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
174 | RCC_OscInitStruct.HSEState = RCC_HSE_ON;
175 | RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV1;
176 | RCC_OscInitStruct.HSIState = RCC_HSI_ON;
177 | RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
178 | RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
179 | RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
180 | if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
181 | {
182 | Error_Handler();
183 | }
184 | /** Initializes the CPU, AHB and APB busses clocks
185 | */
186 | RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
187 | |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
188 | RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
189 | RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
190 | RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
191 | RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
192 |
193 | if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK)
194 | {
195 | Error_Handler();
196 | }
197 | PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC;
198 | PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6;
199 | if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
200 | {
201 | Error_Handler();
202 | }
203 | }
204 |
205 | /* USER CODE BEGIN 4 */
206 |
207 | void EEProm_Store(unsigned long val, unsigned short address)
208 | {
209 | unsigned short varShort[2];
210 |
211 | varShort[0] = val & 0xFFFF;
212 | varShort[1] = val >> 16;
213 | EE_WriteVariable(address * 2, varShort[0]);
214 | EE_WriteVariable(address * 2 + 1, varShort[1]);
215 |
216 | }
217 |
218 | unsigned long EEProm_Read(unsigned short address)
219 | {
220 | unsigned short varShort[2];
221 | unsigned long value;
222 |
223 | EE_ReadVariable(address * 2, &varShort[0]);
224 | EE_ReadVariable(address * 2 + 1, &varShort[1]);
225 | value = varShort[1] << 16 | varShort[0];
226 | }
227 |
228 | /* USER CODE END 4 */
229 |
230 | /**
231 | * @brief This function is executed in case of error occurrence.
232 | * @retval None
233 | */
234 | void Error_Handler(void)
235 | {
236 | /* USER CODE BEGIN Error_Handler_Debug */
237 | /* User can add his own implementation to report the HAL error return state */
238 | ledD2(true);
239 | while(1)
240 | {
241 | }
242 | /* USER CODE END Error_Handler_Debug */
243 | }
244 |
245 | #ifdef USE_FULL_ASSERT
246 | /**
247 | * @brief Reports the name of the source file and the source line number
248 | * where the assert_param error has occurred.
249 | * @param file: pointer to the source file name
250 | * @param line: assert_param error line source number
251 | * @retval None
252 | */
253 | void assert_failed(uint8_t *file, uint32_t line)
254 | {
255 | /* USER CODE BEGIN 6 */
256 | /* User can add his own implementation to report the file name and line number,
257 | ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
258 | /* USER CODE END 6 */
259 | }
260 | #endif /* USE_FULL_ASSERT */
261 |
262 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
263 |
--------------------------------------------------------------------------------
/Src/Loop.cpp:
--------------------------------------------------------------------------------
1 | /* Copyright (C)
2 | * 2019 Jose Luu
3 | * additional authors:
4 | *
5 | * This program is free software: you can redistribute it and/or modify
6 | * it under the terms of the GNU General Public License as published by
7 | * the Free Software Foundation, version 3.
8 | *
9 | * This program is distributed in the hope that it will be useful, but
10 | * WITHOUT ANY WARRANTY; without even the implied warranty of
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 | * General Public License for more details.
13 | *
14 | * You should have received a copy of the GNU General Public License
15 | * along with this program. If not, see .
16 | */
17 |
18 | #include
19 | #include "D6Board.h"
20 | #include "main.h"
21 | #include "Command.h"
22 | #include "Loop.h"
23 | #include "debouncedButton.h"
24 |
25 | #include "Serial.h"
26 |
27 | #define SERIAL_BUFFER_SIZE 50
28 | static char bufferOut[SERIAL_BUFFER_SIZE];
29 | static char bufferIn[SERIAL_BUFFER_SIZE];
30 |
31 | static SerialOutput SerialOut(&huart1, bufferOut, SERIAL_BUFFER_SIZE); // via USB
32 | static SerialInput SerialIn(&huart1, bufferIn, SERIAL_BUFFER_SIZE);
33 |
34 | static SerialOutput* pSerialOut;
35 | static SerialInput* pSerialIn;
36 |
37 |
38 |
39 | typedef enum {
40 | eInteractive, // command interpreter user friendly
41 | eDWT // DWT mode
42 | } eInputProtocol_t;
43 |
44 | eInputProtocol_t inputProtocolState;
45 | DebouncedButton *button;
46 |
47 | void initializeListener()
48 | {
49 | pSerialOut = &SerialOut;
50 | pSerialIn = &SerialIn;
51 | pSerialIn->initialize(NULL); // start receiving DMA and IT NULL means no echo channel
52 | //pSerialIn->initialize(pSerialOut); // with echo
53 | pSerialOut->puts("\r\nD6 ready\r\n");
54 | inputProtocolState = eDWT;
55 | button = new DebouncedButton(SW_GPIO_Port,SW_Pin);
56 | analyzerStandbyLedOn(true);
57 | DebouncedButton::addButton(button);
58 | }
59 |
60 | void sendChar(char c)
61 | {
62 | pSerialOut->putch(c);
63 | }
64 |
65 | bool getInputBinary(unsigned long &longValue, unsigned int timeoutMs)
66 | {
67 | char cNext[2];
68 | char c;
69 | unsigned char inputBytes[4];
70 | int inputCount = 0;
71 | unsigned long inputValue = 0;
72 | while (inputCount < sizeof(longValue)) {
73 | if (pSerialIn->fgetsNonBlocking(cNext, 2) != NULL) {
74 | inputBytes[inputCount]=cNext[0];
75 | inputCount++;
76 | }
77 | // check for timeout
78 | }
79 | longValue = inputBytes[0] | inputBytes[1] << 8 | inputBytes[2] << 16 | inputBytes[3] <<24;
80 | return true;
81 | }
82 | bool getInputBinary(unsigned char &byteValue, unsigned int timeoutMs)
83 | {
84 | char cNext[2];
85 | char c;
86 | unsigned int inputBytes = 0;
87 | int inputValue = 0;
88 | while (inputBytes < sizeof(byteValue)) {
89 | if (pSerialIn->fgetsNonBlocking(cNext, 2) != NULL) {
90 | cNext[0];
91 | byteValue = cNext[0];
92 | inputBytes++;
93 | }
94 | // check for timeout
95 | }
96 | }
97 | bool getInputInt(long long &value, unsigned int nbDigits, unsigned int timeoutMs)
98 | {
99 | char cNext[2];
100 | char c;
101 | unsigned int inputDigits = 0;
102 | int inputValue = 0;
103 | while (inputDigits < nbDigits)
104 | {
105 | if (pSerialIn->fgetsNonBlocking(cNext, 2) != NULL) {
106 | c = cNext[0];
107 | if (c >= '0' && c <= '9') {
108 | inputValue *= 10;
109 | inputValue += (c - '0');
110 | inputDigits++;
111 | }
112 | else
113 | {
114 | return false;
115 | }
116 | }
117 | // check for timeout
118 | }
119 | value = inputValue;
120 | return true;
121 | }
122 |
123 | bool getInputC(char & c)
124 | {
125 | char cNext[2];
126 | if (pSerialIn->fgetsNonBlocking(cNext, 2) != NULL) {
127 | c = cNext[0];
128 | return true;
129 | }
130 | return false;
131 | }
132 |
133 | void doInteractive(unsigned char)
134 | {
135 | }
136 |
137 | void doListen()
138 | {
139 | unsigned char c;
140 |
141 | do
142 | {
143 | bool buttonChanged;
144 | bool buttonStateDown = button->buttonState(&buttonChanged);
145 | bool pushedButton = buttonChanged && (buttonStateDown);
146 | executeButtonAction(pushedButton);
147 | }
148 | while (!pSerialIn->fgetc(c))
149 | ;
150 |
151 | switch (inputProtocolState)
152 | {
153 | case eInteractive:
154 | doInteractive(c);
155 | break;
156 | case eDWT:
157 | doNWT(c);
158 | break;
159 | }
160 | }
161 |
162 | typedef enum {
163 | undef = 0 ,
164 | samplingBits,
165 | serialSpeed,
166 | outputLevelTrackingGenerator,
167 | outputLevelAnalyzerGenerator,
168 | fullName,
169 | phaseVNA,
170 | offsetFI
171 | } Caps;
172 | bool getReadCapabilities(Command &command)
173 | {
174 | unsigned char c;
175 | while (!pSerialIn->fgetc(c)) ;
176 | switch (c)
177 | {
178 | case 1:
179 | break;
180 | }
181 | return true;
182 |
183 | }
184 |
185 | bool getWriteCapabilities(Command &command)
186 | {
187 | return true;
188 | }
189 |
190 |
191 | typedef enum {
192 | eFrame=0,
193 | eCode,
194 | eArgs
195 | } eState;
196 |
197 |
198 | #define RESTART_IF_FAILED(parse_expression) if (!parse_expression) \
199 | { \
200 | state = eFrame; \
201 | }
202 | void doNWT(unsigned char c)
203 | {
204 | static eState state = eFrame;
205 | Command command;
206 | bool bCommandReady = false;
207 |
208 | switch (state)
209 | {
210 | case eFrame:
211 | if (c == 0x8F)
212 | {
213 | state = eCode;
214 | }
215 | break;
216 | case eCode:
217 | command.code = c;
218 | switch (c)
219 | {
220 | case 'a'://sweep with us delay between measurement and audiosens, 27 bytes command, returns log measurement n x 2 x 2 bytes
221 | case 'b'://sweep with us delay between measurement and audiosens, 27 bytes command, returns linear measurement n x 2 x 2 bytes
222 | int ff;
223 | RESTART_IF_FAILED(getInputInt(command.frequency, 9, 0));
224 | RESTART_IF_FAILED(getInputInt(command.step, 8, 0));
225 | RESTART_IF_FAILED(getInputInt(command.count, 4, 0));
226 | RESTART_IF_FAILED(getInputInt(command.delay, 3, 0));
227 | RESTART_IF_FAILED(getInputInt(command.audio, 2, 0));
228 | command.step *= 10;
229 | command.frequency *= 10;
230 | bCommandReady = true;
231 | break;
232 | case 'c'://sweep with us delay between measurement and audiosens, 25 bytes command, returns log measurement n x 2 x 2 bytes
233 | case 'd'://sweep with us delay between measurement and audiosens, 25 bytes command, returns linear measurement n x 2 x 2 bytes
234 | RESTART_IF_FAILED(getInputInt(command.frequency, 9, 0));
235 | RESTART_IF_FAILED(getInputInt(command.step, 8, 0));
236 | RESTART_IF_FAILED(getInputInt(command.count, 4, 0));
237 | RESTART_IF_FAILED(getInputInt(command.delay, 3, 0));
238 | command.step *= 10;
239 | command.frequency *= 10;
240 | bCommandReady = true;
241 | break;
242 | case 'e'://pll adjust TODO
243 | break;
244 | case 'f'://VFO
245 | RESTART_IF_FAILED(getInputInt(command.frequency, 9, 0));
246 | command.step *= 1000;
247 | command.frequency *= 10;
248 | bCommandReady = true;
249 | break;
250 | case 'g':// read capability parameters
251 | RESTART_IF_FAILED(getReadCapabilities(command));
252 | bCommandReady = true;
253 | break;
254 | case 'h':// set capability parameters
255 | RESTART_IF_FAILED(getWriteCapabilities(command));
256 | bCommandReady = true;
257 | break;
258 | case 'i': // immediate programming 6 bytes command: Which ADF, register
259 | RESTART_IF_FAILED(getInputBinary(command.which, 0));
260 | RESTART_IF_FAILED(getInputBinary(command.r, 0));
261 | bCommandReady = true;
262 | break;
263 | case 'm': // read measure value now, 1 byte command, returns 4 bytes
264 | break;
265 | case 'n': // read measure value now (log?), 1 byte command, returns 4 bytes
266 | break;
267 | case 'o' ://not implemented: activate SWV relay, 2 byte command o0 or o1, no return
268 | case 'r' ://not implemented: attenuators setting, 3 bytes commannd, no return
269 | break;
270 | case 's': // status, 1 byte command 4 bytes return (version, atten, lo-hi of pin4 ADC measure)
271 | bCommandReady = true;
272 | break;
273 | case 'v': // get firmware version, 1 byte command, returns 1 byte
274 | bCommandReady = true;
275 | break;
276 | case 'w': // sweep AD8361 (linear RMS) 22 bytes command, returns n x 2 x 2 bytes
277 | case 'x': // sweep AD8307 (log) 22 bytes command, returns n x 2 x 2 bytes
278 | RESTART_IF_FAILED(getInputInt(command.frequency, 9, 0));
279 | RESTART_IF_FAILED(getInputInt(command.step, 8, 0));
280 | RESTART_IF_FAILED(getInputInt(command.count, 4, 0));
281 | command.step *= 10;
282 | command.frequency *= 10;
283 | bCommandReady = true;
284 | break;
285 | case 'z': // counter, 9 bytes command, returns binary on 4 bytes
286 | RESTART_IF_FAILED(getInputInt(command.count, 4, 0));
287 | bCommandReady = true;
288 | break;
289 | }
290 | }
291 | if (bCommandReady)
292 | {
293 | executeCommand(command);
294 | state = eFrame;
295 | }
296 | }
297 |
--------------------------------------------------------------------------------
/D6_firmware.ioc:
--------------------------------------------------------------------------------
1 | #MicroXplorer Configuration settings - do not modify
2 | ADC1.Channel-7\#ChannelRegularConversion=ADC_CHANNEL_3
3 | ADC1.ContinuousConvMode=ENABLE
4 | ADC1.DataAlign=ADC_DATAALIGN_RIGHT
5 | ADC1.DiscontinuousConvMode=DISABLE
6 | ADC1.EnableAnalogWatchDog=false
7 | ADC1.EnableRegularConversion=ENABLE
8 | ADC1.ExternalTrigConv=ADC_SOFTWARE_START
9 | ADC1.IPParameters=Rank-7\#ChannelRegularConversion,Channel-7\#ChannelRegularConversion,SamplingTime-7\#ChannelRegularConversion,NbrOfConversionFlag,master,InjNumberOfConversion,DataAlign,ScanConvMode,ContinuousConvMode,DiscontinuousConvMode,EnableRegularConversion,NbrOfConversion,ExternalTrigConv,EnableAnalogWatchDog
10 | ADC1.InjNumberOfConversion=0
11 | ADC1.NbrOfConversion=1
12 | ADC1.NbrOfConversionFlag=1
13 | ADC1.Rank-7\#ChannelRegularConversion=1
14 | ADC1.SamplingTime-7\#ChannelRegularConversion=ADC_SAMPLETIME_239CYCLES_5
15 | ADC1.ScanConvMode=ADC_SCAN_DISABLE
16 | ADC1.master=1
17 | Dma.Request0=USART1_RX
18 | Dma.RequestsNb=1
19 | Dma.USART1_RX.0.Direction=DMA_PERIPH_TO_MEMORY
20 | Dma.USART1_RX.0.Instance=DMA1_Channel5
21 | Dma.USART1_RX.0.MemDataAlignment=DMA_MDATAALIGN_BYTE
22 | Dma.USART1_RX.0.MemInc=DMA_MINC_ENABLE
23 | Dma.USART1_RX.0.Mode=DMA_CIRCULAR
24 | Dma.USART1_RX.0.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
25 | Dma.USART1_RX.0.PeriphInc=DMA_PINC_DISABLE
26 | Dma.USART1_RX.0.Priority=DMA_PRIORITY_LOW
27 | Dma.USART1_RX.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority
28 | File.Version=6
29 | KeepUserPlacement=true
30 | Mcu.Family=STM32F1
31 | Mcu.IP0=ADC1
32 | Mcu.IP1=DMA
33 | Mcu.IP2=NVIC
34 | Mcu.IP3=RCC
35 | Mcu.IP4=SPI1
36 | Mcu.IP5=SPI2
37 | Mcu.IP6=SYS
38 | Mcu.IP7=TIM3
39 | Mcu.IP8=USART1
40 | Mcu.IPNb=9
41 | Mcu.Name=STM32F103C(8-B)Tx
42 | Mcu.Package=LQFP48
43 | Mcu.Pin0=PC15-OSC32_OUT
44 | Mcu.Pin1=PD0-OSC_IN
45 | Mcu.Pin10=PB15
46 | Mcu.Pin11=PA11
47 | Mcu.Pin12=PA12
48 | Mcu.Pin13=PA13
49 | Mcu.Pin14=PA14
50 | Mcu.Pin15=PB6
51 | Mcu.Pin16=PB7
52 | Mcu.Pin17=VP_SYS_VS_Systick
53 | Mcu.Pin18=VP_TIM3_VS_ClockSourceINT
54 | Mcu.Pin2=PD1-OSC_OUT
55 | Mcu.Pin3=PA3
56 | Mcu.Pin4=PA4
57 | Mcu.Pin5=PA5
58 | Mcu.Pin6=PA7
59 | Mcu.Pin7=PB1
60 | Mcu.Pin8=PB12
61 | Mcu.Pin9=PB13
62 | Mcu.PinsNb=19
63 | Mcu.ThirdPartyNb=0
64 | Mcu.UserConstants=
65 | Mcu.UserName=STM32F103C8Tx
66 | MxCube.Version=5.1.0
67 | MxDb.Version=DB.5.0.10
68 | NVIC.ADC1_2_IRQn=true\:0\:0\:false\:false\:true\:true\:true
69 | NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
70 | NVIC.DMA1_Channel5_IRQn=true\:0\:0\:false\:false\:true\:false\:true
71 | NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false
72 | NVIC.HardFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
73 | NVIC.MemoryManagement_IRQn=true\:0\:0\:false\:false\:true\:false\:false
74 | NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false
75 | NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false
76 | NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4
77 | NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false
78 | NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true
79 | NVIC.USART1_IRQn=true\:0\:0\:false\:false\:true\:true\:true
80 | NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false
81 | PA11.GPIOParameters=GPIO_Label
82 | PA11.GPIO_Label=D2
83 | PA11.Locked=true
84 | PA11.Signal=GPIO_Output
85 | PA12.GPIOParameters=GPIO_Label
86 | PA12.GPIO_Label=SW
87 | PA12.Locked=true
88 | PA12.Signal=GPIO_Input
89 | PA13.Mode=Serial_Wire
90 | PA13.Signal=SYS_JTMS-SWDIO
91 | PA14.Mode=Serial_Wire
92 | PA14.Signal=SYS_JTCK-SWCLK
93 | PA3.GPIOParameters=GPIO_Label
94 | PA3.GPIO_Label=ADC
95 | PA3.Locked=true
96 | PA3.Signal=ADCx_IN3
97 | PA4.GPIOParameters=GPIO_Label
98 | PA4.GPIO_Label=LEA
99 | PA4.Locked=true
100 | PA4.Signal=GPIO_Output
101 | PA5.Locked=true
102 | PA5.Mode=TX_Only_Simplex_Unidirect_Master
103 | PA5.Signal=SPI1_SCK
104 | PA7.Locked=true
105 | PA7.Mode=TX_Only_Simplex_Unidirect_Master
106 | PA7.Signal=SPI1_MOSI
107 | PB1.GPIOParameters=GPIO_Label
108 | PB1.GPIO_Label=D1
109 | PB1.Locked=true
110 | PB1.Signal=S_TIM3_CH4
111 | PB12.GPIOParameters=GPIO_Label
112 | PB12.GPIO_Label=LE
113 | PB12.Locked=true
114 | PB12.Signal=GPIO_Output
115 | PB13.Locked=true
116 | PB13.Mode=TX_Only_Simplex_Unidirect_Master
117 | PB13.Signal=SPI2_SCK
118 | PB15.Locked=true
119 | PB15.Mode=TX_Only_Simplex_Unidirect_Master
120 | PB15.Signal=SPI2_MOSI
121 | PB6.GPIOParameters=GPIO_Label
122 | PB6.GPIO_Label=T
123 | PB6.Locked=true
124 | PB6.Mode=Asynchronous
125 | PB6.Signal=USART1_TX
126 | PB7.GPIOParameters=GPIO_Label
127 | PB7.GPIO_Label=R
128 | PB7.Locked=true
129 | PB7.Mode=Asynchronous
130 | PB7.Signal=USART1_RX
131 | PC15-OSC32_OUT.GPIOParameters=GPIO_PuPd,GPIO_Label
132 | PC15-OSC32_OUT.GPIO_Label=AD8307_EN
133 | PC15-OSC32_OUT.GPIO_PuPd=GPIO_PULLUP
134 | PC15-OSC32_OUT.Locked=true
135 | PC15-OSC32_OUT.Signal=GPIO_Input
136 | PCC.Checker=false
137 | PCC.Line=STM32F103
138 | PCC.MCU=STM32F103C(8-B)Tx
139 | PCC.PartNumber=STM32F103C8Tx
140 | PCC.Seq0=0
141 | PCC.Series=STM32F1
142 | PCC.Temperature=25
143 | PCC.Vdd=3.3
144 | PD0-OSC_IN.Mode=HSE-External-Oscillator
145 | PD0-OSC_IN.Signal=RCC_OSC_IN
146 | PD1-OSC_OUT.Mode=HSE-External-Oscillator
147 | PD1-OSC_OUT.Signal=RCC_OSC_OUT
148 | PinOutPanel.RotationAngle=0
149 | ProjectManager.AskForMigrate=true
150 | ProjectManager.BackupPrevious=false
151 | ProjectManager.CompilerOptimize=2
152 | ProjectManager.ComputerToolchain=false
153 | ProjectManager.CoupleFile=true
154 | ProjectManager.CustomerFirmwarePackage=
155 | ProjectManager.DefaultFWLocation=true
156 | ProjectManager.DeletePrevious=true
157 | ProjectManager.DeviceId=STM32F103C8Tx
158 | ProjectManager.FirmwarePackage=STM32Cube FW_F1 V1.7.0
159 | ProjectManager.FreePins=false
160 | ProjectManager.HalAssertFull=false
161 | ProjectManager.HeapSize=0x200
162 | ProjectManager.KeepUserCode=true
163 | ProjectManager.LastFirmware=true
164 | ProjectManager.LibraryCopy=2
165 | ProjectManager.MainLocation=Src
166 | ProjectManager.NoMain=false
167 | ProjectManager.PreviousToolchain=TrueSTUDIO
168 | ProjectManager.ProjectBuild=false
169 | ProjectManager.ProjectFileName=D6_firmware.ioc
170 | ProjectManager.ProjectName=D6_firmware
171 | ProjectManager.StackSize=0x400
172 | ProjectManager.TargetToolchain=TrueSTUDIO
173 | ProjectManager.ToolChainLocation=
174 | ProjectManager.UnderRoot=true
175 | ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-MX_DMA_Init-DMA-false-HAL-true,3-MX_USART1_UART_Init-USART1-false-HAL-true,4-MX_SPI1_Init-SPI1-false-HAL-true,5-MX_SPI2_Init-SPI2-false-HAL-true,6-MX_ADC1_Init-ADC1-false-HAL-true,7-SystemClock_Config-RCC-false-HAL-false,8-MX_TIM3_Init-TIM3-false-HAL-true
176 | RCC.ADCFreqValue=12000000
177 | RCC.ADCPresc=RCC_ADCPCLK2_DIV6
178 | RCC.AHBFreq_Value=72000000
179 | RCC.APB1CLKDivider=RCC_HCLK_DIV2
180 | RCC.APB1Freq_Value=36000000
181 | RCC.APB1TimFreq_Value=72000000
182 | RCC.APB2Freq_Value=72000000
183 | RCC.APB2TimFreq_Value=72000000
184 | RCC.FCLKCortexFreq_Value=72000000
185 | RCC.FamilyName=M
186 | RCC.HCLKFreq_Value=72000000
187 | RCC.IPParameters=ADCFreqValue,ADCPresc,AHBFreq_Value,APB1CLKDivider,APB1Freq_Value,APB1TimFreq_Value,APB2Freq_Value,APB2TimFreq_Value,FCLKCortexFreq_Value,FamilyName,HCLKFreq_Value,MCOFreq_Value,PLLCLKFreq_Value,PLLMCOFreq_Value,PLLMUL,PLLSourceVirtual,SYSCLKFreq_VALUE,SYSCLKSource,TimSysFreq_Value,USBFreq_Value,VCOOutput2Freq_Value
188 | RCC.MCOFreq_Value=72000000
189 | RCC.PLLCLKFreq_Value=72000000
190 | RCC.PLLMCOFreq_Value=36000000
191 | RCC.PLLMUL=RCC_PLL_MUL9
192 | RCC.PLLSourceVirtual=RCC_PLLSOURCE_HSE
193 | RCC.SYSCLKFreq_VALUE=72000000
194 | RCC.SYSCLKSource=RCC_SYSCLKSOURCE_PLLCLK
195 | RCC.TimSysFreq_Value=72000000
196 | RCC.USBFreq_Value=72000000
197 | RCC.VCOOutput2Freq_Value=8000000
198 | SH.ADCx_IN3.0=ADC2_IN3
199 | SH.ADCx_IN3.1=ADC1_IN3,IN3
200 | SH.ADCx_IN3.ConfNb=2
201 | SH.S_TIM3_CH4.0=TIM3_CH4,PWM Generation4 CH4
202 | SH.S_TIM3_CH4.ConfNb=1
203 | SPI1.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_8
204 | SPI1.CRCCalculation=SPI_CRCCALCULATION_DISABLE
205 | SPI1.CalculateBaudRate=9.0 MBits/s
206 | SPI1.Direction=SPI_DIRECTION_2LINES
207 | SPI1.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler,CRCCalculation
208 | SPI1.Mode=SPI_MODE_MASTER
209 | SPI1.VirtualType=VM_MASTER
210 | SPI2.BaudRatePrescaler=SPI_BAUDRATEPRESCALER_8
211 | SPI2.CalculateBaudRate=4.5 MBits/s
212 | SPI2.Direction=SPI_DIRECTION_2LINES
213 | SPI2.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,BaudRatePrescaler
214 | SPI2.Mode=SPI_MODE_MASTER
215 | SPI2.VirtualType=VM_MASTER
216 | TIM3.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_DISABLE
217 | TIM3.Channel-PWM\ Generation4\ CH4=TIM_CHANNEL_4
218 | TIM3.IPParameters=Prescaler,Period,OCPolarity_4,AutoReloadPreload,Channel-PWM Generation4 CH4,Pulse-PWM Generation4 CH4
219 | TIM3.OCPolarity_4=TIM_OCPOLARITY_HIGH
220 | TIM3.Period=2000
221 | TIM3.Prescaler=18000
222 | TIM3.Pulse-PWM\ Generation4\ CH4=1000
223 | USART1.BaudRate=57600
224 | USART1.IPParameters=VirtualMode,BaudRate
225 | USART1.VirtualMode=VM_ASYNC
226 | VP_SYS_VS_Systick.Mode=SysTick
227 | VP_SYS_VS_Systick.Signal=SYS_VS_Systick
228 | VP_TIM3_VS_ClockSourceINT.Mode=Internal
229 | VP_TIM3_VS_ClockSourceINT.Signal=TIM3_VS_ClockSourceINT
230 | board=D6_firmware
231 |
--------------------------------------------------------------------------------
/startup/startup_stm32f103xb.s:
--------------------------------------------------------------------------------
1 | /**
2 | *************** (C) COPYRIGHT 2017 STMicroelectronics ************************
3 | * @file startup_stm32f103xb.s
4 | * @author MCD Application Team
5 | * @version V4.2.0
6 | * @date 31-March-2017
7 | * @brief STM32F103xB Devices vector table for Atollic toolchain.
8 | * This module performs:
9 | * - Set the initial SP
10 | * - Set the initial PC == Reset_Handler,
11 | * - Set the vector table entries with the exceptions ISR address
12 | * - Configure the clock system
13 | * - Branches to main in the C library (which eventually
14 | * calls main()).
15 | * After Reset the Cortex-M3 processor is in Thread mode,
16 | * priority is Privileged, and the Stack is set to Main.
17 | ******************************************************************************
18 | *
19 | * © COPYRIGHT(c) 2017 STMicroelectronics
20 | *
21 | * Redistribution and use in source and binary forms, with or without modification,
22 | * are permitted provided that the following conditions are met:
23 | * 1. Redistributions of source code must retain the above copyright notice,
24 | * this list of conditions and the following disclaimer.
25 | * 2. Redistributions in binary form must reproduce the above copyright notice,
26 | * this list of conditions and the following disclaimer in the documentation
27 | * and/or other materials provided with the distribution.
28 | * 3. Neither the name of STMicroelectronics nor the names of its contributors
29 | * may be used to endorse or promote products derived from this software
30 | * without specific prior written permission.
31 | *
32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
33 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
34 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
35 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
36 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
38 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
39 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
40 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
41 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 | *
43 | ******************************************************************************
44 | */
45 |
46 | .syntax unified
47 | .cpu cortex-m3
48 | .fpu softvfp
49 | .thumb
50 |
51 | .global g_pfnVectors
52 | .global Default_Handler
53 |
54 | /* start address for the initialization values of the .data section.
55 | defined in linker script */
56 | .word _sidata
57 | /* start address for the .data section. defined in linker script */
58 | .word _sdata
59 | /* end address for the .data section. defined in linker script */
60 | .word _edata
61 | /* start address for the .bss section. defined in linker script */
62 | .word _sbss
63 | /* end address for the .bss section. defined in linker script */
64 | .word _ebss
65 |
66 | .equ BootRAM, 0xF108F85F
67 | /**
68 | * @brief This is the code that gets called when the processor first
69 | * starts execution following a reset event. Only the absolutely
70 | * necessary set is performed, after which the application
71 | * supplied main() routine is called.
72 | * @param None
73 | * @retval : None
74 | */
75 |
76 | .section .text.Reset_Handler
77 | .weak Reset_Handler
78 | .type Reset_Handler, %function
79 | Reset_Handler:
80 |
81 | /* Copy the data segment initializers from flash to SRAM */
82 | movs r1, #0
83 | b LoopCopyDataInit
84 |
85 | CopyDataInit:
86 | ldr r3, =_sidata
87 | ldr r3, [r3, r1]
88 | str r3, [r0, r1]
89 | adds r1, r1, #4
90 |
91 | LoopCopyDataInit:
92 | ldr r0, =_sdata
93 | ldr r3, =_edata
94 | adds r2, r0, r1
95 | cmp r2, r3
96 | bcc CopyDataInit
97 | ldr r2, =_sbss
98 | b LoopFillZerobss
99 | /* Zero fill the bss segment. */
100 | FillZerobss:
101 | movs r3, #0
102 | str r3, [r2], #4
103 |
104 | LoopFillZerobss:
105 | ldr r3, = _ebss
106 | cmp r2, r3
107 | bcc FillZerobss
108 |
109 | /* Call the clock system intitialization function.*/
110 | bl SystemInit
111 | /* Call static constructors */
112 | bl __libc_init_array
113 | /* Call the application's entry point.*/
114 | bl main
115 | bx lr
116 | .size Reset_Handler, .-Reset_Handler
117 |
118 | /**
119 | * @brief This is the code that gets called when the processor receives an
120 | * unexpected interrupt. This simply enters an infinite loop, preserving
121 | * the system state for examination by a debugger.
122 | *
123 | * @param None
124 | * @retval : None
125 | */
126 | .section .text.Default_Handler,"ax",%progbits
127 | Default_Handler:
128 | Infinite_Loop:
129 | b Infinite_Loop
130 | .size Default_Handler, .-Default_Handler
131 | /******************************************************************************
132 | *
133 | * The minimal vector table for a Cortex M3. Note that the proper constructs
134 | * must be placed on this to ensure that it ends up at physical address
135 | * 0x0000.0000.
136 | *
137 | ******************************************************************************/
138 | .section .isr_vector,"a",%progbits
139 | .type g_pfnVectors, %object
140 | .size g_pfnVectors, .-g_pfnVectors
141 |
142 |
143 | g_pfnVectors:
144 |
145 | .word _estack
146 | .word Reset_Handler
147 | .word NMI_Handler
148 | .word HardFault_Handler
149 | .word MemManage_Handler
150 | .word BusFault_Handler
151 | .word UsageFault_Handler
152 | .word 0
153 | .word 0
154 | .word 0
155 | .word 0
156 | .word SVC_Handler
157 | .word DebugMon_Handler
158 | .word 0
159 | .word PendSV_Handler
160 | .word SysTick_Handler
161 | .word WWDG_IRQHandler
162 | .word PVD_IRQHandler
163 | .word TAMPER_IRQHandler
164 | .word RTC_IRQHandler
165 | .word FLASH_IRQHandler
166 | .word RCC_IRQHandler
167 | .word EXTI0_IRQHandler
168 | .word EXTI1_IRQHandler
169 | .word EXTI2_IRQHandler
170 | .word EXTI3_IRQHandler
171 | .word EXTI4_IRQHandler
172 | .word DMA1_Channel1_IRQHandler
173 | .word DMA1_Channel2_IRQHandler
174 | .word DMA1_Channel3_IRQHandler
175 | .word DMA1_Channel4_IRQHandler
176 | .word DMA1_Channel5_IRQHandler
177 | .word DMA1_Channel6_IRQHandler
178 | .word DMA1_Channel7_IRQHandler
179 | .word ADC1_2_IRQHandler
180 | .word USB_HP_CAN1_TX_IRQHandler
181 | .word USB_LP_CAN1_RX0_IRQHandler
182 | .word CAN1_RX1_IRQHandler
183 | .word CAN1_SCE_IRQHandler
184 | .word EXTI9_5_IRQHandler
185 | .word TIM1_BRK_IRQHandler
186 | .word TIM1_UP_IRQHandler
187 | .word TIM1_TRG_COM_IRQHandler
188 | .word TIM1_CC_IRQHandler
189 | .word TIM2_IRQHandler
190 | .word TIM3_IRQHandler
191 | .word TIM4_IRQHandler
192 | .word I2C1_EV_IRQHandler
193 | .word I2C1_ER_IRQHandler
194 | .word I2C2_EV_IRQHandler
195 | .word I2C2_ER_IRQHandler
196 | .word SPI1_IRQHandler
197 | .word SPI2_IRQHandler
198 | .word USART1_IRQHandler
199 | .word USART2_IRQHandler
200 | .word USART3_IRQHandler
201 | .word EXTI15_10_IRQHandler
202 | .word RTC_Alarm_IRQHandler
203 | .word USBWakeUp_IRQHandler
204 | .word 0
205 | .word 0
206 | .word 0
207 | .word 0
208 | .word 0
209 | .word 0
210 | .word 0
211 | .word BootRAM /* @0x108. This is for boot in RAM mode for
212 | STM32F10x Medium Density devices. */
213 |
214 | /*******************************************************************************
215 | *
216 | * Provide weak aliases for each Exception handler to the Default_Handler.
217 | * As they are weak aliases, any function with the same name will override
218 | * this definition.
219 | *
220 | *******************************************************************************/
221 |
222 | .weak NMI_Handler
223 | .thumb_set NMI_Handler,Default_Handler
224 |
225 | .weak HardFault_Handler
226 | .thumb_set HardFault_Handler,Default_Handler
227 |
228 | .weak MemManage_Handler
229 | .thumb_set MemManage_Handler,Default_Handler
230 |
231 | .weak BusFault_Handler
232 | .thumb_set BusFault_Handler,Default_Handler
233 |
234 | .weak UsageFault_Handler
235 | .thumb_set UsageFault_Handler,Default_Handler
236 |
237 | .weak SVC_Handler
238 | .thumb_set SVC_Handler,Default_Handler
239 |
240 | .weak DebugMon_Handler
241 | .thumb_set DebugMon_Handler,Default_Handler
242 |
243 | .weak PendSV_Handler
244 | .thumb_set PendSV_Handler,Default_Handler
245 |
246 | .weak SysTick_Handler
247 | .thumb_set SysTick_Handler,Default_Handler
248 |
249 | .weak WWDG_IRQHandler
250 | .thumb_set WWDG_IRQHandler,Default_Handler
251 |
252 | .weak PVD_IRQHandler
253 | .thumb_set PVD_IRQHandler,Default_Handler
254 |
255 | .weak TAMPER_IRQHandler
256 | .thumb_set TAMPER_IRQHandler,Default_Handler
257 |
258 | .weak RTC_IRQHandler
259 | .thumb_set RTC_IRQHandler,Default_Handler
260 |
261 | .weak FLASH_IRQHandler
262 | .thumb_set FLASH_IRQHandler,Default_Handler
263 |
264 | .weak RCC_IRQHandler
265 | .thumb_set RCC_IRQHandler,Default_Handler
266 |
267 | .weak EXTI0_IRQHandler
268 | .thumb_set EXTI0_IRQHandler,Default_Handler
269 |
270 | .weak EXTI1_IRQHandler
271 | .thumb_set EXTI1_IRQHandler,Default_Handler
272 |
273 | .weak EXTI2_IRQHandler
274 | .thumb_set EXTI2_IRQHandler,Default_Handler
275 |
276 | .weak EXTI3_IRQHandler
277 | .thumb_set EXTI3_IRQHandler,Default_Handler
278 |
279 | .weak EXTI4_IRQHandler
280 | .thumb_set EXTI4_IRQHandler,Default_Handler
281 |
282 | .weak DMA1_Channel1_IRQHandler
283 | .thumb_set DMA1_Channel1_IRQHandler,Default_Handler
284 |
285 | .weak DMA1_Channel2_IRQHandler
286 | .thumb_set DMA1_Channel2_IRQHandler,Default_Handler
287 |
288 | .weak DMA1_Channel3_IRQHandler
289 | .thumb_set DMA1_Channel3_IRQHandler,Default_Handler
290 |
291 | .weak DMA1_Channel4_IRQHandler
292 | .thumb_set DMA1_Channel4_IRQHandler,Default_Handler
293 |
294 | .weak DMA1_Channel5_IRQHandler
295 | .thumb_set DMA1_Channel5_IRQHandler,Default_Handler
296 |
297 | .weak DMA1_Channel6_IRQHandler
298 | .thumb_set DMA1_Channel6_IRQHandler,Default_Handler
299 |
300 | .weak DMA1_Channel7_IRQHandler
301 | .thumb_set DMA1_Channel7_IRQHandler,Default_Handler
302 |
303 | .weak ADC1_2_IRQHandler
304 | .thumb_set ADC1_2_IRQHandler,Default_Handler
305 |
306 | .weak USB_HP_CAN1_TX_IRQHandler
307 | .thumb_set USB_HP_CAN1_TX_IRQHandler,Default_Handler
308 |
309 | .weak USB_LP_CAN1_RX0_IRQHandler
310 | .thumb_set USB_LP_CAN1_RX0_IRQHandler,Default_Handler
311 |
312 | .weak CAN1_RX1_IRQHandler
313 | .thumb_set CAN1_RX1_IRQHandler,Default_Handler
314 |
315 | .weak CAN1_SCE_IRQHandler
316 | .thumb_set CAN1_SCE_IRQHandler,Default_Handler
317 |
318 | .weak EXTI9_5_IRQHandler
319 | .thumb_set EXTI9_5_IRQHandler,Default_Handler
320 |
321 | .weak TIM1_BRK_IRQHandler
322 | .thumb_set TIM1_BRK_IRQHandler,Default_Handler
323 |
324 | .weak TIM1_UP_IRQHandler
325 | .thumb_set TIM1_UP_IRQHandler,Default_Handler
326 |
327 | .weak TIM1_TRG_COM_IRQHandler
328 | .thumb_set TIM1_TRG_COM_IRQHandler,Default_Handler
329 |
330 | .weak TIM1_CC_IRQHandler
331 | .thumb_set TIM1_CC_IRQHandler,Default_Handler
332 |
333 | .weak TIM2_IRQHandler
334 | .thumb_set TIM2_IRQHandler,Default_Handler
335 |
336 | .weak TIM3_IRQHandler
337 | .thumb_set TIM3_IRQHandler,Default_Handler
338 |
339 | .weak TIM4_IRQHandler
340 | .thumb_set TIM4_IRQHandler,Default_Handler
341 |
342 | .weak I2C1_EV_IRQHandler
343 | .thumb_set I2C1_EV_IRQHandler,Default_Handler
344 |
345 | .weak I2C1_ER_IRQHandler
346 | .thumb_set I2C1_ER_IRQHandler,Default_Handler
347 |
348 | .weak I2C2_EV_IRQHandler
349 | .thumb_set I2C2_EV_IRQHandler,Default_Handler
350 |
351 | .weak I2C2_ER_IRQHandler
352 | .thumb_set I2C2_ER_IRQHandler,Default_Handler
353 |
354 | .weak SPI1_IRQHandler
355 | .thumb_set SPI1_IRQHandler,Default_Handler
356 |
357 | .weak SPI2_IRQHandler
358 | .thumb_set SPI2_IRQHandler,Default_Handler
359 |
360 | .weak USART1_IRQHandler
361 | .thumb_set USART1_IRQHandler,Default_Handler
362 |
363 | .weak USART2_IRQHandler
364 | .thumb_set USART2_IRQHandler,Default_Handler
365 |
366 | .weak USART3_IRQHandler
367 | .thumb_set USART3_IRQHandler,Default_Handler
368 |
369 | .weak EXTI15_10_IRQHandler
370 | .thumb_set EXTI15_10_IRQHandler,Default_Handler
371 |
372 | .weak RTC_Alarm_IRQHandler
373 | .thumb_set RTC_Alarm_IRQHandler,Default_Handler
374 |
375 | .weak USBWakeUp_IRQHandler
376 | .thumb_set USBWakeUp_IRQHandler,Default_Handler
377 |
378 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
379 |
380 |
--------------------------------------------------------------------------------
/Inc/stm32f1xx_hal_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f1xx_hal_conf.h
4 | * @brief HAL configuration file.
5 | ******************************************************************************
6 | * @attention
7 | *
8 | * © COPYRIGHT(c) 2019 STMicroelectronics
9 | *
10 | * Redistribution and use in source and binary forms, with or without modification,
11 | * are permitted provided that the following conditions are met:
12 | * 1. Redistributions of source code must retain the above copyright notice,
13 | * this list of conditions and the following disclaimer.
14 | * 2. Redistributions in binary form must reproduce the above copyright notice,
15 | * this list of conditions and the following disclaimer in the documentation
16 | * and/or other materials provided with the distribution.
17 | * 3. Neither the name of STMicroelectronics nor the names of its contributors
18 | * may be used to endorse or promote products derived from this software
19 | * without specific prior written permission.
20 | *
21 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
25 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 | *
32 | ******************************************************************************
33 | */
34 |
35 | /* Define to prevent recursive inclusion -------------------------------------*/
36 | #ifndef __STM32F1xx_HAL_CONF_H
37 | #define __STM32F1xx_HAL_CONF_H
38 |
39 | #ifdef __cplusplus
40 | extern "C" {
41 | #endif
42 |
43 | /* Exported types ------------------------------------------------------------*/
44 | /* Exported constants --------------------------------------------------------*/
45 |
46 | /* ########################## Module Selection ############################## */
47 | /**
48 | * @brief This is the list of modules to be used in the HAL driver
49 | */
50 |
51 | #define HAL_MODULE_ENABLED
52 | #define HAL_ADC_MODULE_ENABLED
53 | /*#define HAL_CRYP_MODULE_ENABLED */
54 | /*#define HAL_CAN_MODULE_ENABLED */
55 | /*#define HAL_CEC_MODULE_ENABLED */
56 | /*#define HAL_CORTEX_MODULE_ENABLED */
57 | /*#define HAL_CRC_MODULE_ENABLED */
58 | /*#define HAL_DAC_MODULE_ENABLED */
59 | #define HAL_DMA_MODULE_ENABLED
60 | /*#define HAL_ETH_MODULE_ENABLED */
61 | /*#define HAL_FLASH_MODULE_ENABLED */
62 | #define HAL_GPIO_MODULE_ENABLED
63 | /*#define HAL_I2C_MODULE_ENABLED */
64 | /*#define HAL_I2S_MODULE_ENABLED */
65 | /*#define HAL_IRDA_MODULE_ENABLED */
66 | /*#define HAL_IWDG_MODULE_ENABLED */
67 | /*#define HAL_NOR_MODULE_ENABLED */
68 | /*#define HAL_NAND_MODULE_ENABLED */
69 | /*#define HAL_PCCARD_MODULE_ENABLED */
70 | /*#define HAL_PCD_MODULE_ENABLED */
71 | /*#define HAL_HCD_MODULE_ENABLED */
72 | /*#define HAL_PWR_MODULE_ENABLED */
73 | /*#define HAL_RCC_MODULE_ENABLED */
74 | /*#define HAL_RTC_MODULE_ENABLED */
75 | /*#define HAL_SD_MODULE_ENABLED */
76 | /*#define HAL_MMC_MODULE_ENABLED */
77 | /*#define HAL_SDRAM_MODULE_ENABLED */
78 | /*#define HAL_SMARTCARD_MODULE_ENABLED */
79 | #define HAL_SPI_MODULE_ENABLED
80 | /*#define HAL_SRAM_MODULE_ENABLED */
81 | #define HAL_TIM_MODULE_ENABLED
82 | #define HAL_UART_MODULE_ENABLED
83 | /*#define HAL_USART_MODULE_ENABLED */
84 | /*#define HAL_WWDG_MODULE_ENABLED */
85 | /*#define HAL_EXTI_MODULE_ENABLED */
86 |
87 | #define HAL_CORTEX_MODULE_ENABLED
88 | #define HAL_DMA_MODULE_ENABLED
89 | #define HAL_FLASH_MODULE_ENABLED
90 | #define HAL_GPIO_MODULE_ENABLED
91 | #define HAL_PWR_MODULE_ENABLED
92 | #define HAL_RCC_MODULE_ENABLED
93 |
94 | /* ########################## Oscillator Values adaptation ####################*/
95 | /**
96 | * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
97 | * This value is used by the RCC HAL module to compute the system frequency
98 | * (when HSE is used as system clock source, directly or through the PLL).
99 | */
100 | #if !defined (HSE_VALUE)
101 | #define HSE_VALUE ((uint32_t)8000000) /*!< Value of the External oscillator in Hz */
102 | #endif /* HSE_VALUE */
103 |
104 | #if !defined (HSE_STARTUP_TIMEOUT)
105 | #define HSE_STARTUP_TIMEOUT ((uint32_t)100) /*!< Time out for HSE start up, in ms */
106 | #endif /* HSE_STARTUP_TIMEOUT */
107 |
108 | /**
109 | * @brief Internal High Speed oscillator (HSI) value.
110 | * This value is used by the RCC HAL module to compute the system frequency
111 | * (when HSI is used as system clock source, directly or through the PLL).
112 | */
113 | #if !defined (HSI_VALUE)
114 | #define HSI_VALUE ((uint32_t)8000000) /*!< Value of the Internal oscillator in Hz*/
115 | #endif /* HSI_VALUE */
116 |
117 | /**
118 | * @brief Internal Low Speed oscillator (LSI) value.
119 | */
120 | #if !defined (LSI_VALUE)
121 | #define LSI_VALUE 40000U /*!< LSI Typical Value in Hz */
122 | #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
123 | The real value may vary depending on the variations
124 | in voltage and temperature. */
125 |
126 | /**
127 | * @brief External Low Speed oscillator (LSE) value.
128 | * This value is used by the UART, RTC HAL module to compute the system frequency
129 | */
130 | #if !defined (LSE_VALUE)
131 | #define LSE_VALUE ((uint32_t)32768) /*!< Value of the External oscillator in Hz*/
132 | #endif /* LSE_VALUE */
133 |
134 | #if !defined (LSE_STARTUP_TIMEOUT)
135 | #define LSE_STARTUP_TIMEOUT ((uint32_t)5000) /*!< Time out for LSE start up, in ms */
136 | #endif /* LSE_STARTUP_TIMEOUT */
137 |
138 | /* Tip: To avoid modifying this file each time you need to use different HSE,
139 | === you can define the HSE value in your toolchain compiler preprocessor. */
140 |
141 | /* ########################### System Configuration ######################### */
142 | /**
143 | * @brief This is the HAL system configuration section
144 | */
145 | #define VDD_VALUE ((uint32_t)3300) /*!< Value of VDD in mv */
146 | #define TICK_INT_PRIORITY ((uint32_t)0) /*!< tick interrupt priority (lowest by default) */
147 | #define USE_RTOS 0
148 | #define PREFETCH_ENABLE 1
149 |
150 | /* ########################## Assert Selection ############################## */
151 | /**
152 | * @brief Uncomment the line below to expanse the "assert_param" macro in the
153 | * HAL drivers code
154 | */
155 | /* #define USE_FULL_ASSERT 1U */
156 |
157 | /* ################## Ethernet peripheral configuration ##################### */
158 |
159 | /* Section 1 : Ethernet peripheral configuration */
160 |
161 | /* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
162 | #define MAC_ADDR0 2
163 | #define MAC_ADDR1 0
164 | #define MAC_ADDR2 0
165 | #define MAC_ADDR3 0
166 | #define MAC_ADDR4 0
167 | #define MAC_ADDR5 0
168 |
169 | /* Definition of the Ethernet driver buffers size and count */
170 | #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
171 | #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
172 | #define ETH_RXBUFNB ((uint32_t)8) /* 4 Rx buffers of size ETH_RX_BUF_SIZE */
173 | #define ETH_TXBUFNB ((uint32_t)4) /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
174 |
175 | /* Section 2: PHY configuration section */
176 |
177 | /* DP83848_PHY_ADDRESS Address*/
178 | #define DP83848_PHY_ADDRESS 0x01U
179 | /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
180 | #define PHY_RESET_DELAY ((uint32_t)0x000000FF)
181 | /* PHY Configuration delay */
182 | #define PHY_CONFIG_DELAY ((uint32_t)0x00000FFF)
183 |
184 | #define PHY_READ_TO ((uint32_t)0x0000FFFF)
185 | #define PHY_WRITE_TO ((uint32_t)0x0000FFFF)
186 |
187 | /* Section 3: Common PHY Registers */
188 |
189 | #define PHY_BCR ((uint16_t)0x00) /*!< Transceiver Basic Control Register */
190 | #define PHY_BSR ((uint16_t)0x01) /*!< Transceiver Basic Status Register */
191 |
192 | #define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
193 | #define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
194 | #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
195 | #define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
196 | #define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
197 | #define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
198 | #define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
199 | #define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
200 | #define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
201 | #define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
202 |
203 | #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
204 | #define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
205 | #define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
206 |
207 | /* Section 4: Extended PHY Registers */
208 | #define PHY_SR ((uint16_t)0x10U) /*!< PHY status register Offset */
209 |
210 | #define PHY_SPEED_STATUS ((uint16_t)0x0002U) /*!< PHY Speed mask */
211 | #define PHY_DUPLEX_STATUS ((uint16_t)0x0004U) /*!< PHY Duplex mask */
212 |
213 | /* Includes ------------------------------------------------------------------*/
214 | /**
215 | * @brief Include module's header file
216 | */
217 |
218 | #ifdef HAL_RCC_MODULE_ENABLED
219 | #include "stm32f1xx_hal_rcc.h"
220 | #endif /* HAL_RCC_MODULE_ENABLED */
221 |
222 | #ifdef HAL_EXTI_MODULE_ENABLED
223 | #include "stm32f1xx_hal_exti.h"
224 | #endif /* HAL_EXTI_MODULE_ENABLED */
225 |
226 | #ifdef HAL_GPIO_MODULE_ENABLED
227 | #include "stm32f1xx_hal_gpio.h"
228 | #endif /* HAL_GPIO_MODULE_ENABLED */
229 |
230 | #ifdef HAL_DMA_MODULE_ENABLED
231 | #include "stm32f1xx_hal_dma.h"
232 | #endif /* HAL_DMA_MODULE_ENABLED */
233 |
234 | #ifdef HAL_ETH_MODULE_ENABLED
235 | #include "stm32f1xx_hal_eth.h"
236 | #endif /* HAL_ETH_MODULE_ENABLED */
237 |
238 | #ifdef HAL_CAN_MODULE_ENABLED
239 | #include "stm32f1xx_hal_can.h"
240 | #endif /* HAL_CAN_MODULE_ENABLED */
241 |
242 | #ifdef HAL_CEC_MODULE_ENABLED
243 | #include "stm32f1xx_hal_cec.h"
244 | #endif /* HAL_CEC_MODULE_ENABLED */
245 |
246 | #ifdef HAL_CORTEX_MODULE_ENABLED
247 | #include "stm32f1xx_hal_cortex.h"
248 | #endif /* HAL_CORTEX_MODULE_ENABLED */
249 |
250 | #ifdef HAL_ADC_MODULE_ENABLED
251 | #include "stm32f1xx_hal_adc.h"
252 | #endif /* HAL_ADC_MODULE_ENABLED */
253 |
254 | #ifdef HAL_CRC_MODULE_ENABLED
255 | #include "stm32f1xx_hal_crc.h"
256 | #endif /* HAL_CRC_MODULE_ENABLED */
257 |
258 | #ifdef HAL_DAC_MODULE_ENABLED
259 | #include "stm32f1xx_hal_dac.h"
260 | #endif /* HAL_DAC_MODULE_ENABLED */
261 |
262 | #ifdef HAL_FLASH_MODULE_ENABLED
263 | #include "stm32f1xx_hal_flash.h"
264 | #endif /* HAL_FLASH_MODULE_ENABLED */
265 |
266 | #ifdef HAL_SRAM_MODULE_ENABLED
267 | #include "stm32f1xx_hal_sram.h"
268 | #endif /* HAL_SRAM_MODULE_ENABLED */
269 |
270 | #ifdef HAL_NOR_MODULE_ENABLED
271 | #include "stm32f1xx_hal_nor.h"
272 | #endif /* HAL_NOR_MODULE_ENABLED */
273 |
274 | #ifdef HAL_I2C_MODULE_ENABLED
275 | #include "stm32f1xx_hal_i2c.h"
276 | #endif /* HAL_I2C_MODULE_ENABLED */
277 |
278 | #ifdef HAL_I2S_MODULE_ENABLED
279 | #include "stm32f1xx_hal_i2s.h"
280 | #endif /* HAL_I2S_MODULE_ENABLED */
281 |
282 | #ifdef HAL_IWDG_MODULE_ENABLED
283 | #include "stm32f1xx_hal_iwdg.h"
284 | #endif /* HAL_IWDG_MODULE_ENABLED */
285 |
286 | #ifdef HAL_PWR_MODULE_ENABLED
287 | #include "stm32f1xx_hal_pwr.h"
288 | #endif /* HAL_PWR_MODULE_ENABLED */
289 |
290 | #ifdef HAL_RTC_MODULE_ENABLED
291 | #include "stm32f1xx_hal_rtc.h"
292 | #endif /* HAL_RTC_MODULE_ENABLED */
293 |
294 | #ifdef HAL_PCCARD_MODULE_ENABLED
295 | #include "stm32f1xx_hal_pccard.h"
296 | #endif /* HAL_PCCARD_MODULE_ENABLED */
297 |
298 | #ifdef HAL_SD_MODULE_ENABLED
299 | #include "stm32f1xx_hal_sd.h"
300 | #endif /* HAL_SD_MODULE_ENABLED */
301 |
302 | #ifdef HAL_MMC_MODULE_ENABLED
303 | #include "stm32f1xx_hal_mmc.h"
304 | #endif /* HAL_MMC_MODULE_ENABLED */
305 |
306 | #ifdef HAL_NAND_MODULE_ENABLED
307 | #include "stm32f1xx_hal_nand.h"
308 | #endif /* HAL_NAND_MODULE_ENABLED */
309 |
310 | #ifdef HAL_SPI_MODULE_ENABLED
311 | #include "stm32f1xx_hal_spi.h"
312 | #endif /* HAL_SPI_MODULE_ENABLED */
313 |
314 | #ifdef HAL_TIM_MODULE_ENABLED
315 | #include "stm32f1xx_hal_tim.h"
316 | #endif /* HAL_TIM_MODULE_ENABLED */
317 |
318 | #ifdef HAL_UART_MODULE_ENABLED
319 | #include "stm32f1xx_hal_uart.h"
320 | #endif /* HAL_UART_MODULE_ENABLED */
321 |
322 | #ifdef HAL_USART_MODULE_ENABLED
323 | #include "stm32f1xx_hal_usart.h"
324 | #endif /* HAL_USART_MODULE_ENABLED */
325 |
326 | #ifdef HAL_IRDA_MODULE_ENABLED
327 | #include "stm32f1xx_hal_irda.h"
328 | #endif /* HAL_IRDA_MODULE_ENABLED */
329 |
330 | #ifdef HAL_SMARTCARD_MODULE_ENABLED
331 | #include "stm32f1xx_hal_smartcard.h"
332 | #endif /* HAL_SMARTCARD_MODULE_ENABLED */
333 |
334 | #ifdef HAL_WWDG_MODULE_ENABLED
335 | #include "stm32f1xx_hal_wwdg.h"
336 | #endif /* HAL_WWDG_MODULE_ENABLED */
337 |
338 | #ifdef HAL_PCD_MODULE_ENABLED
339 | #include "stm32f1xx_hal_pcd.h"
340 | #endif /* HAL_PCD_MODULE_ENABLED */
341 |
342 | #ifdef HAL_HCD_MODULE_ENABLED
343 | #include "stm32f1xx_hal_hcd.h"
344 | #endif /* HAL_HCD_MODULE_ENABLED */
345 |
346 |
347 | /* Exported macro ------------------------------------------------------------*/
348 | #ifdef USE_FULL_ASSERT
349 | /**
350 | * @brief The assert_param macro is used for function's parameters check.
351 | * @param expr: If expr is false, it calls assert_failed function
352 | * which reports the name of the source file and the source
353 | * line number of the call that failed.
354 | * If expr is true, it returns no value.
355 | * @retval None
356 | */
357 | #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
358 | /* Exported functions ------------------------------------------------------- */
359 | void assert_failed(uint8_t* file, uint32_t line);
360 | #else
361 | #define assert_param(expr) ((void)0U)
362 | #endif /* USE_FULL_ASSERT */
363 |
364 | #ifdef __cplusplus
365 | }
366 | #endif
367 |
368 | #endif /* __STM32F1xx_HAL_CONF_H */
369 |
370 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
371 |
--------------------------------------------------------------------------------
/Inc/eeprom.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file EEPROM_Emulation/inc/eeprom.h
4 | * @author MCD Application Team
5 | * @version V1.4.0
6 | * @date 29-April-2016
7 | * @brief This file contains all the functions prototypes for the EEPROM
8 | * emulation firmware library.
9 | ******************************************************************************
10 | * @attention
11 | *
12 | * © COPYRIGHT(c) 2016 STMicroelectronics
13 | *
14 | * Redistribution and use in source and binary forms, with or without modification,
15 | * are permitted provided that the following conditions are met:
16 | * 1. Redistributions of source code must retain the above copyright notice,
17 | * this list of conditions and the following disclaimer.
18 | * 2. Redistributions in binary form must reproduce the above copyright notice,
19 | * this list of conditions and the following disclaimer in the documentation
20 | * and/or other materials provided with the distribution.
21 | * 3. Neither the name of STMicroelectronics nor the names of its contributors
22 | * may be used to endorse or promote products derived from this software
23 | * without specific prior written permission.
24 | *
25 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 | *
36 | ******************************************************************************
37 | */
38 |
39 | /* Define to prevent recursive inclusion -------------------------------------*/
40 | #ifndef __EEPROM_H
41 | #define __EEPROM_H
42 |
43 | /* Includes ------------------------------------------------------------------*/
44 | #include "stm32f1xx_hal.h"
45 |
46 | /* Exported constants --------------------------------------------------------*/
47 | /* Base address of the Flash sectors */
48 | #define ADDR_FLASH_PAGE_0 ((uint32_t)0x08000000) /* Base @ of Page 0, 1 Kbytes */
49 | #define ADDR_FLASH_PAGE_1 ((uint32_t)0x08000400) /* Base @ of Page 1, 1 Kbytes */
50 | #define ADDR_FLASH_PAGE_2 ((uint32_t)0x08000800) /* Base @ of Page 2, 1 Kbytes */
51 | #define ADDR_FLASH_PAGE_3 ((uint32_t)0x08000C00) /* Base @ of Page 3, 1 Kbytes */
52 | #define ADDR_FLASH_PAGE_4 ((uint32_t)0x08001000) /* Base @ of Page 4, 1 Kbytes */
53 | #define ADDR_FLASH_PAGE_5 ((uint32_t)0x08001400) /* Base @ of Page 5, 1 Kbytes */
54 | #define ADDR_FLASH_PAGE_6 ((uint32_t)0x08001800) /* Base @ of Page 6, 1 Kbytes */
55 | #define ADDR_FLASH_PAGE_7 ((uint32_t)0x08001C00) /* Base @ of Page 7, 1 Kbytes */
56 | #define ADDR_FLASH_PAGE_8 ((uint32_t)0x08002000) /* Base @ of Page 8, 1 Kbytes */
57 | #define ADDR_FLASH_PAGE_9 ((uint32_t)0x08002400) /* Base @ of Page 9, 1 Kbytes */
58 | #define ADDR_FLASH_PAGE_10 ((uint32_t)0x08002800) /* Base @ of Page 10, 1 Kbytes */
59 | #define ADDR_FLASH_PAGE_11 ((uint32_t)0x08002C00) /* Base @ of Page 11, 1 Kbytes */
60 | #define ADDR_FLASH_PAGE_12 ((uint32_t)0x08003000) /* Base @ of Page 12, 1 Kbytes */
61 | #define ADDR_FLASH_PAGE_13 ((uint32_t)0x08003400) /* Base @ of Page 13, 1 Kbytes */
62 | #define ADDR_FLASH_PAGE_14 ((uint32_t)0x08003800) /* Base @ of Page 14, 1 Kbytes */
63 | #define ADDR_FLASH_PAGE_15 ((uint32_t)0x08003C00) /* Base @ of Page 15, 1 Kbytes */
64 | #define ADDR_FLASH_PAGE_16 ((uint32_t)0x08004000) /* Base @ of Page 16, 1 Kbytes */
65 | #define ADDR_FLASH_PAGE_17 ((uint32_t)0x08004400) /* Base @ of Page 17, 1 Kbytes */
66 | #define ADDR_FLASH_PAGE_18 ((uint32_t)0x08004800) /* Base @ of Page 18, 1 Kbytes */
67 | #define ADDR_FLASH_PAGE_19 ((uint32_t)0x08004C00) /* Base @ of Page 19, 1 Kbytes */
68 | #define ADDR_FLASH_PAGE_20 ((uint32_t)0x08005000) /* Base @ of Page 20, 1 Kbytes */
69 | #define ADDR_FLASH_PAGE_21 ((uint32_t)0x08005400) /* Base @ of Page 21, 1 Kbytes */
70 | #define ADDR_FLASH_PAGE_22 ((uint32_t)0x08005800) /* Base @ of Page 22, 1 Kbytes */
71 | #define ADDR_FLASH_PAGE_23 ((uint32_t)0x08005C00) /* Base @ of Page 23, 1 Kbytes */
72 | #define ADDR_FLASH_PAGE_24 ((uint32_t)0x08006000) /* Base @ of Page 24, 1 Kbytes */
73 | #define ADDR_FLASH_PAGE_25 ((uint32_t)0x08006400) /* Base @ of Page 25, 1 Kbytes */
74 | #define ADDR_FLASH_PAGE_26 ((uint32_t)0x08006800) /* Base @ of Page 26, 1 Kbytes */
75 | #define ADDR_FLASH_PAGE_27 ((uint32_t)0x08006C00) /* Base @ of Page 27, 1 Kbytes */
76 | #define ADDR_FLASH_PAGE_28 ((uint32_t)0x08007000) /* Base @ of Page 28, 1 Kbytes */
77 | #define ADDR_FLASH_PAGE_29 ((uint32_t)0x08007400) /* Base @ of Page 29, 1 Kbytes */
78 | #define ADDR_FLASH_PAGE_30 ((uint32_t)0x08007800) /* Base @ of Page 30, 1 Kbytes */
79 | #define ADDR_FLASH_PAGE_31 ((uint32_t)0x08007C00) /* Base @ of Page 31, 1 Kbytes */
80 | #define ADDR_FLASH_PAGE_32 ((uint32_t)0x08008000) /* Base @ of Page 32, 1 Kbytes */
81 | #define ADDR_FLASH_PAGE_33 ((uint32_t)0x08008400) /* Base @ of Page 33, 1 Kbytes */
82 | #define ADDR_FLASH_PAGE_34 ((uint32_t)0x08008800) /* Base @ of Page 34, 1 Kbytes */
83 | #define ADDR_FLASH_PAGE_35 ((uint32_t)0x08008C00) /* Base @ of Page 35, 1 Kbytes */
84 | #define ADDR_FLASH_PAGE_36 ((uint32_t)0x08009000) /* Base @ of Page 36, 1 Kbytes */
85 | #define ADDR_FLASH_PAGE_37 ((uint32_t)0x08009400) /* Base @ of Page 37, 1 Kbytes */
86 | #define ADDR_FLASH_PAGE_38 ((uint32_t)0x08009800) /* Base @ of Page 38, 1 Kbytes */
87 | #define ADDR_FLASH_PAGE_39 ((uint32_t)0x08009C00) /* Base @ of Page 39, 1 Kbytes */
88 | #define ADDR_FLASH_PAGE_40 ((uint32_t)0x0800A000) /* Base @ of Page 40, 1 Kbytes */
89 | #define ADDR_FLASH_PAGE_41 ((uint32_t)0x0800A400) /* Base @ of Page 41, 1 Kbytes */
90 | #define ADDR_FLASH_PAGE_42 ((uint32_t)0x0800A800) /* Base @ of Page 42, 1 Kbytes */
91 | #define ADDR_FLASH_PAGE_43 ((uint32_t)0x0800AC00) /* Base @ of Page 43, 1 Kbytes */
92 | #define ADDR_FLASH_PAGE_44 ((uint32_t)0x0800B000) /* Base @ of Page 44, 1 Kbytes */
93 | #define ADDR_FLASH_PAGE_45 ((uint32_t)0x0800B400) /* Base @ of Page 45, 1 Kbytes */
94 | #define ADDR_FLASH_PAGE_46 ((uint32_t)0x0800B800) /* Base @ of Page 46, 1 Kbytes */
95 | #define ADDR_FLASH_PAGE_47 ((uint32_t)0x0800BC00) /* Base @ of Page 47, 1 Kbytes */
96 | #define ADDR_FLASH_PAGE_48 ((uint32_t)0x0800C000) /* Base @ of Page 48, 1 Kbytes */
97 | #define ADDR_FLASH_PAGE_49 ((uint32_t)0x0800C400) /* Base @ of Page 49, 1 Kbytes */
98 | #define ADDR_FLASH_PAGE_50 ((uint32_t)0x0800C800) /* Base @ of Page 50, 1 Kbytes */
99 | #define ADDR_FLASH_PAGE_51 ((uint32_t)0x0800CC00) /* Base @ of Page 51, 1 Kbytes */
100 | #define ADDR_FLASH_PAGE_52 ((uint32_t)0x0800D000) /* Base @ of Page 52, 1 Kbytes */
101 | #define ADDR_FLASH_PAGE_53 ((uint32_t)0x0800D400) /* Base @ of Page 53, 1 Kbytes */
102 | #define ADDR_FLASH_PAGE_54 ((uint32_t)0x0800D800) /* Base @ of Page 54, 1 Kbytes */
103 | #define ADDR_FLASH_PAGE_55 ((uint32_t)0x0800DC00) /* Base @ of Page 55, 1 Kbytes */
104 | #define ADDR_FLASH_PAGE_56 ((uint32_t)0x0800E000) /* Base @ of Page 56, 1 Kbytes */
105 | #define ADDR_FLASH_PAGE_57 ((uint32_t)0x0800E400) /* Base @ of Page 57, 1 Kbytes */
106 | #define ADDR_FLASH_PAGE_58 ((uint32_t)0x0800E800) /* Base @ of Page 58, 1 Kbytes */
107 | #define ADDR_FLASH_PAGE_59 ((uint32_t)0x0800EC00) /* Base @ of Page 59, 1 Kbytes */
108 | #define ADDR_FLASH_PAGE_60 ((uint32_t)0x0800F000) /* Base @ of Page 60, 1 Kbytes */
109 | #define ADDR_FLASH_PAGE_61 ((uint32_t)0x0800F400) /* Base @ of Page 61, 1 Kbytes */
110 | #define ADDR_FLASH_PAGE_62 ((uint32_t)0x0800F800) /* Base @ of Page 62, 1 Kbytes */
111 | #define ADDR_FLASH_PAGE_63 ((uint32_t)0x0800FC00) /* Base @ of Page 63, 1 Kbytes */
112 | #define ADDR_FLASH_PAGE_64 ((uint32_t)0x08010000) /* Base @ of Page 64, 1 Kbytes */
113 | #define ADDR_FLASH_PAGE_65 ((uint32_t)0x08010400) /* Base @ of Page 65, 1 Kbytes */
114 | #define ADDR_FLASH_PAGE_66 ((uint32_t)0x08010800) /* Base @ of Page 66, 1 Kbytes */
115 | #define ADDR_FLASH_PAGE_67 ((uint32_t)0x08010C00) /* Base @ of Page 67, 1 Kbytes */
116 | #define ADDR_FLASH_PAGE_68 ((uint32_t)0x08011000) /* Base @ of Page 68, 1 Kbytes */
117 | #define ADDR_FLASH_PAGE_69 ((uint32_t)0x08011400) /* Base @ of Page 69, 1 Kbytes */
118 | #define ADDR_FLASH_PAGE_70 ((uint32_t)0x08011800) /* Base @ of Page 70, 1 Kbytes */
119 | #define ADDR_FLASH_PAGE_71 ((uint32_t)0x08011C00) /* Base @ of Page 71, 1 Kbytes */
120 | #define ADDR_FLASH_PAGE_72 ((uint32_t)0x08012000) /* Base @ of Page 72, 1 Kbytes */
121 | #define ADDR_FLASH_PAGE_73 ((uint32_t)0x08012400) /* Base @ of Page 73, 1 Kbytes */
122 | #define ADDR_FLASH_PAGE_74 ((uint32_t)0x08012800) /* Base @ of Page 74, 1 Kbytes */
123 | #define ADDR_FLASH_PAGE_75 ((uint32_t)0x08012C00) /* Base @ of Page 75, 1 Kbytes */
124 | #define ADDR_FLASH_PAGE_76 ((uint32_t)0x08013000) /* Base @ of Page 76, 1 Kbytes */
125 | #define ADDR_FLASH_PAGE_77 ((uint32_t)0x08013400) /* Base @ of Page 77, 1 Kbytes */
126 | #define ADDR_FLASH_PAGE_78 ((uint32_t)0x08013800) /* Base @ of Page 78, 1 Kbytes */
127 | #define ADDR_FLASH_PAGE_79 ((uint32_t)0x08013C00) /* Base @ of Page 79, 1 Kbytes */
128 | #define ADDR_FLASH_PAGE_80 ((uint32_t)0x08014000) /* Base @ of Page 80, 1 Kbytes */
129 | #define ADDR_FLASH_PAGE_81 ((uint32_t)0x08014400) /* Base @ of Page 81, 1 Kbytes */
130 | #define ADDR_FLASH_PAGE_82 ((uint32_t)0x08014800) /* Base @ of Page 82, 1 Kbytes */
131 | #define ADDR_FLASH_PAGE_83 ((uint32_t)0x08014C00) /* Base @ of Page 83, 1 Kbytes */
132 | #define ADDR_FLASH_PAGE_84 ((uint32_t)0x08015000) /* Base @ of Page 84, 1 Kbytes */
133 | #define ADDR_FLASH_PAGE_85 ((uint32_t)0x08015400) /* Base @ of Page 85, 1 Kbytes */
134 | #define ADDR_FLASH_PAGE_86 ((uint32_t)0x08015800) /* Base @ of Page 86, 1 Kbytes */
135 | #define ADDR_FLASH_PAGE_87 ((uint32_t)0x08015C00) /* Base @ of Page 87, 1 Kbytes */
136 | #define ADDR_FLASH_PAGE_88 ((uint32_t)0x08016000) /* Base @ of Page 88, 1 Kbytes */
137 | #define ADDR_FLASH_PAGE_89 ((uint32_t)0x08016400) /* Base @ of Page 89, 1 Kbytes */
138 | #define ADDR_FLASH_PAGE_90 ((uint32_t)0x08016800) /* Base @ of Page 90, 1 Kbytes */
139 | #define ADDR_FLASH_PAGE_91 ((uint32_t)0x08016C00) /* Base @ of Page 91, 1 Kbytes */
140 | #define ADDR_FLASH_PAGE_92 ((uint32_t)0x08017000) /* Base @ of Page 92, 1 Kbytes */
141 | #define ADDR_FLASH_PAGE_93 ((uint32_t)0x08017400) /* Base @ of Page 93, 1 Kbytes */
142 | #define ADDR_FLASH_PAGE_94 ((uint32_t)0x08017800) /* Base @ of Page 94, 1 Kbytes */
143 | #define ADDR_FLASH_PAGE_95 ((uint32_t)0x08017C00) /* Base @ of Page 95, 1 Kbytes */
144 | #define ADDR_FLASH_PAGE_96 ((uint32_t)0x08018000) /* Base @ of Page 96, 1 Kbytes */
145 | #define ADDR_FLASH_PAGE_97 ((uint32_t)0x08018400) /* Base @ of Page 97, 1 Kbytes */
146 | #define ADDR_FLASH_PAGE_98 ((uint32_t)0x08018800) /* Base @ of Page 98, 1 Kbytes */
147 | #define ADDR_FLASH_PAGE_99 ((uint32_t)0x08018C00) /* Base @ of Page 99, 1 Kbytes */
148 | #define ADDR_FLASH_PAGE_100 ((uint32_t)0x08019000) /* Base @ of Page 100, 1 Kbytes */
149 | #define ADDR_FLASH_PAGE_101 ((uint32_t)0x08019400) /* Base @ of Page 101, 1 Kbytes */
150 | #define ADDR_FLASH_PAGE_102 ((uint32_t)0x08019800) /* Base @ of Page 102, 1 Kbytes */
151 | #define ADDR_FLASH_PAGE_103 ((uint32_t)0x08019C00) /* Base @ of Page 103, 1 Kbytes */
152 | #define ADDR_FLASH_PAGE_104 ((uint32_t)0x0801A000) /* Base @ of Page 104, 1 Kbytes */
153 | #define ADDR_FLASH_PAGE_105 ((uint32_t)0x0801A400) /* Base @ of Page 105, 1 Kbytes */
154 | #define ADDR_FLASH_PAGE_106 ((uint32_t)0x0801A800) /* Base @ of Page 106, 1 Kbytes */
155 | #define ADDR_FLASH_PAGE_107 ((uint32_t)0x0801AC00) /* Base @ of Page 107, 1 Kbytes */
156 | #define ADDR_FLASH_PAGE_108 ((uint32_t)0x0801B000) /* Base @ of Page 108, 1 Kbytes */
157 | #define ADDR_FLASH_PAGE_109 ((uint32_t)0x0801B400) /* Base @ of Page 109, 1 Kbytes */
158 | #define ADDR_FLASH_PAGE_110 ((uint32_t)0x0801B800) /* Base @ of Page 110, 1 Kbytes */
159 | #define ADDR_FLASH_PAGE_111 ((uint32_t)0x0801BC00) /* Base @ of Page 111, 1 Kbytes */
160 | #define ADDR_FLASH_PAGE_112 ((uint32_t)0x0801C000) /* Base @ of Page 112, 1 Kbytes */
161 | #define ADDR_FLASH_PAGE_113 ((uint32_t)0x0801C400) /* Base @ of Page 113, 1 Kbytes */
162 | #define ADDR_FLASH_PAGE_114 ((uint32_t)0x0801C800) /* Base @ of Page 114, 1 Kbytes */
163 | #define ADDR_FLASH_PAGE_115 ((uint32_t)0x0801CC00) /* Base @ of Page 115, 1 Kbytes */
164 | #define ADDR_FLASH_PAGE_116 ((uint32_t)0x0801D000) /* Base @ of Page 116, 1 Kbytes */
165 | #define ADDR_FLASH_PAGE_117 ((uint32_t)0x0801D400) /* Base @ of Page 117, 1 Kbytes */
166 | #define ADDR_FLASH_PAGE_118 ((uint32_t)0x0801D800) /* Base @ of Page 118, 1 Kbytes */
167 | #define ADDR_FLASH_PAGE_119 ((uint32_t)0x0801DC00) /* Base @ of Page 119, 1 Kbytes */
168 | #define ADDR_FLASH_PAGE_120 ((uint32_t)0x0801E000) /* Base @ of Page 120, 1 Kbytes */
169 | #define ADDR_FLASH_PAGE_121 ((uint32_t)0x0801E400) /* Base @ of Page 121, 1 Kbytes */
170 | #define ADDR_FLASH_PAGE_122 ((uint32_t)0x0801E800) /* Base @ of Page 122, 1 Kbytes */
171 | #define ADDR_FLASH_PAGE_123 ((uint32_t)0x0801EC00) /* Base @ of Page 123, 1 Kbytes */
172 | #define ADDR_FLASH_PAGE_124 ((uint32_t)0x0801F000) /* Base @ of Page 124, 1 Kbytes */
173 | #define ADDR_FLASH_PAGE_125 ((uint32_t)0x0801F400) /* Base @ of Page 125, 1 Kbytes */
174 | #define ADDR_FLASH_PAGE_126 ((uint32_t)0x0801F800) /* Base @ of Page 126, 1 Kbytes */
175 | #define ADDR_FLASH_PAGE_127 ((uint32_t)0x0801FC00) /* Base @ of Page 127, 1 Kbytes */
176 |
177 | /* Define the size of the sectors to be used */
178 | #define PAGE_SIZE (uint32_t)FLASH_PAGE_SIZE /* Page size */
179 |
180 | /* EEPROM start address in Flash */
181 | #define EEPROM_START_ADDRESS ((uint32_t)ADDR_FLASH_PAGE_32) /* EEPROM emulation start address */
182 |
183 | /* Pages 0 and 1 base and end addresses */
184 | #define PAGE0_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x0000))
185 | #define PAGE0_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + (PAGE_SIZE - 1)))
186 | #define PAGE0_ID ADDR_FLASH_PAGE_32
187 |
188 | #define PAGE1_BASE_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x10000))
189 | #define PAGE1_END_ADDRESS ((uint32_t)(EEPROM_START_ADDRESS + 0x10000 + PAGE_SIZE - 1))
190 | #define PAGE1_ID ADDR_FLASH_PAGE_96
191 |
192 | /* Used Flash pages for EEPROM emulation */
193 | #define PAGE0 ((uint16_t)0x0000)
194 | #define PAGE1 ((uint16_t)0x0040)
195 |
196 | /* No valid page define */
197 | #define NO_VALID_PAGE ((uint16_t)0x00AB)
198 |
199 | /* Page status definitions */
200 | #define ERASED ((uint16_t)0xFFFF) /* Page is empty */
201 | #define RECEIVE_DATA ((uint16_t)0xEEEE) /* Page is marked to receive data */
202 | #define VALID_PAGE ((uint16_t)0x0000) /* Page containing valid data */
203 |
204 | /* Valid pages in read and write defines */
205 | #define READ_FROM_VALID_PAGE ((uint8_t)0x00)
206 | #define WRITE_IN_VALID_PAGE ((uint8_t)0x01)
207 |
208 | /* Page full define */
209 | #define PAGE_FULL ((uint8_t)0x80)
210 |
211 | /* Variables' number */
212 | #define NB_OF_VAR ((uint8_t)0x12)
213 |
214 | /* Exported types ------------------------------------------------------------*/
215 | /* Exported macro ------------------------------------------------------------*/
216 | /* Exported functions ------------------------------------------------------- */
217 | uint16_t EE_Init(void);
218 | uint16_t EE_ReadVariable(uint16_t VirtAddress, uint16_t* Data);
219 | uint16_t EE_WriteVariable(uint16_t VirtAddress, uint16_t Data);
220 |
221 | #endif /* __EEPROM_H */
222 |
223 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
224 |
--------------------------------------------------------------------------------
/tests/D6_blinkTest/stm32f1xx_hal_conf.h:
--------------------------------------------------------------------------------
1 | /**
2 | ******************************************************************************
3 | * @file stm32f1xx_hal_conf.h
4 | * @author MCD Application Team
5 | * @brief HAL configuration template file.
6 | * This file should be copied to the application folder and renamed
7 | * to stm32f1xx_hal_conf.h.
8 | ******************************************************************************
9 | * @attention
10 | *
11 | * © COPYRIGHT(c) 2017 STMicroelectronics
12 | *
13 | * Redistribution and use in source and binary forms, with or without modification,
14 | * are permitted provided that the following conditions are met:
15 | * 1. Redistributions of source code must retain the above copyright notice,
16 | * this list of conditions and the following disclaimer.
17 | * 2. Redistributions in binary form must reproduce the above copyright notice,
18 | * this list of conditions and the following disclaimer in the documentation
19 | * and/or other materials provided with the distribution.
20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 | * may be used to endorse or promote products derived from this software
22 | * without specific prior written permission.
23 | *
24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 | *
35 | ******************************************************************************
36 | */
37 |
38 | /* Define to prevent recursive inclusion -------------------------------------*/
39 | #ifndef __STM32F1xx_HAL_CONF_H
40 | #define __STM32F1xx_HAL_CONF_H
41 |
42 | #ifdef __cplusplus
43 | extern "C" {
44 | #endif
45 |
46 | /* Exported types ------------------------------------------------------------*/
47 | /* Exported constants --------------------------------------------------------*/
48 |
49 | /* ########################## Module Selection ############################## */
50 | /**
51 | * @brief This is the list of modules to be used in the HAL driver
52 | */
53 | #define HAL_MODULE_ENABLED
54 | #define HAL_ADC_MODULE_ENABLED
55 | #define HAL_CAN_MODULE_ENABLED
56 | /* #define HAL_CAN_LEGACY_MODULE_ENABLED */
57 | #define HAL_CEC_MODULE_ENABLED
58 | #define HAL_CORTEX_MODULE_ENABLED
59 | #define HAL_CRC_MODULE_ENABLED
60 | #define HAL_DAC_MODULE_ENABLED
61 | #define HAL_DMA_MODULE_ENABLED
62 | #define HAL_ETH_MODULE_ENABLED
63 | #define HAL_FLASH_MODULE_ENABLED
64 | #define HAL_GPIO_MODULE_ENABLED
65 | #define HAL_HCD_MODULE_ENABLED
66 | #define HAL_I2C_MODULE_ENABLED
67 | #define HAL_I2S_MODULE_ENABLED
68 | #define HAL_IRDA_MODULE_ENABLED
69 | #define HAL_IWDG_MODULE_ENABLED
70 | #define HAL_NAND_MODULE_ENABLED
71 | #define HAL_NOR_MODULE_ENABLED
72 | #define HAL_PCCARD_MODULE_ENABLED
73 | #define HAL_PCD_MODULE_ENABLED
74 | #define HAL_PWR_MODULE_ENABLED
75 | #define HAL_RCC_MODULE_ENABLED
76 | #define HAL_RTC_MODULE_ENABLED
77 | #define HAL_SD_MODULE_ENABLED
78 | #define HAL_SMARTCARD_MODULE_ENABLED
79 | #define HAL_SPI_MODULE_ENABLED
80 | #define HAL_SRAM_MODULE_ENABLED
81 | #define HAL_TIM_MODULE_ENABLED
82 | #define HAL_UART_MODULE_ENABLED
83 | #define HAL_USART_MODULE_ENABLED
84 | #define HAL_WWDG_MODULE_ENABLED
85 | #define HAL_MMC_MODULE_ENABLED
86 |
87 | /* ########################## Oscillator Values adaptation ####################*/
88 | /**
89 | * @brief Adjust the value of External High Speed oscillator (HSE) used in your application.
90 | * This value is used by the RCC HAL module to compute the system frequency
91 | * (when HSE is used as system clock source, directly or through the PLL).
92 | */
93 | #if !defined (HSE_VALUE)
94 | #if defined(USE_STM3210C_EVAL)
95 | #define HSE_VALUE 25000000U /*!< Value of the External oscillator in Hz */
96 | #else
97 | #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */
98 | #endif
99 | #endif /* HSE_VALUE */
100 |
101 | #if !defined (HSE_STARTUP_TIMEOUT)
102 | #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */
103 | #endif /* HSE_STARTUP_TIMEOUT */
104 |
105 | /**
106 | * @brief Internal High Speed oscillator (HSI) value.
107 | * This value is used by the RCC HAL module to compute the system frequency
108 | * (when HSI is used as system clock source, directly or through the PLL).
109 | */
110 | #if !defined (HSI_VALUE)
111 | #define HSI_VALUE 8000000U /*!< Value of the Internal oscillator in Hz */
112 | #endif /* HSI_VALUE */
113 |
114 | /**
115 | * @brief Internal Low Speed oscillator (LSI) value.
116 | */
117 | #if !defined (LSI_VALUE)
118 | #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz */
119 | #endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz
120 | The real value may vary depending on the variations
121 | in voltage and temperature. */
122 | /**
123 | * @brief External Low Speed oscillator (LSE) value.
124 | * This value is used by the UART, RTC HAL module to compute the system frequency
125 | */
126 | #if !defined (LSE_VALUE)
127 | #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */
128 | #endif /* LSE_VALUE */
129 |
130 | #if !defined (LSE_STARTUP_TIMEOUT)
131 | #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */
132 | #endif /* LSE_STARTUP_TIMEOUT */
133 |
134 | /* Tip: To avoid modifying this file each time you need to use different HSE,
135 | === you can define the HSE value in your toolchain compiler preprocessor. */
136 |
137 | /* ########################### System Configuration ######################### */
138 | /**
139 | * @brief This is the HAL system configuration section
140 | */
141 | #define VDD_VALUE 3300U /*!< Value of VDD in mv */
142 | #define TICK_INT_PRIORITY 0x0FU /*!< tick interrupt priority */
143 | #define USE_RTOS 0U
144 | #define PREFETCH_ENABLE 1U
145 |
146 | /* ########################## Assert Selection ############################## */
147 | /**
148 | * @brief Uncomment the line below to expanse the "assert_param" macro in the
149 | * HAL drivers code
150 | */
151 | /* #define USE_FULL_ASSERT 1U */
152 |
153 | /* ################## Ethernet peripheral configuration ##################### */
154 |
155 | /* Section 1 : Ethernet peripheral configuration */
156 |
157 | /* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */
158 | #define MAC_ADDR0 2U
159 | #define MAC_ADDR1 0U
160 | #define MAC_ADDR2 0U
161 | #define MAC_ADDR3 0U
162 | #define MAC_ADDR4 0U
163 | #define MAC_ADDR5 0U
164 |
165 | /* Definition of the Ethernet driver buffers size and count */
166 | #define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */
167 | #define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */
168 | #define ETH_RXBUFNB 8U /* 8 Rx buffers of size ETH_RX_BUF_SIZE */
169 | #define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */
170 |
171 | /* Section 2: PHY configuration section */
172 |
173 | /* DP83848 PHY Address*/
174 | #define DP83848_PHY_ADDRESS 0x01U
175 | /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/
176 | #define PHY_RESET_DELAY 0x000000FFU
177 | /* PHY Configuration delay */
178 | #define PHY_CONFIG_DELAY 0x00000FFFU
179 |
180 | #define PHY_READ_TO 0x0000FFFFU
181 | #define PHY_WRITE_TO 0x0000FFFFU
182 |
183 | /* Section 3: Common PHY Registers */
184 |
185 | #define PHY_BCR ((uint16_t)0x0000) /*!< Transceiver Basic Control Register */
186 | #define PHY_BSR ((uint16_t)0x0001) /*!< Transceiver Basic Status Register */
187 |
188 | #define PHY_RESET ((uint16_t)0x8000) /*!< PHY Reset */
189 | #define PHY_LOOPBACK ((uint16_t)0x4000) /*!< Select loop-back mode */
190 | #define PHY_FULLDUPLEX_100M ((uint16_t)0x2100) /*!< Set the full-duplex mode at 100 Mb/s */
191 | #define PHY_HALFDUPLEX_100M ((uint16_t)0x2000) /*!< Set the half-duplex mode at 100 Mb/s */
192 | #define PHY_FULLDUPLEX_10M ((uint16_t)0x0100) /*!< Set the full-duplex mode at 10 Mb/s */
193 | #define PHY_HALFDUPLEX_10M ((uint16_t)0x0000) /*!< Set the half-duplex mode at 10 Mb/s */
194 | #define PHY_AUTONEGOTIATION ((uint16_t)0x1000) /*!< Enable auto-negotiation function */
195 | #define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200) /*!< Restart auto-negotiation function */
196 | #define PHY_POWERDOWN ((uint16_t)0x0800) /*!< Select the power down mode */
197 | #define PHY_ISOLATE ((uint16_t)0x0400) /*!< Isolate PHY from MII */
198 |
199 | #define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020) /*!< Auto-Negotiation process completed */
200 | #define PHY_LINKED_STATUS ((uint16_t)0x0004) /*!< Valid link established */
201 | #define PHY_JABBER_DETECTION ((uint16_t)0x0002) /*!< Jabber condition detected */
202 |
203 | /* Section 4: Extended PHY Registers */
204 |
205 | #define PHY_SR ((uint16_t)0x0010) /*!< PHY status register Offset */
206 | #define PHY_MICR ((uint16_t)0x0011) /*!< MII Interrupt Control Register */
207 | #define PHY_MISR ((uint16_t)0x0012) /*!< MII Interrupt Status and Misc. Control Register */
208 |
209 | #define PHY_LINK_STATUS ((uint16_t)0x0001) /*!< PHY Link mask */
210 | #define PHY_SPEED_STATUS ((uint16_t)0x0002) /*!< PHY Speed mask */
211 | #define PHY_DUPLEX_STATUS ((uint16_t)0x0004) /*!< PHY Duplex mask */
212 |
213 | #define PHY_MICR_INT_EN ((uint16_t)0x0002) /*!< PHY Enable interrupts */
214 | #define PHY_MICR_INT_OE ((uint16_t)0x0001) /*!< PHY Enable output interrupt events */
215 |
216 | #define PHY_MISR_LINK_INT_EN ((uint16_t)0x0020) /*!< Enable Interrupt on change of link status */
217 | #define PHY_LINK_INTERRUPT ((uint16_t)0x2000) /*!< PHY link status interrupt mask */
218 |
219 | /* ################## SPI peripheral configuration ########################## */
220 |
221 | /* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver
222 | * Activated: CRC code is present inside driver
223 | * Deactivated: CRC code cleaned from driver
224 | */
225 |
226 | #define USE_SPI_CRC 1U
227 |
228 | /* Includes ------------------------------------------------------------------*/
229 | /**
230 | * @brief Include module's header file
231 | */
232 |
233 | #ifdef HAL_RCC_MODULE_ENABLED
234 | #include "stm32f1xx_hal_rcc.h"
235 | #endif /* HAL_RCC_MODULE_ENABLED */
236 |
237 | #ifdef HAL_GPIO_MODULE_ENABLED
238 | #include "stm32f1xx_hal_gpio.h"
239 | #endif /* HAL_GPIO_MODULE_ENABLED */
240 |
241 | #ifdef HAL_DMA_MODULE_ENABLED
242 | #include "stm32f1xx_hal_dma.h"
243 | #endif /* HAL_DMA_MODULE_ENABLED */
244 |
245 | #ifdef HAL_ETH_MODULE_ENABLED
246 | #include "stm32f1xx_hal_eth.h"
247 | #endif /* HAL_ETH_MODULE_ENABLED */
248 |
249 | #ifdef HAL_CAN_MODULE_ENABLED
250 | #include "stm32f1xx_hal_can.h"
251 | #endif /* HAL_CAN_MODULE_ENABLED */
252 |
253 | #ifdef HAL_CAN_LEGACY_MODULE_ENABLED
254 | #include "Legacy/stm32f1xx_hal_can_legacy.h"
255 | #endif /* HAL_CAN_LEGACY_MODULE_ENABLED */
256 |
257 | #ifdef HAL_CEC_MODULE_ENABLED
258 | #include "stm32f1xx_hal_cec.h"
259 | #endif /* HAL_CEC_MODULE_ENABLED */
260 |
261 | #ifdef HAL_CORTEX_MODULE_ENABLED
262 | #include "stm32f1xx_hal_cortex.h"
263 | #endif /* HAL_CORTEX_MODULE_ENABLED */
264 |
265 | #ifdef HAL_ADC_MODULE_ENABLED
266 | #include "stm32f1xx_hal_adc.h"
267 | #endif /* HAL_ADC_MODULE_ENABLED */
268 |
269 | #ifdef HAL_CRC_MODULE_ENABLED
270 | #include "stm32f1xx_hal_crc.h"
271 | #endif /* HAL_CRC_MODULE_ENABLED */
272 |
273 | #ifdef HAL_DAC_MODULE_ENABLED
274 | #include "stm32f1xx_hal_dac.h"
275 | #endif /* HAL_DAC_MODULE_ENABLED */
276 |
277 | #ifdef HAL_FLASH_MODULE_ENABLED
278 | #include "stm32f1xx_hal_flash.h"
279 | #endif /* HAL_FLASH_MODULE_ENABLED */
280 |
281 | #ifdef HAL_SRAM_MODULE_ENABLED
282 | #include "stm32f1xx_hal_sram.h"
283 | #endif /* HAL_SRAM_MODULE_ENABLED */
284 |
285 | #ifdef HAL_NOR_MODULE_ENABLED
286 | #include "stm32f1xx_hal_nor.h"
287 | #endif /* HAL_NOR_MODULE_ENABLED */
288 |
289 | #ifdef HAL_I2C_MODULE_ENABLED
290 | #include "stm32f1xx_hal_i2c.h"
291 | #endif /* HAL_I2C_MODULE_ENABLED */
292 |
293 | #ifdef HAL_I2S_MODULE_ENABLED
294 | #include "stm32f1xx_hal_i2s.h"
295 | #endif /* HAL_I2S_MODULE_ENABLED */
296 |
297 | #ifdef HAL_IWDG_MODULE_ENABLED
298 | #include "stm32f1xx_hal_iwdg.h"
299 | #endif /* HAL_IWDG_MODULE_ENABLED */
300 |
301 | #ifdef HAL_PWR_MODULE_ENABLED
302 | #include "stm32f1xx_hal_pwr.h"
303 | #endif /* HAL_PWR_MODULE_ENABLED */
304 |
305 | #ifdef HAL_RTC_MODULE_ENABLED
306 | #include "stm32f1xx_hal_rtc.h"
307 | #endif /* HAL_RTC_MODULE_ENABLED */
308 |
309 | #ifdef HAL_PCCARD_MODULE_ENABLED
310 | #include "stm32f1xx_hal_pccard.h"
311 | #endif /* HAL_PCCARD_MODULE_ENABLED */
312 |
313 | #ifdef HAL_SD_MODULE_ENABLED
314 | #include "stm32f1xx_hal_sd.h"
315 | #endif /* HAL_SD_MODULE_ENABLED */
316 |
317 | #ifdef HAL_NAND_MODULE_ENABLED
318 | #include "stm32f1xx_hal_nand.h"
319 | #endif /* HAL_NAND_MODULE_ENABLED */
320 |
321 | #ifdef HAL_SPI_MODULE_ENABLED
322 | #include "stm32f1xx_hal_spi.h"
323 | #endif /* HAL_SPI_MODULE_ENABLED */
324 |
325 | #ifdef HAL_TIM_MODULE_ENABLED
326 | #include "stm32f1xx_hal_tim.h"
327 | #endif /* HAL_TIM_MODULE_ENABLED */
328 |
329 | #ifdef HAL_UART_MODULE_ENABLED
330 | #include "stm32f1xx_hal_uart.h"
331 | #endif /* HAL_UART_MODULE_ENABLED */
332 |
333 | #ifdef HAL_USART_MODULE_ENABLED
334 | #include "stm32f1xx_hal_usart.h"
335 | #endif /* HAL_USART_MODULE_ENABLED */
336 |
337 | #ifdef HAL_IRDA_MODULE_ENABLED
338 | #include "stm32f1xx_hal_irda.h"
339 | #endif /* HAL_IRDA_MODULE_ENABLED */
340 |
341 | #ifdef HAL_SMARTCARD_MODULE_ENABLED
342 | #include "stm32f1xx_hal_smartcard.h"
343 | #endif /* HAL_SMARTCARD_MODULE_ENABLED */
344 |
345 | #ifdef HAL_WWDG_MODULE_ENABLED
346 | #include "stm32f1xx_hal_wwdg.h"
347 | #endif /* HAL_WWDG_MODULE_ENABLED */
348 |
349 | #ifdef HAL_PCD_MODULE_ENABLED
350 | #include "stm32f1xx_hal_pcd.h"
351 | #endif /* HAL_PCD_MODULE_ENABLED */
352 |
353 | #ifdef HAL_HCD_MODULE_ENABLED
354 | #include "stm32f1xx_hal_hcd.h"
355 | #endif /* HAL_HCD_MODULE_ENABLED */
356 |
357 | #ifdef HAL_MMC_MODULE_ENABLED
358 | #include "stm32f1xx_hal_mmc.h"
359 | #endif /* HAL_MMC_MODULE_ENABLED */
360 |
361 | /* Exported macro ------------------------------------------------------------*/
362 | #ifdef USE_FULL_ASSERT
363 | /**
364 | * @brief The assert_param macro is used for function's parameters check.
365 | * @param expr: If expr is false, it calls assert_failed function
366 | * which reports the name of the source file and the source
367 | * line number of the call that failed.
368 | * If expr is true, it returns no value.
369 | * @retval None
370 | */
371 | #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__))
372 | /* Exported functions ------------------------------------------------------- */
373 | void assert_failed(uint8_t *file, uint32_t line);
374 | #else
375 | #define assert_param(expr) ((void)0U)
376 | #endif /* USE_FULL_ASSERT */
377 |
378 |
379 | #ifdef __cplusplus
380 | }
381 | #endif
382 |
383 | #endif /* __STM32F1xx_HAL_CONF_H */
384 |
385 |
386 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
387 |
--------------------------------------------------------------------------------