#include "stm32f10x.h" #include "STM32vldiscovery.h" #define LCD_PIN_ENABLE GPIO_Pin_12 #define LCD_PIN_RESET GPIO_Pin_11 #define LCD_PIN_COMMAND GPIO_Pin_10 #define LCD_PIN_DATA GPIO_Pin_9 #define LCD_PIN_CLOCK GPIO_Pin_8 #define LCD_CMD 0 #define LCD_DATA 1 GPIO_InitTypeDef GPIO_InitStructure; uint8_t messageBytes[] = { 0x3e, 0x41, 0x41, 0x41, 0x22, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x7c, 0x08, 0x04, 0x04, 0x08, 0x00, 0x04, 0x3f, 0x44, 0x40, 0x20, 0x00, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x44, 0x28, 0x10, 0x28, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x02, 0x0c, 0x02, 0x7f, 0x00, 0x21, 0x41, 0x45, 0x4b, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x49, 0x49, 0x49, 0x31, 0x00, 0x01, 0x01, 0x7f, 0x01, 0x01, 0x00, 0x7f, 0x02, 0x0c, 0x02, 0x7f, 0x00, 0x21, 0x41, 0x45, 0x4b, 0x31, 0x00, 0x42, 0x61, 0x51, 0x49, 0x46, 0x00, 0x7f, 0x41, 0x41, 0x22, 0x1c, 0x00, 0x00, 0x44, 0x7d, 0x40, 0x00, 0x00, 0x48, 0x54, 0x54, 0x54, 0x20, 0x00, 0x38, 0x44, 0x44, 0x44, 0x20, 0x00, 0x38, 0x44, 0x44, 0x44, 0x38, 0x00, 0x1c, 0x20, 0x40, 0x20, 0x1c, 0x00, 0x38, 0x54, 0x54, 0x54, 0x18, 0x00, 0x7c, 0x08, 0x04, 0x04, 0x08, 0x00, 0x0c, 0x50, 0x50, 0x50, 0x3c, 0x00 }; void LcdWrite(uint8_t dataOrCommand, uint8_t value); void delay_ms(__IO uint32_t nCount); int main(void) { // Configure all unused GPIO port pins in Analog Input mode RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AIN; GPIO_Init(GPIOA, &GPIO_InitStructure); GPIO_Init(GPIOB, &GPIO_InitStructure); GPIO_Init(GPIOC, &GPIO_InitStructure); GPIO_Init(GPIOD, &GPIO_InitStructure); GPIO_Init(GPIOE, &GPIO_InitStructure); RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA | RCC_APB2Periph_GPIOB | RCC_APB2Periph_GPIOC | RCC_APB2Periph_GPIOD | RCC_APB2Periph_GPIOE, DISABLE); // Initialize PA8-PA12 as outputs RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA, ENABLE); GPIO_InitStructure.GPIO_Pin = LCD_PIN_ENABLE | LCD_PIN_RESET | LCD_PIN_COMMAND | LCD_PIN_DATA | LCD_PIN_CLOCK; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_10MHz; GPIO_Init(GPIOA, &GPIO_InitStructure); // Reset LCD GPIO_SetBits(GPIOA, LCD_PIN_RESET); delay_ms(10); GPIO_ResetBits(GPIOA, LCD_PIN_RESET); delay_ms(10); GPIO_SetBits(GPIOA, LCD_PIN_RESET); // Initialize LCD state LcdWrite(LCD_CMD, 0x21); // LCD Extended Commands. LcdWrite(LCD_CMD, 0xB1); // Set LCD Vop (Contrast). LcdWrite(LCD_CMD, 0x04); // Set Temp coefficent. LcdWrite(LCD_CMD, 0x15); // LCD bias mode LcdWrite(LCD_CMD, 0x20); LcdWrite(LCD_CMD, 0x0C); // LCD in normal mode. // Write the message int i; for (i=0; i