1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102 |
- #include "stm32f4xx_ltdc.h"
- #include "stm32f4xx_rcc.h"
- #define GCR_MASK ((uint32_t)0x0FFE888F)
- void LTDC_DeInit(void)
- {
-
- RCC_APB2PeriphResetCmd(RCC_APB2Periph_LTDC, ENABLE);
-
- RCC_APB2PeriphResetCmd(RCC_APB2Periph_LTDC, DISABLE);
- }
- void LTDC_Init(LTDC_InitTypeDef* LTDC_InitStruct)
- {
- uint32_t horizontalsync = 0;
- uint32_t accumulatedHBP = 0;
- uint32_t accumulatedactiveW = 0;
- uint32_t totalwidth = 0;
- uint32_t backgreen = 0;
- uint32_t backred = 0;
-
- assert_param(IS_LTDC_HSYNC(LTDC_InitStruct->LTDC_HorizontalSync));
- assert_param(IS_LTDC_VSYNC(LTDC_InitStruct->LTDC_VerticalSync));
- assert_param(IS_LTDC_AHBP(LTDC_InitStruct->LTDC_AccumulatedHBP));
- assert_param(IS_LTDC_AVBP(LTDC_InitStruct->LTDC_AccumulatedVBP));
- assert_param(IS_LTDC_AAH(LTDC_InitStruct->LTDC_AccumulatedActiveH));
- assert_param(IS_LTDC_AAW(LTDC_InitStruct->LTDC_AccumulatedActiveW));
- assert_param(IS_LTDC_TOTALH(LTDC_InitStruct->LTDC_TotalHeigh));
- assert_param(IS_LTDC_TOTALW(LTDC_InitStruct->LTDC_TotalWidth));
- assert_param(IS_LTDC_HSPOL(LTDC_InitStruct->LTDC_HSPolarity));
- assert_param(IS_LTDC_VSPOL(LTDC_InitStruct->LTDC_VSPolarity));
- assert_param(IS_LTDC_DEPOL(LTDC_InitStruct->LTDC_DEPolarity));
- assert_param(IS_LTDC_PCPOL(LTDC_InitStruct->LTDC_PCPolarity));
- assert_param(IS_LTDC_BackBlueValue(LTDC_InitStruct->LTDC_BackgroundBlueValue));
- assert_param(IS_LTDC_BackGreenValue(LTDC_InitStruct->LTDC_BackgroundGreenValue));
- assert_param(IS_LTDC_BackRedValue(LTDC_InitStruct->LTDC_BackgroundRedValue));
-
- LTDC->SSCR &= ~(LTDC_SSCR_VSH | LTDC_SSCR_HSW);
- horizontalsync = (LTDC_InitStruct->LTDC_HorizontalSync << 16);
- LTDC->SSCR |= (horizontalsync | LTDC_InitStruct->LTDC_VerticalSync);
-
- LTDC->BPCR &= ~(LTDC_BPCR_AVBP | LTDC_BPCR_AHBP);
- accumulatedHBP = (LTDC_InitStruct->LTDC_AccumulatedHBP << 16);
- LTDC->BPCR |= (accumulatedHBP | LTDC_InitStruct->LTDC_AccumulatedVBP);
-
- LTDC->AWCR &= ~(LTDC_AWCR_AAH | LTDC_AWCR_AAW);
- accumulatedactiveW = (LTDC_InitStruct->LTDC_AccumulatedActiveW << 16);
- LTDC->AWCR |= (accumulatedactiveW | LTDC_InitStruct->LTDC_AccumulatedActiveH);
-
- LTDC->TWCR &= ~(LTDC_TWCR_TOTALH | LTDC_TWCR_TOTALW);
- totalwidth = (LTDC_InitStruct->LTDC_TotalWidth << 16);
- LTDC->TWCR |= (totalwidth | LTDC_InitStruct->LTDC_TotalHeigh);
- LTDC->GCR &= (uint32_t)GCR_MASK;
- LTDC->GCR |= (uint32_t)(LTDC_InitStruct->LTDC_HSPolarity | LTDC_InitStruct->LTDC_VSPolarity | \
- LTDC_InitStruct->LTDC_DEPolarity | LTDC_InitStruct->LTDC_PCPolarity);
-
- backgreen = (LTDC_InitStruct->LTDC_BackgroundGreenValue << 8);
- backred = (LTDC_InitStruct->LTDC_BackgroundRedValue << 16);
- LTDC->BCCR &= ~(LTDC_BCCR_BCBLUE | LTDC_BCCR_BCGREEN | LTDC_BCCR_BCRED);
- LTDC->BCCR |= (backred | backgreen | LTDC_InitStruct->LTDC_BackgroundBlueValue);
- }
- void LTDC_StructInit(LTDC_InitTypeDef* LTDC_InitStruct)
- {
-
- LTDC_InitStruct->LTDC_HSPolarity = LTDC_HSPolarity_AL;
- LTDC_InitStruct->LTDC_VSPolarity = LTDC_VSPolarity_AL;
- LTDC_InitStruct->LTDC_DEPolarity = LTDC_DEPolarity_AL;
- LTDC_InitStruct->LTDC_PCPolarity = LTDC_PCPolarity_IPC;
- LTDC_InitStruct->LTDC_HorizontalSync = 0x00;
- LTDC_InitStruct->LTDC_VerticalSync = 0x00;
- LTDC_InitStruct->LTDC_AccumulatedHBP = 0x00;
- LTDC_InitStruct->LTDC_AccumulatedVBP = 0x00;
- LTDC_InitStruct->LTDC_AccumulatedActiveW = 0x00;
- LTDC_InitStruct->LTDC_AccumulatedActiveH = 0x00;
- LTDC_InitStruct->LTDC_TotalWidth = 0x00;
- LTDC_InitStruct->LTDC_TotalHeigh = 0x00;
- LTDC_InitStruct->LTDC_BackgroundRedValue = 0x00;
- LTDC_InitStruct->LTDC_BackgroundGreenValue = 0x00;
- LTDC_InitStruct->LTDC_BackgroundBlueValue = 0x00;
- }
- void LTDC_Cmd(FunctionalState NewState)
- {
-
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
-
- LTDC->GCR |= (uint32_t)LTDC_GCR_LTDCEN;
- }
- else
- {
-
- LTDC->GCR &= ~(uint32_t)LTDC_GCR_LTDCEN;
- }
- }
- void LTDC_DitherCmd(FunctionalState NewState)
- {
-
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
-
- LTDC->GCR |= (uint32_t)LTDC_GCR_DTEN;
- }
- else
- {
-
- LTDC->GCR &= ~(uint32_t)LTDC_GCR_DTEN;
- }
- }
- LTDC_RGBTypeDef LTDC_GetRGBWidth(void)
- {
- LTDC_RGBTypeDef LTDC_RGB_InitStruct;
- LTDC->GCR &= (uint32_t)GCR_MASK;
- LTDC_RGB_InitStruct.LTDC_BlueWidth = (uint32_t)((LTDC->GCR >> 4) & 0x7);
- LTDC_RGB_InitStruct.LTDC_GreenWidth = (uint32_t)((LTDC->GCR >> 8) & 0x7);
- LTDC_RGB_InitStruct.LTDC_RedWidth = (uint32_t)((LTDC->GCR >> 12) & 0x7);
- return LTDC_RGB_InitStruct;
- }
- void LTDC_RGBStructInit(LTDC_RGBTypeDef* LTDC_RGB_InitStruct)
- {
- LTDC_RGB_InitStruct->LTDC_BlueWidth = 0x02;
- LTDC_RGB_InitStruct->LTDC_GreenWidth = 0x02;
- LTDC_RGB_InitStruct->LTDC_RedWidth = 0x02;
- }
- void LTDC_LIPConfig(uint32_t LTDC_LIPositionConfig)
- {
-
- assert_param(IS_LTDC_LIPOS(LTDC_LIPositionConfig));
-
- LTDC->LIPCR = (uint32_t)LTDC_LIPositionConfig;
- }
- void LTDC_ReloadConfig(uint32_t LTDC_Reload)
- {
-
- assert_param(IS_LTDC_RELOAD(LTDC_Reload));
-
- LTDC->SRCR = (uint32_t)LTDC_Reload;
- }
- void LTDC_LayerInit(LTDC_Layer_TypeDef* LTDC_Layerx, LTDC_Layer_InitTypeDef* LTDC_Layer_InitStruct)
- {
- uint32_t whsppos = 0;
- uint32_t wvsppos = 0;
- uint32_t dcgreen = 0;
- uint32_t dcred = 0;
- uint32_t dcalpha = 0;
- uint32_t cfbp = 0;
- assert_param(IS_LTDC_Pixelformat(LTDC_Layer_InitStruct->LTDC_PixelFormat));
- assert_param(IS_LTDC_BlendingFactor1(LTDC_Layer_InitStruct->LTDC_BlendingFactor_1));
- assert_param(IS_LTDC_BlendingFactor2(LTDC_Layer_InitStruct->LTDC_BlendingFactor_2));
- assert_param(IS_LTDC_HCONFIGST(LTDC_Layer_InitStruct->LTDC_HorizontalStart));
- assert_param(IS_LTDC_HCONFIGSP(LTDC_Layer_InitStruct->LTDC_HorizontalStop));
- assert_param(IS_LTDC_VCONFIGST(LTDC_Layer_InitStruct->LTDC_VerticalStart));
- assert_param(IS_LTDC_VCONFIGSP(LTDC_Layer_InitStruct->LTDC_VerticalStop));
- assert_param(IS_LTDC_DEFAULTCOLOR(LTDC_Layer_InitStruct->LTDC_DefaultColorBlue));
- assert_param(IS_LTDC_DEFAULTCOLOR(LTDC_Layer_InitStruct->LTDC_DefaultColorGreen));
- assert_param(IS_LTDC_DEFAULTCOLOR(LTDC_Layer_InitStruct->LTDC_DefaultColorRed));
- assert_param(IS_LTDC_DEFAULTCOLOR(LTDC_Layer_InitStruct->LTDC_DefaultColorAlpha));
- assert_param(IS_LTDC_CFBP(LTDC_Layer_InitStruct->LTDC_CFBPitch));
- assert_param(IS_LTDC_CFBLL(LTDC_Layer_InitStruct->LTDC_CFBLineLength));
- assert_param(IS_LTDC_CFBLNBR(LTDC_Layer_InitStruct->LTDC_CFBLineNumber));
-
- whsppos = LTDC_Layer_InitStruct->LTDC_HorizontalStop << 16;
- LTDC_Layerx->WHPCR &= ~(LTDC_LxWHPCR_WHSTPOS | LTDC_LxWHPCR_WHSPPOS);
- LTDC_Layerx->WHPCR = (LTDC_Layer_InitStruct->LTDC_HorizontalStart | whsppos);
-
- wvsppos = LTDC_Layer_InitStruct->LTDC_VerticalStop << 16;
- LTDC_Layerx->WVPCR &= ~(LTDC_LxWVPCR_WVSTPOS | LTDC_LxWVPCR_WVSPPOS);
- LTDC_Layerx->WVPCR = (LTDC_Layer_InitStruct->LTDC_VerticalStart | wvsppos);
-
- LTDC_Layerx->PFCR &= ~(LTDC_LxPFCR_PF);
- LTDC_Layerx->PFCR = (LTDC_Layer_InitStruct->LTDC_PixelFormat);
-
- dcgreen = (LTDC_Layer_InitStruct->LTDC_DefaultColorGreen << 8);
- dcred = (LTDC_Layer_InitStruct->LTDC_DefaultColorRed << 16);
- dcalpha = (LTDC_Layer_InitStruct->LTDC_DefaultColorAlpha << 24);
- LTDC_Layerx->DCCR &= ~(LTDC_LxDCCR_DCBLUE | LTDC_LxDCCR_DCGREEN | LTDC_LxDCCR_DCRED | LTDC_LxDCCR_DCALPHA);
- LTDC_Layerx->DCCR = (LTDC_Layer_InitStruct->LTDC_DefaultColorBlue | dcgreen | \
- dcred | dcalpha);
-
- LTDC_Layerx->CACR &= ~(LTDC_LxCACR_CONSTA);
- LTDC_Layerx->CACR = (LTDC_Layer_InitStruct->LTDC_ConstantAlpha);
-
- LTDC_Layerx->BFCR &= ~(LTDC_LxBFCR_BF2 | LTDC_LxBFCR_BF1);
- LTDC_Layerx->BFCR = (LTDC_Layer_InitStruct->LTDC_BlendingFactor_1 | LTDC_Layer_InitStruct->LTDC_BlendingFactor_2);
-
- LTDC_Layerx->CFBAR &= ~(LTDC_LxCFBAR_CFBADD);
- LTDC_Layerx->CFBAR = (LTDC_Layer_InitStruct->LTDC_CFBStartAdress);
-
- cfbp = (LTDC_Layer_InitStruct->LTDC_CFBPitch << 16);
- LTDC_Layerx->CFBLR &= ~(LTDC_LxCFBLR_CFBLL | LTDC_LxCFBLR_CFBP);
- LTDC_Layerx->CFBLR = (LTDC_Layer_InitStruct->LTDC_CFBLineLength | cfbp);
-
- LTDC_Layerx->CFBLNR &= ~(LTDC_LxCFBLNR_CFBLNBR);
- LTDC_Layerx->CFBLNR = (LTDC_Layer_InitStruct->LTDC_CFBLineNumber);
- }
- void LTDC_LayerStructInit(LTDC_Layer_InitTypeDef * LTDC_Layer_InitStruct)
- {
-
-
- LTDC_Layer_InitStruct->LTDC_HorizontalStart = 0x00;
- LTDC_Layer_InitStruct->LTDC_HorizontalStop = 0x00;
-
- LTDC_Layer_InitStruct->LTDC_VerticalStart = 0x00;
- LTDC_Layer_InitStruct->LTDC_VerticalStop = 0x00;
-
- LTDC_Layer_InitStruct->LTDC_PixelFormat = LTDC_Pixelformat_ARGB8888;
-
- LTDC_Layer_InitStruct->LTDC_ConstantAlpha = 0xFF;
-
- LTDC_Layer_InitStruct->LTDC_DefaultColorBlue = 0x00;
- LTDC_Layer_InitStruct->LTDC_DefaultColorGreen = 0x00;
- LTDC_Layer_InitStruct->LTDC_DefaultColorRed = 0x00;
- LTDC_Layer_InitStruct->LTDC_DefaultColorAlpha = 0x00;
-
- LTDC_Layer_InitStruct->LTDC_BlendingFactor_1 = LTDC_BlendingFactor1_PAxCA;
- LTDC_Layer_InitStruct->LTDC_BlendingFactor_2 = LTDC_BlendingFactor2_PAxCA;
-
- LTDC_Layer_InitStruct->LTDC_CFBStartAdress = 0x00;
-
- LTDC_Layer_InitStruct->LTDC_CFBLineLength = 0x00;
- LTDC_Layer_InitStruct->LTDC_CFBPitch = 0x00;
-
- LTDC_Layer_InitStruct->LTDC_CFBLineNumber = 0x00;
- }
- void LTDC_LayerCmd(LTDC_Layer_TypeDef* LTDC_Layerx, FunctionalState NewState)
- {
-
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
-
- LTDC_Layerx->CR |= (uint32_t)LTDC_LxCR_LEN;
- }
- else
- {
-
- LTDC_Layerx->CR &= ~(uint32_t)LTDC_LxCR_LEN;
- }
- }
- LTDC_PosTypeDef LTDC_GetPosStatus(void)
- {
- LTDC_PosTypeDef LTDC_Pos_InitStruct;
- LTDC->CPSR &= ~(LTDC_CPSR_CYPOS | LTDC_CPSR_CXPOS);
- LTDC_Pos_InitStruct.LTDC_POSX = (uint32_t)(LTDC->CPSR >> 16);
- LTDC_Pos_InitStruct.LTDC_POSY = (uint32_t)(LTDC->CPSR & 0xFFFF);
- return LTDC_Pos_InitStruct;
- }
- void LTDC_PosStructInit(LTDC_PosTypeDef* LTDC_Pos_InitStruct)
- {
- LTDC_Pos_InitStruct->LTDC_POSX = 0x00;
- LTDC_Pos_InitStruct->LTDC_POSY = 0x00;
- }
- FlagStatus LTDC_GetCDStatus(uint32_t LTDC_CD)
- {
- FlagStatus bitstatus;
-
- assert_param(IS_LTDC_GET_CD(LTDC_CD));
- if ((LTDC->CDSR & LTDC_CD) != (uint32_t)RESET)
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- return bitstatus;
- }
- void LTDC_ColorKeyingConfig(LTDC_Layer_TypeDef* LTDC_Layerx, LTDC_ColorKeying_InitTypeDef* LTDC_colorkeying_InitStruct, FunctionalState NewState)
- {
- uint32_t ckgreen = 0;
- uint32_t ckred = 0;
-
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- assert_param(IS_LTDC_CKEYING(LTDC_colorkeying_InitStruct->LTDC_ColorKeyBlue));
- assert_param(IS_LTDC_CKEYING(LTDC_colorkeying_InitStruct->LTDC_ColorKeyGreen));
- assert_param(IS_LTDC_CKEYING(LTDC_colorkeying_InitStruct->LTDC_ColorKeyRed));
-
- if (NewState != DISABLE)
- {
-
- LTDC_Layerx->CR |= (uint32_t)LTDC_LxCR_COLKEN;
-
-
- ckgreen = (LTDC_colorkeying_InitStruct->LTDC_ColorKeyGreen << 8);
- ckred = (LTDC_colorkeying_InitStruct->LTDC_ColorKeyRed << 16);
- LTDC_Layerx->CKCR &= ~(LTDC_LxCKCR_CKBLUE | LTDC_LxCKCR_CKGREEN | LTDC_LxCKCR_CKRED);
- LTDC_Layerx->CKCR |= (LTDC_colorkeying_InitStruct->LTDC_ColorKeyBlue | ckgreen | ckred);
- }
- else
- {
-
- LTDC_Layerx->CR &= ~(uint32_t)LTDC_LxCR_COLKEN;
- }
-
-
- LTDC->SRCR = LTDC_IMReload;
- }
- void LTDC_ColorKeyingStructInit(LTDC_ColorKeying_InitTypeDef* LTDC_colorkeying_InitStruct)
- {
-
- LTDC_colorkeying_InitStruct->LTDC_ColorKeyBlue = 0x00;
- LTDC_colorkeying_InitStruct->LTDC_ColorKeyGreen = 0x00;
- LTDC_colorkeying_InitStruct->LTDC_ColorKeyRed = 0x00;
- }
- void LTDC_CLUTCmd(LTDC_Layer_TypeDef* LTDC_Layerx, FunctionalState NewState)
- {
-
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
-
- LTDC_Layerx->CR |= (uint32_t)LTDC_LxCR_CLUTEN;
- }
- else
- {
-
- LTDC_Layerx->CR &= ~(uint32_t)LTDC_LxCR_CLUTEN;
- }
-
-
- LTDC->SRCR = LTDC_IMReload;
- }
- void LTDC_CLUTInit(LTDC_Layer_TypeDef* LTDC_Layerx, LTDC_CLUT_InitTypeDef* LTDC_CLUT_InitStruct)
- {
- uint32_t green = 0;
- uint32_t red = 0;
- uint32_t clutadd = 0;
-
- assert_param(IS_LTDC_CLUTWR(LTDC_CLUT_InitStruct->LTDC_CLUTAdress));
- assert_param(IS_LTDC_CLUTWR(LTDC_CLUT_InitStruct->LTDC_RedValue));
- assert_param(IS_LTDC_CLUTWR(LTDC_CLUT_InitStruct->LTDC_GreenValue));
- assert_param(IS_LTDC_CLUTWR(LTDC_CLUT_InitStruct->LTDC_BlueValue));
-
-
- green = (LTDC_CLUT_InitStruct->LTDC_GreenValue << 8);
- red = (LTDC_CLUT_InitStruct->LTDC_RedValue << 16);
- clutadd = (LTDC_CLUT_InitStruct->LTDC_CLUTAdress << 24);
- LTDC_Layerx->CLUTWR = (clutadd | LTDC_CLUT_InitStruct->LTDC_BlueValue | \
- green | red);
- }
- void LTDC_CLUTStructInit(LTDC_CLUT_InitTypeDef* LTDC_CLUT_InitStruct)
- {
-
- LTDC_CLUT_InitStruct->LTDC_CLUTAdress = 0x00;
- LTDC_CLUT_InitStruct->LTDC_BlueValue = 0x00;
- LTDC_CLUT_InitStruct->LTDC_GreenValue = 0x00;
- LTDC_CLUT_InitStruct->LTDC_RedValue = 0x00;
- }
- void LTDC_LayerPosition(LTDC_Layer_TypeDef* LTDC_Layerx, uint16_t OffsetX, uint16_t OffsetY)
- {
-
- uint32_t tempreg, temp;
- uint32_t horizontal_start;
- uint32_t horizontal_stop;
- uint32_t vertical_start;
- uint32_t vertical_stop;
-
- LTDC_Layerx->WHPCR &= ~(LTDC_LxWHPCR_WHSTPOS | LTDC_LxWHPCR_WHSPPOS);
- LTDC_Layerx->WVPCR &= ~(LTDC_LxWVPCR_WVSTPOS | LTDC_LxWVPCR_WVSPPOS);
-
-
- tempreg = LTDC->BPCR;
- horizontal_start = (tempreg >> 16) + 1 + OffsetX;
- vertical_start = (tempreg & 0xFFFF) + 1 + OffsetY;
-
-
-
-
- tempreg = LTDC_Layerx->PFCR;
-
- if (tempreg == LTDC_Pixelformat_ARGB8888)
- {
- temp = 4;
- }
- else if (tempreg == LTDC_Pixelformat_RGB888)
- {
- temp = 3;
- }
- else if ((tempreg == LTDC_Pixelformat_ARGB4444) ||
- (tempreg == LTDC_Pixelformat_RGB565) ||
- (tempreg == LTDC_Pixelformat_ARGB1555) ||
- (tempreg == LTDC_Pixelformat_AL88))
- {
- temp = 2;
- }
- else
- {
- temp = 1;
- }
-
- tempreg = LTDC_Layerx->CFBLR;
- horizontal_stop = (((tempreg & 0x1FFF) - 3)/temp) + horizontal_start - 1;
-
- tempreg = LTDC_Layerx->CFBLNR;
- vertical_stop = (tempreg & 0x7FF) + vertical_start - 1;
-
- LTDC_Layerx->WHPCR = horizontal_start | (horizontal_stop << 16);
- LTDC_Layerx->WVPCR = vertical_start | (vertical_stop << 16);
- }
-
- void LTDC_LayerAlpha(LTDC_Layer_TypeDef* LTDC_Layerx, uint8_t ConstantAlpha)
- {
-
- LTDC_Layerx->CACR = ConstantAlpha;
- }
- void LTDC_LayerAddress(LTDC_Layer_TypeDef* LTDC_Layerx, uint32_t Address)
- {
-
- LTDC_Layerx->CFBAR = Address;
- }
-
- void LTDC_LayerSize(LTDC_Layer_TypeDef* LTDC_Layerx, uint32_t Width, uint32_t Height)
- {
- uint8_t temp;
- uint32_t tempreg;
- uint32_t horizontal_start;
- uint32_t horizontal_stop;
- uint32_t vertical_start;
- uint32_t vertical_stop;
-
- tempreg = LTDC_Layerx->PFCR;
-
- if (tempreg == LTDC_Pixelformat_ARGB8888)
- {
- temp = 4;
- }
- else if (tempreg == LTDC_Pixelformat_RGB888)
- {
- temp = 3;
- }
- else if ((tempreg == LTDC_Pixelformat_ARGB4444) || \
- (tempreg == LTDC_Pixelformat_RGB565) || \
- (tempreg == LTDC_Pixelformat_ARGB1555) || \
- (tempreg == LTDC_Pixelformat_AL88))
- {
- temp = 2;
- }
- else
- {
- temp = 1;
- }
-
- tempreg = LTDC_Layerx->WHPCR;
- horizontal_start = (tempreg & 0x1FFF);
- horizontal_stop = Width + horizontal_start - 1;
- tempreg = LTDC_Layerx->WVPCR;
- vertical_start = (tempreg & 0x1FFF);
- vertical_stop = Height + vertical_start - 1;
-
- LTDC_Layerx->WHPCR = horizontal_start | (horizontal_stop << 16);
- LTDC_Layerx->WVPCR = vertical_start | (vertical_stop << 16);
-
- LTDC_Layerx->CFBLR = ((Width * temp) << 16) | ((Width * temp) + 3);
-
- LTDC_Layerx->CFBLNR = Height;
-
- }
- void LTDC_LayerPixelFormat(LTDC_Layer_TypeDef* LTDC_Layerx, uint32_t PixelFormat)
- {
- uint8_t temp;
- uint32_t tempreg;
-
- tempreg = LTDC_Layerx->PFCR;
-
- if (tempreg == LTDC_Pixelformat_ARGB8888)
- {
- temp = 4;
- }
- else if (tempreg == LTDC_Pixelformat_RGB888)
- {
- temp = 3;
- }
- else if ((tempreg == LTDC_Pixelformat_ARGB4444) || \
- (tempreg == LTDC_Pixelformat_RGB565) || \
- (tempreg == LTDC_Pixelformat_ARGB1555) || \
- (tempreg == LTDC_Pixelformat_AL88))
- {
- temp = 2;
- }
- else
- {
- temp = 1;
- }
-
- tempreg = (LTDC_Layerx->CFBLR >> 16);
- tempreg = (tempreg / temp);
-
- if (PixelFormat == LTDC_Pixelformat_ARGB8888)
- {
- temp = 4;
- }
- else if (PixelFormat == LTDC_Pixelformat_RGB888)
- {
- temp = 3;
- }
- else if ((PixelFormat == LTDC_Pixelformat_ARGB4444) || \
- (PixelFormat == LTDC_Pixelformat_RGB565) || \
- (PixelFormat == LTDC_Pixelformat_ARGB1555) || \
- (PixelFormat == LTDC_Pixelformat_AL88))
- {
- temp = 2;
- }
- else
- {
- temp = 1;
- }
-
-
- LTDC_Layerx->CFBLR = ((tempreg * temp) << 16) | ((tempreg * temp) + 3);
-
- LTDC_Layerx->PFCR = PixelFormat;
-
- }
-
- void LTDC_ITConfig(uint32_t LTDC_IT, FunctionalState NewState)
- {
-
- assert_param(IS_LTDC_IT(LTDC_IT));
- assert_param(IS_FUNCTIONAL_STATE(NewState));
- if (NewState != DISABLE)
- {
- LTDC->IER |= LTDC_IT;
- }
- else
- {
- LTDC->IER &= (uint32_t)~LTDC_IT;
- }
- }
- FlagStatus LTDC_GetFlagStatus(uint32_t LTDC_FLAG)
- {
- FlagStatus bitstatus = RESET;
-
- assert_param(IS_LTDC_FLAG(LTDC_FLAG));
- if ((LTDC->ISR & LTDC_FLAG) != (uint32_t)RESET)
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- return bitstatus;
- }
- void LTDC_ClearFlag(uint32_t LTDC_FLAG)
- {
-
- assert_param(IS_LTDC_FLAG(LTDC_FLAG));
-
- LTDC->ICR = (uint32_t)LTDC_FLAG;
- }
- ITStatus LTDC_GetITStatus(uint32_t LTDC_IT)
- {
- ITStatus bitstatus = RESET;
-
- assert_param(IS_LTDC_IT(LTDC_IT));
- if ((LTDC->ISR & LTDC_IT) != (uint32_t)RESET)
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- if (((LTDC->IER & LTDC_IT) != (uint32_t)RESET) && (bitstatus != (uint32_t)RESET))
- {
- bitstatus = SET;
- }
- else
- {
- bitstatus = RESET;
- }
- return bitstatus;
- }
- void LTDC_ClearITPendingBit(uint32_t LTDC_IT)
- {
-
- assert_param(IS_LTDC_IT(LTDC_IT));
-
- LTDC->ICR = (uint32_t)LTDC_IT;
- }
-
-
-
|