made it not working, changed data output method
This commit is contained in:
parent
bb11ddd447
commit
731c2381ce
|
@ -99,7 +99,7 @@ include $(CHIBIOS)/os/hal/osal/rt/osal.mk
|
|||
include $(CHIBIOS)/os/rt/rt.mk
|
||||
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
|
||||
# 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/various/shell/shell.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
|
||||
UDEFS =
|
||||
UDEFS = -DSHELL_CMD_TEST_ENABLED=FALSE
|
||||
|
||||
# Define ASM defines here
|
||||
UADEFS =
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
#include "dfi.h"
|
||||
|
||||
|
||||
#define DATA_LINES 6
|
||||
#define MODULES 10
|
||||
#define FET_COUNT 8
|
||||
#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;
|
||||
|
||||
// prototypes
|
||||
|
@ -24,30 +25,19 @@ THD_FUNCTION(dfiFunc, p) {
|
|||
chRegSetThreadName("dfi");
|
||||
|
||||
static systime_t last_time_simul = 0;
|
||||
static uint8_t counterFet = 0;
|
||||
static uint8_t counterDigit = 0;
|
||||
static uint8_t counterBit = 0;
|
||||
|
||||
chVTObjectInit(&mosfet_timer);
|
||||
chVTSet(&mosfet_timer, US2ST(1500), refreshDisplay, NULL);
|
||||
chVTSet(&mosfet_timer, US2ST(1570), refreshDisplay, NULL);
|
||||
|
||||
while(true) {
|
||||
|
||||
if(ST2MS(chVTTimeElapsedSinceX(last_time_simul)) > 5) {
|
||||
|
||||
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;
|
||||
|
||||
if(ST2MS(chVTTimeElapsedSinceX(last_time_simul)) > 100) {
|
||||
|
||||
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++) {
|
||||
|
@ -83,14 +73,23 @@ THD_FUNCTION(dfiFunc, p) {
|
|||
void initializeSRData() {
|
||||
palSetPad(GPIOE, GPIOE_PIN1); //Tells all SRs that uController is sending data
|
||||
|
||||
for(int seg = 0; seg < SEGMENTS; seg++) {
|
||||
shiftOut(0,0,0,0,0,0);
|
||||
for (uint16_t i = 0; i < SEGMENTS * MODULES * BIT_PER_FET_PER_SEG; i++) {
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
// all 1.5ms
|
||||
static void refreshDisplay(void *arg) {
|
||||
(void)arg;
|
||||
|
||||
|
@ -100,33 +99,43 @@ static void refreshDisplay(void *arg) {
|
|||
fet++;
|
||||
fet %= FET_COUNT;
|
||||
|
||||
// switch fets
|
||||
|
||||
for(int module = MODULES-1; module >= 0; module--) {
|
||||
for(int seg = 0; seg < SEGMENTS; seg++) {
|
||||
shiftOut(data[0][module][fet][seg],
|
||||
data[1][module][fet][seg],
|
||||
data[2][module][fet][seg],
|
||||
data[3][module][fet][seg],
|
||||
data[4][module][fet][seg],
|
||||
data[5][module][fet][seg]);
|
||||
}
|
||||
for (uint16_t i = 0; i < SEGMENTS * MODULES * BIT_PER_FET_PER_SEG; i++) {
|
||||
palClearPort(GPIOE, 0xfc);
|
||||
palWriteGroup(GPIOE, 0xfc, 0, data[fet][i]);
|
||||
|
||||
//palSetPort(GPIOE, data[fet][i]);
|
||||
|
||||
palSetPad(GPIOE, GPIOE_PIN0); //clock
|
||||
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
|
||||
|
||||
for (int w = 0; w < 125; w++) { // wait ca 8µS /7 125
|
||||
asm ("nop");
|
||||
}
|
||||
palSetPad(GPIOE, GPIOE_PIN1); // latch high
|
||||
for (int w = 0; w < 25; w++) { // wait ca 1,6µS = 25
|
||||
for (uint8_t w = 0; w < 125; w++) {
|
||||
asm ("nop");
|
||||
}
|
||||
|
||||
palSetPad(GPIOE, GPIOE_PIN1); // latch high
|
||||
for (uint8_t w = 0; w < 60; w++) {
|
||||
asm ("nop");
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
|
@ -142,9 +151,7 @@ static void refreshDisplay(void *arg) {
|
|||
palWritePad(GPIOD, GPIOD_PIN15, (fet == 7) ? 1 : 0);
|
||||
|
||||
|
||||
//palClearPort(GPIOD, 0xff00);
|
||||
|
||||
chVTSetI(&mosfet_timer, US2ST(1500), refreshDisplay, NULL);
|
||||
chVTSetI(&mosfet_timer, US2ST(1570), refreshDisplay, NULL);
|
||||
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();
|
||||
|
||||
palSetGroupMode(GPIOD, 0xff00, 0, PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
|
||||
palSetGroupMode(GPIOE, 0x00ff, 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_LOWEST);
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -17,9 +17,11 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define SHELL_CMD_TEST_ENABLED FALSE
|
||||
|
||||
#include "ch.h"
|
||||
#include "hal.h"
|
||||
#include "ch_test.h"
|
||||
//#include "ch_test.h"
|
||||
#include "chprintf.h"
|
||||
#include "shell.h"
|
||||
#include "lwipthread.h"
|
||||
|
|
Loading…
Reference in New Issue