Skip to content

Commit

Permalink
1. Synchronize the source code to DiSlord version 1.2.27, please refe…
Browse files Browse the repository at this point in the history
…r to DiSlord's NanoVNA-D project for software function update. ;

2. Add ST7789 support for 2.8-inch version display;
3. uploaded version 3.6.1 schematic, frequency synthesizer added support for SMC5351, using the same parameters as MS5351, but with lower power consumption and better port isolation.
  • Loading branch information
hugen79 committed Feb 20, 2024
1 parent fe09511 commit 4eb9a9e
Show file tree
Hide file tree
Showing 39 changed files with 3,123 additions and 6,222 deletions.
220 changes: 115 additions & 105 deletions .cproject

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions .gitmodules

This file was deleted.

2 changes: 2 additions & 0 deletions FatFs/ff.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include "ff.h" /* Declarations of FatFs API */
#include "diskio.h" /* Declarations of device I/O functions */

// Use size optimization
#pragma GCC optimize ("Os")

/*--------------------------------------------------------------------------
Expand Down
1,715 changes: 0 additions & 1,715 deletions Font10x14.c

This file was deleted.

16 changes: 8 additions & 8 deletions Font7x11b.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ const uint8_t x7x11b_bits[] =
0b11111110, // |******* |
0b00000000, // | |

// Char "\030" width = 5
0b00000000|CW_05, // | |
// Char "\030" width = 6
0b00000000|CW_06, // | |
0b10000000, // |* |
0b11000000, // |** |
0b11100000, // |*** |
Expand Down Expand Up @@ -406,14 +406,14 @@ const uint8_t x7x11b_bits[] =
0b00010000, // | * |
0b00000000, // | |

// Char "\033" width = 7
0b00000000|CW_07, // | |
// Char "\033" width = 8
0b00000000|CW_08, // | |
0b00000000, // | |
0b00010000, // | * |
0b00011000, // | ** |
0b00001100, // | ** |
0b01111110, // | ****** |
0b01111110, // | ****** |
0b11111110, // |******* |
0b11111110, // |******* |
0b00001100, // | ** |
0b00011000, // | ** |
0b00010000, // | * |
Expand Down Expand Up @@ -564,8 +564,8 @@ const uint8_t x7x11b_bits[] =

// Char ''' width = 5
0b00000000|CW_05, // | |
0b01110000, // | *** |
0b01110000, // | *** |
0b11100000, // |*** |
0b11100000, // |*** |
0b01100000, // | ** |
0b11000000, // |** |
0b00000000, // | |
Expand Down
17 changes: 9 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ USE_OPT = -O2 -fno-inline-small-functions -ggdb -fomit-frame-pointer -falign-fun
endif
# additional options, use math optimisations
USE_OPT+= -ffast-math -fsingle-precision-constant

USE_OPT+= -D__BAND_MODE__

#USE_OPT+= -D__MS5351__


Expand Down Expand Up @@ -101,7 +98,11 @@ endif
#

# Define project name here
PROJECT = ch
ifeq ($(TARGET),F303)
PROJECT = H4
else
PROJECT = H
endif

# Imported source files and paths
#CHIBIOS = ../ChibiOS-RT
Expand Down Expand Up @@ -154,7 +155,7 @@ CSRC = $(STARTUPSRC) \
FatFs/ff.c \
FatFs/ffunicode.c \
usbcfg.c \
main.c si5351.c tlv320aic3204.c dsp.c plot.c ui.c ili9341.c numfont20x22.c Font5x7.c Font6x10.c Font7x11b.c Font11x14.c data_storage.c hardware.c vna_math.c
main.c si5351.c tlv320aic3204.c dsp.c plot.c ui.c ili9341.c numfont16x22.c Font5x7.c Font6x10.c Font7x11b.c Font11x14.c data_storage.c hardware.c vna_math.c

# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
Expand Down Expand Up @@ -249,7 +250,7 @@ endif
UDEFS+= -DVNA_AUTO_SELECT_RTC_SOURCE
#Enable if install external 32.768kHz clock quartz on PC14 and PC15 pins on STM32 CPU and no VNA_AUTO_SELECT_RTC_SOURCE
#UDEFS+= -DVNA_USE_LSE
#UDEFS+= -D__VNA_Z_RENORMALIZATION__ -D__SD_FILE_BROWSER__ -D__VNA_FAST_LINES__
#UDEFS+= -D__VNA_Z_RENORMALIZATION__ -D__VNA_FAST_LINES__

# Define ASM defines here
UADEFS =
Expand All @@ -270,8 +271,8 @@ ULIBS = -lm
RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC
include $(RULESPATH)/rules.mk

flash: build/ch.bin
dfu-util -d 0483:df11 -a 0 -s 0x08000000:leave -D build/ch.bin
flash: build/$(PROJECT).bin
dfu-util -d 0483:df11 -a 0 -s 0x08000000:leave -D build/$(PROJECT).bin

dfu:
-@printf "reset dfu\r" >/dev/cu.usbmodem401
Expand Down
29 changes: 27 additions & 2 deletions NANOVNA_STM32_F072/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,38 @@ const PALConfig pal_default_config = {
};
#endif

static bool needDFU(void) {
// Magick data in memory before reset
if (*((unsigned long *)BOOT_FROM_SYTEM_MEMORY_MAGIC_ADDRESS) == BOOT_FROM_SYTEM_MEMORY_MAGIC)
return true;
// init PortA (leveler port) and check press
rccEnableAHB(STM32_GPIO_EN_MASK, FALSE);
GPIOA->OTYPER = VAL_GPIOA_OTYPER;
// GPIOA->OSPEEDR = VAL_GPIOA_OSPEEDR;
GPIOA->PUPDR = VAL_GPIOA_PUPDR;
GPIOA->ODR = VAL_GPIOA_ODR;
// GPIOA->AFR[0] = VAL_GPIOA_AFRL;
// GPIOA->AFR[1] = VAL_GPIOA_AFRH;
GPIOA->MODER = VAL_GPIOA_MODER;
if (GPIOA->IDR & (1<<GPIOA_PUSH)) {
while(GPIOA->IDR & (1<<GPIOA_PUSH)) {}; // Wait press
return true;
}
return false;
}

void boardDFUEnter(void) {
*((unsigned long *)BOOT_FROM_SYTEM_MEMORY_MAGIC_ADDRESS) = BOOT_FROM_SYTEM_MEMORY_MAGIC;
NVIC_SystemReset();
}

/*
* Early initialization code.
* This initialization must be performed just after stack setup and before
* any other initialization.
*/
void __early_init(void) {
if ( *((unsigned long *)BOOT_FROM_SYTEM_MEMORY_MAGIC_ADDRESS) == BOOT_FROM_SYTEM_MEMORY_MAGIC ) {
if (needDFU()) {
// require irq
__enable_irq();
// reset magic bytes
Expand All @@ -79,7 +104,7 @@ void __early_init(void) {
// set msp for system memory
__set_MSP(SYSTEM_BOOT_MSP);
// jump to system memory
( (void (*)(void)) (*((uint32_t *)(STM32F072xB_SYSTEM_MEMORY+4))) )();
((void (*)(void))(*((uint32_t *)(STM32F072xB_SYSTEM_MEMORY + 4))))();
while (1);
}

Expand Down
23 changes: 12 additions & 11 deletions NANOVNA_STM32_F072/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
*/
#define STM32F072xB

#define STM32F072xB_SYSTEM_MEMORY 0x1FFFC800
#define STM32F072xB_SYSTEM_MEMORY 0x1FFFC800
#define BOOT_FROM_SYTEM_MEMORY_MAGIC_ADDRESS 0x20003FF0
#define BOOT_FROM_SYTEM_MEMORY_MAGIC 0xDEADBEEF
#define SYSTEM_BOOT_MSP 0x20002250
#define BOOT_FROM_SYTEM_MEMORY_MAGIC 0xDEADBEEF
#define SYSTEM_BOOT_MSP 0x20002250

/*
* IO pins assignments
Expand All @@ -49,8 +49,8 @@

#define GPIOA_BUTTON 0 // (not used)
#define GPIOA_LEVER1 1
#define GPIOA_LEVER2 2
#define GPIOA_PUSH 3
#define GPIOA_PUSH 2
#define GPIOA_LEVER2 3
#define GPIOA_DAC2 5
#define GPIOA_XP 6
#define GPIOA_YP 7
Expand Down Expand Up @@ -131,8 +131,8 @@
*/
#define VAL_GPIOA_MODER (PIN_MODE_INPUT(0U) | \
PIN_MODE_INPUT(GPIOA_LEVER1) | \
PIN_MODE_INPUT(GPIOA_LEVER2) | \
PIN_MODE_INPUT(GPIOA_PUSH) | \
PIN_MODE_INPUT(GPIOA_LEVER2) | \
PIN_MODE_INPUT(4U) | \
PIN_MODE_ANALOG(GPIOA_DAC2) | \
PIN_MODE_ANALOG(GPIOA_XP) | \
Expand All @@ -147,8 +147,8 @@
PIN_MODE_OUTPUT(GPIOA_LCD_RESET))
#define VAL_GPIOA_OTYPER (PIN_OTYPE_PUSHPULL(0U) | \
PIN_OTYPE_PUSHPULL(GPIOA_LEVER1) | \
PIN_OTYPE_PUSHPULL(GPIOA_LEVER2) | \
PIN_OTYPE_PUSHPULL(GPIOA_PUSH) | \
PIN_OTYPE_PUSHPULL(GPIOA_LEVER2) | \
PIN_OTYPE_PUSHPULL(4U) | \
PIN_OTYPE_PUSHPULL(GPIOA_DAC2) | \
PIN_OTYPE_PUSHPULL(GPIOA_XP) | \
Expand All @@ -163,8 +163,8 @@
PIN_OTYPE_PUSHPULL(GPIOA_LCD_RESET))
#define VAL_GPIOA_OSPEEDR (PIN_OSPEED_2M(0) | \
PIN_OSPEED_2M(GPIOA_LEVER1) | \
PIN_OSPEED_2M(GPIOA_LEVER2) | \
PIN_OSPEED_2M(GPIOA_PUSH) | \
PIN_OSPEED_2M(GPIOA_LEVER2) | \
PIN_OSPEED_2M(4) | \
PIN_OSPEED_2M(GPIOA_DAC2) | \
PIN_OSPEED_2M(GPIOA_XP) | \
Expand All @@ -179,8 +179,8 @@
PIN_OSPEED_100M(GPIOA_LCD_RESET))
#define VAL_GPIOA_PUPDR (PIN_PUPDR_PULLDOWN(0) | \
PIN_PUPDR_PULLDOWN(GPIOA_LEVER1) | \
PIN_PUPDR_PULLDOWN(GPIOA_LEVER2) | \
PIN_PUPDR_PULLDOWN(GPIOA_PUSH) | \
PIN_PUPDR_PULLDOWN(GPIOA_LEVER2) | \
PIN_PUPDR_PULLUP(4) | \
PIN_PUPDR_FLOATING(GPIOA_DAC2) | \
PIN_PUPDR_FLOATING(GPIOA_XP) | \
Expand All @@ -195,8 +195,8 @@
PIN_PUPDR_PULLDOWN(GPIOA_LCD_RESET))
#define VAL_GPIOA_ODR (PIN_ODR_HIGH(0) | \
PIN_ODR_HIGH(GPIOA_LEVER1) | \
PIN_ODR_HIGH(GPIOA_LEVER2) | \
PIN_ODR_HIGH(GPIOA_PUSH) | \
PIN_ODR_HIGH(GPIOA_LEVER2) | \
PIN_ODR_HIGH(4) | \
PIN_ODR_LOW(GPIOA_DAC2) | \
PIN_ODR_HIGH(GPIOA_XP) | \
Expand All @@ -211,8 +211,8 @@
PIN_ODR_HIGH(GPIOA_LCD_RESET))
#define VAL_GPIOA_AFRL (PIN_AFIO_AF(0, 0) | \
PIN_AFIO_AF(GPIOA_LEVER1, 0) | \
PIN_AFIO_AF(GPIOA_LEVER2, 0) | \
PIN_AFIO_AF(GPIOA_PUSH, 0) | \
PIN_AFIO_AF(GPIOA_LEVER2, 0) | \
PIN_AFIO_AF(4, 0) | \
PIN_AFIO_AF(GPIOA_DAC2, 0) | \
PIN_AFIO_AF(GPIOA_XP, 0) | \
Expand Down Expand Up @@ -769,6 +769,7 @@
extern "C" {
#endif
void boardInit(void);
void boardDFUEnter(void);
#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion NANOVNA_STM32_F303/adc_v3.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ void adc_init(void)
//ADC3_4_COMMON->CCR = STM32_ADC_ADC34_CLOCK_MODE;
}

