-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move sd and display initialization to seperate
- Loading branch information
1 parent
1e6b76c
commit 19a853b
Showing
9 changed files
with
2,104 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#include "SD.h" | ||
|
||
void HAL_SD_MspInit(SD_HandleTypeDef *hsd) | ||
{ | ||
GPIO_InitTypeDef GPIO_InitStruct = {0}; | ||
if(hsd->Instance==SDIO) | ||
{ | ||
/* Peripheral clock enable */ | ||
__HAL_RCC_SDIO_CLK_ENABLE(); | ||
|
||
__HAL_RCC_GPIOC_CLK_ENABLE(); | ||
__HAL_RCC_GPIOD_CLK_ENABLE(); | ||
/**SDIO GPIO Configuration | ||
PC8 ------> SDIO_D0 | ||
PC9 ------> SDIO_D1 | ||
PC10 ------> SDIO_D2 | ||
PC11 ------> SDIO_D3 | ||
PC12 ------> SDIO_CK | ||
PD2 ------> SDIO_CMD | ||
*/ | ||
GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 | ||
|GPIO_PIN_12; | ||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||
GPIO_InitStruct.Pull = GPIO_PULLUP; | ||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||
GPIO_InitStruct.Alternate = GPIO_AF12_SDIO; | ||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); | ||
|
||
GPIO_InitStruct.Pin = GPIO_PIN_2; | ||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||
GPIO_InitStruct.Pull = GPIO_PULLUP; | ||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||
GPIO_InitStruct.Alternate = GPIO_AF12_SDIO; | ||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); | ||
|
||
/* USER CODE BEGIN SDIO_MspInit 1 */ | ||
|
||
/* USER CODE END SDIO_MspInit 1 */ | ||
} | ||
} | ||
|
||
SD_HandleTypeDef hsd; | ||
void initSD_Card() | ||
{ | ||
hsd.Instance = SDIO; | ||
hsd.Init.ClockEdge = SDIO_CLOCK_EDGE_RISING; | ||
hsd.Init.ClockBypass = SDIO_CLOCK_BYPASS_DISABLE; | ||
hsd.Init.ClockPowerSave = SDIO_CLOCK_POWER_SAVE_DISABLE; | ||
hsd.Init.BusWide = SDIO_BUS_WIDE_1B; | ||
hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE; | ||
hsd.Init.ClockDiv = 0; | ||
// setupSD_handle(hsd); | ||
FATFS_LinkDriver(&SD_Driver, SDPath); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#pragma once | ||
#include "fatfs.h" | ||
|
||
void HAL_SD_MspInit(SD_HandleTypeDef *hsd); | ||
|
||
void initSD_Card(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
#include "display_setup.h" | ||
|
||
/** | ||
* @brief GPIO Initialization Function | ||
* @param None | ||
* @retval None | ||
*/ | ||
void MX_GPIO_Init(void) | ||
{ | ||
/* GPIO Ports Clock Enable */ | ||
__HAL_RCC_GPIOE_CLK_ENABLE(); | ||
__HAL_RCC_GPIOD_CLK_ENABLE(); | ||
GPIO_InitTypeDef GPIO_InitStruct; | ||
GPIO_InitStruct.Pin = 0b1110011110110111; | ||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; | ||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; | ||
GPIO_InitStruct.Pull = GPIO_NOPULL; | ||
GPIO_InitStruct.Alternate = GPIO_AF12_FSMC; | ||
HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); | ||
GPIO_InitStruct.Pin = 0b1111111110000000; | ||
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); | ||
} | ||
|
||
/* FSMC initialization function */ | ||
void MX_FSMC_Init(void) | ||
{ | ||
|
||
SRAM_HandleTypeDef hsram1; | ||
FSMC_NORSRAM_TimingTypeDef Timing = {0}; | ||
|
||
/** Perform the SRAM1 memory initialization sequence | ||
*/ | ||
hsram1.Instance = FSMC_NORSRAM_DEVICE; | ||
hsram1.Extended = FSMC_NORSRAM_EXTENDED_DEVICE; | ||
/* hsram1.Init */ | ||
hsram1.Init.NSBank = FSMC_NORSRAM_BANK1; | ||
hsram1.Init.DataAddressMux = FSMC_DATA_ADDRESS_MUX_DISABLE; | ||
hsram1.Init.MemoryType = FSMC_MEMORY_TYPE_SRAM; | ||
hsram1.Init.MemoryDataWidth = FSMC_NORSRAM_MEM_BUS_WIDTH_16; | ||
hsram1.Init.BurstAccessMode = FSMC_BURST_ACCESS_MODE_DISABLE; | ||
hsram1.Init.WaitSignalPolarity = FSMC_WAIT_SIGNAL_POLARITY_LOW; | ||
hsram1.Init.WrapMode = FSMC_WRAP_MODE_DISABLE; | ||
hsram1.Init.WaitSignalActive = FSMC_WAIT_TIMING_BEFORE_WS; | ||
hsram1.Init.WriteOperation = FSMC_WRITE_OPERATION_ENABLE; | ||
hsram1.Init.WaitSignal = FSMC_WAIT_SIGNAL_DISABLE; | ||
hsram1.Init.ExtendedMode = FSMC_EXTENDED_MODE_DISABLE; | ||
hsram1.Init.AsynchronousWait = FSMC_ASYNCHRONOUS_WAIT_DISABLE; | ||
hsram1.Init.WriteBurst = FSMC_WRITE_BURST_DISABLE; | ||
hsram1.Init.PageSize = FSMC_PAGE_SIZE_NONE; | ||
/* Timing */ | ||
Timing.AddressSetupTime = 1; | ||
Timing.AddressHoldTime = 15; | ||
Timing.DataSetupTime = 5; | ||
Timing.BusTurnAroundDuration = 0; | ||
Timing.CLKDivision = 16; | ||
Timing.DataLatency = 17; | ||
Timing.AccessMode = FSMC_ACCESS_MODE_A; | ||
/* ExtTiming */ | ||
__HAL_RCC_FSMC_CLK_ENABLE(); | ||
if (HAL_SRAM_Init(&hsram1, &Timing, NULL) != HAL_OK) | ||
{ | ||
while (true) | ||
; | ||
} | ||
} | ||
|
||
void initLCDHardware() | ||
{ | ||
MX_GPIO_Init(); | ||
MX_FSMC_Init(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#pragma once | ||
|
||
#include "ili9341.h" | ||
|
||
void initLCDHardware(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters