void f3d_lcd_setAddrWindow ( uint16_t x0 , uint16_t y0 , uint16_t x1 , uint16_t y1 , uint8_t madctl) { madctl = MADVAL ( madctl ); if ( madctl != madctlcurrent ){ f3d_lcd_writeCmd(ST7735_MADCTL); LcdWrite(LCD_D, &madctl, 1); madctlcurrent = madctl ; } f3d_lcd_writeCmd(ST7735_CASET); LcdWrite16(LCD_D,&x0,1); LcdWrite16(LCD_D,&x1,1); f3d_lcd_writeCmd(ST7735_RASET); LcdWrite16(LCD_D,&y0,1); LcdWrite16(LCD_D,&y1,1); f3d_lcd_writeCmd(ST7735_RAMWR); }
#include <stm32f10x.h> #include <stm32f10x_rcc.h> #include <stm32f10x_gpio.h> #include <stm32f10x_spi.h> #include "st7735_init.h" #include "spi_drive.h" extern void Delay(uint32_t nTime); static uint8_t madctlcurrent = MADVAL( MADCTLGRAPHICS ); void ST7735_init( void ) { const struct ST7735_cmdBuf *cmd; GPIO_InitTypeDef GPIO_InitStructure; // set up pins RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOA, ENABLE ); // LCD - BACKLIGHT, LCD_CS, Rest, Data/Ctrl GPIO_StructInit( &GPIO_InitStructure ); // BackLight = BKL GPIO_InitStructure.GPIO_Pin = GPIO_PIN_BKL; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init( LCD_PORT_BKL, &GPIO_InitStructure ); GPIO_InitStructure.GPIO_Pin = GPIO_PIN_SCE; // LCD_CS = LCD Select = SCE GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_Init( LCD_PORT, &GPIO_InitStructure );
* Date Created: 2/25/16 --- * Last Modified by: Kyle Dijkstra --- * Date Last Modified: 2/26/16 --- * Assignment: Lab7 --- */ #include <f3d_lcd_sd.h> #include <f3d_delay.h> #include <glcdfont.h> static uint8_t madctlcurrent = MADVAL(MADCTLGRAPHICS); void f3d_lcd_sd_interface_init(void) { /* vvvvvvvvvvv pin initialization for the LCD goes here vvvvvvvvvv*/ RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE); RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOB, ENABLE); GPIO_InitTypeDef GPIO_InitStructure; GPIO_StructInit(&GPIO_InitStructure); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_9|GPIO_Pin_10|GPIO_Pin_11|GPIO_Pin_12; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOB, &GPIO_InitStructure);
// INVCTR Display inversion (no inversion) { 0xB4, 0, 1, { 0x07 } }, // PWCTR1 Power control -4.6V, Auto mode { 0xC0, 0, 3, { 0xA2, 0x02, 0x84 } }, // PWCTR2 Power control VGH25 2.4C, VGSEL -10, VGH = 3 * AVDD { 0xC1, 0, 1, { 0xC5 } }, // PWCTR3 Power control, opamp current smal, boost frequency { 0xC2, 0, 2, { 0x0A, 0x00 } }, // PWCTR4 Power control, BLK/2, opamp current small and medium low { 0xC3, 0, 2, { 0x8A, 0x2A } }, // PWRCTR5, VMCTR1 Power control { 0xC4, 0, 2, { 0x8A, 0xEE } }, { 0xC5, 0, 1, { 0x0E } }, // INVOFF Don't invert display { 0x20, 0, 0, { 0 } }, // Memory access directions. row address/col address, bottom to top refesh (10.1.27) { ST7735_MADCTL, 0, 1, { MADVAL(MADCTLGRAPHICS) } }, // Color mode 16 bit (10.1.30 { ST7735_COLMOD, 0, 1, { 0x05 } }, // // Column address set 0..127 // { ST7735_CASET, 0, 4, { 0x00, 0x00, 0x00, 0x7F } }, // // Row address set 0..127 // { ST7735_RASET, 0, 4, { 0x00, 0x00, 0x00, 0x7F } }, // GMCTRP1 Gamma correction { 0xE0, 0, 16, { 0x02, 0x1C, 0x07, 0x12, 0x37, 0x32, 0x29, 0x2D, 0x29, 0x25, 0x2B, 0x39, 0x00, 0x01, 0x03, 0x10 } }, // GMCTRP2 Gamma Polarity corrction { 0xE1, 0, 16, { 0x03, 0x1d, 0x07, 0x06, 0x2E, 0x2C, 0x29, 0x2D, 0x2E, 0x2E, 0x37, 0x3F, 0x00, 0x00, 0x02, 0x10 } }, // DISPON Display on { 0x29, 100, 0, { 0 } }, // NORON Normal on