36 #if defined(GLCD_DEVICE_STM32F10X)
43 #if defined(GLCD_CONTROLLER_PCD8544)
47 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_SPI1, ENABLE);
50 GPIO_InitTypeDef GPIO_InitStructure;
53 GPIO_InitStructure.GPIO_Pin = CONTROLLER_SPI_SS_PIN;
54 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
55 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
56 GPIO_Init(CONTROLLER_SPI_SS_PORT, &GPIO_InitStructure);
59 GPIO_InitStructure.GPIO_Pin = CONTROLLER_SPI_DC_PIN;
60 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
61 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
62 GPIO_Init(CONTROLLER_SPI_DC_PORT, &GPIO_InitStructure);
65 GPIO_InitStructure.GPIO_Pin = CONTROLLER_SPI_RST_PIN;
66 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
67 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
68 GPIO_Init(CONTROLLER_SPI_RST_PORT, &GPIO_InitStructure);
74 GPIO_InitStructure.GPIO_Pin = CONTROLLER_SPI_SCK_PIN | CONTROLLER_SPI_MISO_PIN | CONTROLLER_SPI_MOSI_PIN;
75 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_2MHz;
76 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_PP;
77 GPIO_Init(CONTROLLER_SPI_PORT, &GPIO_InitStructure);
80 SPI_InitTypeDef SPI_InitStructure;
81 SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
82 SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
83 SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
84 SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
85 SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
86 SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
87 SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_32;
88 SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
89 SPI_InitStructure.SPI_CRCPolynomial = 7;
90 SPI_Init(CONTROLLER_SPI_NUMBER, &SPI_InitStructure);
92 SPI_I2S_ITConfig(CONTROLLER_SPI_NUMBER, SPI_I2S_IT_RXNE, ENABLE);
95 SPI_Cmd(CONTROLLER_SPI_NUMBER, ENABLE);
101 #error "Controller not supported by STM32F100x"
110 SPI_I2S_SendData(CONTROLLER_SPI_NUMBER, (uint16_t) data);
113 while( SPI_I2S_GetFlagStatus(CONTROLLER_SPI_NUMBER,SPI_I2S_FLAG_RXNE) != SET );
void glcd_spi_write(uint8_t c)
Write a byte to the connected SPI slave.
void glcd_reset(void)
Reset the LCD.
Device implementation for ST STM32F10x ARM Cortex-M3 MCUs Requires the use of ST's Standard Periphera...
#define GLCD_RESET_TIME
Reset duration by glcd_reset(), in milliseconds.
void glcd_init(void)
Initialise the LCD.