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

Yardforce 500b #12

Open
wants to merge 22 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
030a57e
Start board support for yardforce 500B
Janrupf Jun 24, 2023
54f42f1
Replace board specific includes with generic one
Janrupf Jun 24, 2023
f96b4e4
Port adc.c to STM32f4
Janrupf Jun 24, 2023
463c23a
Port blademotor.c to STM32f4
Janrupf Jun 24, 2023
696028c
Port drivemotor.c to STM32f4
Janrupf Jun 24, 2023
8e96ff8
Port perimeter.c to STM32f4
Janrupf Jun 24, 2023
75e84cb
Port panel.c to STM32f4
Janrupf Jun 24, 2023
26a2a4f
Port soft_i2c.c to STM32f4
Janrupf Jun 24, 2023
6e6c326
Port main.c to STM32f4
Janrupf Jun 24, 2023
6af29b9
Port compiles
Janrupf Jun 24, 2023
45d8c26
Fix hardware initialization for stm32f4.
slashphotos Jun 30, 2023
e4aa722
Add alternate function to blademotor usart pins
Jul 1, 2023
3433f27
Fix infinite check of blademotor DMA and UART caused by RX/TX mistake.
slashphotos Jul 4, 2023
86f1353
Fix bug in ADC init. Use the right trigger.
slashphotos Jul 7, 2023
d79052a
Fix 500b system clock
benjaminlundgreen Aug 31, 2023
69d6568
Fix UART pin definition so interrupt fires (Drive)
wjcloudy Sep 5, 2023
e4dbbf9
Fix UART pin definition so interrupt fires (Blade)
wjcloudy Sep 5, 2023
1c0535b
Add back __HAL_RCC_PWR_CLK_ENABLE() call for 500 classic
jeremysalwen May 11, 2024
b465a18
Fix double definition warning in board.h for 500b
jeremysalwen May 11, 2024
3aa2285
Remove accidentally committed files
jeremysalwen May 11, 2024
b36ab84
Fix startup assembly bugs in 500b
jeremysalwen Jul 29, 2024
3acdbe2
Add framework-stm32cubef4 to platform.ini
jeremysalwen Aug 11, 2024
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
.DS_Store
sync_msg.sh
sync_msg.sh
.idea/
7 changes: 0 additions & 7 deletions stm32/mainboard_firmware/debug.cfg

This file was deleted.

Binary file removed stm32/mainboard_firmware/orig_firmware.bin
Binary file not shown.
5 changes: 4 additions & 1 deletion stm32/ros_usbnode/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,7 @@ __pycache__
*.o
raspi_remote_upload.py
platformio.ini
*.bin
*.bin
CMakeLists.txt
CMakeListsPrivate.txt
cmake-build*
47 changes: 47 additions & 0 deletions stm32/ros_usbnode/boards/genericSTM32F401VC.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"build": {
"core": "stm32",
"cpu": "cortex-m4",
"extra_flags": "-DSTM32F4xx -DSTM32F401xC -DSTM32F401VC",
"f_cpu": "84000000L",
"mcu": "stm32f401vct6",
"product_line": "STM32F401xx"
},
"connectivity": [
"can",
"ethernet"
],
"debug": {
"default_tools": [
"stlink"
],
"jlink_device": "STM32F401VC",
"onboard_tools": [
"stlink"
],
"openocd_target": "stm32f4x",
"svd_path": "STM32F40x.svd"
},
"frameworks": [
"stm32cube"
],
"name": "STM32F401VC (48k RAM, 256k Flash)",
"upload": {
"disable_flushing": false,
"maximum_ram_size": 49152,
"maximum_size": 262144,
"protocol": "stlink",
"protocols": [
"jlink",
"stlink",
"blackmagic",
"mbed",
"dfu"
],
"require_upload_port": true,
"use_1200bps_touch": false,
"wait_for_upload_port": false
},
"url": "https://www.st.com/en/microcontrollers-microprocessors/stm32f401vc.html",
"vendor": "Generic"
}
2 changes: 1 addition & 1 deletion stm32/ros_usbnode/include/adc.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ extern union FtoU charge_current_offset;
*******************************************************************************/

void TIM2_Init(void);
void ADC2_Init(void);
void ADC_Charging_Init(void);

void ADC_input(void);

Expand Down
61 changes: 53 additions & 8 deletions stm32/ros_usbnode/include/board.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ extern "C"
* BOARD SELECTION
* the specific board setting are set a the end of this file
********************************************************************************/
#define BOARD_YARDFORCE500 1
//#define BOARD_LUV1000RI 1

/* definition type don't modify */
Expand All @@ -35,7 +34,13 @@ extern "C"
#define PANEL_TYPE_YARDFORCE_LUV1000RI 2
#define PANEL_TYPE_YARDFORCE_900_ECO 3

#if defined(BOARD_YARDFORCE500)
#if BOARD_YARDFORCE500_VARIANT_ORIG
///////////////////////////
// Yardforce 500 CLASSIC //
///////////////////////////
#define BLADEMOTOR_USART_INSTANCE USART3

