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

Firmware cleanup #778

Merged
merged 26 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
48708aa
Inline Surface::init into the constructor
Daft-Freak Jun 12, 2022
3ddd1e2
stm32: remove old resed-based switching code
Daft-Freak Jun 12, 2022
79eb319
stm32: remove ADC stop code
Daft-Freak Jun 12, 2022
ef7c205
stm32: remove APPLICATION_VTOR define
Daft-Freak Jun 12, 2022
82cd0ea
stm32: remove EXTERNAL_LOAD_ADDRESS define
Daft-Freak Jun 12, 2022
c570da0
stm32: remove INITIALISE_QSPI define
Daft-Freak Jun 12, 2022
3482e6b
stm32: remove CDC_FIFO_BUFFERS_EXT
Daft-Freak Jun 12, 2022
8db5590
stm32: move qspi flash size/address values to a header
Daft-Freak Jun 12, 2022
c2f69f4
stm32: simplify flash size calculation
Daft-Freak Jun 12, 2022
3044757
Reject files with no relocs when flashing from SD
Daft-Freak Jun 12, 2022
84f4632
Require relocs in parse_file_metadata too
Daft-Freak Jun 12, 2022
c33bcf5
stm32: map set_screen_mode to set_screen_mode_format
Daft-Freak Jun 12, 2022
a97e011
stm32: move some #defines from main.h to the only user
Daft-Freak Jun 12, 2022
1f736bf
stm32: add GPIO read/write inline functions
Daft-Freak Jun 12, 2022
6be44fd
stm32: use gpio::read/write
Daft-Freak Jun 12, 2022
4776e12
stm32: merge the 6 GPIO clock enables
Daft-Freak Jun 12, 2022
7432745
stm32: move the directory check out of the loop in save_screenshot
Daft-Freak Jun 12, 2022
5924cb5
stm32: avoid std::string usage in get_save_path
Daft-Freak Jun 12, 2022
f0ea90c
stm32: avoid std::string usage in save_screenshot
Daft-Freak Jun 12, 2022
02beafe
stm32: remove screen surface templates
Daft-Freak Jun 12, 2022
c871d57
stm32: remove a few layers between fatfs and the SD code
Daft-Freak Jun 12, 2022
355efc7
stm32: move internal display function declarations to the cpp
Daft-Freak Sep 10, 2022
596c36b
stm32: make internal display functions static
Daft-Freak Sep 10, 2022
6a7b86c
stm32: make the CDC stream header static const
Daft-Freak Sep 10, 2022
eead6b7
stm32: shave a few more bytes off CDCCommandStream
Daft-Freak Sep 10, 2022
f82274e
stm32: avoid map[] in CDCCommandStream
Daft-Freak Sep 10, 2022
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
9 changes: 1 addition & 8 deletions 32blit-stm32/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ list(APPEND SOURCES
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_jpeg.c
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_hcd.c
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_usb.c
Middlewares/Third_Party/FatFs/src/diskio.c
Middlewares/Third_Party/FatFs/src/ff_gen_drv.c
../3rd-party/fatfs/ff.c
../3rd-party/fatfs/ffsystem.c
../3rd-party/fatfs/ffunicode.c
Expand All @@ -58,8 +56,7 @@ list(APPEND SOURCES
Middlewares/ST/STM32_USB_Host_Library/Class/CDC/Src/usbh_cdc.c
Src/usbd_msc_scsi.c
Src/system_stm32h7xx.c
Src/user_diskio.c
Src/fatfs.c
Src/fatfs.cpp
Src/fatfs_sd.c
Src/usb_otg.c
Src/usb_device.c
Expand Down Expand Up @@ -131,7 +128,6 @@ set(INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/CMSIS/Device/ST/STM32H7xx/Include
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/CMSIS/Include
${CMAKE_CURRENT_SOURCE_DIR}/Drivers/CMSIS/Include
${CMAKE_CURRENT_SOURCE_DIR}/Middlewares/Third_Party/FatFs/src
${CMAKE_CURRENT_SOURCE_DIR}/Middlewares/ST/STM32_USB_Device_Library/Core/Inc
${CMAKE_CURRENT_SOURCE_DIR}/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Inc
${CMAKE_CURRENT_SOURCE_DIR}/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Inc
Expand Down Expand Up @@ -162,9 +158,6 @@ target_include_directories(BlitHalSTM32
target_compile_definitions(BlitHalSTM32
PRIVATE
${DEFINITIONS}
-DAPPLICATION_VTOR=${APPLICATION_VTOR}
-DEXTERNAL_LOAD_ADDRESS=${EXTERNAL_LOAD_ADDRESS}
-DINITIALISE_QSPI=${INITIALISE_QSPI}
-DCDC_FIFO_BUFFERS=${CDC_FIFO_BUFFERS}
)

Expand Down
5 changes: 1 addition & 4 deletions 32blit-stm32/Inc/CDCCommandStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ class CDCCommandStream

StreamState m_state;

uint8_t m_header[4] = { '3', '2', 'B', 'L' };
uint8_t m_uHeaderScanPos = 0;
uint8_t m_uCommandScanPos = 0;
uint8_t m_uRetryCount = 0;
CDCCommandHandler::CDCFourCC uCommand = 0;


Expand All @@ -63,9 +63,6 @@ class CDCCommandStream

CDCDataStream m_dataStream;

uint8_t m_uRetryCount = 0;


CDCFifoElement m_fifoElements[CDC_FIFO_BUFFERS];
uint8_t m_uFifoReadPos;
uint8_t m_uFifoWritePos;
Expand Down
11 changes: 0 additions & 11 deletions 32blit-stm32/Inc/display.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,6 @@ namespace display {
SurfaceInfo &set_screen_mode(ScreenMode new_mode);
void set_screen_palette(const Pen *colours, int num_cols);
bool set_screen_mode_format(ScreenMode new_mode, SurfaceTemplate &new_surf_template);

void flip(const Surface &source);

void screen_init();
void ltdc_init();

uint32_t get_dma2d_count(void);

void dma2d_lores_flip_step2(void);
void dma2d_lores_flip_step3(void);
void dma2d_lores_flip_step4(void);
}


Expand Down
49 changes: 0 additions & 49 deletions 32blit-stm32/Inc/fatfs.h

This file was deleted.

18 changes: 15 additions & 3 deletions 32blit-stm32/Inc/gpio.hpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
#ifndef __PIN_CONFIGURATION_H
#define __PIN_CONFIGURATION_H

#include <cstdint>

#include "main.h"
#include "gpio_defs.h"

namespace gpio {

// initialises all of the pins of the MCU into the correct
// configuration for 32blit
// initialises all of the pins of the MCU into the correct
// configuration for 32blit
void init();

inline bool read(GPIO_TypeDef *port, uint16_t pins) {
return port->IDR & pins;
}

inline void write(GPIO_TypeDef *port, uint16_t pins, bool value) {
if(value)
port->BSRR = pins;
else
port->BSRR = pins << 16;
}
}

#endif
#endif
3 changes: 0 additions & 3 deletions 32blit-stm32/Inc/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,7 @@ extern uint8_t charge_led_b;
/* Private defines -----------------------------------------------------------*/

/* USER CODE BEGIN Private defines */
#define HIGH(PORT, PIN) HAL_GPIO_WritePin(PORT, PIN, GPIO_PIN_SET);
#define LOW(PORT, PIN) HAL_GPIO_WritePin(PORT, PIN, GPIO_PIN_RESET);

#define DELAY(MS) HAL_Delay(MS)
/* USER CODE END Private defines */

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion 32blit-stm32/Inc/quadspi.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ extern QSPI_HandleTypeDef hqspi;
#define APPLICATION_ADDRESS QSPI_BASE

// Flash example
#define QSPI_FLASH_SIZE POSITION_VAL(0x2000000)-1
#define QSPI_FLASH_SIZE __builtin_ctz(0x2000000)-1
#define QSPI_PAGE_SIZE 256

/* Reset Operations */
Expand Down
9 changes: 9 additions & 0 deletions 32blit-stm32/Inc/quadspi.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#pragma once
#include <cstdint>

constexpr uint32_t qspi_flash_sector_size = 64 * 1024;
constexpr uint32_t qspi_flash_size = 32768 * 1024;
constexpr uint32_t qspi_flash_address = 0x90000000;

// resevered space for temp/cached files
constexpr uint32_t qspi_tmp_reserved = 4 * 1024 * 1024;
7 changes: 5 additions & 2 deletions 32blit-stm32/Inc/spi-st7272a.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
#define ST7272A_DISPLAY_MODE_REGISTER 0x19
#define ST7272A_DISPLAY_MODE_DEFAULT 0xec // 0b11101100 VA Mode, Top/Bottom & Left/Right scan, Negative polarity VSync/HSync pulses

#define HIGH(PORT, PIN) HAL_GPIO_WritePin(PORT, PIN, GPIO_PIN_SET);
#define LOW(PORT, PIN) HAL_GPIO_WritePin(PORT, PIN, GPIO_PIN_RESET);

#define ST7272A_CS(active) if(active) {LOW(LCD_CS_GPIO_Port, LCD_CS_Pin)} else {HIGH(LCD_CS_GPIO_Port, LCD_CS_Pin)}
#define ST7272A_RESET() LOW(LCD_RESET_GPIO_Port, LCD_RESET_Pin); DELAY(100); HIGH(LCD_RESET_GPIO_Port, LCD_RESET_Pin); DELAY(100);
#define ST7272A_RESET() LOW(LCD_RESET_GPIO_Port, LCD_RESET_Pin); HAL_Delay(100); HIGH(LCD_RESET_GPIO_Port, LCD_RESET_Pin); HAL_Delay(100);

#ifdef __cplusplus
extern "C" {
Expand All @@ -18,4 +21,4 @@ extern void st7272a_set_bgr();
}
#endif

#endif
#endif
105 changes: 0 additions & 105 deletions 32blit-stm32/Middlewares/Third_Party/FatFs/src/diskio.c

This file was deleted.

Loading