0.3.1
Backup (BUP)

Data Structures

struct  bup
 Space required when using BUP functions. More...
 
struct  bup_config
 Storage device connection information. More...
 
union  bup_devices
 BUP device configurations connected when BUP is initialized. More...
 
struct  bup_stat
 Status information. More...
 
struct  bup_date
 Date and time. More...
 
struct  bup_directory
 Directory information. More...
 
struct  bup_devices.__unnamed1__
 

Typedefs

typedef struct bup bup_t
 Space required when using BUP functions.
 
typedef enum bup_device bup_device_t
 Type of device.
 
typedef struct bup_config bup_config_t
 Storage device connection information.
 
typedef union bup_devices bup_devices_t
 BUP device configurations connected when BUP is initialized.
 
typedef enum bup_language bup_language_t
 Language.
 
typedef enum bup_status bup_status_t
 Status of BUP functions.
 
typedef enum bup_write_mode bup_write_mode_t
 Write mode.
 
typedef struct bup_stat bup_stat_t
 Status information.
 
typedef struct bup_date bup_date_t
 Date and time.
 
typedef uint32_t bup_dir_date_t
 BUP date data type.
 
typedef struct bup_directory bup_directory_t
 Directory information.
 

Enumerations

enum  bup_device
 Type of device. More...
 
enum  bup_language
 Language.
 
enum  bup_status
 Status of BUP functions. More...
 
enum  bup_write_mode
 Write mode. More...
 

Functions

static bup_status_t bup_partition_select (bup_device_t device, uint16_t partition)
 Select partition.
 
static bup_status_t bup_format (bup_device_t device)
 Format.
 
static bup_status_t bup_status (bup_device_t device, size_t data_size, bup_stat_t *tb)
 Get status.
 
static bup_status_t bup_write (bup_device_t device, bup_directory_t *tb, const void *data, bup_write_mode_t write_mode)
 Write to the backup device.
 
static bup_status_t bup_read (bup_device_t device, const char *filename, void *data)
 Read data from the backup device storage.
 
static bup_status_t bup_delete (bup_device_t device, const char *filename)
 Delete data from the backup device storage.
 
static int32_t bup_dir (bup_device_t device, const char *filename, uint16_t tb_size, bup_directory_t *tb)
 Get directory information.
 
static bup_status_t bup_verify (bup_device_t device, const char *filename, const void *data)
 Verify data written to the backup device storage.
 
static void bup_date_get (bup_dir_date_t date, bup_date_t *tb)
 Expands data and time data in the directory.
 
static bup_dir_date_t bup_date_set (const bup_date_t *tb)
 Compress date and time data.
 
void bup_init (bup_t *bup, bup_devices_t *devices)
 Initialize the BUP.
 

Detailed Description

Description goes here.


Data Structure Documentation

◆ bup_config

struct bup_config

Storage device connection information.

See also
bup_init
Data Fields
bup_device_t device Connected device. If no device is connected, -1 is used.
uint16_t partition_count Number of partitions.

◆ bup_devices

union bup_devices

BUP device configurations connected when BUP is initialized.

See also
bup_init
Data Fields
struct bup_devices.__unnamed1__ __unnamed__
bup_config_t configs[3] Configurations.

◆ bup_stat

struct bup_stat

Status information.

See also
bup_status
Data Fields
uint32_t total_size Total size in bytes.
uint32_t total_blocks Number of used blocks.
uint32_t block_size Size of one block in bytes.
uint32_t free_size Remaining bytes.
uint32_t free_blocks Number of free blocks.
uint32_t data_num Number of items that can be written.

◆ bup_date

struct bup_date

Date and time.

See also
bup_date_get
bup_date_set
Data Fields
uint8_t year Year with 1980 subtracted from the year.
uint8_t month Month in the 1 to 12 range.
uint8_t day Day in the 1 to 31 range.
uint8_t hour Hour in the 0 to 23 range.
uint8_t minute Minute in the 0 to 59 range.
uint8_t week Day of week, where Sunday is 0, and Saturday is 6.

◆ bup_directory

struct bup_directory

Directory information.

Data Fields
char filename[12] File name. 12th byte is \0.
char comment[11] comment. 10th byte is \0.
bup_language_t language Language comment.
bup_dir_date_t date Date and time.
size_t data_size Size in bytes.
uint16_t block_size Size in blocks.

◆ bup_devices.__unnamed1__

struct bup_devices.__unnamed1__
Data Fields
bup_config_t internal Configuration for the built-in memory.
bup_config_t external Configuration for the cartridge.
bup_config_t serial Configuration for the serial interface.

Typedef Documentation

◆ bup_t

typedef struct bup bup_t

Space required when using BUP functions.

See also
bup_init

◆ bup_config_t