#define VALID_BOARD_DEFINED 1
#define PANEL_TYPE PANEL_TYPE_YARDFORCE_500_CLASSIC
#define BLADEMOTOR_LENGTH_RECEIVED_MSG 16
#define DEBUG_TYPE DEBUG_TYPE_UART
Expand All @@ -47,7 +52,29 @@ extern "C"

#define OPTION_ULTRASONIC 0
#define OPTION_BUMPER 0
#elif defined(BOARD_LUV1000RI)

#define BOARD_HAS_MASTER_USART 1
#elif BOARD_YARDFORCE500_VARIANT_B
/////////////////////
// Yardforce 500 B //
/////////////////////

// TODO: Are those options valid?
#define BLADEMOTOR_USART_INSTANCE USART6

#define VALID_BOARD_DEFINED 1
#define PANEL_TYPE PANEL_TYPE_YARDFORCE_500_CLASSIC
#define BLADEMOTOR_LENGTH_RECEIVED_MSG 16
#define DEBUG_TYPE DEBUG_TYPE_SWO

#define MAX_MPS 0.5 // Allow maximum speed of 1.0 m/s
#define PWM_PER_MPS 300.0 // PWM value of 300 means 1 m/s bot speed so we divide by 4 to have correct robot speed but still progressive speed
#define TICKS_PER_M 300.0 // Motor Encoder ticks per meter
#define WHEEL_BASE 0.325 // The distance between the center of the wheels in meters

#define OPTION_ULTRASONIC 0
#define OPTION_BUMPER 0
#elif defined(BOARD_LUV1000RI) // TODO: This currently can't be selected via platformio
#define PANEL_TYPE PANEL_TYPE_YARDFORCE_LUV1000RI
#define BLADEMOTOR_LENGTH_RECEIVED_MSG 14

Expand All @@ -61,9 +88,7 @@ extern "C"
#define TICKS_PER_M 300.0 // Motor Encoder ticks per meter
#define WHEEL_BASE 0.285 // The distance between the center of the wheels in meters

#else

#error "No board selection"
#define BOARD_HAS_MASTER_USART 0
#endif

//#define I_DONT_NEED_MY_FINGERS 1 // disables EmergencyController() (no wheel lift, or tilt sensing and stopping the blade anymore)
Expand Down Expand Up @@ -164,7 +189,11 @@ extern "C"
#define WHEEL_LIFT_RED_PORT GPIOD

/* Play button - (LOW when pressed) */
#if BOARD_YARDFORCE500_VARIANT_B
#define PLAY_BUTTON_PIN GPIO_PIN_9
#else
#define PLAY_BUTTON_PIN GPIO_PIN_7
#endif
#define PLAY_BUTTON_PORT GPIOC
#define PLAY_BUTTON_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()

Expand All @@ -185,6 +214,7 @@ extern "C"
#define HALLSTOP_PORT GPIOD
#define HALLSTOP_GPIO_CLK_ENABLE() __HAL_RCC_GPIOD_CLK_ENABLE()

#if BOARD_HAS_MASTER_USART
/* either J6 or J18 can be the master USART port */
#ifdef MASTER_J6
/* USART1 (J6 Pin 1 (TX) Pin 2 (RX)) */
Expand All @@ -208,6 +238,7 @@ extern "C"
#define MASTER_USART_USART_CLK_ENABLE() __HAL_RCC_UART4_CLK_ENABLE()
#define MASTER_USART_IRQ UART4_IRQn
#endif
#endif

#ifdef DRIVEMOTORS_USART_ENABLED
/* drive motors PAC 5210 (USART2) */
Expand All @@ -227,9 +258,8 @@ extern "C"
#endif

#ifdef BLADEMOTOR_USART_ENABLED
#if BOARD_YARDFORCE500_VARIANT_ORIG
/* blade motor PAC 5223 (USART3) */
#define BLADEMOTOR_USART_INSTANCE USART3

#define BLADEMOTOR_USART_RX_PIN GPIO_PIN_11
#define BLADEMOTOR_USART_RX_PORT GPIOB

Expand All @@ -238,6 +268,17 @@ extern "C"

#define BLADEMOTOR_USART_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE()
#define BLADEMOTOR_USART_USART_CLK_ENABLE() __HAL_RCC_USART3_CLK_ENABLE()
#elif BOARD_YARDFORCE500_VARIANT_B
/* blade motor PAC 5223 (USART6) */
#define BLADEMOTOR_USART_RX_PIN GPIO_PIN_7
#define BLADEMOTOR_USART_RX_PORT GPIOC

#define BLADEMOTOR_USART_TX_PIN GPIO_PIN_6
#define BLADEMOTOR_USART_TX_PORT GPIOC

#define BLADEMOTOR_USART_GPIO_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
#define BLADEMOTOR_USART_USART_CLK_ENABLE() __HAL_RCC_USART6_CLK_ENABLE()
#endif
#endif

#ifdef PANEL_USART_ENABLED
Expand All @@ -264,6 +305,10 @@ extern "C"
#define SOFT_I2C_GPIO_CLK_ENABLE() __HAL_RCC_GPIOB_CLK_ENABLE();
#endif

