using circular buffer from penguin buffer until i implement ring buffer

stable
Penguin 2 years ago
parent 252037532b
commit 310e5a1a32

@ -1,23 +1,23 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file stm32l4xx_hal_conf.h
* @author MCD Application Team
* @brief HAL configuration template file.
* This file should be copied to the application folder and renamed
* to stm32l4xx_hal_conf.h.
******************************************************************************
* @attention
*
* Copyright (c) 2017 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.
*
******************************************************************************
*/
******************************************************************************
* @file stm32l4xx_hal_conf.h
* @author MCD Application Team
* @brief HAL configuration template file.
* This file should be copied to the application folder and renamed
* to stm32l4xx_hal_conf.h.
******************************************************************************
* @attention
*
* Copyright (c) 2017 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 -------------------------------------*/
@ -236,7 +236,7 @@
#define USE_HAL_SWPMI_REGISTER_CALLBACKS 0U
#define USE_HAL_TIM_REGISTER_CALLBACKS 0U
#define USE_HAL_TSC_REGISTER_CALLBACKS 0U
#define USE_HAL_UART_REGISTER_CALLBACKS 0U
#define USE_HAL_UART_REGISTER_CALLBACKS 1U
#define USE_HAL_USART_REGISTER_CALLBACKS 0U
#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U

