Add version field, make it bitfield struct

This commit is contained in:
Dominik Szymański
2023-08-15 22:56:53 +02:00
parent 166faaeee7
commit 6e81b5917e
4 changed files with 17 additions and 10 deletions
@@ -5,12 +5,11 @@
#include <stdint.h>
#include <stdbool.h>
#include "utils.h"
#include "tag_base_type.h"
// 最多八张卡槽
#define TAG_MAX_SLOT_NUM 8
// u32 size align.
#define ALIGN_U32 __attribute__((aligned(4)))
extern bool g_is_tag_emulating;
+2 -3
View File
@@ -53,11 +53,10 @@ uint8_t settings_save_config(void)
uint8_t settings_get_animation_config()
{
return config & 0x3;
return config.animation_config;
}
void settings_set_animation_config(uint8_t value)
{
config &= ~(0x3);
config |= value;
config.animation_config = value;
}
+7 -5
View File
@@ -3,15 +3,17 @@
#include <stdint.h>
#include "utils.h"
#define SETTINGS_ANIMATION_FULL 0
#define SETTINGS_ANIMATION_MINIMAL 1
#define SETTINGS_ANIMATION_NONE 2
/*
* bits [0-1]: animation config
* bits [2-31]: reserved
*/
typedef uint32_t settings_data_t;
typedef struct ALIGN_U32 {
uint16_t version;
uint16_t animation_config : 2;
} settings_data_t;
void settings_load_config(void);
uint8_t settings_save_config(void);
+7
View File
@@ -0,0 +1,7 @@
#ifndef UTILS_H_
#define UTILS_H_
// u32 size align.
#define ALIGN_U32 __attribute__((aligned(4)))
#endif