Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
50 changes: 50 additions & 0 deletions experimenting/Core/Inc/comms.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
******************************************************************************
* @file : comms.h
* @brief : Header for comms.c file.
* This file contains the display (serial, LCD, etc) defines
* of the application.
******************************************************************************
* @attention
*
* Copyright (c) 2024 The Digital Mermaid
* 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.
*
******************************************************************************
*/

#ifndef __COMMS_H__
#define __COMMS_H__

#include <inttypes.h>

/**
* @brief Stores the switch settings of the system for display.
* @param main: main switch (LCD display)
* @param throttleStop: throttle stop switch
* @param speed10kwHigh High speed switch for 10kw motor
* @param speed10kwLow Low speed switch for 10kw motor
* @param speed5kwHigh High speed switch for 5kw motor
* @param speed5kwLow Low speed switch for 5kw motor
* @retval None
*/
void lcdSetGlobalSwitches(uint8_t main, uint8_t throttleStop, uint8_t speed10kwHigh, uint8_t speed10kwLow, uint8_t speed5kwHigh, uint8_t speed5kwLow);

/**
* @brief Prints data to serial, LCDs, LED displays, etc.
* @retval None
* @note All but serial are disabled if the main switch is off.
*/
void commsPrint();

/**
* @brief Initialize Comms; LCD, serial, LED displays, etc.
* @retval None
*/
void commsInit();

#endif
32 changes: 32 additions & 0 deletions experimenting/Core/Inc/config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
******************************************************************************
* @file : config.h
* @brief : Header for config.c file.
* This file contains global configs for mhelm
******************************************************************************
* @attention
*
* Copyright (c) 2024 The Digital Mermaid.
* All rights reserved.
*
* This software is licensed under the GPL v3, the terms can be found in the
* LICENSE file in the root directory of this software component.
*
******************************************************************************
*/

#ifndef CONFIG_H
#define CONFIG_H

#define MAJOR_VERSION 0
#define MINOR_VERSION 1
#define ADC_NUM_CHANS 3

// interrupt prios
#define INT_PRIO_SYSTICK 0
#define INT_PRIO_USB 4
#define INT_PRIO_SPI 5
#define INT_PRIO_RT_TASK 6
#define INT_PRIO_ADC 7

#endif
130 changes: 130 additions & 0 deletions experimenting/Core/Inc/main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.h
* @brief : Header for main.c file.
* This file contains the common defines of the application.
******************************************************************************
* @attention
*
* Copyright (c) 2024 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 __MAIN_H
#define __MAIN_H

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include "stm32f0xx_hal.h"

/* 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 */

void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);

/* Exported functions prototypes ---------------------------------------------*/
void Error_Handler(void);

/* USER CODE BEGIN EFP */

/* USER CODE END EFP */

/* Private defines -----------------------------------------------------------*/
// Define pins
#define B1_Pin GPIO_PIN_13
#define B1_GPIO_Port GPIOC
#define THROTTLE_STBD_POT_Pin GPIO_PIN_0
#define THROTTLE_STBD_POT_GPIO_Port GPIOA
#define REGEN_POT_Pin GPIO_PIN_1
#define REGEN_POT_GPIO_Port GPIOA
#define USART_TX_Pin GPIO_PIN_2
#define USART_TX_GPIO_Port GPIOA
#define USART_RX_Pin GPIO_PIN_3
#define USART_RX_GPIO_Port GPIOA
#define M5KW_BRAKE_OUT_Pin GPIO_PIN_4
#define M5KW_BRAKE_OUT_GPIO_Port GPIOF
#define M5KW_SPEED_LOW_OUT_Pin GPIO_PIN_5
#define M5KW_SPEED_LOW_OUT_GPIO_Port GPIOF
#define THROTTLE_PORT_POT_Pin GPIO_PIN_4
#define THROTTLE_PORT_POT_GPIO_Port GPIOA
#define LD2_Pin GPIO_PIN_5
#define LD2_GPIO_Port GPIOA
#define LCD_BL_RED_Pin GPIO_PIN_6
#define LCD_BL_RED_GPIO_Port GPIOA
#define LCD_BL_GREEN_Pin GPIO_PIN_7
#define LCD_BL_GREEN_GPIO_Port GPIOA
#define M5KW_SPEED_HIGH_OUT_Pin GPIO_PIN_4
#define M5KW_SPEED_HIGH_OUT_GPIO_Port GPIOC
#define LCD_BL_BLUE_Pin GPIO_PIN_0
#define LCD_BL_BLUE_GPIO_Port GPIOB
#define PANEL_CS_Pin GPIO_PIN_10
#define PANEL_CS_GPIO_Port GPIOB
#define LCD_SDA_Pin GPIO_PIN_11
#define LCD_SDA_GPIO_Port GPIOB
#define M10KW_BRAKE_OUT_Pin GPIO_PIN_13
#define M10KW_BRAKE_OUT_GPIO_Port GPIOB
#define M10KW_SPEED_LOW_OUT_Pin GPIO_PIN_14
#define M10KW_SPEED_LOW_OUT_GPIO_Port GPIOB
#define M10KW_SPEED_HIGH_OUT_Pin GPIO_PIN_15
#define M10KW_SPEED_HIGH_OUT_GPIO_Port GPIOB
#define LCD_SCL_Pin GPIO_PIN_6
#define LCD_SCL_GPIO_Port GPIOF
#define ESTOP_SW_IN_Pin GPIO_PIN_7
#define ESTOP_SW_IN_GPIO_Port GPIOF
#define TCK_Pin GPIO_PIN_14
#define TCK_GPIO_Port GPIOA
#define BACKUP_KEY_SW_IN_Pin GPIO_PIN_15
#define BACKUP_KEY_SW_IN_GPIO_Port GPIOA
#define M5KW_REGEN_DAC_A0_Pin GPIO_PIN_10
#define M5KW_REGEN_DAC_A0_GPIO_Port GPIOC
#define M10KW_REGEN_DAC_A0_Pin GPIO_PIN_11
#define M10KW_REGEN_DAC_A0_GPIO_Port GPIOC
#define M5KW_THROTTLE_DAC_A0_Pin GPIO_PIN_12
#define M5KW_THROTTLE_DAC_A0_GPIO_Port GPIOC
#define M10KW_THROTTLE_DAC_A0_Pin GPIO_PIN_2
#define M10KW_THROTTLE_DAC_A0_GPIO_Port GPIOD
#define DAC_SDA_Pin GPIO_PIN_7
#define DAC_SDA_GPIO_Port GPIOB
#define DAC_SCL_Pin GPIO_PIN_8
#define DAC_SCL_GPIO_Port GPIOB

/* USER CODE BEGIN Private defines */
// main timer task
void main_timer_task(void);

/* USER CODE END Private defines */

#ifdef __cplusplus
}
#endif

#endif /* __MAIN_H */
30 changes: 30 additions & 0 deletions experimenting/Core/Inc/panel.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Panel Interface Code
*
* Copyright 2024: Digital Mermaid
* Written by: digimer
*
*/
#ifndef PANEL_H
#define PANEL_H

#include <inttypes.h>

// settings
#define PANEL_SPI_BUFLEN 2

// init the panel
void panel_init(void);

// run the panel timer task
void panel_timer_task(void);

typedef struct panel_state {
uint8_t spi_tx_buf[PANEL_SPI_BUFLEN];
uint8_t spi_rx_buf[PANEL_SPI_BUFLEN];
};

// panel state
extern struct panel_state panstate;

#endif
Loading