made it not working, changed data output method
This commit is contained in:
parent
bb11ddd447
commit
731c2381ce
3 changed files with 55 additions and 80 deletions
|
@ -99,7 +99,7 @@ include $(CHIBIOS)/os/hal/osal/rt/osal.mk
|
||||||
include $(CHIBIOS)/os/rt/rt.mk
|
include $(CHIBIOS)/os/rt/rt.mk
|
||||||
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
|
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
|
||||||
# Other files (optional).
|
# Other files (optional).
|
||||||
include $(CHIBIOS)/test/rt/test.mk
|
#include $(CHIBIOS)/test/rt/test.mk
|
||||||
include $(CHIBIOS)/os/hal/lib/streams/streams.mk
|
include $(CHIBIOS)/os/hal/lib/streams/streams.mk
|
||||||
include $(CHIBIOS)/os/various/shell/shell.mk
|
include $(CHIBIOS)/os/various/shell/shell.mk
|
||||||
include $(CHIBIOS)/os/various/lwip_bindings/lwip.mk
|
include $(CHIBIOS)/os/various/lwip_bindings/lwip.mk
|
||||||
|
@ -208,7 +208,7 @@ CPPWARN = -Wall -Wextra -Wundef
|
||||||
#
|
#
|
||||||
|
|
||||||
# List all user C define here, like -D_DEBUG=1
|
# List all user C define here, like -D_DEBUG=1
|
||||||
UDEFS =
|
UDEFS = -DSHELL_CMD_TEST_ENABLED=FALSE
|
||||||
|
|
||||||
# Define ASM defines here
|
# Define ASM defines here
|
||||||
UADEFS =
|
UADEFS =
|
||||||
|
|
|
@ -4,12 +4,13 @@
|
||||||
#include "dfi.h"
|
#include "dfi.h"
|
||||||
|
|
||||||
|
|
||||||
#define DATA_LINES 6
|
|
||||||
#define MODULES 10
|
#define MODULES 10
|
||||||
#define FET_COUNT 8
|
#define FET_COUNT 8
|
||||||
#define SEGMENTS 6
|
#define SEGMENTS 6
|
||||||
|
#define BIT_PER_FET_PER_SEG 8
|
||||||
|
|
||||||
volatile uint8_t data[DATA_LINES][MODULES][FET_COUNT][SEGMENTS];
|
//volatile uint8_t data[DATA_LINES][MODULES][FET_COUNT][SEGMENTS];
|
||||||
|
volatile uint8_t data[FET_COUNT][SEGMENTS * MODULES * BIT_PER_FET_PER_SEG];
|
||||||
static virtual_timer_t mosfet_timer;
|
static virtual_timer_t mosfet_timer;
|
||||||
|
|
||||||
// prototypes
|
// prototypes
|
||||||
|
@ -24,30 +25,19 @@ THD_FUNCTION(dfiFunc, p) {
|
||||||
chRegSetThreadName("dfi");
|
chRegSetThreadName("dfi");
|
||||||
|
|
||||||
static systime_t last_time_simul = 0;
|
static systime_t last_time_simul = 0;
|
||||||
static uint8_t counterFet = 0;
|
|
||||||
static uint8_t counterDigit = 0;
|
|
||||||
static uint8_t counterBit = 0;
|
static uint8_t counterBit = 0;
|
||||||
|
|
||||||
chVTObjectInit(&mosfet_timer);
|
chVTObjectInit(&mosfet_timer);
|
||||||
chVTSet(&mosfet_timer, US2ST(1500), refreshDisplay, NULL);
|
chVTSet(&mosfet_timer, US2ST(1570), refreshDisplay, NULL);
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
|
|
||||||
if(ST2MS(chVTTimeElapsedSinceX(last_time_simul)) > 5) {
|
if(ST2MS(chVTTimeElapsedSinceX(last_time_simul)) > 100) {
|
||||||
|
|
||||||
for(int dataline = 0; dataline < DATA_LINES; dataline++) {
|
|
||||||
|
|
||||||
data[dataline][0][0][1] = counterBit;
|
|
||||||
data[dataline][1][0][1] = 255 - counterBit;
|
|
||||||
data[dataline][2][0][1] = counterBit;
|
|
||||||
data[dataline][3][0][1] = counterBit;
|
|
||||||
data[dataline][4][0][1] = counterBit;
|
|
||||||
data[dataline][5][0][1] = counterBit;
|
|
||||||
data[dataline][6][0][1] = counterBit;
|
|
||||||
data[dataline][7][0][1] = counterBit;
|
|
||||||
data[dataline][8][0][1] = counterBit;
|
|
||||||
data[dataline][9][0][1] = counterBit;
|
|
||||||
|
|
||||||
|
|
||||||
|
for(int fet = 0; fet< FET_COUNT; fet++) {
|
||||||
|
for (size_t i = 0; i < 480; i++) {
|
||||||
|
data[fet][i] = 0xff;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
for(int fet=0; fet<FET_COUNT; fet++) {
|
for(int fet=0; fet<FET_COUNT; fet++) {
|
||||||
|
@ -83,14 +73,23 @@ THD_FUNCTION(dfiFunc, p) {
|
||||||
void initializeSRData() {
|
void initializeSRData() {
|
||||||
palSetPad(GPIOE, GPIOE_PIN1); //Tells all SRs that uController is sending data
|
palSetPad(GPIOE, GPIOE_PIN1); //Tells all SRs that uController is sending data
|
||||||
|
|
||||||
for(int seg = 0; seg < SEGMENTS; seg++) {
|
for (uint16_t i = 0; i < SEGMENTS * MODULES * BIT_PER_FET_PER_SEG; i++) {
|
||||||
shiftOut(0,0,0,0,0,0);
|
palWriteGroup(GPIOE, 0b11111100, 0, 0);
|
||||||
|
palSetPad(GPIOE, GPIOE_PIN0); //clock
|
||||||
|
asm ("nop");
|
||||||
|
asm ("nop");
|
||||||
|
asm ("nop");
|
||||||
|
asm ("nop");
|
||||||
|
palClearPad(GPIOE, GPIOE_PIN0); //clock
|
||||||
|
asm ("nop");
|
||||||
|
asm ("nop");
|
||||||
}
|
}
|
||||||
|
|
||||||
palClearPad(GPIOE, GPIOE_PIN1); //Tells all SRs that uController is done sending data
|
palClearPad(GPIOE, GPIOE_PIN1); //Tells all SRs that uController is done sending data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// all 1.5ms
|
||||||
static void refreshDisplay(void *arg) {
|
static void refreshDisplay(void *arg) {
|
||||||
(void)arg;
|
(void)arg;
|
||||||
|
|
||||||
|
@ -100,33 +99,43 @@ static void refreshDisplay(void *arg) {
|
||||||
fet++;
|
fet++;
|
||||||
fet %= FET_COUNT;
|
fet %= FET_COUNT;
|
||||||
|
|
||||||
// switch fets
|
|
||||||
|
|
||||||
for(int module = MODULES-1; module >= 0; module--) {
|
for (uint16_t i = 0; i < SEGMENTS * MODULES * BIT_PER_FET_PER_SEG; i++) {
|
||||||
for(int seg = 0; seg < SEGMENTS; seg++) {
|
palClearPort(GPIOE, 0xfc);
|
||||||
shiftOut(data[0][module][fet][seg],
|
palWriteGroup(GPIOE, 0xfc, 0, data[fet][i]);
|
||||||
data[1][module][fet][seg],
|
|
||||||
data[2][module][fet][seg],
|
//palSetPort(GPIOE, data[fet][i]);
|
||||||
data[3][module][fet][seg],
|
|
||||||
data[4][module][fet][seg],
|
palSetPad(GPIOE, GPIOE_PIN0); //clock
|
||||||
data[5][module][fet][seg]);
|
asm ("nop");
|
||||||
}
|
asm ("nop");
|
||||||
|
asm ("nop");
|
||||||
|
asm ("nop");
|
||||||
|
asm ("nop");
|
||||||
|
asm ("nop");
|
||||||
|
asm ("nop");
|
||||||
|
asm ("nop");
|
||||||
|
asm ("nop");
|
||||||
|
asm ("nop");
|
||||||
|
palClearPad(GPIOE, GPIOE_PIN0); //clock
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
palClearPort(GPIOD, 0xff00); // fets off
|
palClearPort(GPIOD, 0xff00); // fets off
|
||||||
|
|
||||||
for (int w = 0; w < 125; w++) { // wait ca 8µS /7 125
|
for (uint8_t w = 0; w < 125; w++) {
|
||||||
asm ("nop");
|
|
||||||
}
|
|
||||||
palSetPad(GPIOE, GPIOE_PIN1); // latch high
|
|
||||||
for (int w = 0; w < 25; w++) { // wait ca 1,6µS = 25
|
|
||||||
asm ("nop");
|
asm ("nop");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
palSetPad(GPIOE, GPIOE_PIN1); // latch high
|
||||||
|
for (uint8_t w = 0; w < 60; w++) {
|
||||||
|
asm ("nop");
|
||||||
|
}
|
||||||
palClearPad(GPIOE, GPIOE_PIN1); // latch low
|
palClearPad(GPIOE, GPIOE_PIN1); // latch low
|
||||||
|
|
||||||
|
|
||||||
for (int w = 0; w < 13; w++) { // wait ca 1µS
|
for (uint8_t w = 0; w < 26; w++) {
|
||||||
asm ("nop");
|
asm ("nop");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,9 +151,7 @@ static void refreshDisplay(void *arg) {
|
||||||
palWritePad(GPIOD, GPIOD_PIN15, (fet == 7) ? 1 : 0);
|
palWritePad(GPIOD, GPIOD_PIN15, (fet == 7) ? 1 : 0);
|
||||||
|
|
||||||
|
|
||||||
//palClearPort(GPIOD, 0xff00);
|
chVTSetI(&mosfet_timer, US2ST(1570), refreshDisplay, NULL);
|
||||||
|
|
||||||
chVTSetI(&mosfet_timer, US2ST(1500), refreshDisplay, NULL);
|
|
||||||
chSysUnlockFromISR();
|
chSysUnlockFromISR();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -152,40 +159,6 @@ static void refreshDisplay(void *arg) {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void shiftOut(uint8_t val1, uint8_t val2, uint8_t val3,
|
|
||||||
uint8_t val4, uint8_t val5, uint8_t val6) {
|
|
||||||
|
|
||||||
uint8_t i;
|
|
||||||
|
|
||||||
for (i = 0; i < 8; i++) {
|
|
||||||
|
|
||||||
palWritePad(GPIOE, GPIOE_PIN2, (val1 & (1 << i)) >> i);
|
|
||||||
palWritePad(GPIOE, GPIOE_PIN3, (val2 & (1 << i)) >> i);
|
|
||||||
palWritePad(GPIOE, GPIOE_PIN4, (val3 & (1 << i)) >> i);
|
|
||||||
palWritePad(GPIOE, GPIOE_PIN5, (val4 & (1 << i)) >> i);
|
|
||||||
palWritePad(GPIOE, GPIOE_PIN6, (val5 & (1 << i)) >> i);
|
|
||||||
palWritePad(GPIOE, GPIOE_PIN7, (val6 & (1 << i)) >> i);
|
|
||||||
|
|
||||||
/* int val = ((val6 & (1 << i) >> i) << 7) |
|
|
||||||
((val5 & (1 << i) >> i) << 6) |
|
|
||||||
((val4 & (1 << i) >> i) << 5) |
|
|
||||||
((val3 & (1 << i) >> i) << 4) |
|
|
||||||
((val2 & (1 << i) >> i) << 3) |
|
|
||||||
((val1 & (1 << i) >> i) << 2);
|
|
||||||
|
|
||||||
palWriteGroup(GPIOE, 0b11111100, 0, val);
|
|
||||||
*/
|
|
||||||
palSetPad(GPIOE, GPIOE_PIN0); //clock
|
|
||||||
asm ("nop");
|
|
||||||
asm ("nop");
|
|
||||||
asm ("nop");
|
|
||||||
asm ("nop");
|
|
||||||
asm ("nop");
|
|
||||||
asm ("nop");
|
|
||||||
palClearPad(GPIOE, GPIOE_PIN0); //clock
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -193,8 +166,8 @@ void init_hw() {
|
||||||
|
|
||||||
initializeSRData();
|
initializeSRData();
|
||||||
|
|
||||||
palSetGroupMode(GPIOD, 0xff00, 0, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
|
palSetGroupMode(GPIOD, 0xff00, 0, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_LOWEST);
|
||||||
palSetGroupMode(GPIOE, 0x00ff, 0, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
|
palSetGroupMode(GPIOE, 0x00ff, 0, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_LOWEST);
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -17,9 +17,11 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#define SHELL_CMD_TEST_ENABLED FALSE
|
||||||
|
|
||||||
#include "ch.h"
|
#include "ch.h"
|
||||||
#include "hal.h"
|
#include "hal.h"
|
||||||
#include "ch_test.h"
|
//#include "ch_test.h"
|
||||||
#include "chprintf.h"
|
#include "chprintf.h"
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
#include "lwipthread.h"
|
#include "lwipthread.h"
|
||||||
|
|
Loading…
Reference in a new issue