コード例 #1
0
ファイル: f3d_lcd_sd.c プロジェクト: gaoyuu/III_III_V_CS
void f3d_lcd_init(void) {
  const struct lcd_cmdBuf *cmd;
  
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_DMA1, ENABLE);
  
  f3d_lcd_sd_interface_init();    // Setup SPI2 Link and configure GPIO pins
  LCD_BKL_ON();                   // Enable Backlight

  // Make sure that the chip select and reset lines are deasserted
  LCD_CS_DEASSERT();              // Deassert Chip Select

  LCD_RESET_DEASSERT();           
  delay(100);
  LCD_RESET_ASSERT();
  delay(100);
  LCD_RESET_DEASSERT();
  delay(100);

  // Write initialization sequence to the lcd
  for (cmd=initializers; cmd->command; cmd++) {
    LcdWrite(LCD_C,&(cmd->command),1);
    if (cmd->len)
      LcdWrite(LCD_D,cmd->data,cmd->len);
    if (cmd->delay) {
      delay(cmd->delay);
    }
  }
}
コード例 #2
0
void ClearLcd(void)
{
  EnableSmClkUser(LCD_USER);
  LCD_CS_ASSERT();

  LCD_SPI_UCBxTXBUF = LCD_CLEAR_CMD;
  while (!(LCD_SPI_UCBxIFG & UCTXIFG));

  LCD_SPI_UCBxTXBUF = 0x00;
  while (!(LCD_SPI_UCBxIFG & UCTXIFG));

  /* wait for shift to complete ( ~3 us ) */
  while((LCD_SPI_UCBxSTAT & 0x01) != 0);

  LCD_CS_DEASSERT();
  DisableSmClkUser(LCD_USER);
}
コード例 #3
0
static void Write(unsigned char Cmd, unsigned char *pBuffer, unsigned int Size)
{  
  EnableSmClkUser(LCD_USER);
  LCD_CS_ASSERT();
  
#if LCD_DMA
  
  LcdDmaBusy = 1;
  
  /* send the lcd write command before starting the dma */
  LCD_SPI_UCBxTXBUF = Cmd;
  while (!(LCD_SPI_UCBxIFG&UCTXIFG));
  
  /* USCIB0 TXIFG is the DMA trigger
   * DMACTL1 controls dma2 and [dma3]
   */
  DMACTL1 = DMA2TSEL_19;    
    
  __data16_write_addr((unsigned short) &DMA2SA, (unsigned long) pBuffer);
  __data16_write_addr((unsigned short) &DMA2DA, (unsigned long) &LCD_SPI_UCBxTXBUF);
            
  DMA2SZ = Size;
  
  /* 
   * single transfer, increment source address, source byte and dest byte,
   * level sensitive, enable interrupt, clear interrupt flag
   */
  DMA2CTL = DMADT_0 + DMASRCINCR_3 + DMASBDB + DMALEVEL + DMAIE;  
  
  /* start the transfer */
  DMA2CTL |= DMAEN;
  
  while(LcdDmaBusy);

#else

  /* send the lcd write command */
  LCD_SPI_UCBxTXBUF = Cmd;
  while (!(LCD_SPI_UCBxIFG&UCTXIFG));
  
  for (unsigned int i = 0; i < Size; ++i)
  {
    LCD_SPI_UCBxTXBUF = pBuffer[i];
    while (!(LCD_SPI_UCBxIFG&UCTXIFG));
  }
    
#endif
  
  /* add one more dummy byte at the end */
  LCD_SPI_UCBxTXBUF = 0x00;
  while (!(LCD_SPI_UCBxIFG&UCTXIFG));
  
  /* wait for shift to complete ( ~3 us ) */
  while((LCD_SPI_UCBxSTAT & 0x01) != 0);
        
  LCD_SPI_UCBxTXBUF = LCD_STATIC_CMD;
  while (!(LCD_SPI_UCBxIFG&UCTXIFG));

  LCD_SPI_UCBxTXBUF = 0x00;
  while (!(LCD_SPI_UCBxIFG&UCTXIFG));

  /* now the chip select can be deasserted */
  LCD_CS_DEASSERT();
  DisableSmClkUser(LCD_USER);
}