This commit is contained in:
2025-05-13 02:03:18 +03:00
parent 72860c7968
commit 90ef6120fd
463 changed files with 380758 additions and 2 deletions
+83
View File
@@ -0,0 +1,83 @@
/*
* display_fsmc_interface.h
*
* Created on: 23 ���. 2016 �.
* Author: l-pro
*/
#ifndef DISPLAY_FSMC_INTERFACE_H_
#define DISPLAY_FSMC_INTERFACE_H_
#include "stm32h7xx_hal.h"
#include "main.h"
namespace Stm32PlusPlus { namespace Display {
#define LCD_REG (*((volatile unsigned short *) 0x60000000))
#define LCD_RAM (*((volatile unsigned short *) (0x60000000 | 0x00020000)))
struct FmcLcdAddressMap {
volatile uint16_t* addressLocation() const {
return reinterpret_cast<volatile uint16_t*>(0x60000000);
}
volatile uint16_t* dataLocation() const {
return reinterpret_cast<volatile uint16_t*> (0x60000000 | 0x00020000);
}
};
class DisplayFsmcInterface {
public:
//static const uint16_t* addressLocation = reinterpret_cast<uint16_t*>(0x60000000);
//static const uint16_t* dataLocation = reinterpret_cast<uint16_t*> (0x60000000 | 0x00020000);
static constexpr FmcLcdAddressMap addressMap = {};
static void init(){
MPU_Region_InitTypeDef MPU_InitStruct;
// Disable the MPU
HAL_MPU_Disable();
// Configure the MPU attributes for 16Mb NOR Flash
MPU_InitStruct.Enable = MPU_REGION_ENABLE;
MPU_InitStruct.BaseAddress = 0x60000000;
MPU_InitStruct.Size = MPU_REGION_SIZE_1MB;
MPU_InitStruct.AccessPermission = MPU_REGION_FULL_ACCESS;
MPU_InitStruct.IsBufferable = MPU_ACCESS_NOT_BUFFERABLE;
MPU_InitStruct.IsCacheable = MPU_ACCESS_NOT_CACHEABLE;
MPU_InitStruct.IsShareable = MPU_ACCESS_NOT_SHAREABLE;
MPU_InitStruct.Number = MPU_REGION_NUMBER1;
MPU_InitStruct.TypeExtField = MPU_TEX_LEVEL0;
MPU_InitStruct.SubRegionDisable = 0x00;
MPU_InitStruct.DisableExec = MPU_INSTRUCTION_ACCESS_ENABLE;
HAL_MPU_ConfigRegion(&MPU_InitStruct);
// Enable the MPU
HAL_MPU_Enable(MPU_PRIVILEGED_DEFAULT);
}
static void reset(){
HAL_GPIO_WritePin(LCD_RESET_GPIO_Port, LCD_RESET_Pin, GPIO_PIN_RESET);
HAL_Delay(1);
HAL_GPIO_WritePin(LCD_RESET_GPIO_Port, LCD_RESET_Pin, GPIO_PIN_SET);
HAL_Delay(10);
}
static void setAddress(uint16_t address){
*addressMap.addressLocation() = address;
}
static void write(uint16_t value){
*addressMap.dataLocation() = value;
}
static uint16_t read(){
return *addressMap.dataLocation();
}
};
}}
#endif /* DISPLAY_FSMC_INTERFACE_H_ */