Warning: Undefined array key "rss_show_deleted" in /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php on line 86
Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/feed.php on line 53
Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/feed.php on line 54
Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/feed.php on line 55
Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/feed.php on line 56
Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/inc/httputils.php on line 32
Warning: Cannot modify header information - headers already sent by (output started at /var/www/w12/dw/inc/Feed/FeedCreatorOptions.php:86) in /var/www/w12/dw/inc/httputils.php on line 33 wi12.unix7.org - stm32
https://w12.unix7.org/
Wed, 05 Aug 2026 03:50:44 +0000FeedCreator 1.8https://w12.unix7.org/_media/wiki/dokuwiki.svgwi12.unix7.org
https://w12.unix7.org/
STM32 F103 ADC, injected and regular
https://w12.unix7.org/stm32/adc
c embed
STM32 F103 ADC, injected and regular
Injected ADC
/* Author, Copyright: Oleg Borodin */
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/usart.h>
#include <libopencm3/stm32/adc.h>
#include <libopencm3/stm32/dma.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <wctype.h>
#include <ctype.h>
#include <time.h>
#include <string.h>
void delay(uint32_t n) {
for (volatile int i = 0; i < n; i++)
__asm__("nop")…anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000DSHOT draft on opencm3
https://w12.unix7.org/stm32/dshot01
DSHOT draft on opencm3
Also there <https://github.com/kindsoldier/flightdrafts/tree/master/dshot300>
/*
* Copyright 2022 Oleg Borodin <borodin@unix7.org>
*/
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/timer.h>
#include <libopencm3/stm32/dma.h>
#include <libopencm3/cm3/nvic.h>
static void timer_gpio_setup(uint32_t gpio_group, uint32_t gpio_af, uint32_t gpio_pin) {
gpio_mode_setup(gpio_group, GPIO_MODE_AF, GPIO_PUPD_NONE, gpio_pin)…anonymous@undisclosed.example.com (Anonymous)Wed, 14 Sep 2022 00:30:10 +0000STM32 I2C bus code
https://w12.unix7.org/stm32/i2c
c embed
STM32 I2C bus code
I wrote the code “from scratch”.
* [STM32F10xxx I2C optimized examples]
/* Author, Copyright: Oleg Borodin */
#include <libopencm3/stm32/i2c.h>
#include <stdlib.h>
#include <i2creg.h>
uint16_t i2c_read_seq(uint32_t i2c, uint16_t addr, uint8_t reg, uint8_t *data, uint16_t len) {
i2c_enable_ack(i2c);
i2c_send_start(i2c);
/* I2C_EVENT_MASTER_MODE_SELECT EV5: BUSY, MSL and SB */
while (!((I2C_SR1(i2c) & I2C_SR1_SB) &
(I2C_SR2(i2c…anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000MPU6050
https://w12.unix7.org/stm32/mpu
c embed
MPU6050
Polling mode
void mpu_setup(void) {
gpio_set_mode(GPIOB, GPIO_MODE_OUTPUT_50_MHZ,
GPIO_CNF_OUTPUT_ALTFN_OPENDRAIN, GPIO_I2C1_SCL | GPIO_I2C1_SDA);
i2c_peripheral_disable(I2C1);
i2c_reset(I2C1);
i2c_set_speed(I2C1, i2c_speed_fm_400k, I2C_CR2_FREQ_36MHZ);
i2c_set_dutycycle(I2C1, I2C_CCR_DUTY_DIV2);
i2c_peripheral_enable(I2C1);
}
uint8_t mpu_read_reg(uint32_t i2c, uint16_t addr, uint8_t reg) {
uint8_t data = 0;
i2c_enable_ack(i2c);
…anonymous@undisclosed.example.com (Anonymous)Sat, 27 Nov 2021 13:26:11 +0000STM32 task scheduler
https://w12.unix7.org/stm32/nanoos
STM32 task scheduler
Full code on <https://github.com/kindsoldier/stm32nanoos>
Lib:
* <http://we.easyelectronics.ru/STM32/atomarnye-operacii-v-cortex-m3.html>
* <https://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html>
* <https://ask-dev.ru/info/26222/spinlock-versus-semaphore>
/*
* Copyright 2022 Oleg Borodin <borodin@unix7.org>
*/
#include <libopencm3/cm3/nvic.h>
#include <libopencm3/cm3/systick.h>
#include <libopencm3/cm3/scb.h>
#include <libopencm3/stm32/rcc.h>
#inc…anonymous@undisclosed.example.com (Anonymous)Tue, 30 Aug 2022 17:48:36 +0000STM32 PWM with opencm3 and on CMSIS
https://w12.unix7.org/stm32/pwm
STM32 PWM with opencm3 and on CMSIS
#include <libopencm3/cm3/nvic.h>
#include <libopencm3/stm32/rcc.h>
#include <libopencm3/stm32/gpio.h>
#include <libopencm3/stm32/timer.h>
void delay(uint32_t n) {
for (volatile int i = 0; i < n; i++)
__asm__("nop");
}
int main(void) {
rcc_clock_setup_pll(&rcc_hse_configs[RCC_CLOCK_HSE8_72MHZ]);
rcc_periph_clock_enable(RCC_GPIOA);
rcc_periph_clock_enable(RCC_TIM5);
rcc_periph_reset_pulse(RST_TIM5);
gpio_set_mode(GPIOA, …anonymous@undisclosed.example.com (Anonymous)Thu, 25 Aug 2022 17:14:07 +0000