64 lines
984 B
C
64 lines
984 B
C
#ifndef CONTROL_H
|
|
#define CONTROL_H
|
|
|
|
#include "stm32f4xx_hal.h"
|
|
|
|
typedef enum {
|
|
CONTROL_STOP = 0,
|
|
CONTROL_RESET_BEGIN,
|
|
CONTROL_RESET_1,
|
|
CONTROL_RESET_2,
|
|
CONTROL_RESET_3,
|
|
CONTROL_RESET_4,
|
|
CONTROL_RESET_5,
|
|
CONTROL_RESET_6,
|
|
CONTROL_RESET_7,
|
|
CONTROL_RESET_END = 9,
|
|
CONTROL_CLOCK_LOW,
|
|
CONTROL_CLOCK_HIGH
|
|
} ControlState;
|
|
|
|
typedef struct {
|
|
uint8_t programming;
|
|
uint16_t length;
|
|
uint8_t* data;
|
|
} Eeprom;
|
|
|
|
typedef struct {
|
|
uint8_t received;
|
|
uint8_t c;
|
|
} Input;
|
|
|
|
typedef struct {
|
|
uint8_t dirty;
|
|
uint8_t action;
|
|
uint8_t ready;
|
|
uint8_t lba_1;
|
|
uint8_t lba_2;
|
|
uint8_t lba_3;
|
|
uint32_t lba;
|
|
uint32_t counter;
|
|
uint8_t* buffer;
|
|
} Storage;
|
|
|
|
typedef struct {
|
|
ControlState state;
|
|
uint8_t memory_config;
|
|
Storage storage;
|
|
Input input;
|
|
Eeprom eeprom;
|
|
} Control;
|
|
|
|
uint16_t read_address();
|
|
void write_data(uint8_t value);
|
|
uint8_t read_data();
|
|
|
|
void control_execute_state();
|
|
void control_reset();
|
|
|
|
uint8_t control_receive_program(uint8_t byte);
|
|
|
|
void send_key(uint8_t c);
|
|
|
|
#endif
|