*
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
/*
|
||||
* display_fsmc_interface.h
|
||||
*
|
||||
* Created on: 23 îêò. 2016 ã.
|
||||
* Author: l-pro
|
||||
*/
|
||||
|
||||
#ifndef DISPLAY_FSMC_INTERFACE_H_
|
||||
#define DISPLAY_FSMC_INTERFACE_H_
|
||||
|
||||
#include "stm32f7xx_hal.h"
|
||||
|
||||
namespace Stm32PlusPlus { namespace Display {
|
||||
|
||||
#define LCD_REG (*((volatile unsigned short *) 0x60000000))
|
||||
#define LCD_RAM (*((volatile unsigned short *) (0x60000000 | 0x00020000)))
|
||||
|
||||
class DisplayFsmcInterface {
|
||||
public:
|
||||
static constexpr uint16_t* addressLocation = (uint16_t*) 0x60000000;
|
||||
static constexpr uint16_t* dataLocation = (uint16_t*) (0x60000000 | 0x00020000);
|
||||
|
||||
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){
|
||||
*addressLocation = address;
|
||||
}
|
||||
|
||||
static void write(uint16_t value){
|
||||
*dataLocation = value;
|
||||
}
|
||||
|
||||
static uint16_t read(){
|
||||
return *dataLocation;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
|
||||
|
||||
#endif /* DISPLAY_FSMC_INTERFACE_H_ */
|
||||
Reference in New Issue
Block a user