Skip to content

Commit

Permalink
Sync with local development
Browse files Browse the repository at this point in the history
  • Loading branch information
vanvught committed Mar 1, 2024
1 parent 0674542 commit 1378bb6
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 256 deletions.
5 changes: 4 additions & 1 deletion firmware-template-gd32/Board.mk
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,17 @@ endif

ifeq ($(strip $(BOARD)),BOARD_BW_OPIDMX4)
BOARD_DMX=4
DEFINES+=-DCONFIG_STORE_USE_SPI
endif

ifeq ($(strip $(BOARD)),BOARD_DMX3)
BOARD_DMX=3
DEFINES+=-DCONFIG_STORE_USE_SPI
endif

ifeq ($(strip $(BOARD)),BOARD_DMX4)
BOARD_DMX=4
DEFINES+=-DCONFIG_STORE_USE_SPI
BOARD_DMX=4
endif

ifdef BOARD_DMX
Expand Down
35 changes: 0 additions & 35 deletions firmware-template-gd32/FreeRTOS.mk

This file was deleted.

2 changes: 1 addition & 1 deletion firmware-template-gd32/Mcu.mk
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ ifeq ($(strip $(MCU)),GD32F470ZK)
endif

ifeq ($(strip $(MCU)),GD32H759IM)
LINKER=$(FIRMWARE_DIR)gd32h7xx_M_flash.ld
LINKER=$(FIRMWARE_DIR)gd32h7xx_xM_flash.ld
FAMILY=gd32h7xx
LINE=gd32h759
endif
Expand Down
70 changes: 46 additions & 24 deletions include/stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file stdio.h
*
*/
/* Copyright (C) 2017-2020 by Arjan van Vught mailto:[email protected]
/* Copyright (C) 2017-2024 by Arjan van Vught mailto:[email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -28,10 +28,29 @@

#include <stddef.h>
#include <stdarg.h>

#define EOF -1

typedef void *FILE;
#include <stdint.h>

#define EOF (-1)

typedef struct __sFILE {
void *udata;
#define __SLBF 0x0001 /* line buffered */
#define __SNBF 0x0002 /* unbuffered */
#define __SRD 0x0004 /* OK to read */
#define __SWR 0x0008 /* OK to write */
/* RD and WR are never simultaneously asserted */
#define __SRW 0x0010 /* open for reading & writing */
#define __SEOF 0x0020 /* found EOF */
#define __SERR 0x0040 /* found error */
uint8_t flags;
} FILE;

#if defined(CONFIG_POSIX_ENABLE_STDIN)
#error Not supported
extern FILE *stdin;
extern FILE *stdout;
extern FILE *stderr;
#endif

#ifndef SEEK_SET
#define SEEK_SET 0 /* set file offset to offset */
Expand All @@ -49,36 +68,39 @@ typedef void *FILE;
extern "C" {
#endif

extern int puts(const char *s);
extern int putchar(int c);
int puts(const char *s);
int putchar(int c);

int fileno(FILE *stream);

extern FILE *fopen(const char *path, const char *mode);
extern int fclose(FILE *stream);
FILE *fopen(const char *path, const char *mode);
int fclose(FILE *stream);

extern int fgetc(FILE *stream);
int fgetc(FILE *stream);

extern char *fgets(char *s, int size, FILE *stream);
extern int fputs(const char *s, FILE *stream);
char *fgets(char *s, int size, FILE *stream);
int fputs(const char *s, FILE *stream);

extern size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
extern size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);
size_t fread(void *ptr, size_t size, size_t nmemb, FILE *stream);
size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream);

extern int fseek(FILE *stream, long offset, int whence);
int fseek(FILE *stream, long offset, int whence);

extern long ftell(FILE *stream);
long ftell(FILE *stream);

extern void clearerr(FILE *stream);
extern int ferror(FILE *stream);
void clearerr(FILE *stream);
int ferror(FILE *stream);
int feof(FILE *stream);

extern int printf(const char *format, ...);
int printf(const char *format, ...);

extern int sprintf(char *str, const char *format, ...);
extern int snprintf(char *str, size_t size, const char *format, ...);
int sprintf(char *str, const char *format, ...);
int snprintf(char *str, size_t size, const char *format, ...);

extern int vprintf(const char *format, va_list ap);
extern int vsnprintf(char *str, size_t size, const char *format, va_list);
int vprintf(const char *format, va_list ap);
int vsnprintf(char *str, size_t size, const char *format, va_list);

extern void perror(const char *s);
void perror(const char *s);

#ifdef __cplusplus
}
Expand Down
164 changes: 0 additions & 164 deletions lib-gd32/include/FreeRTOSConfig.h

This file was deleted.

30 changes: 3 additions & 27 deletions lib-gd32/src/f/gd32_spi_dma_i2s.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @file gd32_spi_dma_i2s.cpp
*
*/
/* Copyright (C) 2021-2022 by Arjan van Vught mailto:[email protected]
/* Copyright (C) 2021-2024 by Arjan van Vught mailto:[email protected]
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -50,7 +50,7 @@ void i2s_psc_config_dump(uint32_t spi_periph, uint32_t audiosample, uint32_t fra

static uint16_t s_TxBuffer[SPI_BUFFER_SIZE] __attribute__ ((aligned (4)));

static void _spi_i2s_dma_config() {
static void spi_i2s_dma_config() {
rcu_periph_clock_enable(RCU_DMA1);

dma_deinit(SPI_DMAx, SPI_DMA_CHx);
Expand Down Expand Up @@ -114,36 +114,12 @@ void gd32_spi_dma_begin() {
gpio_output_options_set(SPI_NSS_GPIOx, GPIO_OTYPE_PP, GPIO_OSPEED_50MHZ, SPI_NSS_GPIO_PINx);
#endif

#if defined (GD32F10X_CL) || defined (GD32F20X_CL)
/**
* Setup PLL2
*
* i2sclock=160000000
* i2sdiv=12, i2sof=256
*/

RCU_CTL &= ~RCU_CTL_PLL2EN;

rcu_pll2_config(RCU_PLL2_MUL16);

RCU_CTL |= RCU_CTL_PLL2EN;

while ((RCU_CTL & RCU_CTL_PLL2STB) == 0U) {
}

if (SPI_PERIPH == SPI2) {
rcu_i2s2_clock_config(RCU_I2S2SRC_CKPLL2_MUL2);
} else {
rcu_i2s1_clock_config(RCU_I2S1SRC_CKPLL2_MUL2);
}
#endif

i2s_disable(SPI_PERIPH);
i2s_psc_config(SPI_PERIPH, 200000, I2S_FRAMEFORMAT_DT16B_CH16B, I2S_MCKOUT_DISABLE);
i2s_init(SPI_PERIPH, I2S_MODE_MASTERTX, I2S_STD_MSB, I2S_CKPL_LOW);
i2s_enable(SPI_PERIPH);

_spi_i2s_dma_config();
spi_i2s_dma_config();

#ifndef NDEBUG
i2s_psc_config_dump(SPI_PERIPH, 200000, I2S_FRAMEFORMAT_DT16B_CH16B, I2S_MCKOUT_DISABLE);
Expand Down
Loading

0 comments on commit 1378bb6

Please sign in to comment.