Skip to content

Commit

Permalink
Fix notify display for SPI1 w/ 36 MHz clock (VGA hires mode)
Browse files Browse the repository at this point in the history
  • Loading branch information
Torsten Kurbad committed Jan 3, 2022
1 parent 37b797f commit 5c17777
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
3 changes: 3 additions & 0 deletions inc/stm32f10x_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,9 @@ struct rcc {
#define RCC_AHBRSTR_ETHMACRST (1u<<14)
#define RCC_AHBRSTR_OTGFSRST (1u<<12)

#define RCC_APB1RSTR_SPI2RST (1u<< 14)
#define RCC_APB2RSTR_SPI1RST (1u<< 12)

#define RCC_BASE 0x40021000

/* Independent Watchdog */
Expand Down
28 changes: 25 additions & 3 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -626,11 +626,23 @@ static void update_amiga_keys(void)

/* OSD On/Off. */
if ((del_pressed ^ amiga_key_pressed(AMI_DEL)) && (del_pressed ^= 1)) {
int row;
osd_on ^= 1;
snprintf((char *)notify.text[0], sizeof(notify.text[0]),
memset(notify.text, 0, sizeof(notify.text));
if ((running_display_timing == DISP_VGA)
&& (startup_display_spi == DISP_SPI1)) {
row = 1;
notify.rows = 3;
notify.heights = 1u << row; /* Row index 1 -> double height */
} else {
row = 0;
notify.rows = 1;
notify.heights = 0;
}
snprintf((char *)notify.text[row], sizeof(notify.text[row]),
"OSD O%s", osd_on ? "n" : "ff");
notify.cols = strlen((char *)notify.text[0]);
notify.rows = 1;
notify.cols = (row == 0) ? strlen((char *)notify.text[row])
: sizeof(notify.text[row]);
notify.on = TRUE;
notify_time = time_now();
}
Expand Down Expand Up @@ -727,6 +739,11 @@ void display_off(void)

void setup_spi1(void)
{
/* Reset SPI Port. */
rcc->apb2rstr |= RCC_APB2RSTR_SPI1RST;
rcc->apb2rstr &= ~RCC_APB2RSTR_SPI1RST;
rcc->apb2enr |= RCC_APB2ENR_SPI1EN;

/* Configure SPI: 16-bit mode, MSB first, CPOL Low, CPHA Leading Edge. */
/* SPI1 is on APB2 which runs at 72MHz */
spi_display_spi1->cr2 = SPI_CR2_TXDMAEN;
Expand Down Expand Up @@ -754,6 +771,11 @@ void setup_spi1(void)

void setup_spi2(void)
{
/* Reset SPI Port. */
rcc->apb1rstr |= RCC_APB1RSTR_SPI2RST;
rcc->apb1rstr &= ~RCC_APB1RSTR_SPI2RST;
rcc->apb1enr |= RCC_APB1ENR_SPI2EN;

/* Configure SPI: 16-bit mode, MSB first, CPOL Low, CPHA Leading Edge. */
/* SPI2 is on APB1 which runs at 36MHz */
spi_display_spi2->cr2 = SPI_CR2_TXDMAEN;
Expand Down

0 comments on commit 5c17777

Please sign in to comment.