Based on experience with Serial interface I thought that system would care about all hardware pins, wrote SPI based interface to my display board, but it does not work. Went through source codes, found that pins are not initialized and added settings for the pins. I did not help
What else did I miss?
Here is my initialization
In mcuconfig.h
Code: Select all
/*
* SPI driver system settings.
*/
#define STM32_SPI_USE_SPI1 FALSE
#define STM32_SPI_USE_SPI2 TRUE // FALSE
#define STM32_SPI_SPI1_DMA_PRIORITY 1
#define STM32_SPI_SPI2_DMA_PRIORITY 1
#define STM32_SPI_SPI1_IRQ_PRIORITY 10
#define STM32_SPI_SPI2_IRQ_PRIORITY 10
#define STM32_SPI_DMA_ERROR_HOOK(spip) chSysHalt()
ui_driver.c
Code: Select all
static const SPIConfig display_cfg =
{
NULL, // we use master mode
DISPLAY_CS_PORT,
DISPLAY_CS_PIN,
BR_VALUE // Since CPHA and CPOL are 0, we don't need to set any control for it
} ;
static const SPIConfig ui_cfg =
{
NULL, // we use master mode
BUTTON_CS_PORT,
BUTTON_CS_PIN,
BR_VALUE // Since CPHA and CPOL are 0, we don't need to set any control for it
};
uint8_t DisplayInitSequence[] = //used sequence from NHD-2.23-12832UCY3 datasheet
{
DISPLAYOFF, // Display Off (0x00/0x01)
DISPLAYCLK_C,0x10, // Set Clock as 160 Frames/Sec
...
// my additional init to fill memory with 0
MEMADDRESSMODE_C, 0x00, // Horizontal Addressing Mode
COLUMNADDRESS_C, 0x00, 0x7F, // Set borders of cleaning columns
PAGEADDRESS_C, 0x00, 0x7F // Set borders of cleaning rows
// finish with
// Fill_RAM(0x00); // Clear Screen
// DISPLAYON // Display On (0x00/0x01
};
/*===========================================================================*/
/* Driver local functions. */
/*===========================================================================*/
//const DisplayFont F8x5 = { (uint8_t *)Font8x5, 8, 5};
/*===========================================================================*/
/* Driver exported functions. */
/*===========================================================================*/
/**
* @brief UI Driver initialization.
* @note This function is implicitly invoked by @p halInit(), there is
* no need to explicitly initialize the driver.
*
* @init
*/
void UIInit(void)
{ uint16_t i;
uint8_t data ;
{ // UI (Display, Buttons, LEDs) hardware initialization
palSetPadMode(UI_RST_PORT, UI_RST_PIN, PAL_STM32_MODE_OUTPUT | PAL_MODE_OUTPUT_PUSHPULL); // reset pin for the all display board
palSetPadMode(DISPLAY_CTRL_PORT, DISPLAY_DC_PIN | DISPLAY_CS_PIN | BUTTON_CS_PIN | HEN1_PIN | HEN2_PIN, // hardware control pins
PAL_STM32_MODE_OUTPUT | PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(INT_BUT_PORT, INT_BUT_PIN, PAL_STM32_MODE_INPUT | PAL_STM32_PUDR_PULLUP); // just input yet. Will be used for interrupts from buttons
palSetPadMode(DISPLAY_CTRL_PORT, SPI2_MOSI | SPI2_MISO | SPI2_SCK, PAL_STM32_MODE_ALTERNATE | PAL_STM32_ALTERNATE(5)); // hardware SPI pins
}
// spiInit(); done in halinit()
// Display Init.
{
// spiObjectInit(&Display); it is only for SPI2 and called in spiInit()
spiStart(&Display, &display_cfg);
palClearPad(DISPLAY_DC_PORT, DISPLAY_DC_PIN); // display sending commands mode
spiSelect(&Display);
[b]spiSend(&Display, sizeof(DisplayInitSequence), DisplayInitSequence);[/b] // <<--- stops in here!!!
// Fill Memory with 0
....
spiUnselect(&Display);
}
// End of display init
}chsys.c
Code: Select all
#include "ch.h"
#if !CH_NO_IDLE_THREAD || defined(__DOXYGEN__)
WORKING_AREA(_idle_thread_wa, PORT_IDLE_THREAD_STACK_SIZE);
void _idle_thread(void *p) {
(void)p;
chRegSetThreadName("idle");
while (TRUE) {
port_wait_for_interrupt();
IDLE_LOOP_HOOK();
} // <<< ----------------------- Actually stops here.
}
#endif /* CH_NO_IDLE_THREAD */