Compare commits

1 Commits

Author SHA1 Message Date
hueso
9bec291f4c volatile modifier propagation
Some checks failed
Badgemagic Firmware build / build (push) Has been cancelled
2026-02-09 04:56:12 -03:00
6 changed files with 44 additions and 44 deletions

View File

@@ -485,7 +485,7 @@ void ani_marque(bm_t *bm, uint16_t *fb, int step)
} }
void ani_flash(bm_t *bm, uint16_t *fb, int step) void ani_flash(volatile bm_t *bm, uint16_t *fb, int step)
{ {
if (!(step % 2)) if (!(step % 2))
fb_fill(fb, 0); fb_fill(fb, 0);

View File

@@ -13,22 +13,22 @@ int ani_xbm_scrollup_inf(xbm_t *xbm, uint16_t *fb,
int vh, int col, int row); int vh, int col, int row);
void fb_fill(uint16_t *fb, uint16_t v); void fb_fill(uint16_t *fb, uint16_t v);
void ani_shift_y(bm_t *bm, uint16_t *fb, int dir, int frame); void ani_shift_y(volatile bm_t *bm, uint16_t *fb, int dir, int frame);
void ani_scroll_x(bm_t *bm, uint16_t *fb, int dir); void ani_scroll_x(volatile bm_t *bm, uint16_t *fb, int dir);
void ani_scroll_y(bm_t *bm, uint16_t *fb); void ani_scroll_y(volatile bm_t *bm, uint16_t *fb);
int ani_scroll_left(bm_t *bm, uint16_t *fb); int ani_scroll_left(volatile bm_t *bm, uint16_t *fb);
int ani_scroll_right(bm_t *bm, uint16_t *fb); int ani_scroll_right(volatile bm_t *bm, uint16_t *fb);
int ani_scroll_up(bm_t *bm, uint16_t *fb); int ani_scroll_up(volatile bm_t *bm, uint16_t *fb);
int ani_scroll_down(bm_t *bm, uint16_t *fb); int ani_scroll_down(volatile bm_t *bm, uint16_t *fb);
int ani_fixed(bm_t *bm, uint16_t *fb); int ani_fixed(volatile bm_t *bm, uint16_t *fb);
int ani_laser(bm_t *bm, uint16_t *fb); int ani_laser(volatile bm_t *bm, uint16_t *fb);
int ani_snowflake(bm_t *bm, uint16_t *fb); int ani_snowflake(volatile bm_t *bm, uint16_t *fb);
int ani_animation(bm_t *bm, uint16_t *fb); int ani_animation(volatile bm_t *bm, uint16_t *fb);
int ani_picture(bm_t *bm, uint16_t *fb); int ani_picture(volatile bm_t *bm, uint16_t *fb);
void ani_marque(bm_t *bm, uint16_t *fb, int step); void ani_marque(volatile bm_t *bm, uint16_t *fb, int step);
void ani_flash(bm_t *bm, uint16_t *fb, int step); void ani_flash(volatile bm_t *bm, uint16_t *fb, int step);
#endif /* __ANIMATION_H__ */ #endif /* __ANIMATION_H__ */

View File

@@ -1,9 +1,9 @@
#include "bmlist.h" #include "bmlist.h"
#include <memory.h> #include <memory.h>
static bm_t *current, *head, *tail; volatile static bm_t *current, *head, *tail;
static void bm_add(bm_t *new, bm_t *prev, bm_t *next) static void bm_add(bm_t *new, volatile bm_t *prev, volatile bm_t *next)
{ {
next->prev = new; next->prev = new;
new->next = next; new->next = next;
@@ -11,7 +11,7 @@ static void bm_add(bm_t *new, bm_t *prev, bm_t *next)
prev->next = new; prev->next = new;
} }
bm_t *bmlist_insert(bm_t *at, bm_t *new) bm_t *bmlist_insert(volatile bm_t *at, bm_t *new)
{ {
bm_add(new, at, at->next); bm_add(new, at, at->next);
return new; return new;
@@ -24,52 +24,52 @@ bm_t *bmlist_append(bm_t *new)
return new; return new;
} }
bm_t *bmlist_gonext() volatile bm_t *bmlist_gonext()
{ {
current = current->next; current = current->next;
current->anim_step = 0; current->anim_step = 0;
return current; return current;
} }
bm_t *bmlist_goprev() volatile bm_t *bmlist_goprev()
{ {
current = current->prev; current = current->prev;
current->anim_step = 0; current->anim_step = 0;
return current; return current;
} }
bm_t *bmlist_gohead() volatile bm_t *bmlist_gohead()
{ {
current = head; current = head;
current->anim_step = 0; current->anim_step = 0;
return current; return current;
} }
bm_t *bmlist_head() volatile bm_t *bmlist_head()
{ {
return head; return head;
} }
bm_t *bmlist_current() volatile bm_t *bmlist_current()
{ {
return current; return current;
} }
static void list_del(bm_t *prev, bm_t *next) static void list_del(volatile bm_t *prev, volatile bm_t *next)
{ {
prev->next = next; prev->next = next;
next->prev = prev; next->prev = prev;
} }
bm_t *bmlist_drop(bm_t *bm) volatile bm_t *bmlist_drop(volatile bm_t *bm)
{ {
bm_t *next = bm->next; volatile bm_t *next = bm->next;
list_del(bm->prev, bm->next); list_del(bm->prev, bm->next);
if (bm == head) if (bm == head)
head = bm->next; head = bm->next;
if (bm == tail) if (bm == tail)
tail = bm->prev; tail = bm->prev;
free(bm); free((bm_t *)bm);
return next; return next;
} }

View File

@@ -16,8 +16,8 @@ typedef struct bm_st {
uint32_t timeout; // zero mean no timeout uint32_t timeout; // zero mean no timeout
uint32_t anim_step; // Animation step, zero means restart animation uint32_t anim_step; // Animation step, zero means restart animation
struct bm_st *next; volatile struct bm_st *next;
struct bm_st *prev; volatile struct bm_st *prev;
} bm_t; } bm_t;
bm_t *bm_new(uint16_t width); bm_t *bm_new(uint16_t width);
@@ -27,16 +27,16 @@ static inline void bm_free(bm_t *bm)
free(bm); free(bm);
} }
bm_t *bmlist_insert(bm_t *at, bm_t *new); bm_t *bmlist_insert(volatile bm_t *at, bm_t *new);
bm_t *bmlist_append(bm_t *new); bm_t *bmlist_append(bm_t *new);
bm_t *bmlist_drop(bm_t *bm); volatile bm_t *bmlist_drop(volatile bm_t *bm);
bm_t *bmlist_gonext(); volatile bm_t *bmlist_gonext();
bm_t *bmlist_goprev() ; volatile bm_t *bmlist_goprev() ;
bm_t *bmlist_gohead(); volatile bm_t *bmlist_gohead();
bm_t *bmlist_current(); volatile bm_t *bmlist_current();
bm_t *bmlist_head(); volatile bm_t *bmlist_head();
void bmlist_init(uint16_t first_bm_width); void bmlist_init(uint16_t first_bm_width);

