Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • card10/firmware
  • annejan/firmware
  • astro/firmware
  • fpletz/firmware
  • gerd/firmware
  • fleur/firmware
  • swym/firmware
  • l/firmware
  • uberardy/firmware
  • wink/firmware
  • madonius/firmware
  • mot/firmware
  • filid/firmware
  • q3k/firmware
  • hauke/firmware
  • Woazboat/firmware
  • pink/firmware
  • mossmann/firmware
  • omniskop/firmware
  • zenox/firmware
  • trilader/firmware
  • Danukeru/firmware
  • shoragan/firmware
  • zlatko/firmware
  • sistason/firmware
  • datenwolf/firmware
  • bene/firmware
  • amedee/firmware
  • martinling/firmware
  • griffon/firmware
  • chris007/firmware
  • adisbladis/firmware
  • dbrgn/firmware
  • jelly/firmware
  • rnestler/firmware
  • mh/firmware
  • ln/firmware
  • penguineer/firmware
  • monkeydom/firmware
  • jens/firmware
  • jnaulty/firmware
  • jeffmakes/firmware
  • marekventur/firmware
  • pete/firmware
  • h2obrain/firmware
  • DooMMasteR/firmware
  • jackie/firmware
  • prof_r/firmware
  • Draradech/firmware
  • Kartoffel/firmware
  • hinerk/firmware
  • abbradar/firmware
  • JustTB/firmware
  • LuKaRo/firmware
  • iggy/firmware
  • ente/firmware
  • flgr/firmware
  • Lorphos/firmware
  • matejo/firmware
  • ceddral7/firmware
  • danb/firmware
  • joshi/firmware
  • melle/firmware
  • fitch/firmware
  • deurknop/firmware
  • sargon/firmware
  • markus/firmware
  • kloenk/firmware
  • lucaswerkmeister/firmware
  • derf/firmware
  • meh/firmware
  • dx/card10-firmware
  • torben/firmware
  • yuvadm/firmware
  • AndyBS/firmware
  • klausdieter1/firmware
  • katzenparadoxon/firmware
  • xiretza/firmware
  • ole/firmware
  • techy/firmware
  • thor77/firmware
  • TilCreator/firmware
  • fuchsi/firmware
  • dos/firmware
  • yrlf/firmware
  • PetePriority/firmware
  • SuperVirus/firmware
  • sur5r/firmware
  • tazz/firmware
  • Alienmaster/firmware
  • flo_h/firmware
  • baldo/firmware
  • mmu_man/firmware
  • Foaly/firmware
  • sodoku/firmware
  • Guinness/firmware
  • ssp/firmware
  • led02/firmware
  • Stormwind/firmware
  • arist/firmware
  • coon/firmware
  • mdik/firmware
  • pippin/firmware
  • royrobotiks/firmware
  • zigot83/firmware
  • mo_k/firmware
