⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 display_driver.txt

📁 A display driver for the controller named brief Structures and code specific to the Solomon Systech
💻 TXT
📖 第 1 页 / 共 5 页
字号:
 297. void delay( uint32_t len )   
 298. {   
 299.     uint32_t StartTime, EndTime, ElapsedTime;   
 300.     StartTime = HW_DIGCTL_MICROSECONDS_RD();   
 301.     for( ;; )   
 302.       {   
 303.          EndTime = HW_DIGCTL_MICROSECONDS_RD();    
 304.          ElapsedTime = EndTime - StartTime ;    
 305.          if( ElapsedTime > len )   
 306.               break;   
 307.        }   
 308. }   
 309. ////////////////////////////////////////////////////////////////////////////////   
 310. //! \brief Writes a single command or param/data byte to the controller   
 311. //!   
 312. //! \fntype Function   
 313. //!   
 314. //! \param[in] eCommMode - CMD_MODE or DATA_MODE specifier   
 315. //! \param[in] u16Command- Command or param/data to send   
 316. //!   
 317. //! This function sends a single byte to the display controller   
 318. //!   
 319. ////////////////////////////////////////////////////////////////////////////////   
 320. void WriteDirect(hw_lcdif_CommMode_t eCommMode, uint16_t u16Command)   
 321. {   
 322.     uint32_t u32Command = u16Command;   
 323. #ifdef DEBUG   
 324.     RtStatus_t ret1 = SUCCESS;   
 325.     RtStatus_t ret2 = SUCCESS;   
 326. #endif   
 327.    
 328.     // For 8-bit bus, separate the 16-bit data into two 8-bits    
 329.     uint32_t u32Data0 = u16Command & 0xFF;   
 330.     uint32_t u32Data1 = ((u16Command & 0xFF00)>>8);        
 331.    
 332.     switch( ddi_lcdif_GetDataSwizzle() )   
 333.     {   
 334.         case NO_SWAP:   
 335.             // Leave the data as is   
 336.             break;   
 337.         case HWD_BYTE_SWAP:    // Swap bytes within each half-word   
 338.             // Move command byte to upper half of lower 16-bit word   
 339.             u32Command <<= 8;   
 340.             u32Data0 <<= 8;   
 341.             u32Data1 <<= 8;   
 342.             break;   
 343.         case HWD_SWAP:         // Swap half-words   
 344.             // Move command byte to lower half of upper 16-bit word   
 345.             u32Command <<= 16;   
 346.             u32Data0 <<= 16;   
 347.             u32Data1 <<= 16;   
 348.             break;   
 349.         case SWAP_ALL_BYTES:   // Swap bytes 0,3 and 1,2   
 350.             // Move command byte to upper half of upper 16-bit word   
 351.             u32Command <<= 24;   
 352.             u32Data0 <<= 24;   
 353.             u32Data1 <<= 24;   
 354.             break;   
 355.         default:   
 356.             SystemHalt();      // Programming error   
 357.     }   
 358.    
 359.     if(eCommMode==CMD_MODE)   
 360.     {   
 361.         // 8- and 16-bit bus have same command sizes   
 362.     #ifdef DEBUG   
 363.         ret1 =   
 364.     #endif   
 365.         ddi_lcdif_WriteDirect(eCommMode, (void *)&u32Command, sizeof(DDI_DISPLAY_WORD_TYPE));   
 366.     }   
 367.     else if(eCommMode==DATA_MODE)   
 368.     {   
 369.            
 370.         if(WORDLENGTH_8BITS == hw_lcdif_GetWordLength())   
 371.         {   
 372.             // For 8-bit, we need to send data in two 8 bit parts   
 373.     #ifdef DEBUG   
 374.         ret1 =   
 375.     #endif   
 376.             ddi_lcdif_WriteDirect(eCommMode, (void *)&u32Data1, sizeof(DDI_DISPLAY_WORD_TYPE));   
 377.     #ifdef DEBUG   
 378.         ret2 =   
 379.     #endif       
 380.             ddi_lcdif_WriteDirect(eCommMode, (void *)&u32Data0, sizeof(DDI_DISPLAY_WORD_TYPE));   
 381.         }   
 382.         else   
 383.         {   
 384.             // For 16-bit, data is ok as 16 bits   
 385.     #ifdef DEBUG   
 386.         ret1 =   
 387.     #endif   
 388.             ddi_lcdif_WriteDirect(eCommMode, (void *)&u32Command, sizeof(DDI_DISPLAY_WORD_TYPE));   
 389.         }   
 390.     }   
 391.     #ifdef DEBUG   
 392.         assert(!ret1);   
 393.         assert(!ret2);   
 394.     #endif           
 395. }   
 396.    
 397. ////////////////////////////////////////////////////////////////////////////////   
 398. //! \fn RtStatus_t ddi_display_controller_GetLcdifInitStruct(hw_lcdif_Init_t *pInit, gfx_BitmapTypeEnum_t eBitmapType)   
 399. //!   
 400. //! \brief Copies the LCDIF init struct that corresponds to the given color format   
 401. //!   
 402. //! \fntype Function   
 403. //!   
 404. //! \param[in,out] pInit - Pointer to init struct to copy to     
 405. //! \param[in] eBitmapType - Graphics color format specifier   
 406. //!   
 407. //! \retval SUCCESS No error   
 408. //!   
 409. //! \retval ERROR_DDI_DISPLAY_CONTROLLER_BITMAP_TYPE_UNSUPPORTED - This   
 410. //!         controller does not support the given bitmap color type   
 411. //!   
 412. //! This function is implemented per controller or display.  The appropriate   
 413. //! LCDIF init parameters are copied to the given init struct pointer according   
 414. //! to the type of color format is specified.  Not all controllers/displays are   
 415. //! capable of all color formats, so this function may return an error   
 416. //! indicating that the given color format is not supported.   
 417. //!   
 418. ////////////////////////////////////////////////////////////////////////////////   
 419. RtStatus_t ddi_display_controller_GetLcdifInitStruct(hw_lcdif_Init_t *pInit, gfx_BitmapTypeEnum_t eBitmapType)   
 420. {   
 421.     //! Init structure for LCDIF, may be loaded from a resource   
 422.     hw_lcdif_Init_t LcdifInit =   
 423.     {   
 424.         //! No busy line, no byte-swapping, bring LCD module out of reset   
 425.         false,                          //! m_bBusyEnable   
 426.         DDI_DISPLAY_DATA_SWIZZLE,       //! m_eDataSwizzle   
 427.         LCDRESET_HIGH,                  //! m_eReset   
 428.         BUSMODE_8080,                   //! m_eBusMode   
 429.         DDI_DISPLAY_WORDLENGTH,         //! m_eWordLength   
 430.         //! Bus timing info   
 431.         //! 1XCLK ~= 168ns   
 432.         {   
 433.             DDI_DISPLAY_DATA_SETUP_XCLKS,              //! m_u8DataSetup   
 434.             DDI_DISPLAY_DATA_HOLD_XCLKS,              //! m_u8DataHold   
 435.             DDI_DISPLAY_CMD_SETUP_XCLKS,              //! m_u8CmdSetup   
 436.             DDI_DISPLAY_CMD_HOLD_XCLKS,               //! m_u8CmdHold   
 437.         }   
 438.     };   
 439.    
 440.     if( BITMAP_TYPE_16BPP_565 != eBitmapType )   
 441.         return ERROR_DDI_DISPLAY_CONTROLLER_BITMAP_TYPE_UNSUPPORTED;   
 442.    
 443.     memcpy(pInit, &LcdifInit, sizeof(hw_lcdif_Init_t));   
 444.    
 445.     return SUCCESS;   
 446. }   
 447.    
 448. ////////////////////////////////////////////////////////////////////////////////   
 449. //! \fn static void InitPwmBacklight(void)   
 450. //!   
 451. //! \brief Sets up the PWM backlight control signal   
 452. //!   
 453. //! \fntype Function   
 454. //!   
 455. //! Inits the PWM hardware block and sets up the GPIOs for PWM mode.   
 456. //! The initial backlight frequency is set, but the duty cycle is set to zero   
 457. //!   
 458. ////////////////////////////////////////////////////////////////////////////////   
 459. static void InitPwmBacklight(void)   
 460. {   
 461.     // Do a raw init of the PWM GPIO   
 462. #ifndef BUILD_FOR_ETM   
 463.     HW_PINCTRL_MUXSEL6_CLR(0x00300000 << (2*DDI_DISPLAY_BACKLIGHT_PWM_CHANNEL));   
 464. #endif       
 465.     // Set up the backlight   
 466.     BF_CLR(PWM_CTRL, SFTRST);   
 467.     BF_CLR(PWM_CTRL, CLKGATE);   
 468.    
 469.     // Initialize to 0% duty cycle   
 470.     HW_PWMn_ACTIVE_WR(DDI_DISPLAY_BACKLIGHT_PWM_CHANNEL, 0);   
 471.     BF_CS5n(PWMn_PERIOD, DDI_DISPLAY_BACKLIGHT_PWM_CHANNEL,   
 472.             MATT, 0,    
 473.             CDIV, BACKLIGHT_PWM_CDIV,   
 474.             INACTIVE_STATE, BV_PWMn_PERIOD_INACTIVE_STATE__0,   
 475.             ACTIVE_STATE, BV_PWMn_PERIOD_ACTIVE_STATE__1,   
 476.             PERIOD, BACKLIGHT_PWM_PERIOD);   
 477.    
 478.     HW_PWM_CTRL_CLR(1 << DDI_DISPLAY_BACKLIGHT_PWM_CHANNEL);   
 479. }   
 480.    
 481. ////////////////////////////////////////////////////////////////////////////////   
 482. //! \fn static void SendControllerInitSeq(gfx_BitmapTypeEnum_t eBitmapType, uint32_t u32Width, uint32_t u32Height)   
 483. //!   
 484. //! \brief Sends commands to initialize the controller from reset   
 485. //!   
 486. //! \fntype Function   
 487. //!   
 488. //! \param[in] eBitmapType - Graphics color format specifier   
 489. //! \param[in] u32Width - Desired screen width setting   
 490. //! \param[in] u32Height - Desired screen height setting   
 491. //!   
 492. //! This function sends commands to initialize the controller after it has   
 493. //! been taken out of reset.   
 494. //!   
 495. //! \retval SUCCESS No error   
 496. //!   
 497. //! \retval ERROR_DDI_DISPLAY_CONTROLLER_BITMAP_TYPE_UNSUPPORTED - This   
 498. //!         controller does not support the given bitmap color type   
 499. //!   
 500. //! \retval ERROR_DDI_DISPLAY_CONTROLLER_SCREEN_SIZE - This   
 501. //!         controller does not support the given screen dimensions   
 502. //!   
 503. ////////////////////////////////////////////////////////////////////////////////   
 504. static void SendControllerInitSeq(gfx_BitmapTypeEnum_t eBitmapType, uint32_t u32Width, uint32_t u32Height)   
 505. {   
 506.     //WriteDirect(CMD_MODE,0x22);    
 507.    
 508.     WriteDirect(CMD_MODE,0x46);       
 509.     WriteDirect(DATA_MODE,0x00D2);   
 510.    
 511.     WriteDirect(CMD_MODE,0x47);       
 512.     WriteDirect(DATA_MODE,0x0050);   
 513.    
 514.     WriteDirect(CMD_MODE,0x48);       
 515.     WriteDirect(DATA_MODE,0x0007);    
 516.    
 517.     WriteDirect(CMD_MODE,0x49);       
 518.     WriteDirect(DATA_MODE,0x0043);   
 519.    
 520.     WriteDirect(CMD_MODE,0x4A);       
 521.     WriteDirect(DATA_MODE,0x0044);   
 522.    
 523.     WriteDirect(CMD_MODE,0x4B);       
 524.     WriteDirect(DATA_MODE,0x0077);   
 525.    
 526.     WriteDirect(CMD_MODE,0x4C);       
 527.     WriteDirect(DATA_MODE,0x0066);   
 528.    
 529.     WriteDirect(CMD_MODE,0x4D);       
 530.     WriteDirect(DATA_MODE,0x0016);    
 531.    
 532.     WriteDirect(CMD_MODE,0x4E);       
 533.     WriteDirect(DATA_MODE,0x0012);   
 534.    
 535.     WriteDirect(CMD_MODE,0x4F);       
 536.     WriteDirect(DATA_MODE,0x004C);   
 537.    
 538.     WriteDirect(CMD_MODE,0x50);       
 539.     WriteDirect(DATA_MODE,0x0046);   
 540.    
 541.     WriteDirect(CMD_MODE,0x51);       
 542.     WriteDirect(DATA_MODE,0x0044);   
 543.    
 544. //240*320window setting     
 545.        
 546.     WriteDirect(CMD_MODE,0x02);       
 547.     WriteDirect(DATA_MODE,0x0000);    
 548.    
 549.     WriteDirect(CMD_MODE,0x03);       
 550.     WriteDirect(DATA_MODE,0x0000);    
 551.    
 552.     WriteDirect(CMD_MODE,0x04);       
 553.     WriteDirect(DATA_MODE,0x0000);    
 554.    
 555.     WriteDirect(CMD_MODE,0x05);       
 556.     WriteDirect(DATA_MODE,0x00EF);    
 557.    
 558.     WriteDirect(CMD_MODE,0x06);       
 559.     WriteDirect(DATA_MODE,0x0000);    
 560.    
 561.     WriteDirect(CMD_MODE,0x07);       
 562.     WriteDirect(DATA_MODE,0x0000);    
 563.    
 564.     WriteDirect(CMD_MODE,0x08);       
 565.     WriteDirect(DATA_MODE,0x0001);    
 566.    
 567.     WriteDirect(CMD_MODE,0x09);       
 568.     WriteDirect(DATA_MODE,0x003F);    
 569.    
 570.     //WriteDirect(CMD_MODE,0x22);   
 571.     //Display setting    
 572.     WriteDirect(CMD_MODE,0x01);       
 573.     WriteDirect(DATA_MODE,0x0006); //0x0006   
 574.    
 575.     WriteDirect(CMD_MODE,0x16);       
 576.     WriteDirect(DATA_MODE,0x00A8);//0X48//0x00C8//0x0068//0x0008//0x00A8   
 577.    
 578.     WriteDirect(CMD_MODE,0x23);       
 579.     WriteDirect(DATA_MODE,0x0095);    
 580.    
 581.     WriteDirect(CMD_MODE,0x24);       
 582.     WriteDirect(DATA_MODE,0x0095);    
 583.    
 584.     WriteDirect(CMD_MODE,0x25);       
 585.     WriteDirect(DATA_MODE,0x00FF);    
 586.    
 587.     WriteDirect(CMD_MODE,0x27);       
 588.     WriteDirect(DATA_MODE,0x0002);    
 589.    
 590.     WriteDirect(CMD_MODE,0x28);       
 591.     WriteDirect(DATA_MODE,0x0002);    
 592.    
 593.     WriteDirect(CMD_MODE,0x29);       
 594.     WriteDirect(DATA_MODE,0x0002);    
 595.    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -