controller/Inc/control.h

58 lines
879 B
C

#ifndef CONTROL_H
#define CONTROL_H
#include "stm32f4xx_hal.h"
#include "fatfs.h"
#include <sys/types.h>
enum Type {
TYPE_NONE,
TYPE_FILE,
TYPE_DIR
};
typedef struct {
// Block and size are in blocks of 128
uint32_t start;
uint32_t size;
char* filename;
char name[8];
char ext[3];
} DiskEntry;
typedef struct {
uint8_t entry_count;
uint8_t current;
DiskEntry entries[127];
uint32_t end;
} Disk;
typedef struct {
FATFS *fs;
FIL *file;
uint8_t command;
uint8_t ready;
uint32_t counter;
uint32_t lba;
uint32_t offset;
uint8_t* buffer;
unsigned int size;
enum Type type;
Disk A;
} Storage;
typedef struct {
uint8_t memory_config;
Storage storage;
} Control;
uint16_t read_address();
void write_data(uint8_t value);
uint8_t read_data();
void control_program_eeprom(uint8_t* data, uint16_t length);
void control_cycle();
void control_reset();
#endif