106 results
Show changes
Commits on Source (4)
......@@ -6,31 +6,18 @@
#include "gfx.h"
#include "display.h"
/*
* "Decompress" splash-screen image. The algorithm works as follows:
*
* Each byte encodes up to 127 pixels in either white or black. The most
* significant bit determines the color, the remaining 7 bits determine the
* amount.
*/
static void bootloader_display_splash(void)
{
int idx = 0;
Color white = gfx_color(&display_screen, WHITE);
Color black = gfx_color(&display_screen, BLACK);
for (int i = 0; i < sizeof(splash); i++) {
Color color = (splash[i] & 0x80) ? white : black;
uint8_t length = splash[i] & 0x7f;
for (int j = 0; j < length; j++) {
uint16_t x = idx % 160;
uint16_t y = idx / 160;
gfx_setpixel(&display_screen, x, y, color);
idx++;
}
}
gfx_copy_region(
&display_screen,
0,
0,
160,
80,
GFX_RLE_MONO,
sizeof(splash),
(const void *)(splash)
);
gfx_update(&display_screen);
}
......
......@@ -53,8 +53,15 @@ int main(void)
card10_init();
card10_diag();
gfx_copy_region_raw(
&display_screen, 0, 0, 160, 80, 2, (const void *)(Heart)
gfx_copy_region(
&display_screen,
0,
0,
160,
80,
GFX_RAW,
sizeof(Heart),
(const void *)(Heart)
);
gfx_update(&display_screen);
......
......@@ -3,27 +3,34 @@
******************************************************************************/
/***** Includes *****/
#include "pmic.h"
#include "leds.h"
#include "card10.h"
#include "leds.h"
#include "pmic.h"
#include "gfx.h"
#include "display.h"
#include "gfx.h"
#include "tmr_utils.h"
#include <stdio.h>
#include <Heart.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <Heart.h>
int main(void)
{
card10_init();
card10_diag();
gfx_copy_region_raw(
&display_screen, 0, 0, 160, 80, 2, (const void *)(Heart)
gfx_copy_region(
&display_screen,
0,
0,
160,
80,
GFX_RAW,
sizeof(Heart),
(const void *)(Heart)
);
gfx_update(&display_screen);
......
......@@ -30,8 +30,15 @@ int main(void)
card10_init();
card10_diag();
gfx_copy_region_raw(
&display_screen, 0, 0, 160, 80, 2, (const void *)(Heart)
gfx_copy_region(
&display_screen,
0,
0,
160,
80,
GFX_RAW,
sizeof(Heart),
(const void *)(Heart)
);
gfx_update(&display_screen);
......
......@@ -37,22 +37,24 @@ int main(void)
gfx_line(&display_screen, 100, 10, 70, 40, 2, yellow);
gfx_circle(&display_screen, 85, 25, 22, 2, green);
gfx_copy_region_raw(
gfx_copy_region(
&display_screen,
120,
0,
40,
40,
2,
GFX_RAW,
40 * 40 * 2,
(const void *)(gImage_40X40)
);
gfx_copy_region_raw(
gfx_copy_region(
&display_screen,
0,
0,
160,
80,
2,
GFX_RAW,
160 * 80 * 2,
(const void *)(gImage_160X80)
);
gfx_update(&display_screen);
......
......@@ -20,6 +20,8 @@
#include "spi.h"
#include "gpio.h"
#include "faultscreen.h"
#include <stdio.h>
#include <stdint.h>
#include <string.h>
......@@ -34,6 +36,8 @@ void card10_init(void)
{
printf("card10 init...\n");
card10_set_fault_handlers();
//Setup the I2CM
I2C_Shutdown(MXC_I2C0_BUS0);
I2C_Init(MXC_I2C0_BUS0, I2C_FAST_MODE, NULL);
......
#include "faultscreen.h"
#include <stdio.h>
#include "Fonts/fonts.h"
#include "faultsplash.h"
#include "display.h"
#include "gfx.h"
#include "max32665.h"
#include "nvic_table.h"
#include "core_cmFunc.h"
#include "core1.h"
struct regs_t {
unsigned int pc;
unsigned int sp;
unsigned int lr;
} static regs;
#define LOAD_REGS() \
__asm__ __volatile__( \
"ldr %0, [sp, #24] \n" \
"ldr %1, [sp, #20] \n" \
"mov %2, sp \n" \
: "=r" (regs.pc), \
"=r" (regs.lr), \
"=r" (regs.sp) \
)
static void generic_handler(const char *reason) {
char lines[3][64];
Core1_Stop();
__disable_irq();
snprintf(lines[0], sizeof(lines[0]), "pc: 0x%08x", regs.pc);
snprintf(lines[1], sizeof(lines[1]), "sp: 0x%08x", regs.sp);
snprintf(lines[2], sizeof(lines[2]), "lr: 0x%08x", regs.lr);
gfx_copy_region(&display_screen, 0, 0, 160, 80, GFX_RLE_MONO,
faultsplash_rle_len, faultsplash_rle);
Color black = gfx_color(&display_screen, BLACK);
Color white = gfx_color(&display_screen, WHITE);
gfx_puts(&Font12, &display_screen, 52, 32, reason, white, black);
gfx_puts(&Font12, &display_screen, 52, 44, lines[0], white, black);
gfx_puts(&Font12, &display_screen, 52, 56, lines[1], white, black);
gfx_puts(&Font12, &display_screen, 52, 68, lines[2], white, black);
gfx_update(&display_screen);
}
static void NMI_Handler_(void) {
LOAD_REGS();
generic_handler("NMI Fault");
}
static void HardFault_Handler_(void) {
LOAD_REGS();
generic_handler("HardFault");
}
static void MemManage_Handler_(void) {
LOAD_REGS();
generic_handler("MemMgmtFault");
}
static void BusFault_Handler_(void) {
LOAD_REGS();
generic_handler("BusFault");
}
static void UsageFault_Handler_(void) {
LOAD_REGS();
generic_handler("UsageFault");
}
void card10_set_fault_handlers(void) {
NVIC_SetVector(NonMaskableInt_IRQn, NMI_Handler_);
NVIC_SetVector(HardFault_IRQn, HardFault_Handler_);
NVIC_SetVector(MemoryManagement_IRQn, MemManage_Handler_);
NVIC_SetVector(BusFault_IRQn, BusFault_Handler_);
NVIC_SetVector(UsageFault_IRQn, UsageFault_Handler_);
}
#ifndef FAULT_MGMT_H
#define FAULT_MGMT_H
void card10_set_fault_handlers(void);
#endif
#include "faultsplash.h"
const unsigned char faultsplash_rle[] = {
0x7f, 0x50, 0x83, 0x0f, 0x82, 0x7f, 0x0d, 0x83, 0x0f, 0x82, 0x7f, 0x1d,
0x82, 0x7f, 0x1f, 0x82, 0x7f, 0x1f, 0x82, 0x7f, 0x12, 0x82, 0x09, 0x82,
0x7f, 0x14, 0x82, 0x09, 0x82, 0x7f, 0x09, 0x82, 0x11, 0x83, 0x7f, 0x0b,
0x82, 0x11, 0x83, 0x7f, 0x0f, 0x82, 0x07, 0x82, 0x7f, 0x16, 0x82, 0x07,
0x82, 0x7f, 0x16, 0x82, 0x07, 0x82, 0x7f, 0x1a, 0x83, 0x7f, 0x1e, 0x83,
0x7f, 0x0a, 0x8b, 0x17, 0x82, 0x02, 0x82, 0x02, 0x83, 0x73, 0x8c, 0x16,
0x82, 0x02, 0x82, 0x02, 0x83, 0x72, 0x81, 0x0c, 0x84, 0x07, 0x85, 0x7f,
0x03, 0x82, 0x0c, 0x84, 0x07, 0x86, 0x7f, 0x02, 0x82, 0x0c, 0x84, 0x07,
0x86, 0x7f, 0x82, 0x12, 0x87, 0x7f, 0x06, 0x82, 0x12, 0x87, 0x7f, 0x06,
0x82, 0x24, 0x82, 0x78, 0x82, 0x24, 0x82, 0x78, 0x82, 0x24, 0x82, 0x78,
0x82, 0x16, 0x83, 0x04, 0x82, 0x07, 0x82, 0x76, 0x82, 0x16, 0x83, 0x04,
0x82, 0x07, 0x82, 0x70, 0x8f, 0x0d, 0x82, 0x12, 0x82, 0x6e, 0x8f, 0x0d,
0x82, 0x12, 0x82, 0x6e, 0x8f, 0x0b, 0x82, 0x09, 0x82, 0x0b, 0x82, 0x6c,
0x8f, 0x0b, 0x82, 0x09, 0x82, 0x0b, 0x82, 0x6c, 0x8f, 0x0b, 0x82, 0x09,
0x82, 0x0b, 0x82, 0x6c, 0x8f, 0x7f, 0x12, 0x8f, 0x7f, 0x0d, 0x98, 0x12,
0x82, 0x74, 0x98, 0x12, 0x82, 0x70, 0xa1, 0x7f, 0xa1, 0x7f, 0xa1, 0x7f,
0xa1, 0x7f, 0xa1, 0x7d, 0xa5, 0x7b, 0xa5, 0x7b, 0xa5, 0x7b, 0xa5, 0x7a,
0xa6, 0x78, 0x89, 0x02, 0x9f, 0x76, 0x89, 0x02, 0x9f, 0x76, 0xaa, 0x76,
0xaa, 0x76, 0x87, 0x02, 0xa1, 0x76, 0x87, 0x02, 0xa1, 0x76, 0x87, 0x02,
0xa1, 0x76, 0x87, 0x02, 0xa1, 0x76, 0x87, 0x02, 0xa1, 0x76, 0x87, 0x02,
0xa1, 0x76, 0x87, 0x02, 0xa1, 0x76, 0xaa, 0x76, 0xaa, 0x76, 0xaa, 0x76,
0x89, 0x02, 0x9f, 0x76, 0x89, 0x02, 0x9f, 0x79, 0xa5, 0x7b, 0xa5, 0x7b,
0xa5, 0x7b, 0x8b, 0x02, 0x98, 0x7b, 0x8b, 0x02, 0x98, 0x7d, 0xa1, 0x7f,
0xa1, 0x7f, 0xa1, 0x7f, 0xa1, 0x7f, 0xa1, 0x7f, 0x04, 0x98, 0x7f, 0x09,
0x98, 0x7f, 0x0e, 0x8f, 0x7f, 0x12, 0x8f, 0x7f, 0x7f, 0x7f, 0x7f, 0x7f,
0x7f, 0x06
};
const size_t faultsplash_rle_len = 302;
const size_t faultsplash_width = 160;
const size_t faultsplash_height = 80;
#ifndef FAULTSPLASH_H
#define FAULTSPLASH_H
#include <stddef.h>
extern const unsigned char faultsplash_rle[];
extern const size_t faultsplash_rle_len;
extern const size_t faultsplash_width;
extern const size_t faultsplash_height;
#endif
......@@ -9,7 +9,9 @@ sources = files(
'pmic.c',
'portexpander.c',
'pb.c',
'display.c'
'display.c',
'faultscreen.c',
'faultsplash.c'
)
deps = [
......
......@@ -265,15 +265,17 @@ Color gfx_color(struct gfx_region *reg, enum gfx_color color)
return gfx_color_rgb(reg, c->r, c->g, c->b);
}
void gfx_copy_region_raw(
static void gfx_copy_region_raw(
struct gfx_region *reg,
int x,
int y,
int w,
int h,
size_t bpp,
size_t size,
const void *p
) {
size_t bpp = size / (w * h);
for (int y_ = 0; y_ < h; y_++) {
for (int x_ = 0; x_ < w; x_++) {
Color c;
......@@ -291,6 +293,96 @@ void gfx_copy_region_raw(
}
}
static void gfx_copy_region_mono(
struct gfx_region *reg,
int x,
int y,
int w,
int h,
size_t size,
const void *p
) {
const char *bp = p;
int bit = 0;
Color white = gfx_color(reg, WHITE);
Color black = gfx_color(reg, BLACK);
for (int y_ = 0; y_ < h; y_++) {
for (int x_ = 0; x_ < w; x_++) {
int value = *bp & (1 << bit);
if (++bit >= 8) {
bp++;
bit %= 8;
if ((const void *)(bp) >= (p + size))
return;
}
Color c = value ? white : black;
gfx_setpixel(reg, x + x_, y + y_, c);
}
}
}
/*
* "Decompress" the image. The algorithm works as follows:
*
* Each byte encodes up to 127 pixels in either white or black. The most
* significant bit determines the color, the remaining 7 bits determine the
* amount.
*/
static void gfx_copy_region_rle_mono(
struct gfx_region *reg,
int x,
int y,
int w,
int h,
size_t size,
const void *p
) {
const char *data = p;
int idx = 0;
Color white = gfx_color(reg, WHITE);
Color black = gfx_color(reg, BLACK);
for (int i = 0; i < size; i++) {
Color color = (data[i] & 0x80) ? white : black;
uint8_t length = data[i] & 0x7f;
for (int j = 0; j < length; j++) {
uint16_t x = idx % w;
uint16_t y = idx / w;
gfx_setpixel(reg, x, y, color);
idx++;
}
}
}
void gfx_copy_region(
struct gfx_region *reg,
int x,
int y,
int w,
int h,
enum gfx_encoding encoding,
size_t size,
const void *p
) {
switch (encoding) {
case GFX_RAW:
gfx_copy_region_raw(reg, x, y, w, h, size, p);
break;
case GFX_MONO:
gfx_copy_region_mono(reg, x, y, w, h, size, p);
break;
case GFX_RLE_MONO:
gfx_copy_region_rle_mono(reg, x, y, w, h, size, p);
break;
default:
break;
}
}
void gfx_copy_raw(struct gfx_region *reg, const void *p, size_t size)
{
fb_copy_raw(reg->fb, p, size);
......
......@@ -43,6 +43,12 @@ enum gfx_color {
COLORS
};
enum gfx_encoding {
GFX_RAW,
GFX_MONO,
GFX_RLE_MONO
};
struct gfx_color_rgb {
uint8_t r;
uint8_t g;
......@@ -51,8 +57,9 @@ struct gfx_color_rgb {
Color gfx_color(struct gfx_region *reg, enum gfx_color color);
void gfx_copy_region_raw(struct gfx_region *reg, int x, int y, int w, int h,
size_t bpp, const void *p);
void gfx_copy_region(struct gfx_region *reg, int x, int y, int w, int h,
enum gfx_encoding encoding, size_t size,
const void *p);
void gfx_copy_raw(struct gfx_region *reg, const void *p, size_t size);
#endif