|
| 1 | +/* |
| 2 | + * SPDX-FileCopyrightText: 2025 TU Dresden |
| 3 | + * SPDX-License-Identifier: LGPL-2.1-only |
| 4 | + */ |
| 5 | + |
| 6 | +#pragma once |
| 7 | + |
| 8 | +/** |
| 9 | + * @ingroup boards_bitcraze_crazyflie21_main |
| 10 | + * @{ |
| 11 | + * |
| 12 | + * @file |
| 13 | + * @brief Board specific definitions for the Crazyflie 2.1 main application MCU |
| 14 | + * |
| 15 | + * @author Leonard Herbst <[email protected]> |
| 16 | + */ |
| 17 | + |
| 18 | +#include "cpu.h" |
| 19 | +#include "motor_driver.h" |
| 20 | + |
| 21 | +#ifdef __cplusplus |
| 22 | +extern "C" { |
| 23 | +#endif |
| 24 | + |
| 25 | +/** |
| 26 | + * @name Macros for controlling the on-board LEDs. |
| 27 | + * @{ |
| 28 | + */ |
| 29 | +#define LED0_IS_INVERTED 1 |
| 30 | +#define LED0_PIN_NUM 3 /* LED top right red */ |
| 31 | +#define LED0_PORT GPIO_PORT_C |
| 32 | +#define LED0_PORT_NUM PORT_C |
| 33 | + |
| 34 | +#define LED1_IS_INVERTED 1 |
| 35 | +#define LED1_PIN_NUM 2 /* LED top right green */ |
| 36 | +#define LED1_PORT GPIO_PORT_C |
| 37 | +#define LED1_PORT_NUM PORT_C |
| 38 | + |
| 39 | +#define LED2_PIN_NUM 2 /* LED bottom left blue */ |
| 40 | +#define LED2_PORT GPIO_PORT_D |
| 41 | +#define LED2_PORT_NUM PORT_D |
| 42 | + |
| 43 | +#define LED3_IS_INVERTED 1 |
| 44 | +#define LED3_PIN_NUM 0 /* LED top left red*/ |
| 45 | +#define LED3_PORT GPIO_PORT_C |
| 46 | +#define LED3_PORT_NUM PORT_C |
| 47 | + |
| 48 | +#define LED4_IS_INVERTED 1 |
| 49 | +#define LED4_PIN_NUM 1 /* LED top left green */ |
| 50 | +#define LED4_PORT GPIO_PORT_C |
| 51 | +#define LED4_PORT_NUM PORT_C |
| 52 | +/** @} */ |
| 53 | + |
| 54 | +/** |
| 55 | + * @name Describe DC motors with PWM channel and GPIOs |
| 56 | + * @{ |
| 57 | + */ |
| 58 | +/** Motor driver config. Two driver with three and one motor attached respectively */ |
| 59 | +static const motor_driver_config_t motor_driver_config[] = { |
| 60 | + { |
| 61 | + .pwm_dev = 1, |
| 62 | + .mode = MOTOR_DRIVER_1_DIR, |
| 63 | + .mode_brake = MOTOR_BRAKE_HIGH, |
| 64 | + .pwm_mode = PWM_LEFT, |
| 65 | + .pwm_frequency = 20000U, |
| 66 | + .pwm_resolution = 4200U, |
| 67 | + .nb_motors = 3, |
| 68 | + .motors = { |
| 69 | + { |
| 70 | + .pwm_channel = 1, |
| 71 | + .gpio_enable = 0, |
| 72 | + .gpio_dir0 = 0, |
| 73 | + .gpio_dir1_or_brake = 0, |
| 74 | + .gpio_dir_reverse = 0, |
| 75 | + .gpio_enable_invert = 0, |
| 76 | + .gpio_brake_invert = 0, |
| 77 | + }, |
| 78 | + { |
| 79 | + .pwm_channel = 3, |
| 80 | + .gpio_enable = 0, |
| 81 | + .gpio_dir0 = 0, |
| 82 | + .gpio_dir1_or_brake = 0, |
| 83 | + .gpio_dir_reverse = 0, |
| 84 | + .gpio_enable_invert = 0, |
| 85 | + .gpio_brake_invert = 0, |
| 86 | + }, |
| 87 | + { |
| 88 | + .pwm_channel = 0, |
| 89 | + .gpio_enable = 0, |
| 90 | + .gpio_dir0 = 0, |
| 91 | + .gpio_dir1_or_brake = 0, |
| 92 | + .gpio_dir_reverse = 0, |
| 93 | + .gpio_enable_invert = 0, |
| 94 | + .gpio_brake_invert = 0, |
| 95 | + }, |
| 96 | + }, |
| 97 | + .cb = NULL, |
| 98 | + }, |
| 99 | + { |
| 100 | + .pwm_dev = 2, |
| 101 | + .mode = MOTOR_DRIVER_1_DIR, |
| 102 | + .mode_brake = MOTOR_BRAKE_HIGH, |
| 103 | + .pwm_mode = PWM_LEFT, |
| 104 | + .pwm_frequency = 20000U, |
| 105 | + .pwm_resolution = 4200U, |
| 106 | + .nb_motors = 1, |
| 107 | + .motors = { |
| 108 | + { |
| 109 | + .pwm_channel = 0, |
| 110 | + .gpio_enable = 0, |
| 111 | + .gpio_dir0 = 0, |
| 112 | + .gpio_dir1_or_brake = 0, |
| 113 | + .gpio_dir_reverse = 0, |
| 114 | + .gpio_enable_invert = 0, |
| 115 | + .gpio_brake_invert = 0, |
| 116 | + }, |
| 117 | + }, |
| 118 | + .cb = NULL, |
| 119 | + } |
| 120 | +}; |
| 121 | + |
| 122 | +/** Number of motor drivers */ |
| 123 | +#define MOTOR_DRIVER_NUMOF ARRAY_SIZE(motor_driver_config) |
| 124 | +/** @} */ |
| 125 | + |
| 126 | +#ifdef __cplusplus |
| 127 | +} |
| 128 | +#endif |
| 129 | + |
| 130 | +#include "stm32_leds.h" |
| 131 | +/** @} */ |
0 commit comments