Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Binary file removed build_pcb/backside.zip
Binary file not shown.
Binary file removed build_pcb/front_integrated.zip
Binary file not shown.
Binary file removed build_pcb/front_thin_lfo.zip
Binary file not shown.
Binary file removed build_pcb/longan_adapters.zip
Binary file not shown.
Binary file removed build_pcb/middle.zip
Binary file not shown.
Binary file removed code/script_icon.zip
Binary file not shown.
Binary file removed code/script_lut.zip
Binary file not shown.
Binary file removed code/script_menu.zip
Binary file not shown.
Binary file removed code/src_generic.zip
Binary file not shown.
Binary file removed code/src_midi2cv.zip
Binary file not shown.
10 changes: 0 additions & 10 deletions code/README.md → firmware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,3 @@ This folder contains the platformIO src files for both the generic version (with
The midi to CV codebase is based on https://github.com/nyannkov/nano_midi and is quite different than the generic version since it is relying on build scripts. It should be feasible to merge the two projects to a single project where the midi function is integrated in the menu system - let me know if you succeed ;)

The python scrips were used to generate icons, look up tables (LUT) and menus.


I used the following settings in platform.ini:
```
[env:sipeed-longan-nano]
platform = gd32v
board = sipeed-longan-nano
framework = gd32vf103-sdk
upload_protocol = dfu
```
6 changes: 6 additions & 0 deletions firmware/generic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
packages/framework-gd32vf103-sdk/
packages/toolchain-gd32v/
packages/tool-gd32vflash/
packages/tool-openocd-gd32v/
.pio/
.vscode/
2 changes: 2 additions & 0 deletions firmware/generic/packages/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Download required packages from : https://sourceforge.net/projects/platformio-storage/files/packages/
- Extract them into packages directory
9 changes: 9 additions & 0 deletions firmware/generic/platformio.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[env:sipeed-longan-nano]
platform = gd32v
board = sipeed-longan-nano
framework = gd32vf103-sdk
platform_packages = framework-gd32vf103-sdk @ file://packages/framework-gd32vf103-sdk
toolchain-gd32v @ file://packages/toolchain-gd32v
tool-openocd-gd32v @ file://packages/tool-openocd-gd32v
tool-gd32vflash @ file://packages/tool-gd32vflash
upload_protocol = dfu
119 changes: 119 additions & 0 deletions firmware/generic/src/data/font.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
extern "C"
{
#include "gd32vf103.h"
extern const uint8_t font[1520] ;
}

/*
Font copied from https://github.com/sipeed/Longan_GD32VF_examples.git

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

const uint8_t font[1520]={
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x18,0x18,0x00,0x00,
0x00,0x48,0x6C,0x24,0x12,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x24,0x24,0x24,0x7F,0x12,0x12,0x12,0x7F,0x12,0x12,0x12,0x00,0x00,
0x00,0x00,0x08,0x1C,0x2A,0x2A,0x0A,0x0C,0x18,0x28,0x28,0x2A,0x2A,0x1C,0x08,0x08,
0x00,0x00,0x00,0x22,0x25,0x15,0x15,0x15,0x2A,0x58,0x54,0x54,0x54,0x22,0x00,0x00,
0x00,0x00,0x00,0x0C,0x12,0x12,0x12,0x0A,0x76,0x25,0x29,0x11,0x91,0x6E,0x00,0x00,
0x00,0x06,0x06,0x04,0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x20,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x10,0x10,0x20,0x40,0x00,
0x00,0x02,0x04,0x08,0x08,0x10,0x10,0x10,0x10,0x10,0x10,0x08,0x08,0x04,0x02,0x00,
0x00,0x00,0x00,0x00,0x08,0x08,0x6B,0x1C,0x1C,0x6B,0x08,0x08,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x08,0x08,0x08,0x08,0x7F,0x08,0x08,0x08,0x08,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x04,0x03,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFE,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06,0x00,0x00,
0x00,0x00,0x80,0x40,0x40,0x20,0x20,0x10,0x10,0x08,0x08,0x04,0x04,0x02,0x02,0x00,
0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x24,0x18,0x00,0x00,
0x00,0x00,0x00,0x08,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,
0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x20,0x20,0x10,0x08,0x04,0x42,0x7E,0x00,0x00,
0x00,0x00,0x00,0x3C,0x42,0x42,0x20,0x18,0x20,0x40,0x40,0x42,0x22,0x1C,0x00,0x00,
0x00,0x00,0x00,0x20,0x30,0x28,0x24,0x24,0x22,0x22,0x7E,0x20,0x20,0x78,0x00,0x00,
0x00,0x00,0x00,0x7E,0x02,0x02,0x02,0x1A,0x26,0x40,0x40,0x42,0x22,0x1C,0x00,0x00,
0x00,0x00,0x00,0x38,0x24,0x02,0x02,0x1A,0x26,0x42,0x42,0x42,0x24,0x18,0x00,0x00,
0x00,0x00,0x00,0x7E,0x22,0x22,0x10,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x00,0x00,
0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x24,0x18,0x24,0x42,0x42,0x42,0x3C,0x00,0x00,
0x00,0x00,0x00,0x18,0x24,0x42,0x42,0x42,0x64,0x58,0x40,0x40,0x24,0x1C,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,0x00,0x00,0x18,0x18,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x04,
0x00,0x00,0x00,0x40,0x20,0x10,0x08,0x04,0x02,0x04,0x08,0x10,0x20,0x40,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x7F,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x02,0x04,0x08,0x10,0x20,0x40,0x20,0x10,0x08,0x04,0x02,0x00,0x00,
0x00,0x00,0x00,0x3C,0x42,0x42,0x46,0x40,0x20,0x10,0x10,0x00,0x18,0x18,0x00,0x00,
0x00,0x00,0x00,0x1C,0x22,0x5A,0x55,0x55,0x55,0x55,0x2D,0x42,0x22,0x1C,0x00,0x00,
0x00,0x00,0x00,0x08,0x08,0x18,0x14,0x14,0x24,0x3C,0x22,0x42,0x42,0xE7,0x00,0x00,
0x00,0x00,0x00,0x1F,0x22,0x22,0x22,0x1E,0x22,0x42,0x42,0x42,0x22,0x1F,0x00,0x00,
0x00,0x00,0x00,0x7C,0x42,0x42,0x01,0x01,0x01,0x01,0x01,0x42,0x22,0x1C,0x00,0x00,
0x00,0x00,0x00,0x1F,0x22,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x22,0x1F,0x00,0x00,
0x00,0x00,0x00,0x3F,0x42,0x12,0x12,0x1E,0x12,0x12,0x02,0x42,0x42,0x3F,0x00,0x00,
0x00,0x00,0x00,0x3F,0x42,0x12,0x12,0x1E,0x12,0x12,0x02,0x02,0x02,0x07,0x00,0x00,
0x00,0x00,0x00,0x3C,0x22,0x22,0x01,0x01,0x01,0x71,0x21,0x22,0x22,0x1C,0x00,0x00,
0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x7E,0x42,0x42,0x42,0x42,0xE7,0x00,0x00,
0x00,0x00,0x00,0x3E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,
0x00,0x00,0x00,0x7C,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x11,0x0F,
0x00,0x00,0x00,0x77,0x22,0x12,0x0A,0x0E,0x0A,0x12,0x12,0x22,0x22,0x77,0x00,0x00,
0x00,0x00,0x00,0x07,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x42,0x7F,0x00,0x00,
0x00,0x00,0x00,0x77,0x36,0x36,0x36,0x36,0x2A,0x2A,0x2A,0x2A,0x2A,0x6B,0x00,0x00,
0x00,0x00,0x00,0xE3,0x46,0x46,0x4A,0x4A,0x52,0x52,0x52,0x62,0x62,0x47,0x00,0x00,
0x00,0x00,0x00,0x1C,0x22,0x41,0x41,0x41,0x41,0x41,0x41,0x41,0x22,0x1C,0x00,0x00,
0x00,0x00,0x00,0x3F,0x42,0x42,0x42,0x42,0x3E,0x02,0x02,0x02,0x02,0x07,0x00,0x00,
0x00,0x00,0x00,0x1C,0x22,0x41,0x41,0x41,0x41,0x41,0x4D,0x53,0x32,0x1C,0x60,0x00,
0x00,0x00,0x00,0x3F,0x42,0x42,0x42,0x3E,0x12,0x12,0x22,0x22,0x42,0xC7,0x00,0x00,
0x00,0x00,0x00,0x7C,0x42,0x42,0x02,0x04,0x18,0x20,0x40,0x42,0x42,0x3E,0x00,0x00,
0x00,0x00,0x00,0x7F,0x49,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x1C,0x00,0x00,
0x00,0x00,0x00,0xE7,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00,
0x00,0x00,0x00,0xE7,0x42,0x42,0x22,0x24,0x24,0x14,0x14,0x18,0x08,0x08,0x00,0x00,
0x00,0x00,0x00,0x6B,0x49,0x49,0x49,0x49,0x55,0x55,0x36,0x22,0x22,0x22,0x00,0x00,
0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x18,0x18,0x18,0x24,0x24,0x42,0xE7,0x00,0x00,
0x00,0x00,0x00,0x77,0x22,0x22,0x14,0x14,0x08,0x08,0x08,0x08,0x08,0x1C,0x00,0x00,
0x00,0x00,0x00,0x7E,0x21,0x20,0x10,0x10,0x08,0x04,0x04,0x42,0x42,0x3F,0x00,0x00,
0x00,0x78,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x78,0x00,
0x00,0x00,0x02,0x02,0x04,0x04,0x08,0x08,0x08,0x10,0x10,0x20,0x20,0x20,0x40,0x40,
0x00,0x1E,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x1E,0x00,
0x00,0x38,0x44,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF,
0x00,0x06,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x78,0x44,0x42,0x42,0xFC,0x00,0x00,
0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x1A,0x26,0x42,0x42,0x42,0x26,0x1A,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x38,0x44,0x02,0x02,0x02,0x44,0x38,0x00,0x00,
0x00,0x00,0x00,0x60,0x40,0x40,0x40,0x78,0x44,0x42,0x42,0x42,0x64,0xD8,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x7E,0x02,0x02,0x42,0x3C,0x00,0x00,
0x00,0x00,0x00,0xF0,0x88,0x08,0x08,0x7E,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x22,0x22,0x1C,0x02,0x3C,0x42,0x42,0x3C,
0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x3A,0x46,0x42,0x42,0x42,0x42,0xE7,0x00,0x00,
0x00,0x00,0x00,0x0C,0x0C,0x00,0x00,0x0E,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,
0x00,0x00,0x00,0x30,0x30,0x00,0x00,0x38,0x20,0x20,0x20,0x20,0x20,0x20,0x22,0x1E,
0x00,0x00,0x00,0x03,0x02,0x02,0x02,0x72,0x12,0x0A,0x16,0x12,0x22,0x77,0x00,0x00,
0x00,0x00,0x00,0x0E,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x3E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7F,0x92,0x92,0x92,0x92,0x92,0xB7,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3B,0x46,0x42,0x42,0x42,0x42,0xE7,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x3C,0x42,0x42,0x42,0x42,0x42,0x3C,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x1B,0x26,0x42,0x42,0x42,0x22,0x1E,0x02,0x07,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x78,0x44,0x42,0x42,0x42,0x44,0x78,0x40,0xE0,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x77,0x4C,0x04,0x04,0x04,0x04,0x1F,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7C,0x42,0x02,0x3C,0x40,0x42,0x3E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x08,0x08,0x3E,0x08,0x08,0x08,0x08,0x08,0x30,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x63,0x42,0x42,0x42,0x42,0x62,0xDC,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x14,0x08,0x08,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xEB,0x49,0x49,0x55,0x55,0x22,0x22,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x76,0x24,0x18,0x18,0x18,0x24,0x6E,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xE7,0x42,0x24,0x24,0x14,0x18,0x08,0x08,0x07,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x7E,0x22,0x10,0x08,0x08,0x44,0x7E,0x00,0x00,
0x00,0xC0,0x20,0x20,0x20,0x20,0x20,0x10,0x20,0x20,0x20,0x20,0x20,0x20,0xC0,0x00,
0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,
0x00,0x06,0x08,0x08,0x08,0x08,0x08,0x10,0x08,0x08,0x08,0x08,0x08,0x08,0x06,0x00,
0x0C,0x32,0xC2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
};
9 changes: 9 additions & 0 deletions firmware/generic/src/data/frequency.cpp

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions firmware/generic/src/data/images.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extern "C"
{
#include "gd32vf103.h"
}


const uint8_t img1[176] = {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 50, 8, 102, 66, 38, 15, 115, 1, 66, 1, 34, 1, 130, 0, 70, 0, 32, 0, 131, 0, 72, 0, 30, 0, 131, 0, 74, 0, 28, 0, 255, 116, 0, 76, 0, 26, 0, 255, 255, 112, 24, 9, 24, 45, 11, 120, 0, 33, 0, 69, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 146, 0, 239, 68, 255, 255, 130, 0, 76, 0, 26, 0, 104, 0, 210, 0, 55, 0, 74, 0, 28, 0, 74, 0, 28, 0, 27, 0, 72, 0, 30, 0, 72, 0, 30, 0, 27, 0, 70, 0, 32, 0, 70, 0, 32, 0, 27, 1, 66, 1, 34, 1, 66, 1, 34, 1, 27, 66, 38, 2, 25, 8, 25, 2, 38, 2, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 252};
67 changes: 67 additions & 0 deletions firmware/generic/src/drivers/SysTick.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
extern "C" {
#include "gd32vf103.h"
}
#include <stdint.h>
#include "SysTick.h"
static SysTick *pSysTick = 0;
void SysTick::begin(uint32_t usPeriod)
{
pSysTick = this;
SystemClockSpeed = 108000000/8; // the GD32VF103 divides the high speed clock by 8
Period = usPeriod;
Period = Period * SystemClockSpeed;
Period = Period / 1000000;
NextInterruptTime = Period;
// Zero the clock to start with
*(volatile uint32_t *)(TIMER_CTRL_ADDR + TIMER_MTIME + 4)=0;
*(volatile uint32_t *)(TIMER_CTRL_ADDR + TIMER_MTIME )=0;
*(volatile uint32_t *)(TIMER_CTRL_ADDR + TIMER_MTIMECMP + 4)=NextInterruptTime >> 32;
*(volatile uint32_t *)(TIMER_CTRL_ADDR + TIMER_MTIMECMP ) = NextInterruptTime & 0xffffffff;
eclic_enable_interrupt(CLIC_INT_TMR);
}
void SysTick::OnInterrupt()
{
// At each interrupt the Timer compare register has to be updated to the next
// interrupt time.
NextInterruptTime += Period;
*(volatile uint32_t *)(TIMER_CTRL_ADDR + TIMER_MTIMECMP + 4)=NextInterruptTime >> 32;
*(volatile uint32_t *)(TIMER_CTRL_ADDR + TIMER_MTIMECMP ) = NextInterruptTime & 0xffffffff;

// LED blink (relies on the LED port bits being initialized elsewhere)
static int State = 0;
if (State)
{
GPIO_BOP(GPIOA) = GPIO_PIN_1;
State = 0;
}
else
{
GPIO_BC(GPIOA) = GPIO_PIN_1;
State = 1;
}
}
void SysTick::delay(uint32_t msdly)
{
// delay for thet specified number of milliseconds;
uint64_t EndTime = msdly;
EndTime = (EndTime * SystemCoreClock/8000);
EndTime = EndTime + get_timer_value();

while(get_timer_value() < EndTime);
}

// The interrupt handler for the internal timer. C naming is required
// to allow it to over-ride the weak symbol defined in the startup code.
// Also have to insert assembler to back up and restore registers prior
// to calling C++ interrupt handler
// Based on initial investigations it would seem that context is saved
// before entry in to this function and restored afterwards i.e. this
// is not an interrupt service routine in the true sense - it is a
// function called by another interrupt handler buried deeper in the
// SDK.
extern "C" {
void eclic_mtip_handler()
{
pSysTick->OnInterrupt();
}
}
16 changes: 16 additions & 0 deletions firmware/generic/src/drivers/SysTick.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef __SysTick_h
#define __SysTick_h
#include <stdint.h>
class SysTick{

public:
SysTick() {};
void begin(uint32_t usPeriod);
void OnInterrupt();
void delay(uint32_t msdly);
private:
uint64_t SystemClockSpeed;
uint64_t NextInterruptTime;
uint64_t Period;
};
#endif
28 changes: 28 additions & 0 deletions firmware/generic/src/drivers/adc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "adc.h"
extern "C"
{
#include "gd32vf103.h"
}

// anUpdate (downshifted oversampling)
uint8_t anCount = 0; // counter for oversampling (new value after 255, @44,4KHz => 173Hz, suitable for potentiometers)
uint32_t anTotal[MAX_AN]; // the running total
int anAvg[MAX_AN]; // analog average
uint16_t anRaw[8]; // raw sampled values stored by DMA

// analog average (downshifted oversampling)
void adc::update(uint8_t ch)
{
if (anCount < 255)
{
anTotal[ch] += anRaw[ch];
}
else
{
if (ch == 2 || ch == 3) // these potentiometers are inverted due to routing
anAvg[ch] = 4095 - (anTotal[ch] >> 8); // note that raw[2] and raw[3] is still inverted...
else
anAvg[ch] = anTotal[ch] >> 8; // inputs and pot 3 is not inverted
anTotal[ch] = 0;
}
}
22 changes: 22 additions & 0 deletions firmware/generic/src/drivers/adc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef __adc_h
#define __adc_h
extern "C"
{
#include <gd32vf103.h>
}

#define MAX_AN 5 // number of analog filters

class adc
{
public:
adc(){};
uint16_t anRaw[8]; // raw sampled values stored by DMA
int anAvg[MAX_AN]; // analog average
uint8_t anCount; // counter for oversampling (new value after 255, @44,4KHz => 173Hz, suitable for potentiometers)
void update(uint8_t ch);

private:
uint32_t anTotal[MAX_AN]; // the running total
};
#endif
Loading