35 #if defined(GLCD_DEVICE_STM32F0XX)
39 #include "stm32f0xx_gpio.h"
40 #include "stm32f0xx_spi.h"
41 #include "stm32f0xx_rcc.h"
42 #include "stm32f0xx_misc.h"
51 #if defined(GLCD_CONTROLLER_PCD8544)
55 GPIO_InitTypeDef GPIO_InitStructure;
56 SPI_InitTypeDef SPI_InitStructure;
60 GPIO_StructInit(&GPIO_InitStructure);
61 SPI_StructInit(&SPI_InitStructure);
64 RCC_APB2PeriphClockCmd(RCC_APB2Periph_SPI1, ENABLE);
67 GPIO_InitStructure.GPIO_Pin = CONTROLLER_SPI_SS_PIN;
68 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_3;
69 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
70 GPIO_Init(CONTROLLER_SPI_SS_PORT, &GPIO_InitStructure);
73 GPIO_InitStructure.GPIO_Pin = CONTROLLER_SPI_DC_PIN;
74 GPIO_Init(CONTROLLER_SPI_DC_PORT, &GPIO_InitStructure);
77 GPIO_InitStructure.GPIO_Pin = CONTROLLER_SPI_RST_PIN;
78 GPIO_Init(CONTROLLER_SPI_RST_PORT, &GPIO_InitStructure);
84 GPIO_InitStructure.GPIO_Pin = CONTROLLER_SPI_SCK_PIN | CONTROLLER_SPI_MISO_PIN | CONTROLLER_SPI_MOSI_PIN;
85 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_Level_3;
86 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
87 GPIO_Init(CONTROLLER_SPI_PORT, &GPIO_InitStructure);
90 GPIO_PinAFConfig(GPIOA,CONTROLLER_SPI_SCK_PINSRC,GPIO_AF_0);
91 GPIO_PinAFConfig(GPIOA,CONTROLLER_SPI_MOSI_PINSRC,GPIO_AF_0);
92 GPIO_PinAFConfig(GPIOA,CONTROLLER_SPI_MISO_PINSRC,GPIO_AF_0);
95 SPI_InitStructure.SPI_Direction = SPI_Direction_2Lines_FullDuplex;
96 SPI_InitStructure.SPI_Mode = SPI_Mode_Master;
97 SPI_InitStructure.SPI_DataSize = SPI_DataSize_8b;
98 SPI_InitStructure.SPI_CPOL = SPI_CPOL_Low;
99 SPI_InitStructure.SPI_CPHA = SPI_CPHA_2Edge;
100 SPI_InitStructure.SPI_NSS = SPI_NSS_Soft;
101 SPI_InitStructure.SPI_BaudRatePrescaler = SPI_BaudRatePrescaler_32;
102 SPI_InitStructure.SPI_FirstBit = SPI_FirstBit_MSB;
103 SPI_InitStructure.SPI_CRCPolynomial = 7;
104 SPI_Init(CONTROLLER_SPI_NUMBER, &SPI_InitStructure);
116 SPI_Cmd(CONTROLLER_SPI_NUMBER, ENABLE);
144 #error "Controller not supported by STM32F0xx"
153 SPI_SendData8(CONTROLLER_SPI_NUMBER, (uint16_t) c);
156 while(SPI_I2S_GetFlagStatus(CONTROLLER_SPI_NUMBER, SPI_I2S_FLAG_BSY) != RESET);
#define PCD8544_FUNCTION_SET
void glcd_spi_write(uint8_t c)
Write a byte to the connected SPI slave.
void glcd_select_screen(uint8_t *buffer, glcd_BoundingBox_t *bbox)
Select screen buffer and bounding box structure.
void glcd_reset(void)
Reset the LCD.
#define PCD8544_EXTENDED_INSTRUCTION
#define PCD8544_DISPLAY_NORMAL
glcd_BoundingBox_t glcd_bbox
Keeps track of bounding box of area on LCD which need to be updated next reresh cycle.
#define PCD8544_DISPLAY_CONTROL
void glcd_command(uint8_t c)
Send command byte to LCD.
Functions specific to STM32 F0 ARM Cortex-M0 devices.
void glcd_clear(void)
Clear the display.
void glcd_set_contrast(uint8_t val)
Set contrast.
uint8_t glcd_buffer[GLCD_LCD_WIDTH *GLCD_LCD_HEIGHT/8]
Screen buffer.
#define GLCD_RESET_TIME
Reset duration by glcd_reset(), in milliseconds.
void glcd_init(void)
Initialise the LCD.