fw: Steady white led while waiting cmd; led off while loading app

Signed-off-by: Daniel Lublin <daniel@lublin.se>
This commit is contained in:
Daniel Lublin 2023-03-01 11:50:24 +01:00
parent 7eb4d0304b
commit 4afdc1cd1f
No known key found for this signature in database
GPG key ID: 75BD0FEB8D3E7830
7 changed files with 19 additions and 37 deletions

View file

@ -13,7 +13,7 @@ void forever_redflash()
int led_on = 0;
for (;;) {
*led = led_on ? LED_RED : 0;
*led = led_on ? LED_RED : LED_BLACK;
for (volatile int i = 0; i < 800000; i++) {
}
led_on = !led_on;

View file

@ -11,12 +11,13 @@
// clang-format off
static volatile uint32_t *led = (volatile uint32_t *)TK1_MMIO_TK1_LED;
// clang-format on
#define LED_RED (1 << TK1_MMIO_TK1_LED_R_BIT)
#define LED_BLACK 0
#define LED_RED (1 << TK1_MMIO_TK1_LED_R_BIT)
#define LED_GREEN (1 << TK1_MMIO_TK1_LED_G_BIT)
#define LED_BLUE (1 << TK1_MMIO_TK1_LED_B_BIT)
#define LED_BLUE (1 << TK1_MMIO_TK1_LED_B_BIT)
#define LED_WHITE (LED_RED | LED_GREEN | LED_BLUE)
// clang-format on
void forever_redflash();
#endif

View file

@ -234,12 +234,8 @@ int main()
}
uint8_t in;
if (state == FW_STATE_LOADING) {
*led = LED_WHITE;
in = readbyte();
} else {
in = readbyte_ledflash(LED_WHITE, 800000);
}
*led = (state == FW_STATE_LOADING) ? LED_BLACK : LED_WHITE;
in = readbyte();
if (parseframe(in, &hdr) == -1) {
htif_puts("Couldn't parse header\n");

View file

@ -13,7 +13,6 @@ static volatile uint32_t *can_rx = (volatile uint32_t *)TK1_MMIO_UART_RX_STATUS;
static volatile uint32_t *rx = (volatile uint32_t *)TK1_MMIO_UART_RX_DATA;
static volatile uint32_t *can_tx = (volatile uint32_t *)TK1_MMIO_UART_TX_STATUS;
static volatile uint32_t *tx = (volatile uint32_t *)TK1_MMIO_UART_TX_DATA;
static volatile uint32_t *led = (volatile uint32_t *)TK1_MMIO_TK1_LED;
// clang-format on
uint8_t genhdr(uint8_t id, uint8_t endpoint, uint8_t status, enum cmdlen len)
@ -134,20 +133,6 @@ uint8_t readbyte()
}
}
uint8_t readbyte_ledflash(int ledvalue, int loopcount)
{
int led_on = 0;
for (;;) {
*led = led_on ? ledvalue : 0;
for (int i = 0; i < loopcount; i++) {
if (*can_rx) {
return *rx;
}
}
led_on = !led_on;
}
}
int read(uint8_t *buf, size_t bufsize, size_t nbytes)
{
if (nbytes > bufsize) {

View file

@ -56,7 +56,6 @@ void fwreply(struct frame_header hdr, enum fwcmd rspcode, uint8_t *buf);
void writebyte(uint8_t b);
void write(uint8_t *buf, size_t nbytes);
uint8_t readbyte();
uint8_t readbyte_ledflash(int ledvalue, int loopcount);
int read(uint8_t *buf, size_t bufsize, size_t nbytes);
#endif