View File

@@ -105,7 +105,7 @@ void load_bmlist()
if (memcmp(header.header, "wang", 5)) if (memcmp(header.header, "wang", 5))
return; // There is no bitmap stored in flash return; // There is no bitmap stored in flash
bm_t *curr_bm = bmlist_current(); volatile bm_t *curr_bm = bmlist_current();
for (int i=0; i<8; i++) { for (int i=0; i<8; i++) {
bm_t *bm = flash2newbm(i); bm_t *bm = flash2newbm(i);
@@ -133,7 +133,7 @@ static uint16_t common_tasks(tmosTaskID task_id, uint16_t events)
if(events & ANI_NEXT_STEP) { if(events & ANI_NEXT_STEP) {
static int (*animations[])(bm_t *bm, uint16_t *fb) = { static int (*animations[])(volatile bm_t *bm, uint16_t *fb) = {
ani_scroll_left, ani_scroll_left,
ani_scroll_right, ani_scroll_right,
ani_scroll_up, ani_scroll_up,
@@ -145,7 +145,7 @@ static uint16_t common_tasks(tmosTaskID task_id, uint16_t events)
ani_laser ani_laser
}; };
bm_t *bm = bmlist_current(); volatile bm_t *bm = bmlist_current();
if (animations[LEGACY_GET_ANIMATION(bm->modes)]) if (animations[LEGACY_GET_ANIMATION(bm->modes)])
if (animations[LEGACY_GET_ANIMATION(bm->modes)](bm, fb) == 0 if (animations[LEGACY_GET_ANIMATION(bm->modes)](bm, fb) == 0
&& is_play_sequentially) { && is_play_sequentially) {
@@ -166,7 +166,7 @@ static uint16_t common_tasks(tmosTaskID task_id, uint16_t events)
} }
if (events & ANI_MARQUE) { if (events & ANI_MARQUE) {
bm_t *bm = bmlist_current(); volatile bm_t *bm = bmlist_current();
marque_step++; marque_step++;
if (bm->is_marquee) { if (bm->is_marquee) {
ani_marque(bm, fb, marque_step); ani_marque(bm, fb, marque_step);
@@ -186,7 +186,7 @@ static uint16_t common_tasks(tmosTaskID task_id, uint16_t events)
} }
if (events & ANI_FLASH) { if (events & ANI_FLASH) {
bm_t *bm = bmlist_current(); volatile bm_t *bm = bmlist_current();
flash_step++; flash_step++;
if (bm->is_flash) { if (bm->is_flash) {
@@ -381,7 +381,7 @@ static void mode_setup_download()
void clean_bmlist() void clean_bmlist()
{ {
bm_t *curr_bm = bmlist_current(); volatile bm_t *curr_bm = bmlist_current();
while (curr_bm->next != curr_bm) while (curr_bm->next != curr_bm)
bmlist_drop(curr_bm->next); bmlist_drop(curr_bm->next);
} }

View File

@@ -57,8 +57,8 @@ static uint16_t serial_number[] = {
#ifdef USBC_VERSION #ifdef USBC_VERSION
4 + 4 +
#endif #endif
(12 + sizeof(VERSION_ABBR) - 1) * 2 | /* bLength */ ((12 + sizeof(VERSION_ABBR) - 1) * 2 | /* bLength */
0x03 << 8, /* bDescriptorType */ 0x03 << 8), /* bDescriptorType */
/* bString */ /* bString */
'B', 'M', '1', '1', '4', '4', 'B', 'M', '1', '1', '4', '4',