Buoyancy Firmware  1.0
Buoyancy Vehicle Firmware Documentation
SD card program file

Contain SD card module with related structures and functions. More...

Macros

#define FILE_NAME   "TEST.TXT"
 
#define TEST_STRING   "SD card test string."
 
#define SDC_CS_PIN   (22UL)
 SDCard chip select (CS) pin. More...
 
#define SDC_MOSI_PIN   (23UL)
 SDCard serial data in (DI) pin. More...
 
#define SDC_MISO_PIN   (24UL)
 SDCard serial data out (DO) pin. More...
 
#define SDC_SCK_PIN   (25UL)
 SDCard serial clock (SCK) pin. More...
 

Functions

void SDcardInit (void)
 Initialize SD card and mount disk. More...
 
void openMissionLogDirectory ()
 
More...
 
uint32_t findLatestMissionLog ()
 
More...
 
void createMissionLog ()
 
More...
 
void printMissionLogContent (uint8_t returnMsg[], uint16_t *returnLength)
 
More...
 
uint32_t openFileToRead (uint8_t filename[])
 
More...
 
void lseek (uint32_t index)
 
More...
 
void writeToOpenFile (void *text, uint8_t length, uint32_t *bytes_written)
 
More...
 
void readFromOpenFile (void *text, uint8_t length, uint32_t *bytes_read)
 
More...
 
void closeFile ()
 
More...
 
void writeFile (uint8_t filename[], uint8_t text[], uint8_t length, uint32_t *bytes_written)
 
More...
 
void readFile (uint8_t filename[], uint8_t text[], uint8_t length, uint8_t *p_nrBytesRead)
 
More...
 
void unMount ()
 
More...
 
void writeMissionLog ()
 
More...
 
void deleteLogFile (uint32_t filename, uint8_t returnMsg[], uint16_t *returnLength)
 
More...
 
void deleteAllLogFiles (uint16_t *returnLength, uint8_t returnMsg[])
 
More...
 
uint32_t countMissionLog ()
 
More...
 
void queueLogFilesforTransfer (uint32_t queue[], uint32_t *totalSize)
 
More...
 
 NRF_BLOCK_DEV_SDC_DEFINE (m_block_dev_sdc, NRF_BLOCK_DEV_SDC_CONFIG(SDC_SECTOR_SIZE,),)
 
void readFile (uint8_t *, uint8_t *, uint8_t, uint8_t *)
 open file and read from it. More...
 
void writeFile (uint8_t *, uint8_t *, uint8_t, uint32_t *)
 open file and read from it. More...
 
void printMissionLogContent (uint8_t *, uint16_t *)
 print content of mission Log directory, as a list of log files, to BLE menu. More...
 
uint32_t openFileToRead (uint8_t *)
 Open a file with read permission. More...
 
void deleteLogFile (uint32_t, uint8_t *, uint16_t *)
 Delete one log file. More...
 
void deleteAllLogFiles (uint16_t *, uint8_t *)
 Delete one log file. More...
 
void queueLogFilesforTransfer (uint32_t *, uint32_t *)
 Create a queue for trasnfering all log files over BLE. More...
 

Variables

missionLog_t missionLog
 Create mission log instance. More...
 
FRESULT f_err_code
 
DSTATUS disk_state = STA_NOINIT
 

Detailed Description

Contain SD card module with related structures and functions.

Macro Definition Documentation

◆ FILE_NAME

#define FILE_NAME   "TEST.TXT"

◆ SDC_CS_PIN

#define SDC_CS_PIN   (22UL)

SDCard chip select (CS) pin.

◆ SDC_MISO_PIN

#define SDC_MISO_PIN   (24UL)

SDCard serial data out (DO) pin.

◆ SDC_MOSI_PIN

#define SDC_MOSI_PIN   (23UL)

SDCard serial data in (DI) pin.

◆ SDC_SCK_PIN

#define SDC_SCK_PIN   (25UL)

SDCard serial clock (SCK) pin.

◆ TEST_STRING

#define TEST_STRING   "SD card test string."

Function Documentation

◆ closeFile()

void closeFile ( )

Close open file.

◆ countMissionLog()

uint32_t countMissionLog ( void  )

count the number of log files stored on SD card

Returns
cnt Integer valued number of log files

<Highest integer number is the latest created Log file

◆ createMissionLog()

void createMissionLog ( )

Create log file named one integer higher than the last log file.

<Open missionLog directory

<and count the number of Log files.

<Create a new Log filename as one integer value higher than the previous Log file.

<update latest create log file

<Number of log files increased by one

◆ deleteAllLogFiles() [1/2]

void deleteAllLogFiles ( uint16_t ,
uint8_t  
)

Delete one log file.

From menu a integer value can be typed in to delete a specific log file