typedef struct bup_config bup_config_t

Storage device connection information.

See also
bup_init

◆ bup_devices_t

typedef union bup_devices bup_devices_t

BUP device configurations connected when BUP is initialized.

See also
bup_init

◆ bup_write_mode_t

Write mode.

See also
bup_write

◆ bup_stat_t

typedef struct bup_stat bup_stat_t

Status information.

See also
bup_status

◆ bup_date_t

typedef struct bup_date bup_date_t

Date and time.

See also
bup_date_get
bup_date_set

Enumeration Type Documentation

◆ bup_device

enum bup_device

Type of device.

Enumerator
BUP_DEVICE_INTERNAL 

Internal memory.

BUP_DEVICE_EXTERNAL 

External cartridge.

BUP_DEVICE_SERIAL 

Serial.

◆ bup_status

enum bup_status

Status of BUP functions.

Enumerator
BUP_OK 

Success.

BUP_NON 

Not connected.

BUP_UNFORMAT 

Not formatted.

BUP_WRITE_PROTECTED 

File is write protected.

BUP_NOT_ENOUGH_MEMORY 

Not enough memory available.

BUP_NOT_FOUND 

File not found.

BUP_FOUND 

File with the same name exists.

BUP_NO_MATCH 

Verification failed.

BUP_BROKEN 

File is corrupted.

◆ bup_write_mode

Write mode.

See also
bup_write
Enumerator
BUP_WRITE_MODE_OVERWRITE 

Overwrite save even if the filename of the same name exists.

BUP_WRITE_MODE_PROTECT 

Protect save if the filename of the same name exists.

Function Documentation

◆ bup_partition_select()

static bup_status_t bup_partition_select ( bup_device_t  device,
uint16_t  partition 
)
inlinestatic

Select partition.

Parameters
deviceThe device.
partitionThe partition index.
Returns
The status.

◆ bup_format()

static bup_status_t bup_format ( bup_device_t  device)
inlinestatic

Format.

Parameters
deviceThe device.
Returns
The status.

◆ bup_status()

static bup_status_t bup_status ( bup_device_t  device,
size_t  data_size,
bup_stat_t tb 
)
inlinestatic

Get status.

Parameters
deviceThe device.
data_sizeThe size of data to be written in bytes.
[out]tbThe status structure to write to.
Returns
The status.

◆ bup_write()

static bup_status_t bup_write ( bup_device_t  device,
bup_directory_t tb,
const void *  data,
bup_write_mode_t  write_mode 
)
inlinestatic

Write to the backup device.

Parameters
deviceThe device.
tbThe directory structure where bup_directory_t.block_size is written.
dataThe data to write.
write_modeThe write mode.
Returns
The status.

◆ bup_read()

static bup_status_t bup_read ( bup_device_t  device,
const char *  filename,
void *  data 
)
inlinestatic

Read data from the backup device storage.

Parameters
deviceThe device.
filenameThe filename.
[out]dataThe data to write to.
Returns
The status.

◆ bup_delete()

static bup_status_t bup_delete ( bup_device_t  device,
const char *  filename 
)
inlinestatic

Delete data from the backup device storage.

Parameters
deviceThe device.
filenameThe filename
Returns
The status.

◆ bup_dir()

static int32_t bup_dir ( bup_device_t  device,
const char *  filename,
uint16_t  tb_size,
bup_directory_t tb 
)
inlinestatic

Get directory information.

Parameters
deviceThe device.
filenameThe filename.
tb_sizeThe number of directories.
[out]tbThe directory.
Returns
The number of directories matching filename. Otherwise, a negative value is returned if tb_size is smaller than the number of matches found. Negating the return value yields the number of directories matched. For example, if -5 is returned, then there are 5 directories.

◆ bup_verify()

static bup_status_t bup_verify ( bup_device_t  device,
const char *  filename,
const void *  data 
)
inlinestatic

Verify data written to the backup device storage.

Parameters
deviceThe device.
filenameThe filename.
[in]dataThe data to verify.
Returns
The status.

◆ bup_date_get()

static void bup_date_get ( bup_dir_date_t  date,
bup_date_t tb 
)
inlinestatic

Expands data and time data in the directory.

Parameters
dateThe data and time data from the directory.
[out]tbThe date.
See also
bup_directory_t

◆ bup_date_set()

static bup_dir_date_t bup_date_set ( const bup_date_t tb)
inlinestatic

Compress date and time data.

Parameters
[in]tbThe date and time table.
Returns
The data in date and data form.

◆ bup_init()

void bup_init ( bup_t bup,
bup_devices_t devices 
)

Initialize the BUP.

Warning
bup_t is 24,576 bytes. It's advisable to allocate temporary memory.
Parameters
bupThe BUP state.
[out]devicesThe device configurations.