Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic control #63

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# General Target Settings
TARGET = bluepill-serial-monster
SRCS = main.c system_clock.c system_interrupts.c status_led.c usb_core.c usb_descriptors.c\
usb_io.c usb_uid.c usb_panic.c usb_cdc.c cdc_shell.c gpio.c device_config.c
usb_io.c usb_uid.c usb_panic.c usb_cdc.c cdc_shell.c gpio.c gpion.c device_config.c default_config.c

# Toolchain & Utils
CROSS_COMPILE ?= arm-none-eabi-
Expand All @@ -24,11 +24,11 @@ STM32_INCLUDES += -I$(STM32CUBE)/Drivers/CMSIS/Device/ST/STM32F1xx/Include

DEFINES = -DSTM32F103xB -DHSE_VALUE=8000000U
CPUFLAGS = -mthumb -mcpu=cortex-m3
WARNINGS = -Wall
OPTIMIZATION = -O3
WARNINGS = -Wall -Werror # -Wextra
OPTIMIZATION = #-O3
DEBUG = -ggdb

CFLAGS = $(DEFINES) $(STM32_INCLUDES) $(CPUFLAGS) $(WARNINGS) $(OPTIMIZATION) $(DEBUG)
CFLAGS = $(DEFINES) $(STM32_INCLUDES) $(CPUFLAGS) $(WARNINGS) $(OPTIMIZATION) $(DEBUG)
LDFLAGS = $(CPUFLAGS) -T$(STM32_LDSCRIPT) --specs=nosys.specs --specs=nano.specs
DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.d

Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,8 +198,9 @@ _bluepill-serial-monster_ provides a configuration shell that allows
controlling various parameters of the UART signal lines.

To access the configuration shell, open the first USB serial port (UART1)
with any terminal emulator application (such as _screen_, _Tera Term_, etc.)
and connect **PB5** to ground. Serial port settings do not matter.
with any terminal emulator application (such as _screen_, _Tera Term_, etc.). It
is enabled by default. To disable configuration shell - connect **PB5** to
ground. Serial port settings do not matter.

You should see the configuration shell prompt:

Expand Down
43 changes: 43 additions & 0 deletions aux.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* MIT License
*
* Copyright (c) 2022 Yury Shvedov
*/

#ifndef AUX_H
#define AUX_H

#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) // From linux kernel
#define BUILD_BUG_ON_RET(condition, ret) ({ BUILD_BUG_ON(condition); (ret); })

#ifndef __packed
#define __packed __attribute__ ((packed))
#endif

#ifndef __packed_aligned
#define __packed_aligned(n) __attribute__ ((packed, aligned(n)))
#endif

#ifndef __wpacked
#define __wpacked __packed_aligned(4)
#endif

#ifndef __spacked
#define __spacked __packed_aligned(2)
#endif

#ifndef __aligned
#define __aligned(n) __attribute__ ((aligned(n)))
#endif

#ifndef __noinline
#define __noinline __attribute__ ((noinline))
#endif

#ifndef __always_inline
#define __always_inline __attribute__ ((always_inline))
#endif


#endif /* AUX_H */
12 changes: 6 additions & 6 deletions cdc_config.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/*
* MIT License
*
* MIT License
*
* Copyright (c) 2020 Kirill Kotyagin
*/

#ifndef CDC_CONFIG_H
#define CDC_CONFIG_H

#include "gpio.h"
#include "gpion.h"
#include "usb_cdc.h"

typedef struct {
gpio_pin_t pins[cdc_pin_last];
} __attribute__ ((packed)) cdc_port_t;
gpion_pin_t pins[cdc_pin_last];
} cdc_port_t;

typedef struct {
cdc_port_t port_config[USB_CDC_NUM_PORTS];
} __attribute__ ((packed)) cdc_config_t;
} cdc_config_t;

#endif /* CDC_CONFIG_H */
Loading