Skip to content

Commit

Permalink
ADD: default device configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
r2axz committed Nov 18, 2020
1 parent 40db33f commit 3e452e8
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# General Target Settings
TARGET = bluepill-serial-monster
SRCS = main.c system_clock.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
SRCS = main.c system_clock.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 dev_config.c

# Toolchain & Utils
CC = arm-none-eabi-gcc
Expand Down
2 changes: 1 addition & 1 deletion cdc_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ typedef struct {
} __attribute__ ((packed)) cdc_port_t;

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

#endif /* CDC_CONFIG_H */
48 changes: 48 additions & 0 deletions dev_config.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include <stm32f1xx.h>
#include "dev_config.h"

static const device_config_t default_device_config = {
.cdc_config = {
.port_config = {
/* Port 0 */
{
.pins =
{
/* rx */ { .port = GPIOA, .pin = 10, .dir = gpio_dir_input, .pull = gpio_pull_up, .polarity = gpio_polarity_high },
/* tx */ { .port = GPIOA, .pin = 9, .dir = gpio_dir_output, .speed = gpio_speed_medium, .func = gpio_func_alternate, .output = gpio_output_pp },
/* rts */ { .port = 0 }, /* No RTS due to the below reason */
/* cts */ { .port = 0 }, /* CTS pin is occupied by USB */
/* dsr */ { .port = GPIOB, .pin = 7, .dir = gpio_dir_input, .pull = gpio_pull_up, .polarity = gpio_polarity_low },
/* dtr */ { .port = GPIOA, .pin = 4, .dir = gpio_dir_output, .speed = gpio_speed_medium, .func = gpio_func_general, .polarity = gpio_polarity_low },
/* dcd */ { .port = GPIOB, .pin = 15, .dir = gpio_dir_input, .pull = gpio_pull_up, .polarity = gpio_polarity_low },
}
},
/* Port 1 */
{
.pins =
{
/* rx */ { .port = GPIOA, .pin = 3, .dir = gpio_dir_input, .pull = gpio_pull_up, .polarity = gpio_polarity_high },
/* tx */ { .port = GPIOA, .pin = 2, .dir = gpio_dir_output, .speed = gpio_speed_medium, .func = gpio_func_alternate, .output = gpio_output_pp },
/* rts */ { .port = GPIOA, .pin = 1, .dir = gpio_dir_output, .speed = gpio_speed_medium, .func = gpio_func_alternate, .output = gpio_output_pp },
/* cts */ { .port = GPIOA, .pin = 0, .dir = gpio_dir_input, .pull = gpio_pull_down, .polarity = gpio_polarity_low },
/* dsr */ { .port = GPIOB, .pin = 4, .dir = gpio_dir_input, .pull = gpio_pull_up, .polarity = gpio_polarity_low },
/* dtr */ { .port = GPIOA, .pin = 5, .dir = gpio_dir_output, .speed = gpio_speed_medium, .func = gpio_func_general, .polarity = gpio_polarity_low },
/* dcd */ { .port = GPIOB, .pin = 8, .dir = gpio_dir_input, .pull = gpio_pull_up, .polarity = gpio_polarity_low },
}
},
/* Port 2 */
{
.pins =
{
/* rx */ { .port = GPIOB, .pin = 11, .dir = gpio_dir_input, .pull = gpio_pull_up, .polarity = gpio_polarity_high },
/* tx */ { .port = GPIOB, .pin = 10, .dir = gpio_dir_output, .speed = gpio_speed_medium, .func = gpio_func_alternate, .output = gpio_output_pp },
/* rts */ { .port = GPIOB, .pin = 14, .dir = gpio_dir_output, .speed = gpio_speed_medium, .func = gpio_func_alternate, .output = gpio_output_pp },
/* cts */ { .port = GPIOB, .pin = 13, .dir = gpio_dir_input, .pull = gpio_pull_down, .polarity = gpio_polarity_low },
/* dsr */ { .port = GPIOB, .pin = 6, .dir = gpio_dir_input, .pull = gpio_pull_up, .polarity = gpio_polarity_low },
/* dtr */ { .port = GPIOA, .pin = 6, .dir = gpio_dir_output, .speed = gpio_speed_medium, .func = gpio_func_general, .polarity = gpio_polarity_low },
/* dcd */ { .port = GPIOB, .pin = 9, .dir = gpio_dir_input, .pull = gpio_pull_up, .polarity = gpio_polarity_low },
}
},
}
}
};

0 comments on commit 3e452e8

Please # to comment.