fw: Hide *led in led.c

This commit is contained in:
Michael Cardell Widerkrantz 2023-03-16 14:25:17 +01:00
parent 8665031bb4
commit 9488f0633d
No known key found for this signature in database
GPG Key ID: D3DB3DDF57E704E5
3 changed files with 9 additions and 4 deletions

View File

@ -7,9 +7,15 @@
#include "../tk1_mem.h"
#include "types.h"
static volatile uint32_t *led = (volatile uint32_t *)TK1_MMIO_TK1_LED;
void set_led(uint32_t led_value)
{
*led = led_value;
}
void forever_redflash()
{
static volatile uint32_t *led = (volatile uint32_t *)TK1_MMIO_TK1_LED;
int led_on = 0;
for (;;) {

View File

@ -10,8 +10,6 @@
#include "types.h"
// clang-format off
static volatile uint32_t *led = (volatile uint32_t *)TK1_MMIO_TK1_LED;
#define LED_BLACK 0
#define LED_RED (1 << TK1_MMIO_TK1_LED_R_BIT)
#define LED_GREEN (1 << TK1_MMIO_TK1_LED_G_BIT)
@ -19,5 +17,6 @@ static volatile uint32_t *led = (volatile uint32_t *)TK1_MMIO_TK1_LED;
#define LED_WHITE (LED_RED | LED_GREEN | LED_BLUE)
// clang-format on
void set_led(uint32_t led_value);
void forever_redflash();
#endif

View File

@ -26,7 +26,7 @@ int readcommand(struct frame_header *hdr, uint8_t *cmd, int state)
{
uint8_t in = 0;
*led = (state == FW_STATE_LOADING) ? LED_BLACK : LED_WHITE;
set_led((state == FW_STATE_LOADING) ? LED_BLACK : LED_WHITE);
in = readbyte();
if (parseframe(in, hdr) == -1) {