Browse Source

fixed sd card

alice
Gregor Wüst 3 years ago
parent
commit
441476fb6d
5 changed files with 48 additions and 18 deletions
  1. 1
    1
      RTC/.cproject
  2. 0
    1
      RTC/Core/Inc/stm32f4xx_it.h
  3. 20
    0
      RTC/Core/Src/main.c
  4. 13
    8
      RTC/FATFS/Target/user_diskio.c
  5. 14
    8
      RTC/RTC.ioc

+ 1
- 1
RTC/.cproject View File

<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.1702071327" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.value.fpv4-sp-d16" valueType="enumerated"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.1702071327" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.fpu.value.fpv4-sp-d16" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.136052850" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.136052850" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi" useByScannerDiscovery="true" value="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.floatabi.value.hard" valueType="enumerated"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.845380263" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="NUCLEO-F401RE" valueType="string"/> <option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board.845380263" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_board" useByScannerDiscovery="false" value="NUCLEO-F401RE" valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.1329066155" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.3 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.base.gnu-tools-for-stm32 || NUCLEO-F401RE || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Drivers/CMSIS/Include | ../Core/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc | ../Drivers/CMSIS/Device/ST/STM32F4xx/Include | ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy || || || USE_HAL_DRIVER | STM32F401xE || || Drivers | Core/Startup | Core || || || ${workspace_loc:/${ProjName}/STM32F401RETX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || " valueType="string"/>
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults.1329066155" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.defaults" useByScannerDiscovery="false" value="com.st.stm32cube.ide.common.services.build.inputs.revA.1.0.3 || Release || false || Executable || com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.base.gnu-tools-for-stm32 || NUCLEO-F401RE || 0 || 0 || arm-none-eabi- || ${gnu_tools_for_stm32_compiler_path} || ../Drivers/CMSIS/Include | ../Core/Inc | ../Drivers/STM32F4xx_HAL_Driver/Inc | ../Drivers/CMSIS/Device/ST/STM32F4xx/Include | ../Drivers/STM32F4xx_HAL_Driver/Inc/Legacy | ../FATFS/Target | ../FATFS/App | ../Middlewares/Third_Party/FatFs/src || || || USE_HAL_DRIVER | STM32F401xE || || Drivers | Core/Startup | Middlewares | Core | FATFS || || || ${workspace_loc:/${ProjName}/STM32F401RETX_FLASH.ld} || true || NonSecure || || secure_nsclib.o || " valueType="string"/>
<targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.565325187" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/> <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform.565325187" isAbstract="false" osList="all" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.targetplatform"/>
<builder buildPath="${workspace_loc:/RTC}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.151093449" managedBuildOn="true" name="Gnu Make Builder.Release" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/> <builder buildPath="${workspace_loc:/RTC}/Release" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder.151093449" managedBuildOn="true" name="Gnu Make Builder.Release" parallelBuildOn="true" parallelizationNumber="optimal" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder"/>
<tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.2138585427" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler"> <tool id="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler.2138585427" name="MCU GCC Assembler" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.tool.assembler">

+ 0
- 1
RTC/Core/Inc/stm32f4xx_it.h View File

void PendSV_Handler(void); void PendSV_Handler(void);
void SysTick_Handler(void); void SysTick_Handler(void);
void RTC_Alarm_IRQHandler(void); void RTC_Alarm_IRQHandler(void);

void EXTI15_10_IRQHandler(void); void EXTI15_10_IRQHandler(void);
void TIM4_IRQHandler(void); void TIM4_IRQHandler(void);
/* USER CODE BEGIN EFP */ /* USER CODE BEGIN EFP */

+ 20
- 0
RTC/Core/Src/main.c View File



transmit_uart("Resetting motor position and calculating new dates and times.\r\n"); transmit_uart("Resetting motor position and calculating new dates and times.\r\n");


BSP_MotorControl_Move(0, FORWARD, 300);
BSP_MotorControl_WaitWhileActive(0);
BSP_MotorControl_Move(0, FORWARD, 300);
BSP_MotorControl_WaitWhileActive(0);
BSP_MotorControl_Move(0, FORWARD, 300);
BSP_MotorControl_WaitWhileActive(0);

BSP_MotorControl_GoHome(0); BSP_MotorControl_GoHome(0);
BSP_MotorControl_WaitWhileActive(0); BSP_MotorControl_WaitWhileActive(0);


transmit_uart("File was not opened!\r\n"); transmit_uart("File was not opened!\r\n");
} }


f_puts("Cancer", &fil);

/* Close file */
fres = f_close(&fil);
if (fres == FR_OK) {
transmit_uart("File is closed.\r\n");
} else if (fres != FR_OK) {
transmit_uart("File was not closed.\r\n");
}

//Calculate sunrise and sunset time for tomorrow //Calculate sunrise and sunset time for tomorrow
calc_sunrise_sunset(&initialDate, &sunrise, &sunset, &tomorrowsDate); calc_sunrise_sunset(&initialDate, &sunrise, &sunset, &tomorrowsDate);


/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(LD2_GPIO_Port, LD2_Pin, GPIO_PIN_RESET);


/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET);

/*Configure GPIO pin : B1_Pin */ /*Configure GPIO pin : B1_Pin */
GPIO_InitStruct.Pin = B1_Pin; GPIO_InitStruct.Pin = B1_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING; GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;