#if !VALID_BOARD_DEFINED
#error "No valid board has been defined, this likely is a mismatch between this file and platformio.ini"
#endif

#ifdef __cplusplus
}
#endif
Expand Down
2 changes: 1 addition & 1 deletion stm32/ros_usbnode/include/imu/imu.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
extern "C" {
#endif

#include "stm32f1xx_hal.h"
#include "stm32f_board_hal.h"

typedef struct
{
Expand Down
2 changes: 1 addition & 1 deletion stm32/ros_usbnode/include/imu/wt901.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/******************************************************************************
* Includes
*******************************************************************************/
#include "stm32f1xx_hal.h"
#include "stm32f_board_hal.h"

/**
* @brief Test for WT901
Expand Down
6 changes: 5 additions & 1 deletion stm32/ros_usbnode/include/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ extern "C" {


/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx_hal.h"
#include "stm32f_board_hal.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
Expand Down Expand Up @@ -107,7 +107,9 @@ void LED_Init();
void TF4_Init();
void RAIN_Sensor_Init();
void PAC5210RESET_Init();
#if BOARD_YARDFORCE500_VARIANT_ORIG
void MASTER_USART_Init();
#endif
void DRIVEMOTORS_USART_Init();
void SystemClock_Config();
void ADC1_Init(void);
Expand All @@ -118,7 +120,9 @@ void MX_DMA_Init(void);
void Emergency_Init(void);

// UART Wrapper functions to hide HAL bullshit ...
#if BOARD_YARDFORCE500_VARIANT_ORIG
void MASTER_Transmit(uint8_t *buffer, uint8_t len);
#endif
void DRIVEMOTORS_Transmit(uint8_t *buffer, uint8_t len);

// Sensor Wrapper functions
Expand Down
2 changes: 1 addition & 1 deletion stm32/ros_usbnode/include/panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#define __PANEL_H

#include "board.h"
#include "stm32f1xx_hal.h"
#include "stm32f_board_hal.h"


#ifdef __cplusplus
Expand Down
78 changes: 78 additions & 0 deletions stm32/ros_usbnode/include/stm32f4xx_it.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32f4xx_it.h
* @brief This file contains the headers of the interrupt handlers.
******************************************************************************
* @attention
*
* Copyright (c) 2023 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */

/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F4xx_IT_H
#define __STM32F4xx_IT_H

#ifdef __cplusplus
extern "C" {
#endif

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

/* USER CODE END Includes */

/* Exported types ------------------------------------------------------------*/
/* USER CODE BEGIN ET */

/* USER CODE END ET */

/* Exported constants --------------------------------------------------------*/
/* USER CODE BEGIN EC */

/* USER CODE END EC */

/* Exported macro ------------------------------------------------------------*/
/* USER CODE BEGIN EM */

/* USER CODE END EM */

/* Exported functions prototypes ---------------------------------------------*/
void NMI_Handler(void);
void HardFault_Handler(void);
void MemManage_Handler(void);
void BusFault_Handler(void);
void UsageFault_Handler(void);
void SVC_Handler(void);
void DebugMon_Handler(void);
void PendSV_Handler(void);
void SysTick_Handler(void);
void WWDG_IRQHandler(void);
void DMA2_Stream1_IRQHandler(void);
void DMA2_Stream6_IRQHandler(void);
void ADC_IRQHandler(void);
void USART1_IRQHandler(void);
void USART2_IRQHandler(void);
void DMA1_Stream1_IRQHandler(void);
void OTG_FS_IRQHandler(void);
void DMA1_Stream0_IRQHandler(void);
void DMA1_Stream5_IRQHandler(void);
void DMA1_Stream6_IRQHandler(void);
void USART6_IRQHandler(void);
/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

#ifdef __cplusplus
}
#endif

#endif /* __STM32F4xx_IT_H */
22 changes: 22 additions & 0 deletions stm32/ros_usbnode/include/stm32f_board_hal.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#ifndef __STM32F_BOARD_HAL_H
#define __STM32F_BOARD_HAL_H

#ifdef __cplusplus
extern "C" {
#endif

#if BOARD_YARDFORCE500_VARIANT_ORIG
#include "stm32f1xx_hal.h"
#include "stm32f1xx_hal_uart.h"
#include "stm32f1xx_hal_adc.h"
#elif BOARD_YARDFORCE500_VARIANT_B
#include "stm32f4xx_hal.h"
#include "stm32f4xx_hal_uart.h"
#include "stm32f4xx_hal_adc.h"
#endif

#ifdef __cplusplus
}
#endif

#endif
3 changes: 1 addition & 2 deletions stm32/ros_usbnode/include/usb_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f1xx.h"
#include "stm32f1xx_hal.h"
#include "stm32f_board_hal.h"
#include "usbd_def.h"

/* USER CODE BEGIN INCLUDE */
Expand Down
3 changes: 1 addition & 2 deletions stm32/ros_usbnode/include/usbd_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
#include <stdlib.h>
#include <string.h>
#include "main.h"
#include "stm32f1xx.h"
#include "stm32f1xx_hal.h"
#include "stm32f_board_hal.h"

/* USER CODE BEGIN INCLUDE */

Expand Down
Loading