change names
This commit is contained in:
parent
7129218803
commit
4771a26c9d
17
Inc/main.h
17
Inc/main.h
|
@ -51,6 +51,23 @@
|
|||
|
||||
/* Private define ------------------------------------------------------------*/
|
||||
|
||||
#define button2_Pin GPIO_PIN_3
|
||||
#define button2_GPIO_Port GPIOE
|
||||
#define button1_Pin GPIO_PIN_4
|
||||
#define button1_GPIO_Port GPIOE
|
||||
#define led1_Pin GPIO_PIN_6
|
||||
#define led1_GPIO_Port GPIOA
|
||||
#define led2_Pin GPIO_PIN_7
|
||||
#define led2_GPIO_Port GPIOA
|
||||
#define usart1_tx_Pin GPIO_PIN_9
|
||||
#define usart1_tx_GPIO_Port GPIOA
|
||||
#define usart1_rx_Pin GPIO_PIN_10
|
||||
#define usart1_rx_GPIO_Port GPIOA
|
||||
#define i2c1_scl_Pin GPIO_PIN_6
|
||||
#define i2c1_scl_GPIO_Port GPIOB
|
||||
#define i2c1_sda_Pin GPIO_PIN_7
|
||||
#define i2c1_sda_GPIO_Port GPIOB
|
||||
|
||||
/* USER CODE BEGIN Private defines */
|
||||
|
||||
/* USER CODE END Private defines */
|
||||
|
|
57
Src/main.c
57
Src/main.c
|
@ -35,6 +35,7 @@
|
|||
|
||||
#include "main.h"
|
||||
#include "stm32f4xx_hal.h"
|
||||
#include <stm32f4xx_hal_sd.h>
|
||||
#include "fatfs.h"
|
||||
|
||||
/* USER CODE BEGIN Includes */
|
||||
|
@ -72,11 +73,25 @@ static void MX_SDIO_SD_Init(void);
|
|||
/* USER CODE END PFP */
|
||||
|
||||
/* USER CODE BEGIN 0 */
|
||||
int _write(int file, char *ptr, int len)
|
||||
{
|
||||
int DataIdx;
|
||||
|
||||
for (DataIdx = 0; DataIdx < len; DataIdx++)
|
||||
{
|
||||
ITM_SendChar( *ptr++ );
|
||||
}
|
||||
|
||||
return len;
|
||||
}
|
||||
/* USER CODE END 0 */
|
||||
|
||||
int main(void)
|
||||
{
|
||||
/* USER CODE BEGIN 1 */
|
||||
FATFS mynewdiskFatFs; /* File system object for User logical drive */
|
||||
FIL MyFile; /* File object */
|
||||
char mynewdiskPath[4]; /* User logical drive path */
|
||||
/* USER CODE END 1 */
|
||||
|
||||
/* MCU Configuration----------------------------------------------------------*/
|
||||
|
@ -93,7 +108,28 @@ int main(void)
|
|||
MX_SDIO_SD_Init();
|
||||
MX_FATFS_Init();
|
||||
|
||||
|
||||
HAL_SD_CardInfoTypeDef cardinfo;
|
||||
HAL_SD_GetCardInfo(&hsd, &cardinfo);
|
||||
|
||||
int aids;
|
||||
char buffer[10];
|
||||
|
||||
/* USER CODE BEGIN 2 */
|
||||
if(FATFS_LinkDriver(&mynewdiskFatFs, mynewdiskPath) == 0) {
|
||||
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_7);
|
||||
aids = f_mount(&mynewdiskFatFs, (TCHAR const*)mynewdiskPath, 1);
|
||||
if(aids == FR_OK) {
|
||||
|
||||
//aids = 127;
|
||||
//Mounted OK, turn on RED LED
|
||||
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_6);
|
||||
HAL_Delay(1000);
|
||||
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_6);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ssd1306_Init();
|
||||
//starfield_Init();
|
||||
//cube_Init();
|
||||
|
@ -103,8 +139,13 @@ int main(void)
|
|||
//drawLine(0,2, 150, 2);
|
||||
//drawLine(0,4, 150, 4);
|
||||
|
||||
ssd1306_SetCursor(0, 53);
|
||||
sprintf(buffer, "Valor: %d", cardinfo.BlockNbr);
|
||||
ssd1306_WriteString(buffer, Font_7x10, White);
|
||||
|
||||
|
||||
//ssd1306_LoadImage();
|
||||
//ssd1306_UpdateScreen();
|
||||
ssd1306_UpdateScreen();
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Infinite loop */
|
||||
|
@ -131,9 +172,10 @@ int main(void)
|
|||
//cube_Update(60);
|
||||
*/
|
||||
|
||||
ssd1306_Anim();
|
||||
ssd1306_UpdateScreen();
|
||||
//HAL_Delay(100);
|
||||
//ssd1306_Anim();
|
||||
//ssd1306_UpdateScreen();
|
||||
//printf("LOL GORDOS\n");
|
||||
//HAL_Delay(1000);
|
||||
}
|
||||
/* USER CODE END 3 */
|
||||
}
|
||||
|
@ -224,7 +266,7 @@ static void MX_SDIO_SD_Init(void)
|
|||
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.BusWide = SDIO_BUS_WIDE_4B;
|
||||
hsd.Init.HardwareFlowControl = SDIO_HARDWARE_FLOW_CONTROL_DISABLE;
|
||||
hsd.Init.ClockDiv = 0;
|
||||
|
||||
|
@ -263,16 +305,17 @@ static void MX_GPIO_Init(void)
|
|||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
/* GPIO Ports Clock Enable */
|
||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
|
||||
/*Configure GPIO pin Output Level */
|
||||
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_6|GPIO_PIN_7, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(GPIOA, led1_Pin|led2_Pin, GPIO_PIN_RESET);
|
||||
|
||||
/*Configure GPIO pins : PA6 PA7 */
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
|
||||
GPIO_InitStruct.Pin = led1_Pin|led2_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
|
||||
|
|
|
@ -94,7 +94,7 @@ void HAL_I2C_MspInit(I2C_HandleTypeDef* hi2c)
|
|||
PB6 ------> I2C1_SCL
|
||||
PB7 ------> I2C1_SDA
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_7;
|
||||
GPIO_InitStruct.Pin = i2c1_scl_Pin|i2c1_sda_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
|
@ -125,7 +125,7 @@ void HAL_I2C_MspDeInit(I2C_HandleTypeDef* hi2c)
|
|||
PB6 ------> I2C1_SCL
|
||||
PB7 ------> I2C1_SDA
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_7);
|
||||
HAL_GPIO_DeInit(GPIOB, i2c1_scl_Pin|i2c1_sda_Pin);
|
||||
|
||||
}
|
||||
/* USER CODE BEGIN I2C1_MspDeInit 1 */
|
||||
|
@ -223,7 +223,7 @@ void HAL_UART_MspInit(UART_HandleTypeDef* huart)
|
|||
PA9 ------> USART1_TX
|
||||
PA10 ------> USART1_RX
|
||||
*/
|
||||
GPIO_InitStruct.Pin = GPIO_PIN_9|GPIO_PIN_10;
|
||||
GPIO_InitStruct.Pin = usart1_tx_Pin|usart1_rx_Pin;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
|
||||
|
@ -255,7 +255,7 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* huart)
|
|||
PA9 ------> USART1_TX
|
||||
PA10 ------> USART1_RX
|
||||
*/
|
||||
HAL_GPIO_DeInit(GPIOA, GPIO_PIN_9|GPIO_PIN_10);
|
||||
HAL_GPIO_DeInit(GPIOA, usart1_tx_Pin|usart1_rx_Pin);
|
||||
|
||||
/* Peripheral interrupt DeInit*/
|
||||
HAL_NVIC_DisableIRQ(USART1_IRQn);
|
||||
|
|
Loading…
Reference in New Issue