Skip to content

Commit

Permalink
PT6523 SPI send demo (software)
Browse files Browse the repository at this point in the history
  • Loading branch information
openshwprojects committed Oct 28, 2023
1 parent 0e9ac33 commit 8415451
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions src/driver/drv_pt6523.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,64 @@ byte pt_inh = 10;
byte pt_ce = 11;
byte pt_clk = 24;
byte pt_di = 8;
byte g_screen[15];
byte g_symbols[5];
byte g_address = 130;

void PT6523_shiftOut(byte *data, int totalBytes) {
for (int j = 0; j < totalBytes; j++) {
byte val = data[j];
for (int i = 0; i < 8; i++) {
//if (bitOrder == LSBFIRST)
//HAL_PIN_SetOutputValue(pt_di, !!(val & (1 << i)));
//else
HAL_PIN_SetOutputValue(pt_di, !!(val & (1 << ((8 - 1) - i))));

HAL_PIN_SetOutputValue(pt_clk, 1);
HAL_PIN_SetOutputValue(pt_clk, 0);
}
}
}

void PT6523_Print() {
HAL_PIN_SetOutputValue(pt_ce, 0);
// Address Data (A1- A8)
PT6523_shiftOut(&g_address,1);
HAL_PIN_SetOutputValue(pt_ce, 1);

// Character Segment Data (D1- D120) 15 Byte
PT6523_shiftOut(g_screen, sizeof(g_screen));

// Symbol Segment Data (D121 - D156 & DR, SC, BU, X) 5 Byte
PT6523_shiftOut(g_symbols, sizeof(g_symbols));

HAL_PIN_SetOutputValue(pt_ce, 0);
}

void PT6523_Init()
{
HAL_PIN_Setup_Output(pt_inh);
HAL_PIN_SetOutputValue(pt_inh, 1);
HAL_PIN_Setup_Output(pt_ce);
HAL_PIN_SetOutputValue(pt_ce, 0);
HAL_PIN_Setup_Output(pt_clk);
HAL_PIN_SetOutputValue(pt_clk, 0);
HAL_PIN_Setup_Output(pt_di);
HAL_PIN_SetOutputValue(pt_di, 0);
}


void PT6523_RunFrame()
{
for (int i = 0; i < sizeof(g_screen); i++) {
g_screen[i] = rand();
}
for (int i = 0; i < sizeof(g_symbols); i++) {
// Can't do rand() here, neither ff, because it turns off the display sometimes
// Maybe there is some specal turn-off bit here?
g_symbols[i] = 0x0;// ff;// rand();
}
PT6523_Print();
}


Expand Down

0 comments on commit 8415451

Please sign in to comment.