-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from dm5tt/cw_radar
apps: merge cw_radar
- Loading branch information
Showing
14 changed files
with
617,692 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"files.associations": { | ||
"setup.h": "c" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
This target is a basic test to check if the RTOS and UART is working correctly. | ||
|
||
Connect a UART to PA10 (TX) and PA9 (RX) using a FTDI like FT232H at a baudrate of 4MBaud. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/*! | ||
\file gd32f30x_it.c | ||
\brief main interrupt service routines | ||
\version 2020-08-01, V3.0.0, firmware for GD32F30x | ||
*/ | ||
|
||
/* | ||
Copyright (c) 2020, GigaDevice Semiconductor Inc. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright notice, | ||
this list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from this | ||
software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
#include "gd32f30x_it.h" | ||
#include "setup.h" | ||
/*! | ||
\brief this function handles NMI exception | ||
\param[in] none | ||
\param[out] none | ||
\retval none | ||
*/ | ||
void NMI_Handler(void) {} | ||
|
||
/*! | ||
\brief this function handles HardFault exception | ||
\param[in] none | ||
\param[out] none | ||
\retval none | ||
*/ | ||
void HardFault_Handler(void) { | ||
/* if Hard Fault exception occurs, go to infinite loop */ | ||
while (1) | ||
; | ||
} | ||
|
||
/*! | ||
\brief this function handles MemManage exception | ||
\param[in] none | ||
\param[out] none | ||
\retval none | ||
*/ | ||
void MemManage_Handler(void) { | ||
/* if Memory Manage exception occurs, go to infinite loop */ | ||
while (1) | ||
; | ||
} | ||
|
||
/*! | ||
\brief this function handles BusFault exception | ||
\param[in] none | ||
\param[out] none | ||
\retval none | ||
*/ | ||
void BusFault_Handler(void) { | ||
/* if Bus Fault exception occurs, go to infinite loop */ | ||
while (1) | ||
; | ||
} | ||
|
||
/*! | ||
\brief this function handles UsageFault exception | ||
\param[in] none | ||
\param[out] none | ||
\retval none | ||
*/ | ||
void UsageFault_Handler(void) { | ||
/* if Usage Fault exception occurs, go to infinite loop */ | ||
while (1) | ||
; | ||
} | ||
|
||
/*! | ||
\brief this function handles DebugMon exception | ||
\param[in] none | ||
\param[out] none | ||
\retval none | ||
*/ | ||
void DebugMon_Handler(void) {} | ||
|
||
extern volatile uint16_t bufferA[ADC_SAMPLES]; | ||
extern volatile uint16_t bufferB[ADC_SAMPLES]; | ||
|
||
extern volatile uint16_t *currentBuffer; | ||
extern volatile uint16_t *nextBuffer; | ||
|
||
extern dma_parameter_struct dma_init_struct; | ||
|
||
void DMA1_Channel3_4_IRQHandler(void) { | ||
// Check if DMA transfer is complete | ||
if (dma_interrupt_flag_get(DMA1, DMA_CH4, DMA_INT_FLAG_FTF)) { | ||
// Clear the interrupt flag | ||
|
||
// Toggle between buffers | ||
if (currentBuffer == bufferA) { | ||
currentBuffer = bufferB; // Switch to Buffer B | ||
nextBuffer = bufferA; // Next buffer to fill is Buffer A | ||
} else { | ||
currentBuffer = bufferA; // Switch to Buffer A | ||
nextBuffer = bufferB; // Next buffer to fill is Buffer B | ||
} | ||
|
||
dma_channel_disable(DMA0, DMA_CH3); | ||
dma_channel_disable(DMA1, DMA_CH4); | ||
|
||
dma_memory_address_config(DMA0, DMA_CH3, (uint32_t)nextBuffer); | ||
dma_memory_address_config(DMA1, DMA_CH4, (uint32_t)currentBuffer); | ||
|
||
dma_interrupt_flag_clear(DMA1, DMA_CH4, DMA_INT_FLAG_FTF); | ||
dma_flag_clear(DMA0, DMA_CH3, DMA_FLAG_FTF); | ||
|
||
dma_channel_enable(DMA0, DMA_CH3); | ||
dma_channel_enable(DMA1, DMA_CH4); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/*! | ||
\file gd32f30x_it.h | ||
\brief the header file of the ISR | ||
\version 2020-08-01, V3.0.0, firmware for GD32F30x | ||
*/ | ||
|
||
/* | ||
Copyright (c) 2020, GigaDevice Semiconductor Inc. | ||
Redistribution and use in source and binary forms, with or without modification, | ||
are permitted provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
3. Neither the name of the copyright holder nor the names of its contributors | ||
may be used to endorse or promote products derived from this software without | ||
specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | ||
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | ||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | ||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR | ||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | ||
WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY | ||
OF SUCH DAMAGE. | ||
*/ | ||
|
||
#ifndef GD32F10X_IT_H | ||
#define GD32F10X_IT_H | ||
|
||
#include "gd32f30x.h" | ||
|
||
/* function declarations */ | ||
/* this function handles NMI exception */ | ||
void NMI_Handler(void); | ||
/* this function handles HardFault exception */ | ||
void HardFault_Handler(void); | ||
/* this function handles MemManage exception */ | ||
void MemManage_Handler(void); | ||
/* this function handles BusFault exception */ | ||
void BusFault_Handler(void); | ||
/* this function handles UsageFault exception */ | ||
void UsageFault_Handler(void); | ||
/* this function handles SVC exception */ | ||
void SVC_Handler(void); | ||
/* this function handles DebugMon exception */ | ||
void DebugMon_Handler(void); | ||
/* this function handles PendSV exception */ | ||
void PendSV_Handler(void); | ||
/* this function handles SysTick exception */ | ||
void SysTick_Handler(void); | ||
|
||
#endif /* GD32F10X_IT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import serial | ||
import struct | ||
import time | ||
|
||
def main(): | ||
# Konfiguration der seriellen Schnittstelle | ||
port = '/dev/ttyUSB0' | ||
baudrate = 2000000 | ||
preamble = b'XXXXXXX' # Erwartetes Preamble | ||
|
||
try: | ||
# Öffne die serielle Verbindung | ||
with serial.Serial(port, baudrate, timeout=None) as ser: # Kein Timeout | ||
print(f"Warte auf Preamble '{preamble.decode('utf-8')}'...") | ||
|
||
buffer = b'' | ||
while True: | ||
# Lese Daten byteweise | ||
buffer += ser.read(1) | ||
|
||
# Prüfe, ob das Preamble erkannt wurde | ||
if preamble in buffer: | ||
print("Preamble erkannt!") | ||
buffer = buffer[buffer.index(preamble) + len(preamble):] | ||
|
||
# Empfange uint16_t-Werte, wenn genügend Daten vorhanden sind | ||
while len(buffer) >= 2: | ||
data = buffer[:2] | ||
buffer = buffer[2:] | ||
value = struct.unpack('<H', data)[0] # Little Endian uint16_t | ||
timestamp = int(time.time()) # Unix-Timestamp | ||
print(f"[{timestamp}] {value}") | ||
|
||
except serial.SerialException as e: | ||
print(f"Fehler beim Zugriff auf die serielle Schnittstelle: {e}") | ||
except KeyboardInterrupt: | ||
print("Programm beendet.") | ||
|
||
if __name__ == "__main__": | ||
main() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include "main.h" | ||
|
||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
#include "FreeRTOS.h" | ||
#include "task.h" | ||
|
||
#include "setup.h" | ||
|
||
#include "gd32f30x.h" | ||
|
||
volatile uint16_t bufferA[ADC_SAMPLES] = {0}; | ||
volatile uint16_t bufferB[ADC_SAMPLES] = {0}; | ||
volatile uint16_t *currentBuffer = bufferA; // Start with Buffer A | ||
volatile uint16_t *nextBuffer = bufferB; // Next buffer to fill | ||
|
||
void vTask1(void *pvParameters) { | ||
(void)pvParameters; | ||
|
||
uint16_t value = 0; | ||
|
||
dac_data_set(DAC0, DAC_OUT0, DAC_ALIGN_12B_R, 2000); | ||
/* enable DAC software trigger */ | ||
dac_software_trigger_enable(DAC0, DAC_OUT0); | ||
|
||
for (;;) { | ||
|
||
|
||
|
||
vTaskDelay(100); | ||
|
||
|
||
|
||
|
||
} | ||
} | ||
|
||
int main(void) { | ||
setup_systick_config(); | ||
setup_pins(); | ||
|
||
setup_uart(); | ||
setup_adc(); | ||
setup_dac(); | ||
setup_timer(); | ||
setup_dma(); | ||
|
||
printf("XXXXXXX"); | ||
timer_enable(ADC_PWM_TMER); | ||
|
||
setvbuf(stdout, NULL, _IONBF, 0); | ||
|
||
xTaskCreate(vTask1, // pointer to the task function | ||
"Task 1", // task name | ||
512, // stack size in words | ||
NULL, // stack parameter (not used here) | ||
1, // priority | ||
NULL); // task handle (not used) | ||
|
||
vTaskStartScheduler(); | ||
|
||
while (1) { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// Created by Jonathan Giles on 5/20/22. | ||
// | ||
|
||
#ifndef CLIONGD32F303CG_MAIN_H | ||
#define CLIONGD32F303CG_MAIN_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
int main(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif //CLIONGD32F303CG_MAIN_H |
Oops, something went wrong.