demo of driving MAX2719 dot matrix displays with STM32F103 Bluepill
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
f103-dotmatrix/project/main.c

89 lines
1.4 KiB

#include "main.h"
#include "hw_init.h"
#include "com/debug.h"
#include "com/com_fileio.h"
#include "com/com_iface.h"
#include "bus/event_queue.h"
#include "bus/event_handler.h"
#include "utils/timebase.h"
#include "colorled.h"
#include "display.h"
#include <math.h>
#include <sbmp.h>
//#include "matrixdsp.h"
9 years ago
#include "max2719.h"
#include "dotmatrix.h"
9 years ago
static void poll_subsystems(void);
static DotMatrix_Cfg *dmtx;
9 years ago
int main(void)
{
hw_init();
9 years ago
9 years ago
banner("*** LED MATRIX DEMO ***");
banner_info("(c) Ondrej Hruska, 2016");
banner_info("Katedra mereni K338, CVUT FEL");
9 years ago
DotMatrix_Init dmtx_cfg;
dmtx_cfg.CS_GPIOx = GPIOA;
dmtx_cfg.CS_PINx = GPIO_Pin_4;
dmtx_cfg.SPIx = SPI1;
dmtx_cfg.cols = 4;
dmtx_cfg.rows = 1;
9 years ago
dmtx = dmtx_init(&dmtx_cfg);
9 years ago
dmtx->screen[0] = 0xF0;
dmtx->screen[4] = 0x0F;
dmtx_show(dmtx);
ms_time_t last;
9 years ago
while (1) {
9 years ago
if (ms_loop_elapsed(&last, 500)) {
GPIOC->ODR ^= 1 << 13;
}
poll_subsystems();
9 years ago
dmtx_blank(dmtx, false);
delay_ms(250);
dmtx_blank(dmtx, true);
delay_ms(250);
}
}
9 years ago
9 years ago
static void poll_subsystems(void)
{
// poll serial buffers (runs callback)
com_poll(debug_iface);
com_poll(data_iface);
// run queued tasks
tq_poll();
// handle queued events
Event evt;
until_timeout(2) { // take 2 ms max
if (eq_take(&evt)) {
run_event_handler(&evt);
} else {
break;
9 years ago
}
9 years ago
}
}
void dlnk_rx(SBMP_Datagram *dg)
{
dbg("Rx dg type %d", dg->type);
}