Parameters
[out]returnLengthpointer that points to address where length of returnMsg is stored
[out]returnMsgstring array to report status after delete operation finished

◆ deleteAllLogFiles() [2/2]

void deleteAllLogFiles ( uint16_t returnLength,
uint8_t  returnMsg[] 
)

◆ deleteLogFile() [1/2]

void deleteLogFile ( uint32_t  ,
uint8_t ,
uint16_t  
)

Delete one log file.

From menu a integer value can be typed in to delete a specific log file

Parameters
[in]filenameinteger value for the file to be deleted
[out]returnMsgstring array to report status after delete operation finished
[out]returnLengthpointer that points to address where length of returnMsg is stored

◆ deleteLogFile() [2/2]

void deleteLogFile ( uint32_t  filename,
uint8_t  returnMsg[],
uint16_t returnLength 
)

◆ findLatestMissionLog()

uint32_t findLatestMissionLog ( )

Open missionLog directory and find the highest integer name which is the last created log file - name[integer].txt.

<Highest integer number is the latest created Log file

◆ lseek()

void lseek ( uint32_t  )

find a specific line in an open file

Parameters
[in]indexLine number to be accessed

◆ NRF_BLOCK_DEV_SDC_DEFINE()

NRF_BLOCK_DEV_SDC_DEFINE ( m_block_dev_sdc  ,
NRF_BLOCK_DEV_SDC_CONFIG(SDC_SECTOR_SIZE,)   
)

◆ openFileToRead() [1/2]

uint32_t openFileToRead ( uint8_t )

Open a file with read permission.

Parameters
[in]filenameString array containing filename to open

◆ openFileToRead() [2/2]

uint32_t openFileToRead ( uint8_t  filename[])

◆ openMissionLogDirectory()

void openMissionLogDirectory ( )

Open missionLog directory, and count the number of missionLog files, named [integer].txt.

◆ printMissionLogContent() [1/2]

void printMissionLogContent ( uint8_t ,
uint16_t  
)

print content of mission Log directory, as a list of log files, to BLE menu.

Parameters
[out]returnMsgstring array containing filename
[out]returnLengthpointer to which the length of returnMsg is stored

◆ printMissionLogContent() [2/2]

void printMissionLogContent ( uint8_t  returnMsg[],
uint16_t returnLength 
)

◆ queueLogFilesforTransfer() [1/2]

void queueLogFilesforTransfer ( uint32_t ,
uint32_t  
)

Create a queue for trasnfering all log files over BLE.

in order to transfer all log files a queue must be created, initialy intended to sort the queue and transfer new files first though this step is skipped.

Parameters
[out]queuearray holding the queue for file transmission
[out]totalSizeThe total number og bytes that will be transfered is counted and stored in variable pointed to by totalSize pointer.

◆ queueLogFilesforTransfer() [2/2]

void queueLogFilesforTransfer ( uint32_t  queue[],
uint32_t totalSize 
)

◆ readFile() [1/2]

void readFile ( uint8_t ,
uint8_t ,
uint8_t  ,
uint8_t  
)

open file and read from it.

Parameters

◆ readFile() [2/2]

void readFile ( uint8_t  filename[],
uint8_t  text[],
uint8_t  length,
uint8_t p_nrBytesRead 
)

◆ readFromOpenFile()

void readFromOpenFile ( void *  ,
uint8_t  ,
uint32_t  
)

read data from an already opened file

Parameters
[out]textbytes read from file is stored in address pointed to by text
[in]lengthLength of text string to be written
[out]bytes_readreturn pointer to report how many bytes was read

◆ SDcardInit()

void SDcardInit ( )

Initialize SD card and mount disk.

<Highest integer number is the latest created Log file

◆ unMount()

void unMount ( )

Unmount SD card.

◆ writeFile() [1/2]

void writeFile ( uint8_t ,
uint8_t ,
uint8_t  ,
uint32_t  
)

open file and read from it.

Parameters

◆ writeFile() [2/2]

void writeFile ( uint8_t  filename[],
uint8_t  text[],
uint8_t  length,
uint32_t bytes_written 
)

◆ writeMissionLog()

void writeMissionLog ( void  )

write the mission log structure to a mission log file

Create a string array where each value to be written to file is stored. Then write the string to log file.

◆ writeToOpenFile()

void writeToOpenFile ( void *  ,
uint8_t  ,
uint32_t  
)

write data to an already opened file

Parameters
[in]texttext to be written to file
[in]lengthLength of text string to be written
[out]bytes_writtenreturn pointer to report how many bytes was written

Variable Documentation

◆ disk_state

DSTATUS disk_state = STA_NOINIT

◆ f_err_code

FRESULT f_err_code

◆ missionLog

missionLog_t missionLog

Create mission log instance.