Skip to content

Commit

Permalink
Firmware revision 3
Browse files Browse the repository at this point in the history
+ Sine startup mode

New targets: ESCAPE1, FLYCOLOR1
New build options: INVERTED_HIGH, ANALOG
Define default settings as build options
Minor fixes & cosmetics
  • Loading branch information
neoxic committed May 24, 2023
1 parent 9ea8014 commit 4814601
Show file tree
Hide file tree
Showing 24 changed files with 589 additions and 237 deletions.
11 changes: 5 additions & 6 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ endif()
find_program(FLASH st-flash)
add_compile_options(-ffreestanding -ffunction-sections -fdata-sections -fsingle-precision-constant
-Wall -Wextra -Wpedantic -Wundef -Wshadow -Wredundant-decls -Wstrict-prototypes -Wmissing-prototypes
-Wno-variadic-macros -Wno-unused-result -Wno-unused-parameter)
-Wno-variadic-macros -Wno-unused-result -Wno-unused-parameter -Wno-unused-label)
add_link_options(-nostartfiles -Wl,--gc-sections)

function(add_target name mcu)
Expand All @@ -40,16 +40,16 @@ function(add_target name mcu)
DEPENDS ${elf}
)
add_custom_target(${name} ALL DEPENDS ${hex})
if(mcu MATCHES "^STM32")
add_custom_target(flash-${name} COMMAND ${FLASH} --reset --connect-under-reset --format ihex write ${hex} DEPENDS ${hex})
endif()
add_custom_target(flash-${name} COMMAND ${FLASH} --reset --connect-under-reset --format ihex write ${hex} DEPENDS ${hex})
endfunction()

add_subdirectory(boot)

add_target(AIKON1 STM32G071 DEAD_TIME=35 COMP_MAP=213 IO_PA6)
add_target(AIRBOT1 AT32F421 DEAD_TIME=66 COMP_MAP=321 SENS_MAP=0xA3A6 VOLT_MUL=74 CURR_MUL=20 LED_MAP=0xA15B3B4)
add_target(EMAX1 STM32F051 DEAD_TIME=26 COMP_MAP=123 IO_PA2)
add_target(ESCAPE1 STM32G071 DEAD_TIME=35 COMP_MAP=123 SENS_MAP=0xA5A4 VOLT_MUL=110 CURR_MUL=40 LED_WS2812 IO_PA2)
add_target(FLYCOLOR1 STM32F051 DEAD_TIME=26 COMP_MAP=123 SENS_MAP=0xA6 VOLT_MUL=110 LED_MAP=0xB5B4B3 IO_PA2)
add_target(HAKRC1 STM32F051 DEAD_TIME=26 COMP_MAP=213 SENS_MAP=0xA3 VOLT_MUL=110 LED_MAP=0xA15B5B3 LED_INV)
add_target(HAKRC2 AT32F421 DEAD_TIME=66 COMP_MAP=213 SENS_MAP=0xA3 VOLT_MUL=110 LED_MAP=0xA15B5B3 LED_INV)
add_target(HGLRC1 STM32F051 DEAD_TIME=26 COMP_MAP=123 SENS_MAP=0xA6 VOLT_MUL=210 IO_PA2)
Expand All @@ -63,5 +63,4 @@ add_target(TMOTOR2 STM32F051 DEAD_TIME=26 COMP_MAP=321)
add_target(TMOTOR3 STM32G071 DEAD_TIME=35 COMP_MAP=231 IO_PA6)

# Experimental targets
add_target(_SPIN32 STSPIN32F0 DEAD_TIME=26)
add_target(_G071PA2 STM32G071 DEAD_TIME=35 COMP_MAP=123 LED_WS2812 IO_PA2)
add_target(_SPIN32 STSPIN32F0 DEAD_TIME=26 ANALOG) # Sensored drive using STEVAL_SPIN3201 board
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ Features
+ DSHOT 300/600, bidirectional DSHOT, extended telemetry
+ Analog/serial/iBUS/SBUS input mode
+ KISS/iBUS/S.Port telemetry
+ DSHOT 3D mode, turtle mode, beacon, LED, direction change
+ DSHOT 3D mode, turtle mode, beacon, LED, programming
+ Sine startup mode
+ Proportional brake, drag brake
+ Temperature/voltage/current protection
+ Variable PWM frequency, active freewheeling
Expand Down
2 changes: 1 addition & 1 deletion boot/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
add_target(BOOT1_PA2 STM32F0 IO_PA2)
add_target(BOOT1_PB4 STM32F0)
add_target(BOOT2_PA2 STM32G0 IO_PA2)
add_target(BOOT2_PA6 STM32G0 IO_PA6)
add_target(BOOT2_PB4 STM32G0)
add_target(BOOT3_PA2 STM32F0 IO_PA2 USARTv1)

