Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
board.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2016-2017 Freie Universität Berlin
3
*
4
* This file is subject to the terms and conditions of the GNU Lesser
5
* General Public License v2.1. See the file LICENSE in the top level
6
* directory for more details.
7
*/
8
22
#ifndef BOARD_H
23
#define BOARD_H
24
25
#include "
board_nucleo.h
"
26
#include "
arduino_pinmap.h
"
27
#include "
motor_driver.h
"
28
29
#ifdef __cplusplus
30
extern
"C"
{
31
#endif
32
37
#if defined(CPU_MODEL_STM32F302R8) || defined(CPU_MODEL_STM32L433RC)
38
#define LED0_PORT GPIOB
39
#define LED0_PIN GPIO_PIN(PORT_B, 13)
40
#define LED0_MASK (1 << 13)
41
#else
42
#define LED0_PORT GPIOA
43
#define LED0_PIN GPIO_PIN(PORT_A, 5)
44
#define LED0_MASK (1 << 5)
45
#endif
46
47
#define LED0_ON (LED0_PORT->BSRR = LED0_MASK)
48
#define LED0_OFF (LED0_PORT->BSRR = (LED0_MASK << 16))
49
#define LED0_TOGGLE (LED0_PORT->ODR ^= LED0_MASK)
50
56
#define BTN0_PIN GPIO_PIN(PORT_C, 13)
57
#if defined(CPU_MODEL_STM32L433RC) || defined(CPU_MODEL_STM32G474RE) || \
58
defined(CPU_MODEL_STM32G431RB)
59
#define BTN0_MODE GPIO_IN_PD
60
#else
61
#define BTN0_MODE GPIO_IN_PU
62
#endif
63
69
static
const
motor_driver_config_t
motor_driver_config[] = {
70
{
71
.
pwm_dev
= 1,
72
.mode =
MOTOR_DRIVER_1_DIR
,
73
.mode_brake =
MOTOR_BRAKE_HIGH
,
74
.pwm_mode =
PWM_LEFT
,
75
.pwm_frequency = 20000U,
76
.pwm_resolution = 2250U,
77
.nb_motors = 1,
78
.motors = {
79
{
80
.pwm_channel = 0,
81
.gpio_enable = 0,
82
.gpio_dir0 = ARDUINO_PIN_15,
83
.gpio_dir1_or_brake = 0,
84
.gpio_dir_reverse = 0,
85
.gpio_enable_invert = 0,
86
.gpio_brake_invert = 0,
87
},
88
},
89
.cb = NULL,
90
},
91
};
92
93
#define MOTOR_DRIVER_NUMOF ARRAY_SIZE(motor_driver_config)
94
96
#ifdef __cplusplus
97
}
98
#endif
99
100
#endif
/* BOARD_H */
101
motor_driver.h
High-level driver for DC motors.
motor_driver_config_t::pwm_dev
pwm_t pwm_dev
PWM device driving motors.
Definition:
motor_driver.h:169
MOTOR_BRAKE_HIGH
@ MOTOR_BRAKE_HIGH
High stage brake.
Definition:
motor_driver.h:129
arduino_pinmap.h
Mapping from MCU pins to Arduino pins.
MOTOR_DRIVER_1_DIR
@ MOTOR_DRIVER_1_DIR
Single GPIO for direction, \ no BRAKE.
Definition:
motor_driver.h:118
PWM_LEFT
@ PWM_LEFT
left aligned PWM
Definition:
periph_cpu.h:160
motor_driver_config_t
Describe DC motor driver with PWM device and motors array.
Definition:
motor_driver.h:168
board_nucleo.h
Global common Nucleo board configuration.
Generated on Tue Nov 24 2020 19:46:49 by
1.8.17