Refactoring: common.h with common typedefs etc.

This commit is contained in:
Lexi / Zoe 2021-04-04 17:18:45 +02:00
parent 3a07b3ab6f
commit 55b08b7630
Signed by: binaryDiv
GPG Key ID: F8D4956E224DA232
7 changed files with 26 additions and 18 deletions

View File

@ -1,5 +1,5 @@
#include "config.h"
#include "commands.h"
#include "common.h"
#include "parsing.h"
#include "uart.h"
#include "eeprom.h"

View File

@ -1,7 +1,7 @@
#ifndef COMMANDS_H_
#define COMMANDS_H_
#include "config.h"
#include "common.h"
#include "parsing.h"
void executeCommand(CommandLine cmdLine);

21
firmware/src/common.h Normal file
View File

@ -0,0 +1,21 @@
#ifndef COMMON_H_
#define COMMON_H_
#include "config.h"
#include <avr/io.h>
#include <stdbool.h>
// Define macro for NOP instruction
#define _NOP() __asm__ __volatile__ ("nop");
// Define type for EEPROM addresses
typedef uint16_t address_t;
// Type definition for address ranges (from-to)
typedef struct {
bool isValid;
address_t from;
address_t to;
} AddressRange;
#endif /* COMMON_H_ */

View File

@ -1,4 +1,3 @@
#include "config.h"
#include "eeprom.h"
#include <avr/io.h>

View File

@ -2,14 +2,9 @@
#define EEPROM_H_
#include "config.h"
#include "common.h"
#include <avr/io.h>
// Define macro for NOP instruction
#define _NOP() __asm__ __volatile__ ("nop");
// Define type for (to be shifted) addresses
typedef uint16_t address_t;
// Define address length
// TODO 15 or 16?
#define ADDRESS_LENGTH 15

View File

@ -1,4 +1,5 @@
#include "config.h"
#include "common.h"
#include "uart.h"
#include "eeprom.h"
#include "parsing.h"

View File

@ -1,8 +1,7 @@
#ifndef PARSING_H_
#define PARSING_H_
#include "config.h"
#include "eeprom.h"
#include "common.h"
#include <stdbool.h>
// Type definition for a command line with optional argument (actually just two pointers to strings)
@ -11,13 +10,6 @@ typedef struct {
char* arg;
} CommandLine;
// Type definition for address ranges (from-to)
typedef struct {
bool isValid;
address_t from;
address_t to;
} AddressRange;
void parseNextCommand();
CommandLine readNextCommand(char* buffer, uint8_t bufferLength);
CommandLine tokenizeCommand(char* cmd);