# Experimental targets
add_target(_BOOT1_PA6 STM32F0 IO_PA6)
add_target(_BOOT2_PA2 STM32G0 IO_PA2)
15 changes: 9 additions & 6 deletions boot/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ void main(void) {
RCC_CSR = RCC_CSR_RMVF; // Clear reset flags
sendval(RES_OK); // ACK after reboot
}
#ifdef FAST_EXIT
else goto done;
#endif
for (;;) {
switch (recvval()) {
case CMD_PROBE: // Probe bootloader
Expand All @@ -48,18 +51,18 @@ void main(void) {
}
case CMD_READ: { // Read block
int num = recvval();
if (num == -1) goto error;
if (num == -1) goto done;
int cnt = recvval();
if (cnt == -1) goto error;
if (cnt == -1) goto done;
senddata(_rom_end + (num << 10), (cnt + 1) << 2);
break;
}
case CMD_WRITE: { // Write block
int num = recvval();
if (num == -1) goto error;
if (num == -1) goto done;
char buf[1024];
int len = recvdata(buf);
if (len == -1) goto error;
if (len == -1) goto done;
sendval(write(_rom_end + (num << 10), buf, len) ? RES_OK : RES_ERROR);
break;
}
Expand All @@ -68,7 +71,7 @@ void main(void) {
int pos = 0;
for (int i = 0, n = (_rom_end - _rom) >> 10; i < n; ++i) {
int len = recvdata(buf + pos);
if (len == -1) goto error;
if (len == -1) goto done;
sendval(RES_OK);
pos += len;
if (len < 1024) break; // Last block
Expand All @@ -92,7 +95,7 @@ void main(void) {
sendval(RES_ERROR);
break;
default: // Pass control to application
error:
done:
if (*(uint16_t *)_rom_end != 0x32ea) break;
__asm__("msr msp, %0" :: "g" (*(uint32_t *)(_rom_end + PAGE_SIZE))); // Initialize stack pointer
(*(void (**)(void))(_rom_end + PAGE_SIZE + 4))(); // Jump to application
Expand Down
14 changes: 9 additions & 5 deletions mcu/AT32F421/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void init(void) {
RCC_APB2RSTR = 0;
RCC_APB1RSTR = 0;
RCC_AHBENR = RCC_AHBENR_DMAEN | RCC_AHBENR_SRAMEN | RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN;
RCC_APB2ENR = RCC_APB2ENR_SYSCFGCOMPEN | RCC_APB2ENR_ADCEN | RCC_APB2ENR_TIM1EN | RCC_APB2ENR_USART1EN | RCC_APB2ENR_TIM15EN | RCC_APB2ENR_TIM17EN;
RCC_APB2ENR = RCC_APB2ENR_SYSCFGCOMPEN | RCC_APB2ENR_ADCEN | RCC_APB2ENR_TIM1EN | RCC_APB2ENR_USART1EN | RCC_APB2ENR_TIM17EN;
RCC_APB1ENR = RCC_APB1ENR_TIM3EN | RCC_APB1ENR_TIM14EN | RCC_APB1ENR_WWDGEN;
SCB_VTOR = (uint32_t)_rom; // Set vector table address

Expand All @@ -49,10 +49,15 @@ void init(void) {
GPIOA_AFRH = 0x00000222; // A8 (TIM1_CH1), A9 (TIM1_CH2), A10 (TIM1_CH3)
GPIOB_AFRL = 0x00000022; // B0 (TIM1_CH2N), B1 (TIM1_CH3N)
GPIOB_AFRH = 0x00000000;
GPIOA_PUPDR = 0x24000010; // A2 (pull-up)
GPIOA_PUPDR = 0x24000000;
GPIOB_PUPDR = 0x00001000; // B6 (pull-up)
GPIOA_MODER = 0xebeabfef; // A2 (TIM15_CH1), A7 (TIM1_CH1N), A8 (TIM1_CH1), A9 (TIM1_CH2), A10 (TIM1_CH3)
GPIOA_MODER = 0xebeabfff; // A7 (TIM1_CH1N), A8 (TIM1_CH1), A9 (TIM1_CH2), A10 (TIM1_CH3)
GPIOB_MODER = 0xffffeffa; // B0 (TIM1_CH2N), B1 (TIM1_CH3N), B6 (USART1_TX)
#ifndef ANALOG
RCC_APB2ENR |= RCC_APB2ENR_TIM15EN;
GPIOA_PUPDR |= 0x10; // A2 (pull-up)
GPIOA_MODER &= ~0x10; // A2 (TIM15_CH1)
#endif

nvic_set_priority(NVIC_TIM15_IRQ, 0x40);
nvic_set_priority(NVIC_USART1_IRQ, 0x80);
Expand Down Expand Up @@ -83,8 +88,7 @@ void init(void) {
ADC1_SQR3 = SENS_CHAN;
len = SENS_CNT;
if (IO_ANALOG) {
ADC1_SQR3 |= 0x2 << (len * 5); // A2 (throt)
++len;
ADC1_SQR3 |= THROT_CHAN << (len++ * 5);
ain = 1;
}
ADC1_SQR3 |= 0x230 << (len * 5); // CH16 (temp), CH17 (vref)
Expand Down
4 changes: 4 additions & 0 deletions mcu/AT32F421/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#define SENS_CHAN 0x3
#endif

#ifndef THROT_CHAN
#define THROT_CHAN 2 // A2
#endif

#define CLK 120000000
#define IO_PA2
#define IO_TYPE 0
Expand Down
33 changes: 33 additions & 0 deletions mcu/AT32F421/preset.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
** Copyright (C) 2022-2023 Arseny Vakhrushev <[email protected]>
**
** This firmware is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This firmware is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this firmware. If not, see <http://www.gnu.org/licenses/>.
*/

#include "common.h"

const uint16_t sinedata[] = {
400, 407, 414, 421, 428, 435, 442, 449, 456, 463, 469, 476, 483, 490, 497, 504, 510, 517, 524, 530, 537, 543, 550, 556, 563, 569, 575, 582, 588, 594,
600, 606, 612, 618, 624, 629, 635, 641, 646, 652, 657, 662, 668, 673, 678, 683, 688, 693, 697, 702, 706, 711, 715, 719, 724, 728, 732, 735, 739, 743,
746, 750, 753, 756, 760, 763, 765, 768, 771, 773, 776, 778, 780, 783, 785, 786, 788, 790, 791, 793, 794, 795, 796, 797, 798, 798, 799, 799, 800, 800,
800, 800, 800, 799, 799, 798, 798, 797, 796, 795, 794, 793, 791, 790, 788, 786, 785, 783, 780, 778, 776, 773, 771, 768, 765, 763, 760, 756, 753, 750,
746, 743, 739, 735, 732, 728, 724, 719, 715, 711, 706, 702, 697, 693, 688, 683, 678, 673, 668, 662, 657, 652, 646, 641, 635, 629, 624, 618, 612, 606,
600, 594, 588, 582, 575, 569, 563, 556, 550, 543, 537, 530, 524, 517, 510, 504, 497, 490, 483, 476, 469, 463, 456, 449, 442, 435, 428, 421, 414, 407,
400, 393, 386, 379, 372, 365, 358, 351, 344, 337, 331, 324, 317, 310, 303, 296, 290, 283, 276, 270, 263, 257, 250, 244, 237, 231, 225, 218, 212, 206,
200, 194, 188, 182, 176, 171, 165, 159, 154, 148, 143, 138, 132, 127, 122, 117, 112, 107, 103, 98, 94, 89, 85, 81, 76, 72, 68, 65, 61, 57,
54, 50, 47, 44, 40, 37, 35, 32, 29, 27, 24, 22, 20, 17, 15, 14, 12, 10, 9, 7, 6, 5, 4, 3, 2, 2, 1, 1, 0, 0,
0, 0, 0, 1, 1, 2, 2, 3, 4, 5, 6, 7, 9, 10, 12, 14, 15, 17, 20, 22, 24, 27, 29, 32, 35, 37, 40, 44, 47, 50,
54, 57, 61, 65, 68, 72, 76, 81, 85, 89, 94, 98, 103, 107, 112, 117, 122, 127, 132, 138, 143, 148, 154, 159, 165, 171, 176, 182, 188, 194,
200, 206, 212, 218, 225, 231, 237, 244, 250, 257, 263, 270, 276, 283, 290, 296, 303, 310, 317, 324, 331, 337, 344, 351, 358, 365, 372, 379, 386, 393,
};
14 changes: 9 additions & 5 deletions mcu/GD32E230/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void init(void) {
RCC_APB2RSTR = 0;
RCC_APB1RSTR = 0;
RCC_AHBENR = RCC_AHBENR_DMAEN | RCC_AHBENR_SRAMEN | RCC_AHBENR_GPIOAEN | RCC_AHBENR_GPIOBEN;
RCC_APB2ENR = RCC_APB2ENR_SYSCFGCOMPEN | RCC_APB2ENR_ADCEN | RCC_APB2ENR_TIM1EN | RCC_APB2ENR_USART1EN | RCC_APB2ENR_TIM15EN | RCC_APB2ENR_TIM17EN;
RCC_APB2ENR = RCC_APB2ENR_SYSCFGCOMPEN | RCC_APB2ENR_ADCEN | RCC_APB2ENR_TIM1EN | RCC_APB2ENR_USART1EN | RCC_APB2ENR_TIM17EN;
RCC_APB1ENR = RCC_APB1ENR_TIM3EN | RCC_APB1ENR_TIM14EN | RCC_APB1ENR_WWDGEN;
SCB_VTOR = (uint32_t)_rom; // Set vector table address

Expand All @@ -49,10 +49,15 @@ void init(void) {
GPIOA_AFRH = 0x00000222; // A8 (TIM1_CH1), A9 (TIM1_CH2), A10 (TIM1_CH3)
GPIOB_AFRL = 0x00000022; // B0 (TIM1_CH2N), B1 (TIM1_CH3N)
GPIOB_AFRH = 0x00000000;
GPIOA_PUPDR = 0x24000010; // A2 (pull-up)
GPIOA_PUPDR = 0x24000000;
GPIOB_PUPDR = 0x00001000; // B6 (pull-up)
GPIOA_MODER = 0xebeabfef; // A2 (TIM15_CH1), A7 (TIM1_CH1N), A8 (TIM1_CH1), A9 (TIM1_CH2), A10 (TIM1_CH3)
GPIOA_MODER = 0xebeabfff; // A7 (TIM1_CH1N), A8 (TIM1_CH1), A9 (TIM1_CH2), A10 (TIM1_CH3)
GPIOB_MODER = 0xffffeffa; // B0 (TIM1_CH2N), B1 (TIM1_CH3N), B6 (USART1_TX)
#ifndef ANALOG
RCC_APB2ENR |= RCC_APB2ENR_TIM15EN;
GPIOA_PUPDR |= 0x10; // A2 (pull-up)
GPIOA_MODER &= ~0x10; // A2 (TIM15_CH1)
#endif

nvic_set_priority(NVIC_TIM15_IRQ, 0x40);
nvic_set_priority(NVIC_USART1_IRQ, 0x80);
Expand Down Expand Up @@ -85,8 +90,7 @@ void init(void) {
ADC1_SQR3 = SENS_CHAN;
len = SENS_CNT;
if (IO_ANALOG) {
ADC1_SQR3 |= 0x2 << (len * 5); // A2 (throt)
++len;
ADC1_SQR3 |= THROT_CHAN << (len++ * 5);
ain = 1;
}
ADC1_SQR3 |= 0x230 << (len * 5); // CH16 (temp), CH17 (vref)
Expand Down
4 changes: 4 additions & 0 deletions mcu/GD32E230/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
#define SENS_CHAN 0x3
#endif

#ifndef THROT_CHAN
#define THROT_CHAN 2 // A2
#endif

#define CLK 72000000
#define IO_PA2
#define IO_TYPE 0
Expand Down
33 changes: 33 additions & 0 deletions mcu/GD32E230/preset.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
** Copyright (C) 2022-2023 Arseny Vakhrushev <[email protected]>
**
** This firmware is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This firmware is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this firmware. If not, see <http://www.gnu.org/licenses/>.
*/

#include "common.h"

const uint16_t sinedata[] = {
240, 244, 248, 253, 257, 261, 265, 269, 273, 278, 282, 286, 290, 294, 298, 302, 306, 310, 314, 318, 322, 326, 330, 334, 338, 341, 345, 349, 353, 356,
360, 364, 367, 371, 374, 378, 381, 384, 388, 391, 394, 397, 401, 404, 407, 410, 413, 416, 418, 421, 424, 427, 429, 432, 434, 437, 439, 441, 444, 446,
448, 450, 452, 454, 456, 458, 459, 461, 463, 464, 466, 467, 468, 470, 471, 472, 473, 474, 475, 476, 476, 477, 478, 478, 479, 479, 479, 480, 480, 480,
480, 480, 480, 480, 479, 479, 479, 478, 478, 477, 476, 476, 475, 474, 473, 472, 471, 470, 468, 467, 466, 464, 463, 461, 459, 458, 456, 454, 452, 450,
448, 446, 444, 441, 439, 437, 434, 432, 429, 427, 424, 421, 418, 416, 413, 410, 407, 404, 401, 397, 394, 391, 388, 384, 381, 378, 374, 371, 367, 364,
360, 356, 353, 349, 345, 341, 338, 334, 330, 326, 322, 318, 314, 310, 306, 302, 298, 294, 290, 286, 282, 278, 273, 269, 265, 261, 257, 253, 248, 244,
240, 236, 232, 227, 223, 219, 215, 211, 207, 202, 198, 194, 190, 186, 182, 178, 174, 170, 166, 162, 158, 154, 150, 146, 142, 139, 135, 131, 127, 124,
120, 116, 113, 109, 106, 102, 99, 96, 92, 89, 86, 83, 79, 76, 73, 70, 67, 64, 62, 59, 56, 53, 51, 48, 46, 43, 41, 39, 36, 34,
32, 30, 28, 26, 24, 22, 21, 19, 17, 16, 14, 13, 12, 10, 9, 8, 7, 6, 5, 4, 4, 3, 2, 2, 1, 1, 1, 0, 0, 0,
0, 0, 0, 0, 1, 1, 1, 2, 2, 3, 4, 4, 5, 6, 7, 8, 9, 10, 12, 13, 14, 16, 17, 19, 21, 22, 24, 26, 28, 30,
32, 34, 36, 39, 41, 43, 46, 48, 51, 53, 56, 59, 62, 64, 67, 70, 73, 76, 79, 83, 86, 89, 92, 96, 99, 102, 106, 109, 113, 116,
120, 124, 127, 131, 135, 139, 142, 146, 150, 154, 158, 162, 166, 170, 174, 178, 182, 186, 190, 194, 198, 202, 207, 211, 215, 219, 223, 227, 232, 236,
};
15 changes: 9 additions & 6 deletions mcu/STM32F051/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#define COMP_CSR MMIO32(SYSCFG_COMP_BASE + 0x1c)

static uint16_t buf[10];
static uint16_t buf[5];
static char len, ain;

void init(void) {
Expand All @@ -43,6 +43,7 @@ void init(void) {
GPIOB_PUPDR = 0x00001000; // B6 (pull-up)
GPIOA_MODER = 0xebeabfff; // A7 (TIM1_CH1N), A8 (TIM1_CH1), A9 (TIM1_CH2), A10 (TIM1_CH3)
GPIOB_MODER = 0xffffeffa; // B0 (TIM1_CH2N), B1 (TIM1_CH3N), B6 (USART1_TX)
#ifndef ANALOG
#ifdef IO_PA2
RCC_APB2ENR |= RCC_APB2ENR_TIM15EN;
GPIOA_PUPDR |= 0x10; // A2 (pull-up)
Expand All @@ -52,6 +53,7 @@ void init(void) {
GPIOB_AFRL |= 0x10000; // B4 (TIM3_CH1)
GPIOB_PUPDR |= 0x100; // B4 (pull-up)
GPIOB_MODER &= ~0x100; // B4 (TIM3_CH1)
#endif
#endif

nvic_set_priority(NVIC_TIM3_IRQ, 0x40);
Expand Down Expand Up @@ -82,9 +84,9 @@ void init(void) {
ADC1_CHSELR = SENS_CHAN | 0x30000; // CH16 (temp), CH17 (vref)
len = SENS_CNT + 2;
if (IO_ANALOG) {
ADC1_CHSELR |= 0x4; // A2 (throt)
++len;
ADC1_CHSELR |= THROT_CHAN;
ain = 1;
++len;
}
DMA1_CPAR(1) = (uint32_t)&ADC1_DR;
DMA1_CMAR(1) = (uint32_t)buf;
Expand Down Expand Up @@ -114,7 +116,6 @@ void compctl(int x) {
COMP_CSR = cr;
}

#ifdef IO_PA2
void io_serial(void) {
TIM15_DIER = 0;
nvic_clear_pending_irq(NVIC_TIM15_IRQ);
Expand All @@ -130,7 +131,6 @@ void io_analog(void) {
GPIOA_PUPDR &= ~0x30; // A2 (no pull-up/pull-down)
GPIOA_MODER |= 0x30; // A2 (analog)
}
#endif

void adc_trig(void) {
if (DMA1_CCR(1) & DMA_CCR_EN) return;
Expand All @@ -157,7 +157,7 @@ void dma1_channel1_isr(void) {
DMA1_IFCR = DMA_IFCR_CTCIF(1);
DMA1_CCR(1) = 0;
int i = 0, v = 0, c = 0, x = 0;
#ifdef IO_PA2
#ifndef THROT_LAST
if (ain) x = buf[i++];
#endif
#ifdef SENS_SWAP
Expand All @@ -170,6 +170,9 @@ void dma1_channel1_isr(void) {
#if SENS_CNT >= 1
v = buf[i++];
#endif
#endif
#ifdef THROT_LAST
if (ain) x = buf[i++];
#endif
int r = ST_VREFINT_CAL * 3300 / buf[i + 1];
int t = (buf[i] * r / 3300 - ST_TSENSE_CAL1_30C) * 80 / (ST_TSENSE_CAL2_110C - ST_TSENSE_CAL1_30C) + 30;
Expand Down
4 changes: 4 additions & 0 deletions mcu/STM32F051/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
#define SENS_CHAN 0x40
#endif

#ifndef THROT_CHAN
#define THROT_CHAN 0x4 // A2
#endif

#define CLK 48000000

#define IFTIM TIM2
Expand Down
33 changes: 33 additions & 0 deletions mcu/STM32F051/preset.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
** Copyright (C) 2022-2023 Arseny Vakhrushev <[email protected]>
**
** This firmware is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This firmware is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this firmware. If not, see <http://www.gnu.org/licenses/>.
*/

#include "common.h"

const uint16_t sinedata[] = {
160, 163, 166, 168, 171, 174, 177, 179, 182, 185, 188, 191, 193, 196, 199, 201, 204, 207, 209, 212, 215, 217, 220, 223, 225, 228, 230, 233, 235, 238,
240, 242, 245, 247, 249, 252, 254, 256, 259, 261, 263, 265, 267, 269, 271, 273, 275, 277, 279, 281, 283, 284, 286, 288, 289, 291, 293, 294, 296, 297,
299, 300, 301, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 315, 316, 317, 317, 318, 318, 318, 319, 319, 319, 320, 320, 320, 320,
320, 320, 320, 320, 320, 319, 319, 319, 318, 318, 318, 317, 317, 316, 315, 315, 314, 313, 312, 311, 310, 309, 308, 307, 306, 305, 304, 303, 301, 300,
299, 297, 296, 294, 293, 291, 289, 288, 286, 284, 283, 281, 279, 277, 275, 273, 271, 269, 267, 265, 263, 261, 259, 256, 254, 252, 249, 247, 245, 242,
240, 238, 235, 233, 230, 228, 225, 223, 220, 217, 215, 212, 209, 207, 204, 201, 199, 196, 193, 191, 188, 185, 182, 179, 177, 174, 171, 168, 166, 163,
160, 157, 154, 152, 149, 146, 143, 141, 138, 135, 132, 129, 127, 124, 121, 119, 116, 113, 111, 108, 105, 103, 100, 97, 95, 92, 90, 87, 85, 82,
80, 78, 75, 73, 71, 68, 66, 64, 61, 59, 57, 55, 53, 51, 49, 47, 45, 43, 41, 39, 37, 36, 34, 32, 31, 29, 27, 26, 24, 23,
21, 20, 19, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 5, 4, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0, 0, 0,
0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 5, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 19, 20,
21, 23, 24, 26, 27, 29, 31, 32, 34, 36, 37, 39, 41, 43, 45, 47, 49, 51, 53, 55, 57, 59, 61, 64, 66, 68, 71, 73, 75, 78,
80, 82, 85, 87, 90, 92, 95, 97, 100, 103, 105, 108, 111, 113, 116, 119, 121, 124, 127, 129, 132, 135, 138, 141, 143, 146, 149, 152, 154, 157,
};
Loading

0 comments on commit 4814601

Please sign in to comment.