#define ADC_AVERAGE_N 3
#define ADC_AVERAGE_N 4
static void adcStartMeasure(ADC_TypeDef *adc, uint32_t sqr0, uint16_t *samples) {
// ADC setup
adc->ISR = adc->ISR; // reset interrupts
Expand Down
56 changes: 5 additions & 51 deletions NANOVNA_STM32_F303/board.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,63 +62,17 @@ const PALConfig pal_default_config = {
};
#endif

void boardDFUEnter(void) {
__set_MSP(*((uint32_t *)(STM32F303xC_SYSTEM_MEMORY)));
((void (*)(void))(*((uint32_t *)(STM32F303xC_SYSTEM_MEMORY + 4))))(); // jump to DFU
}

/*
* Early initialization code.
* This initialization must be performed just after stack setup and before
* any other initialization.
*/
void __early_init(void) {
// Refer to thess pages for how to start dfu from software
// https://community.st.com/s/question/0D50X00009XkeeWSAR/stm32l476rg-jump-to-bootloader-from-software
// https://stm32f4-discovery.net/2017/04/tutorial-jump-system-memory-software-stm32/
#if 0
if ( *((unsigned long *)BOOT_FROM_SYTEM_MEMORY_MAGIC_ADDRESS) == BOOT_FROM_SYTEM_MEMORY_MAGIC ) {
// require irq
// __enable_irq();
// reset magic bytes
*((unsigned long *)BOOT_FROM_SYTEM_MEMORY_MAGIC_ADDRESS) = 0;
#if 1
// https://stm32f4-discovery.net/2017/04/tutorial-jump-system-memory-software-stm32/
// Step: Disable systick timer and reset it to default values
#if 0
SysTick->CTRL = 0;
SysTick->LOAD = 0;
SysTick->VAL = 0;
#endif
// Step: Disable all interrupts
__disable_irq();
// Remap system memory to address 0x0000 0000 in address space
typedef void (*pFunction)(void);
pFunction bootloader;
uint32_t msp;
uint32_t foo = SYSCFG->CFGR1;
foo = (foo & ~SYSCFG_CFGR1_MEM_MODE) || SYSCFG_CFGR1_MEM_MODE_0;
SYSCFG->CFGR1 = foo;
//foo = SYSCFG->CFGR1;
__DSB();
__ISB();
//__DSB();
//__ISB();
#if 1
bootloader = (void (*)(void)) (*((uint32_t *)(STM32F303xC_SYSTEM_MEMORY+4)));
//msp = *(uint32_t *) STM32F303xC_SYSTEM_MEMORY;
msp = 0x20002250;
#else
bootloader = (void (*)(void)) (*((uint32_t *)(4)));
//msp = *(uint32_t *) 0;
msp = 0x20002250;
#endif
__set_MSP(msp);
bootloader();
while(1);
#else
__set_MSP(SYSTEM_BOOT_MSP);
( (void (*)(void)) (*((uint32_t *)(STM32F303xC_SYSTEM_MEMORY+4))) )();
while(1);
#endif
}
#endif

stm32_clock_init();
}

Expand Down
13 changes: 6 additions & 7 deletions NANOVNA_STM32_F303/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,9 @@
*/
#define STM32F303xC

#define STM32F303xC_SYSTEM_MEMORY 0x1FFFD800
#define BOOT_FROM_SYTEM_MEMORY_MAGIC_ADDRESS 0x20009FF0
#define BOOT_FROM_SYTEM_MEMORY_MAGIC 0xDEADBEEF
//#define SYSTEM_BOOT_MSP *(uint32_t *)0 // 0x20001258
#define SYSTEM_BOOT_MSP 0x20001258
#define STM32F303xC_SYSTEM_MEMORY 0x1FFFD800
#define BOOT_FROM_SYTEM_MEMORY_MAGIC_ADDRESS 0x20009FFC
#define BOOT_FROM_SYTEM_MEMORY_MAGIC 0xDEADBEEF

/*
* IO pins assignments
Expand All @@ -52,8 +50,8 @@

#define GPIOA_BUTTON 0
#define GPIOA_LEVER1 1
#define GPIOA_LEVER2 2
#define GPIOA_PUSH 3
#define GPIOA_PUSH 2
#define GPIOA_LEVER2 3
#define GPIOA_VBUS 4
#define GPIOA_DAC2 5
#define GPIOA_XP 6
Expand Down Expand Up @@ -794,6 +792,7 @@
extern "C" {
#endif
void boardInit(void);
void boardDFUEnter(void);
#ifdef __cplusplus
}
#endif
Expand Down
Loading

0 comments on commit 4eb9a9e

Please sign in to comment.