@ -22,6 +22,7 @@
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "motor_controller.h"
#include "p_serial_mgr.h"
#include "putil.h"
#include "stm32l4xx_hal_uart.h"
#include <stdbool.h>
@ -66,6 +67,7 @@ static void MX_USART2_UART_Init(void);
static void MX_TIM6_Init(void);
static void MX_USART1_UART_Init(void);
/* USER CODE BEGIN PFP */
static void UART2_RxCpltCallback(UART_HandleTypeDef *huart);
/* USER CODE END PFP */
@ -107,7 +109,10 @@ int main(void)
MX_TIM6_Init();
MX_USART1_UART_Init();
/* USER CODE BEGIN 2 */
huart2.RxCpltCallback = UART2_RxCpltCallback;
p_uart_init(&huart2);
p_serial_mgr_init(&huart1);
// HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_2);
// HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_4);
@ -121,7 +126,6 @@ int main(void)
HAL_UART_Receive_IT(&huart2, &huart2_rxc, 1);
HAL_TIM_Base_Start_IT(&htim6);
HAL_UART_Receive_IT(&huart1, &huart1_rxc, 1);
uint16_t motor_degrees = 0;
/* USER CODE END 2 */
@ -385,23 +389,18 @@ static void MX_GPIO_Init(void)
}
/* USER CODE BEGIN 4 */
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
{
if (huart == &huart1)
{
HAL_GPIO_WritePin(USART1_DE_GPIO_Port, USART1_DE_Pin, 1);
huart2_rxc = huart1_rxc;
HAL_UART_Transmit(&huart2, &huart2_rxc, 1, 500);
HAL_UART_Receive_IT(&huart1, &huart1_rxc, 1);
HAL_GPIO_WritePin(USART1_DE_GPIO_Port, USART1_DE_Pin, 0);
}
else if (huart == &huart2)
{
HAL_UART_Transmit(&huart1, &huart2_rxc, 1, 100);
HAL_UART_Receive_IT(&huart2, &huart2_rxc, 1);
}
void UART2_RxCpltCallback(UART_HandleTypeDef *huart)
{
HAL_UART_Transmit(&huart1, &huart2_rxc, 1, 100);
HAL_UART_Receive_IT(&huart2, &huart2_rxc, 1);
}
// void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
// {
// else if (huart == &huart2)
// {
// }
// }
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
{

@ -1,5 +1,5 @@
##########################################################################################################################
# File automatically-generated by tool: [projectgenerator] version: [3.16.0] date: [Fri Apr 08 15:05:50 CDT 2022]
# File automatically-generated by tool: [projectgenerator] version: [3.16.0] date: [Fri Apr 08 17:14:47 CDT 2022]
##########################################################################################################################
# ------------------------------------------------
@ -60,6 +60,8 @@ Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c \
Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c \
Core/Src/system_stm32l4xx.c \
shared/util/putil.c \
shared/util/PCircularBuffer.c \
shared/drivers/p_serial_mgr.c \
shared/devices/motor_controller.c
# ASM sources

@ -25,14 +25,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_dma.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_dma.lst",
"-MFbuild/stm32l4xx_hal_uart.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_uart.lst",
"-o",
"build/stm32l4xx_hal_dma.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c"
"build/stm32l4xx_hal_uart.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c"
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c"
},
{
"arguments": [
@ -60,14 +60,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_gpio.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_gpio.lst",
"-MFbuild/stm32l4xx_hal_tim_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_tim_ex.lst",
"-o",
"build/stm32l4xx_hal_gpio.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c"
"build/stm32l4xx_hal_tim_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c"
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c"
},
{
"arguments": [
@ -95,14 +95,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal.lst",
"-MFbuild/stm32l4xx_hal_tim.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_tim.lst",
"-o",
"build/stm32l4xx_hal.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c"
"build/stm32l4xx_hal_tim.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c"
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c"
},
{
"arguments": [
@ -130,14 +130,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_it.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_it.lst",
"-MFbuild/stm32l4xx_hal_flash.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_flash.lst",
"-o",
"build/stm32l4xx_it.o",
"Core/Src/stm32l4xx_it.c"
"build/stm32l4xx_hal_flash.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Core/Src/stm32l4xx_it.c"
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c"
},
{
"arguments": [
@ -200,14 +200,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_tim.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_tim.lst",
"-MFbuild/stm32l4xx_hal_i2c.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_i2c.lst",
"-o",
"build/stm32l4xx_hal_tim.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c"
"build/stm32l4xx_hal_i2c.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c"
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c"
},
{
"arguments": [
@ -235,14 +235,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/putil.d",
"-Wa,-a,-ad,-alms=build/putil.lst",
"-MFbuild/stm32l4xx_hal_cortex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_cortex.lst",
"-o",
"build/putil.o",
"shared/util/putil.c"
"build/stm32l4xx_hal_cortex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "shared/util/putil.c"
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c"
},
{
"arguments": [
@ -270,14 +270,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/system_stm32l4xx.d",
"-Wa,-a,-ad,-alms=build/system_stm32l4xx.lst",
"-MFbuild/stm32l4xx_hal_flash_ramfunc.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_flash_ramfunc.lst",
"-o",
"build/system_stm32l4xx.o",
"Core/Src/system_stm32l4xx.c"
"build/stm32l4xx_hal_flash_ramfunc.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Core/Src/system_stm32l4xx.c"
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c"
},
{
"arguments": [
@ -305,14 +305,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/motor_controller.d",
"-Wa,-a,-ad,-alms=build/motor_controller.lst",
"-MFbuild/stm32l4xx_hal_msp.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_msp.lst",
"-o",
"build/motor_controller.o",
"shared/devices/motor_controller.c"
"build/stm32l4xx_hal_msp.o",
"Core/Src/stm32l4xx_hal_msp.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "shared/devices/motor_controller.c"
"file": "Core/Src/stm32l4xx_hal_msp.c"
},
{
"arguments": [
@ -340,14 +340,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_uart_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_uart_ex.lst",
"-MFbuild/system_stm32l4xx.d",
"-Wa,-a,-ad,-alms=build/system_stm32l4xx.lst",
"-o",
"build/stm32l4xx_hal_uart_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c"
"build/system_stm32l4xx.o",
"Core/Src/system_stm32l4xx.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c"
"file": "Core/Src/system_stm32l4xx.c"
},
{
"arguments": [
@ -375,14 +375,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_pwr_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_pwr_ex.lst",
"-MFbuild/stm32l4xx_hal_dma.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_dma.lst",
"-o",
"build/stm32l4xx_hal_pwr_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c"
"build/stm32l4xx_hal_dma.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c"
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c"
},
{
"arguments": [
@ -410,14 +410,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_i2c_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_i2c_ex.lst",
"-MFbuild/stm32l4xx_hal_gpio.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_gpio.lst",
"-o",
"build/stm32l4xx_hal_i2c_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c"
"build/stm32l4xx_hal_gpio.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c"
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c"
},
{
"arguments": [
@ -445,14 +445,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_flash.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_flash.lst",
"-MFbuild/main.d",
"-Wa,-a,-ad,-alms=build/main.lst",
"-o",
"build/stm32l4xx_hal_flash.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c"
"build/main.o",
"Core/Src/main.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c"
"file": "Core/Src/main.c"
},
{
"arguments": [
@ -480,14 +480,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_flash_ramfunc.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_flash_ramfunc.lst",
"-MFbuild/stm32l4xx_hal_flash_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_flash_ex.lst",
"-o",
"build/stm32l4xx_hal_flash_ramfunc.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c"
"build/stm32l4xx_hal_flash_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c"
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c"
},
{
"arguments": [
@ -515,14 +515,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_dma_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_dma_ex.lst",
"-MFbuild/stm32l4xx_hal.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal.lst",
"-o",
"build/stm32l4xx_hal_dma_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c"
"build/stm32l4xx_hal.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c"
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c"
},
{
"arguments": [
@ -550,14 +550,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/main.d",
"-Wa,-a,-ad,-alms=build/main.lst",
"-MFbuild/stm32l4xx_hal_pwr.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_pwr.lst",
"-o",
"build/main.o",
"Core/Src/main.c"
"build/stm32l4xx_hal_pwr.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Core/Src/main.c"
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c"
},
{
"arguments": [
@ -585,14 +585,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_cortex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_cortex.lst",
"-MFbuild/stm32l4xx_hal_i2c_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_i2c_ex.lst",
"-o",
"build/stm32l4xx_hal_cortex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c"
"build/stm32l4xx_hal_i2c_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c"
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c"
},
{
"arguments": [
@ -620,14 +620,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_flash_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_flash_ex.lst",
"-MFbuild/p_serial_mgr.d",
"-Wa,-a,-ad,-alms=build/p_serial_mgr.lst",
"-o",
"build/stm32l4xx_hal_flash_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c"
"build/p_serial_mgr.o",
"shared/drivers/p_serial_mgr.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c"
"file": "shared/drivers/p_serial_mgr.c"
},
{
"arguments": [
@ -655,14 +655,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_rcc_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_rcc_ex.lst",
"-MFbuild/stm32l4xx_hal_uart_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_uart_ex.lst",
"-o",
"build/stm32l4xx_hal_rcc_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c"
"build/stm32l4xx_hal_uart_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c"
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_ex.c"
},
{
"arguments": [
@ -725,14 +725,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_i2c.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_i2c.lst",
"-MFbuild/putil.d",
"-Wa,-a,-ad,-alms=build/putil.lst",
"-o",
"build/stm32l4xx_hal_i2c.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c"
"build/putil.o",
"shared/util/putil.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c"
"file": "shared/util/putil.c"
},
{
"arguments": [
@ -760,14 +760,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_msp.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_msp.lst",
"-MFbuild/motor_controller.d",
"-Wa,-a,-ad,-alms=build/motor_controller.lst",
"-o",
"build/stm32l4xx_hal_msp.o",
"Core/Src/stm32l4xx_hal_msp.c"
"build/motor_controller.o",
"shared/devices/motor_controller.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Core/Src/stm32l4xx_hal_msp.c"
"file": "shared/devices/motor_controller.c"
},
{
"arguments": [
@ -795,14 +795,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_pwr.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_pwr.lst",
"-MFbuild/stm32l4xx_it.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_it.lst",
"-o",
"build/stm32l4xx_hal_pwr.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c"
"build/stm32l4xx_it.o",
"Core/Src/stm32l4xx_it.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c"
"file": "Core/Src/stm32l4xx_it.c"
},
{
"arguments": [
@ -866,14 +866,14 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_uart.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_uart.lst",
"-MFbuild/stm32l4xx_hal_rcc_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_rcc_ex.lst",
"-o",
"build/stm32l4xx_hal_uart.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c"
"build/stm32l4xx_hal_rcc_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c"
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c"
},
{
"arguments": [
@ -901,13 +901,83 @@
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_tim_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_tim_ex.lst",
"-MFbuild/PCircularBuffer.d",
"-Wa,-a,-ad,-alms=build/PCircularBuffer.lst",
"-o",
"build/stm32l4xx_hal_tim_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c"
"build/PCircularBuffer.o",
"shared/util/PCircularBuffer.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c"
"file": "shared/util/PCircularBuffer.c"
},
{
"arguments": [
"arm-none-eabi-gcc",
"-c",
"-mcpu=cortex-m4",
"-mthumb",
"-mfpu=fpv4-sp-d16",
"-mfloat-abi=hard",
"-DUSE_HAL_DRIVER",
"-DSTM32L432xx",
"-ICore/Inc",
"-IDrivers/STM32L4xx_HAL_Driver/Inc",
"-IDrivers/STM32L4xx_HAL_Driver/Inc/Legacy",
"-IDrivers/CMSIS/Device/ST/STM32L4xx/Include",
"-IDrivers/CMSIS/Include",
"-Ishared",
"-Ishared/devices",
"-Ishared/drivers",
"-Ishared/util",
"-Og",
"-Wall",
"-fdata-sections",
"-ffunction-sections",
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_pwr_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_pwr_ex.lst",
"-o",
"build/stm32l4xx_hal_pwr_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c"
},
{
"arguments": [
"arm-none-eabi-gcc",
"-c",
"-mcpu=cortex-m4",
"-mthumb",
"-mfpu=fpv4-sp-d16",
"-mfloat-abi=hard",
"-DUSE_HAL_DRIVER",
"-DSTM32L432xx",
"-ICore/Inc",
"-IDrivers/STM32L4xx_HAL_Driver/Inc",
"-IDrivers/STM32L4xx_HAL_Driver/Inc/Legacy",
"-IDrivers/CMSIS/Device/ST/STM32L4xx/Include",
"-IDrivers/CMSIS/Include",
"-Ishared",
"-Ishared/devices",
"-Ishared/drivers",
"-Ishared/util",
"-Og",
"-Wall",
"-fdata-sections",
"-ffunction-sections",
"-g3",
"-gdwarf-2",
"-D_DEBUG",
"-MFbuild/stm32l4xx_hal_dma_ex.d",
"-Wa,-a,-ad,-alms=build/stm32l4xx_hal_dma_ex.lst",
"-o",
"build/stm32l4xx_hal_dma_ex.o",
"Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c"
],
"directory": "/storage/Shared/Projects/Penguinator/motor_controller",
"file": "Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c"
}
]

9041
gdb.txt

File diff suppressed because it is too large Load Diff

@ -124,7 +124,7 @@ ProjectManager.PreviousToolchain=STM32CubeIDE
ProjectManager.ProjectBuild=false
ProjectManager.ProjectFileName=motor_controller.ioc
ProjectManager.ProjectName=motor_controller
ProjectManager.RegisterCallBack=
ProjectManager.RegisterCallBack=UART
ProjectManager.StackSize=0x400
ProjectManager.TargetToolchain=Makefile
ProjectManager.ToolChainLocation=

@ -0,0 +1,36 @@
#include "p_serial_mgr.h"
#include "PCircularBuffer.h"
#define MAX_SERIAL_BUFFER_SIZE (256)
static uint8_t buffer[MAX_SERIAL_BUFFER_SIZE];
static p_cb_u8 serial_cb;
static UART_HandleTypeDef *_serial_huart_inst = NULL;
static uint8_t serial_cb_rxc = '\0';
void UART1_RxCpltCallback(UART_HandleTypeDef *huart)
{
serial_cb.push(&serial_cb, serial_cb_rxc);
// HAL_GPIO_WritePin(USART1_DE_GPIO_Port, USART1_DE_Pin, 1);
// huart2_rxc = huart1_rxc;
// HAL_UART_Transmit(&huart2, &huart2_rxc, 1, 500);
// HAL_UART_Receive_IT(&huart1, &huart1_rxc, 1);
// HAL_GPIO_WritePin(USART1_DE_GPIO_Port, USART1_DE_Pin, 0);
}
void p_serial_mgr_init(UART_HandleTypeDef *huart)
{
_serial_huart_inst = huart;
_serial_huart_inst->RxCpltCallback = UART1_RxCpltCallback;
memset(buffer, 0, MAX_SERIAL_BUFFER_SIZE);
p_cb_u8_init(&serial_cb, buffer, MAX_SERIAL_BUFFER_SIZE);
}
void p_serial_mgr_service(void)
{
}
void p_serial_mgr_start()
{
HAL_UART_Receive_IT(_serial_huart_inst, &serial_cb_rxc, 1);
}

@ -0,0 +1,9 @@
#ifndef _P_SERIAL_MGR_H_
#define _P_SERIAL_MGR_H_
#include "stm32l4xx_hal.h"
void p_serial_mgr_init(UART_HandleTypeDef *huart);
void p_serial_mgr_service(void);
#endif

@ -0,0 +1,448 @@
#include <PCircularBuffer.h>
// Error handler used for debugging only
#ifdef PB_CB_DEBUG
#include <stdio.h>
static void handle_status(const char *func, PB_CB_STATUS status_code)
{
if (status_code != PB_CB_GOOD)
{
printf("%s failed: error code: %d\r\n", func, status_code);
}
}
#endif
// Circular Buffer Prototypes -- uint8_t
#if PB_CB_U8
static PB_CB_STATUS p_cb_u8_push(p_cb_u8 *cbuffer, uint8_t value);
static PB_CB_STATUS p_cb_u8_empty(p_cb_u8 *cbuffer);
#endif
// Circular Buffer Prototypes -- uint16_t
#if PB_CB_U16
static PB_CB_STATUS p_cb_u16_push(p_cb_double *cbuffer, uint16_t value);
static PB_CB_STATUS p_cb_u16_empty(p_cb_double *cbuffer);
#endif
// Circular Buffer Prototypes -- uint32_t
#if PB_CB_U32
static PB_CB_STATUS p_cb_u32_push(p_cb_double *cbuffer, uint32_t value);
static PB_CB_STATUS p_cb_u32_empty(p_cb_double *cbuffer);
#endif
// Circular Buffer Prototypes -- uint64_t
#if PB_CB_U64
static PB_CB_STATUS p_cb_u64_push(p_cb_double *cbuffer, uint64_t value);
static PB_CB_STATUS p_cb_u64_empty(p_cb_double *cbuffer);
#endif
// Circular Buffer Prototypes -- int8_t
#if PB_CB_I8
static PB_CB_STATUS p_cb_i8_push(p_cb_double *cbuffer, int8_t value);
static PB_CB_STATUS p_cb_i8_empty(p_cb_double *cbuffer);
#endif
// Circular Buffer Prototypes -- int16_t
#if PB_CB_I16
static PB_CB_STATUS p_cb_i16_push(p_cb_double *cbuffer, int16_t value);
static PB_CB_STATUS p_cb_i16_empty(p_cb_double *cbuffer);
#endif
// Circular Buffer Prototypes -- int32_t
#if PB_CB_I32
static PB_CB_STATUS p_cb_i32_push(p_cb_double *cbuffer, int32_t value);
static PB_CB_STATUS p_cb_i32_empty(p_cb_double *cbuffer);
#endif
// Circular Buffer Prototypes -- int64_t
#if PB_CB_I64
static PB_CB_STATUS p_cb_i64_push(p_cb_double *cbuffer, int64_t value);
static PB_CB_STATUS p_cb_i64_empty(p_cb_double *cbuffer);
#endif
// Circular Buffer Prototypes -- Float
#if PB_CB_FLOAT
static PB_CB_STATUS p_cb_float_push(p_cb_double *cbuffer, float value);
static PB_CB_STATUS p_cb_float_empty(p_cb_double *cbuffer);
#endif
// Circular Buffer Prototypes -- Double
#if PB_CB_DOUBLE
static PB_CB_STATUS p_cb_double_push(p_cb_double *cbuffer, double value);
static PB_CB_STATUS p_cb_double_empty(p_cb_double *cbuffer);
#endif
// Circular Buffer Definitions -- uint8_t
#if PB_CB_U8
PB_CB_STATUS p_cb_u8_init(p_cb_u8 *circ_buffer, uint8_t *buff, uint32_t max_length)
{
PB_CB_STATUS ret = PB_CB_GOOD;
do
{
// Make sure the buffer isn't bad (null)
if (!buff)
{
ret = PB_CB_NULL_BUFFER;
break;
}
// Make sure the max buffer is a useable size
if (max_length > PB_CB_MAX_BUFFER_SIZE || max_length <= 0)
{
ret = PB_CB_BAD_BUFFER_SIZE;
break;
}
} while (0);
// Debugging
#ifdef PB_CB_DEBUG
handle_status(__func__, ret);
#endif
return ret;
}
PB_CB_STATUS p_cb_u8_push(p_cb_u8 *cbuffer, uint8_t value)
{
PB_CB_STATUS ret = PB_CB_GOOD;
if (!cbuffer)
{
ret = PB_CB_NULL_CBUFFER;
}
else
{
cbuffer->buffer[cbuffer->head] = value;
cbuffer->head = (cbuffer->head + 1) % cbuffer->max_len;
}
// Debugging
#ifdef PB_CB_DEBUG
handle_status(__func__, ret);
#endif
return ret;
}
PB_CB_STATUS p_cb_u8_empty(p_cb_u8 *cbuffer)
{
PB_CB_STATUS ret = PB_CB_GOOD;
do
{
if (!cbuffer)
{
ret = PB_CB_NULL_CBUFFER;
break;
}
if (!cbuffer->buffer)
{
ret = PB_CB_NULL_BUFFER;
break;
}
memset(cbuffer->buffer, 0, cbuffer->max_len);
cbuffer->head = 0;
cbuffer->b_empty = true;
cbuffer->b_filled = false;
} while (0);
// Debugging
#ifdef PB_CB_DEBUG
handle_status(__func__, ret);
#endif
return ret;
}
#endif
// Circular Buffer Definitions -- uint16_t
#if PB_CB_U16
PB_CB_STATUS p_cb_u16_init(p_cb_u16 *circ_buffer, uint16_t *buff, uint32_t max_length)
{
PB_CB_STATUS ret = PB_CB_GOOD;
do
{
// Make sure the buffer isn't bad (null)
if (!buff)
{
ret = PB_CB_NULL_BUFFER;
break;
}
// Make sure the max buffer is a useable size
if (max_length > PB_CB_MAX_BUFFER_SIZE || max_length <= 0)
{
ret = PB_CB_BAD_BUFFER_SIZE;
break;
}
} while (0);
// Debugging
#ifdef PB_CB_DEBUG
handle_status(__func__, ret);
#endif
return ret;
}
PB_CB_STATUS p_cb_u16_push(p_cb_double *cbuffer, uint16_t value)
{
PB_CB_STATUS ret = PB_CB_GOOD;
// Debugging
#ifdef PB_CB_DEBUG
handle_status(__func__, ret);
#endif
return ret;
}
PB_CB_STATUS p_cb_u16_empty(p_cb_double *cbuffer)
{
PB_CB_STATUS ret = PB_CB_GOOD;
// Debugging
#ifdef PB_CB_DEBUG
handle_status(__func__, ret);
#endif
return ret;
}
#endif
// Circular Buffer Definitions -- uint32_t
#if PB_CB_U32
PB_CB_STATUS p_cb_u32_init(p_cb_u32 *circ_buffer, uint32_t *buff, uint32_t max_length)
{
PB_CB_STATUS ret = PB_CB_GOOD;
do
{
// Make sure the buffer isn't bad (null)
if (!buff)
{
ret = PB_CB_NULL_BUFFER;
break;
}
// Make sure the max buffer is a useable size
if (max_length > PB_CB_MAX_BUFFER_SIZE || max_length <= 0)
{
ret = PB_CB_BAD_BUFFER_SIZE;
break;
}
} while (0);
// Debugging
#ifdef PB_CB_DEBUG
handle_status(__func__, ret);
#endif
return ret;
}
PB_CB_STATUS p_cb_u32_push(p_cb_double *cbuffer, uint32_t value)
{
PB_CB_STATUS ret = PB_CB_GOOD;
// Debugging
#ifdef PB_CB_DEBUG
handle_status(__func__, ret);
#endif
return ret;
}
PB_CB_STATUS p_cb_u32_empty(p_cb_double *cbuffer)
{
PB_CB_STATUS ret = PB_CB_GOOD;
// Debugging
#ifdef PB_CB_DEBUG
handle_status(__func__, ret);
#endif
return ret;
}
#endif
// Circular Buffer Definitions -- uint64_t
#if PB_CB_U64
PB_CB_STATUS p_cb_u64_init(p_cb_u64 *circ_buffer, uint64_t *buff, uint32_t max_length)
{
PB_CB_STATUS ret = PB_CB_GOOD;
do
{
// Make sure the buffer isn't bad (null)
if (!buff)
{
ret = PB_CB_NULL_BUFFER;
break;
}
// Make sure the max buffer is a useable size
if (max_length > PB_CB_MAX_BUFFER_SIZE || max_length <= 0)
{
ret = PB_CB_BAD_BUFFER_SIZE;
break;
}
} while (0);
// Debugging
#ifdef PB_CB_DEBUG
handle_status(__func__, ret);
#endif
return ret;
}
PB_CB_STATUS p_cb_u64_push(p_cb_double *cbuffer, uint64_t value)
{
PB_CB_STATUS ret = PB_CB_GOOD;
// Debugging
#ifdef PB_CB_DEBUG
handle_status(__func__, ret);
#endif
return ret;
}
PB_CB_STATUS p_cb_u64_empty(p_cb_double *cbuffer)
{
PB_CB_STATUS ret = PB_CB_GOOD;
// Debugging
#ifdef PB_CB_DEBUG
handle_status(__func__, ret);
#endif
return ret;
}
#endif
#if PB_CB_FLOAT
PB_CB_STATUS p_cb_float_init(p_cb_float *circ_buffer, float *buff, uint32_t max_length)
{
PB_CB_STATUS ret = PB_CB_GOOD;
do
{
// Make sure the buffer isn't bad (null)
if (!buff)
{
ret = PB_CB_NULL_BUFFER;
break;
}
// Make sure the max buffer is a useable size
if (max_length > PB_CB_MAX_BUFFER_SIZE || max_length <= 0)
{
ret = PB_CB_BAD_BUFFER_SIZE;
break;
}
} while (0);
// Debugging
#ifdef PB_CB_DEBUG
handle_status(__func__, ret);
#endif
return ret;
}
PB_CB_STATUS p_cb_float_push(p_cb_double *cbuffer, float value)
{
PB_CB_STATUS ret = PB_CB_GOOD;
// Debugging
#ifdef PB_CB_DEBUG
handle_status(__func__, ret);
#endif
return ret;
}
PB_CB_STATUS p_cb_float_empty(p_cb_double *cbuffer)
{
PB_CB_STATUS ret = PB_CB_GOOD;
// Debugging
#ifdef PB_CB_DEBUG
handle_status(__func__, ret);
#endif
return ret;
}
#endif
// Circular Buffer Definitions -- double
#if PB_CB_DOUBLE
PB_CB_STATUS p_cb_double_init(p_cb_double *circ_buffer, double *buff, uint32_t max_length)
{
PB_CB_STATUS ret = PB_CB_GOOD;
do
{
// Make sure the buffer isn't bad (null)
if (!buff)
{
ret = PB_CB_NULL_BUFFER;
break;
}
// Make sure the max buffer is a useable size
if (max_length > PB_CB_MAX_BUFFER_SIZE || max_length <= 0)
{
ret = PB_CB_BAD_BUFFER_SIZE;
break;
}
circ_buffer->buffer = buff;
circ_buffer->max_len = (uint16_t)max_length;
circ_buffer->head = 0;
circ_buffer->push = p_cb_double_push;
circ_buffer->empty = p_cb_double_empty;
circ_buffer->empty(circ_buffer);
} while (0);
// Debugging
#ifdef PB_CB_DEBUG
handle_status(__func__, ret);
#endif
return ret;
}
PB_CB_STATUS p_cb_double_push(p_cb_double *cbuffer, double value)
{
PB_CB_STATUS ret = PB_CB_GOOD;
if (!cbuffer)
{
ret = PB_CB_NULL_CBUFFER;
}
else
{
cbuffer->buffer[cbuffer->head] = value;
cbuffer->head = (cbuffer->head + 1) % cbuffer->max_len;
}
// Debugging
#ifdef PB_CB_DEBUG
handle_status(__func__, ret);
#endif
return ret;
}
PB_CB_STATUS p_cb_double_empty(p_cb_double *cbuffer)
{
PB_CB_STATUS ret = PB_CB_GOOD;
do
{
if (!cbuffer)
{
ret = PB_CB_NULL_CBUFFER;
break;
}
if (!cbuffer->buffer)
{
ret = PB_CB_NULL_BUFFER;
break;
}
memset(cbuffer->buffer, 0, sizeof(double) * cbuffer->max_len);
cbuffer->head = 0;
cbuffer->b_empty = true;
cbuffer->b_filled = false;
} while (0);
// Debugging
#ifdef PB_CB_DEBUG
handle_status(__func__, ret);
#endif
return ret;
}
#endif

@ -0,0 +1,200 @@
// Resource/Inspiration: https://embedjournal.com/implementing-circular-buffer-embedded-c/
/*
Penguin's Circular Buffer -- a simple floating queue designed for low memory usage (mainly for embedded)
This is a ring buffer with limited capabilities. It is meant as a container for moving data.
Normally included features such as checks to see if the buffer is full or empty have been omitted
because this type of buffer is being implemented mainly for sensor data usage. Data is almost never read
individually, and even if it is, it isn't meant to be cleared on read. It is a simple moving buffer that
automatically writes over old data for the purpose of keeping track of the most up to date data.
Notes:
- Initialization is mandatory using p_cb_<type>_init.
- If a circular buffer is not initialized, you will run into a LOT of hard-to-debug problems. Just initialize it.
- By default, all cb types should be defined as disabled. This is to save on size. Enable the ones you want to use.
Behavior:
- Oldest data is overwritten
- popping of data isn't implemented. If this feature is required, use a ring buffer.
Acronyms:
- p: penguin
- pb: penguin buffer
- cb: circular buffer
- uX, where X is bit size: unsigned X bit integer
- iX, where X is bit size: signed X bit integer
Note: I wrote this like 3 years ago or something. I hope it works.
*/
#ifndef _PCIRCULARBUFFER_H_
#define _PCIRCULARBUFFER_H_
#include <stdbool.h>
#include <stdint.h>
// comment this out for release builds
//#define PB_CB_DEBUG
// Making these PB_EN/DIS rather than just ENABLE/DISABLE because
// some enable/disable definition might already exist that is
// inversely active (enabled = 0, disable = 1)
// this way our en/dis definitions are explicit
#ifndef PB_ENABLE
#define PB_ENABLE (1)
#endif
#ifndef PB_DISABLE
#define PB_DISABLE (0)
#endif
// Max size is 65535 (2^16 - 1) so variables can be safely set 16 bits (unsigned)
// If you want to change this, you'll need to change the sizes of all heads and max lengths
#define PB_CB_MAX_BUFFER_SIZE (65535)
// Config
// Disable or Enable types needed here
// We can save code size this way
// While there are better ways to do this, this is the most accessible for anyone imo
#define PB_CB_FLOAT PB_DISABLE
#define PB_CB_DOUBLE PB_DISABLE
#define PB_CB_U8 PB_ENABLE
#define PB_CB_U16 PB_DISABLE
#define PB_CB_U32 PB_DISABLE
#define PB_CB_U64 PB_DISABLE
#define PB_CB_I8 PB_DISABLE
#define PB_CB_I16 PB_DISABLE
#define PB_CB_I32 PB_DISABLE
#define PB_CB_I64 PB_DISABLE
typedef enum PB_CB_STATUS
{
PB_CB_GOOD = 0,
PB_CB_BAD = 1,
PB_CB_BAD_BUFFER_SIZE = 2,
PB_CB_NULL_BUFFER = 3,
PB_CB_NULL_CBUFFER = 4
} PB_CB_STATUS;
#if PB_CB_U8
typedef struct p_cb_u8
{
uint8_t *buffer;
uint16_t head;
uint16_t max_len;
// Signifies the buffer being filled at least once.
// Useful for initializing sensor data
bool b_filled;
// Signifies the buffer being empty
// Useful for knowing if data is being received
bool b_empty;
PB_CB_STATUS (*push)(struct p_cb_u8 *cbuffer, uint8_t value);
PB_CB_STATUS (*empty)(struct p_cb_u8 *cbuffer);
} p_cb_u8;
PB_CB_STATUS p_cb_u8_init(p_cb_u8 *circ_buffer, uint8_t *buff, uint32_t max_length);
#endif
#if PB_CB_U16
typedef struct p_cb_u16
{
uint16_t *buffer;
uint16_t head;
uint16_t max_len;
// Signifies the buffer being filled at least once.
// Useful for initializing sensor data
bool b_filled;
// Signifies the buffer being empty
// Useful for knowing if data is being received
bool b_empty;
PB_CB_STATUS (*push)(struct p_cb_u16 *cbuffer, uint16_t value);
PB_CB_STATUS (*empty)(struct p_cb_u16 *cbuffer);
} p_cb_u16;
PB_CB_STATUS p_cb_u16_init(p_cb_u16 *circ_buffer, uint16_t *buff, uint32_t max_length);
#endif
#if PB_CB_U32
typedef struct p_cb_u32
{
uint32_t *buffer;
uint16_t head;
uint16_t max_len;
// Signifies the buffer being filled at least once.
// Useful for initializing sensor data
bool b_filled;
// Signifies the buffer being empty
// Useful for knowing if data is being received
bool b_empty;
PB_CB_STATUS (*push)(struct p_cb_u32 *cbuffer, uint32_t value);
PB_CB_STATUS (*empty)(struct p_cb_u32 *cbuffer);
} p_cb_u32;
PB_CB_STATUS p_cb_u32_init(p_cb_u32 *circ_buffer, uint32_t *buff, uint32_t max_length);
#endif
#if PB_CB_U64
typedef struct p_cb_u64
{
uint64_t *buffer;
uint16_t head;
uint16_t max_len;
// Signifies the buffer being filled at least once.
// Useful for initializing sensor data
bool b_filled;
// Signifies the buffer being empty
// Useful for knowing if data is being received
bool b_empty;
PB_CB_STATUS (*push)(struct p_cb_u64 *cbuffer, uint64_t value);
PB_CB_STATUS (*empty)(struct p_cb_u64 *cbuffer);
} p_cb_u64;
PB_CB_STATUS p_cb_u64_init(p_cb_u64 *circ_buffer, uint64_t *buff, uint32_t max_length);
#endif
#if PB_CB_FLOAT
typedef struct p_cb_float
{
float *buffer;
uint16_t head;
uint16_t max_len;
// Signifies the buffer being filled at least once.
// Useful for initializing sensor data
bool b_filled;
// Signifies the buffer being empty
// Useful for knowing if data is being received
bool b_empty;
PB_CB_STATUS (*push)(struct p_cb_float *cbuffer, float value);
PB_CB_STATUS (*empty)(struct p_cb_float *cbuffer);
} p_cb_float;
PB_CB_STATUS p_cb_float_init(p_cb_float *circ_buffer, float *buff, uint32_t max_length);
#endif
#if PB_CB_DOUBLE
typedef struct p_cb_double
{
double *buffer;
uint16_t head;
uint16_t max_len;
// Signifies the buffer being filled at least once.
// Useful for initializing sensor data
bool b_filled;
// Signifies the buffer being empty
// Useful for knowing if data is being received
bool b_empty;
PB_CB_STATUS (*push)(struct p_cb_double *cbuffer, double value);
PB_CB_STATUS (*empty)(struct p_cb_double *cbuffer);
} p_cb_double;
PB_CB_STATUS p_cb_double_init(p_cb_double *circ_buffer, double *buff, uint32_t max_length);
#endif
#endif

@ -3,13 +3,13 @@
#include "stm32l4xx_hal.h"
int p_printf(const char* fmt, ...);
void p_uart_init(UART_HandleTypeDef* huart);
int p_printf(const char *fmt, ...);
void p_uart_init(UART_HandleTypeDef *huart);
#ifdef _DEBUG
#define PDEBUG(f_, ...) p_printf((f_), ##__VA_ARGS__)
#define PDEBUG(f_, ...) p_printf((f_), ##__VA_ARGS__)
#else
#define PDEBUG(f_, ...) void(f_, ...)
#define PDEBUG(f_, ...) void(f_, ...)
#endif
#endif

Loading…
Cancel
Save