From 0a5bcc9e022823b1d8cf245917958384d51ca7f9 Mon Sep 17 00:00:00 2001 From: liuyihui Date: Thu, 27 Apr 2023 01:20:47 +0800 Subject: [PATCH] fix: conversion errors --- Makefile | 2 +- include/fft/fft.h | 2 +- include/sstv.h | 2 +- src/fft/fft.c | 6 +++--- src/sstv.c | 14 ++++++++------ 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 3ea640b..f4bd044 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ SOURCES = main.c src/*.c # 编译选项 CFLAGS ?= -W -Wall -Wextra -Werror -Wundef -Wshadow -Wdouble-promotion \ - -Wformat-truncation -fno-common -Wconversion \ + -Wformat-truncation -fno-common \ -g3 -Og -ffunction-sections -fdata-sections \ -Iinclude -mcpu=cortex-m0plus -mthumb -lm $(EXTRA_CFLAGS) LDFLAGS ?= -T $(DEPS_DIR)/link.ld -nostartfiles -nostdlib --specs nano.specs \ diff --git a/include/fft/fft.h b/include/fft/fft.h index 4ac8ac5..dfd5005 100644 --- a/include/fft/fft.h +++ b/include/fft/fft.h @@ -1,6 +1,6 @@ #pragma once -#include "inttypes.h" +#include #define q15_t int16_t #define q31_t int32_t diff --git a/include/sstv.h b/include/sstv.h index 0be6438..36728ed 100644 --- a/include/sstv.h +++ b/include/sstv.h @@ -1,6 +1,6 @@ #pragma once -#include "inttypes.h" +#include #define float32_t float diff --git a/src/fft/fft.c b/src/fft/fft.c index 79f9fac..f359376 100644 --- a/src/fft/fft.c +++ b/src/fft/fft.c @@ -1,8 +1,8 @@ #include "fft/fft.h" #include "fft/table.h" -#include "inttypes.h" -#include "math.h" -#include "stdlib.h" +#include +#include +#include #define N 1024 #define Re(x) 2 * x diff --git a/src/sstv.c b/src/sstv.c index a6b4f49..8b8c28b 100644 --- a/src/sstv.c +++ b/src/sstv.c @@ -3,7 +3,8 @@ #include "fft/table.h" #include "math.h" #include "sstv.h" -#include "stdio.h" +#include +#include static q15_t data[N]; static q15_t buffer[MN]; @@ -26,7 +27,8 @@ static void read_data(q15_t* pSrc, uint16_t len) { } static uint16_t find_peak(uint16_t L, uint16_t R) { - uint16_t index = 0, peak = 0; + q15_t peak = 0; + uint16_t index = 0; for (uint16_t i = L; i <= R; i++) if (data[i] > peak) { index = i; @@ -38,9 +40,9 @@ static uint16_t find_peak(uint16_t L, uint16_t R) { static void hanning(uint16_t len) { for (uint16_t i = len; i < N; i++) data[i] = 0; if (len == 160) - for (uint16_t i = 0; i < len; i++) data[i] = ((q31_t)data[i] * hanning_160[i]) >> 15; + for (uint16_t i = 0; i < len; i++) data[i] = (q15_t)(((q31_t)data[i] * hanning_160[i]) >> 15); else - for (uint16_t i = 0; i < len; i++) data[i] = ((q31_t)data[i] * hanning_17[i]) >> 15; + for (uint16_t i = 0; i < len; i++) data[i] = (q15_t)(((q31_t)data[i] * hanning_17[i]) >> 15); } static uint32_t cSample = 0; @@ -109,7 +111,7 @@ static uint8_t read_mode() { if (abs(fre - FREQ_BIT1) < 80) cBit1++; else if (abs(fre - FREQ_BIT0) > 80) { printf("Error VIS BIT: %d\r\n", fre); - return -1; + return 0; } if (i % 3 == 2) { @@ -126,7 +128,7 @@ static uint8_t read_mode() { if (!cParity) { printf("Error Parity Check: %d\r\n", mode); - return -2; + return 0; } read_data(pData, len * 3); return mode;