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 #ifdef CPU_MODEL_STM32L433RC
58 #define BTN0_MODE GPIO_IN_PD
59 #else
60 #define BTN0_MODE GPIO_IN_PU
61 #endif
62 
68 static const motor_driver_config_t motor_driver_config[] = {
69  {
70  .pwm_dev = 1,
71  .mode = MOTOR_DRIVER_1_DIR,
72  .mode_brake = MOTOR_BRAKE_HIGH,
73  .pwm_mode = PWM_LEFT,
74  .pwm_frequency = 20000U,
75  .pwm_resolution = 2250U,
76  .nb_motors = 1,
77  .motors = {
78  {
79  .pwm_channel = 0,
80  .gpio_enable = 0,
81  .gpio_dir0 = ARDUINO_PIN_15,
82  .gpio_dir1_or_brake = 0,
83  .gpio_dir_reverse = 0,
84  .gpio_enable_invert = 0,
85  .gpio_brake_invert = 0,
86  },
87  },
88  .cb = NULL,
89  },
90 };
91 
92 #define MOTOR_DRIVER_NUMOF ARRAY_SIZE(motor_driver_config)
93 
95 #ifdef __cplusplus
96 }
97 #endif
98 
99 #endif /* BOARD_H */
100 
High stage brake.
Definition: motor_driver.h:123
pwm_t pwm_dev
PWM device driving motors.
Definition: motor_driver.h:163
Single GPIO for direction, \ no BRAKE.
Definition: motor_driver.h:112
Global common Nucleo board configuration.
left aligned PWM
Definition: periph_cpu.h:138
High-level driver for DC motors.
Mapping from MCU pins to Arduino pins.
Describe DC motor driver with PWM device and motors array.
Definition: motor_driver.h:162