100 lines
2.1 KiB
C
100 lines
2.1 KiB
C
#include "storage.h"
|
|
#include "app_state.h" /* fgoto */
|
|
#include "File_Handling.h" /* Mount_SD, Update_File_byte, Seek_Read_File, Remove_File, Create_File, FR_OK */
|
|
|
|
/* --- SD_SAVE / SD_READ / SD_REMOVE из main.c (дословно) --- */
|
|
int SD_SAVE(uint16_t *pbuff)
|
|
{
|
|
int test=0;
|
|
if (HAL_GPIO_ReadPin(SDMMC1_EN_GPIO_Port, SDMMC1_EN_Pin)==GPIO_PIN_RESET)
|
|
{
|
|
test = Mount_SD("/");
|
|
if (test == 0) //0 - suc
|
|
{
|
|
//Format_SD();
|
|
test = Update_File_byte("FILE1.TXT", (uint8_t *)pbuff, DL_8);
|
|
test = Unmount_SD("/"); // 0 - succ
|
|
return test;
|
|
}
|
|
else
|
|
{
|
|
return 1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return 1;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//uint32_t Get_Length(void)
|
|
//{
|
|
// return SD_matr[0][0] + ((uint32_t) (SD_matr[0][1])<<16);
|
|
//}
|
|
|
|
int SD_READ(uint16_t *pbuff)
|
|
{
|
|
int test=0;
|
|
if (HAL_GPIO_ReadPin(SDMMC1_EN_GPIO_Port, SDMMC1_EN_Pin)==GPIO_PIN_RESET)
|
|
{
|
|
test = Mount_SD("/");
|
|
if (test == 0) //0 - suc
|
|
{
|
|
//Format_SD();
|
|
test = Seek_Read_File ("FILE1.TXT", (uint8_t *)pbuff, DL_8, fgoto);//Read next 246 bytes
|
|
fgoto+=DL_8;
|
|
test = Unmount_SD("/"); // 0 - succ
|
|
return test;
|
|
}
|
|
else
|
|
{
|
|
return 1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return 1;
|
|
}
|
|
|
|
/* for (uint16_t j = 0; j < DL_16; j++)
|
|
{
|
|
*(pbuff+j) = SD_matr[SD_SLIDE][j];
|
|
}
|
|
if (SD_SLIDE<Get_Length())
|
|
{
|
|
SD_SLIDE++;
|
|
return 0x0000;
|
|
}
|
|
else
|
|
{
|
|
return 0x0001;
|
|
}*/
|
|
}
|
|
|
|
int SD_REMOVE(void)
|
|
{
|
|
int test=0;
|
|
if (HAL_GPIO_ReadPin(SDMMC1_EN_GPIO_Port, SDMMC1_EN_Pin)==GPIO_PIN_RESET)
|
|
{
|
|
test = Mount_SD("/");
|
|
if (test==FR_OK)
|
|
{
|
|
test = Remove_File ("FILE1.TXT");
|
|
test = Create_File("FILE1.TXT"); // 0 -suc
|
|
//test = Write_File ("FILE1.TXT", "____OSGG main borad information. Program made by Kazakov Viktor. Part ?01 (for DFB-1550-14BF lasers). Parameters of plate: Ilaser: 0...66.7 mA; Vlaser: 0...2 V; Itec: -1.27...1.27 A; Vtec: -2.56...2.56 V; IMphD: 0...519 uA; Tint: -1.2...+45.8 C; Text: -25.8...+43.4 C. Place for your advertising:..................................................................................................................................");
|
|
test = Unmount_SD("/"); // 0 - succ
|
|
return test;
|
|
}
|
|
else
|
|
{
|
|
return 1;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return 1;
|
|
}
|
|
}
|