+ 13
- 8
RTC/FATFS/Target/user_diskio.c View File

) )
{ {
/* USER CODE BEGIN INIT */ /* USER CODE BEGIN INIT */
Stat = STA_NOINIT;
return Stat;
SD_disk_initialize (pdrv);
//Stat = STA_NOINIT;
//return Stat;
/* USER CODE END INIT */ /* USER CODE END INIT */
} }


) )
{ {
/* USER CODE BEGIN STATUS */ /* USER CODE BEGIN STATUS */
Stat = STA_NOINIT;
return Stat;
SD_disk_status (pdrv);
//Stat = STA_NOINIT;
//return Stat;
/* USER CODE END STATUS */ /* USER CODE END STATUS */
} }


) )
{ {
/* USER CODE BEGIN READ */ /* USER CODE BEGIN READ */
return RES_OK;
SD_disk_read (pdrv,buff,sector,count);
//return RES_OK;
/* USER CODE END READ */ /* USER CODE END READ */
} }


{ {
/* USER CODE BEGIN WRITE */ /* USER CODE BEGIN WRITE */
/* USER CODE HERE */ /* USER CODE HERE */
return RES_OK;
SD_disk_write (pdrv, buff, sector, count);
//return RES_OK;
/* USER CODE END WRITE */ /* USER CODE END WRITE */
} }
#endif /* _USE_WRITE == 1 */ #endif /* _USE_WRITE == 1 */
) )
{ {
/* USER CODE BEGIN IOCTL */ /* USER CODE BEGIN IOCTL */
DRESULT res = RES_ERROR;
return res;
SD_disk_ioctl (pdrv, cmd, buff);
//DRESULT res = RES_ERROR;
//return res;
/* USER CODE END IOCTL */ /* USER CODE END IOCTL */
} }
#endif /* _USE_IOCTL == 1 */ #endif /* _USE_IOCTL == 1 */

+ 14
- 8
RTC/RTC.ioc View File

Mcu.Pin0=PC13-ANTI_TAMP Mcu.Pin0=PC13-ANTI_TAMP
Mcu.Pin1=PC14-OSC32_IN Mcu.Pin1=PC14-OSC32_IN
Mcu.Pin10=PB3 Mcu.Pin10=PB3
Mcu.Pin11=VP_FATFS_VS_Generic
Mcu.Pin12=VP_RTC_VS_RTC_Activate
Mcu.Pin13=VP_RTC_VS_RTC_Calendar
Mcu.Pin14=VP_RTC_VS_RTC_Alarm_B_Intern
Mcu.Pin15=VP_RTC_VS_RTC_Alarm_A_Intern
Mcu.Pin16=VP_SYS_VS_Systick
Mcu.Pin11=PB6
Mcu.Pin12=VP_FATFS_VS_Generic
Mcu.Pin13=VP_RTC_VS_RTC_Activate
Mcu.Pin14=VP_RTC_VS_RTC_Calendar
Mcu.Pin15=VP_RTC_VS_RTC_Alarm_B_Intern
Mcu.Pin16=VP_RTC_VS_RTC_Alarm_A_Intern
Mcu.Pin17=VP_SYS_VS_Systick
Mcu.Pin2=PC15-OSC32_OUT Mcu.Pin2=PC15-OSC32_OUT
Mcu.Pin3=PH0 - OSC_IN Mcu.Pin3=PH0 - OSC_IN
Mcu.Pin4=PH1 - OSC_OUT Mcu.Pin4=PH1 - OSC_OUT
Mcu.Pin7=PA5 Mcu.Pin7=PA5
Mcu.Pin8=PA13 Mcu.Pin8=PA13
Mcu.Pin9=PA14 Mcu.Pin9=PA14
Mcu.PinsNb=17
Mcu.PinsNb=18
Mcu.ThirdPartyNb=0 Mcu.ThirdPartyNb=0
Mcu.UserConstants= Mcu.UserConstants=
Mcu.UserName=STM32F401RETx Mcu.UserName=STM32F401RETx
PB3.GPIO_Label=SWO PB3.GPIO_Label=SWO
PB3.Locked=true PB3.Locked=true
PB3.Signal=SYS_JTDO-SWO PB3.Signal=SYS_JTDO-SWO
PB6.GPIOParameters=GPIO_Speed,PinState
PB6.GPIO_Speed=GPIO_SPEED_FREQ_MEDIUM
PB6.Locked=true
PB6.PinState=GPIO_PIN_SET
PB6.Signal=GPIO_Output
PC13-ANTI_TAMP.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI PC13-ANTI_TAMP.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI
PC13-ANTI_TAMP.GPIO_Label=B1 [Blue PushButton] PC13-ANTI_TAMP.GPIO_Label=B1 [Blue PushButton]
PC13-ANTI_TAMP.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING PC13-ANTI_TAMP.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_FALLING
ProjectManager.TargetToolchain=STM32CubeIDE ProjectManager.TargetToolchain=STM32CubeIDE
ProjectManager.ToolChainLocation= ProjectManager.ToolChainLocation=
ProjectManager.UnderRoot=true ProjectManager.UnderRoot=true
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART2_UART_Init-USART2-false-HAL-true,4-MX_RTC_Init-RTC-false-HAL-true
ProjectManager.functionlistsort=1-MX_GPIO_Init-GPIO-false-HAL-true,2-SystemClock_Config-RCC-false-HAL-false,3-MX_USART2_UART_Init-USART2-false-HAL-true,4-MX_RTC_Init-RTC-false-HAL-true,5-MX_FATFS_Init-FATFS-false-HAL-false
RCC.48MHZClocksFreq_Value=48000000 RCC.48MHZClocksFreq_Value=48000000
RCC.AHBFreq_Value=84000000 RCC.AHBFreq_Value=84000000
RCC.APB1CLKDivider=RCC_HCLK_DIV2 RCC.APB1CLKDivider=RCC_HCLK_DIV2

Loading…
Cancel
Save