Ignore:
Timestamp:
Dec 5, 2024, 1:46:10 PM (6 weeks ago)
Author:
Zed
Message:

Backlight was turned on for Display.

Location:
ctrl/firmware/Main/CubeMX
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • ctrl/firmware/Main/CubeMX/Core/Inc/main.h

    r45 r48  
    6262#define SPI4_SCK_DISPLAY_Pin GPIO_PIN_12
    6363#define SPI4_SCK_DISPLAY_GPIO_Port GPIOE
     64#define PWM_DISPLAY_LIGHT_Pin GPIO_PIN_13
     65#define PWM_DISPLAY_LIGHT_GPIO_Port GPIOE
    6466#define SPI4_MOSI_DISPLAY_Pin GPIO_PIN_14
    6567#define SPI4_MOSI_DISPLAY_GPIO_Port GPIOE
     68#define RST_DISPLAY_Pin GPIO_PIN_15
     69#define RST_DISPLAY_GPIO_Port GPIOE
    6670
    6771/* USER CODE BEGIN Private defines */
  • ctrl/firmware/Main/CubeMX/Core/Src/gpio.c

    r47 r48  
    5757  __HAL_RCC_GPIOD_CLK_ENABLE();
    5858
     59  /*Configure GPIO pin Output Level */
     60  HAL_GPIO_WritePin(GPIOE, PWM_DISPLAY_LIGHT_Pin|RST_DISPLAY_Pin, GPIO_PIN_RESET);
     61
    5962  /*Configure GPIO pins : PE2 PE3 PE4 PE5
    6063                           PE6 PE7 PE8 PE9
    61                            PE10 PE13 PE15 PE0
    62                            PE1 */
     64                           PE10 PE0 PE1 */
    6365  GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5
    6466                          |GPIO_PIN_6|GPIO_PIN_7|GPIO_PIN_8|GPIO_PIN_9
    65                           |GPIO_PIN_10|GPIO_PIN_13|GPIO_PIN_15|GPIO_PIN_0
    66                           |GPIO_PIN_1;
     67                          |GPIO_PIN_10|GPIO_PIN_0|GPIO_PIN_1;
    6768  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
    6869  GPIO_InitStruct.Pull = GPIO_NOPULL;
     
    9697                           PA4 PA5 PA6 PA7
    9798                           PA8 PA9 PA10 PA11
    98                            PA12 PA13 PA14 PA15 */
     99                           PA12 PA15 */
    99100  GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3
    100101                          |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7
    101102                          |GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11
    102                           |GPIO_PIN_12|GPIO_PIN_13|GPIO_PIN_14|GPIO_PIN_15;
     103                          |GPIO_PIN_12|GPIO_PIN_15;
    103104  GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
    104105  GPIO_InitStruct.Pull = GPIO_NOPULL;
     
    129130  HAL_GPIO_Init(GPIOG, &GPIO_InitStruct);
    130131
     132  /*Configure GPIO pins : PWM_DISPLAY_LIGHT_Pin RST_DISPLAY_Pin */
     133  GPIO_InitStruct.Pin = PWM_DISPLAY_LIGHT_Pin|RST_DISPLAY_Pin;
     134  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
     135  GPIO_InitStruct.Pull = GPIO_NOPULL;
     136  GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
     137  HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
     138
    131139  /*Configure GPIO pins : PD8 PD9 PD10 PD11
    132140                           PD12 PD13 PD14 PD15
  • ctrl/firmware/Main/CubeMX/Core/Src/main.c

    r47 r48  
    2828/* USER CODE BEGIN Includes */
    2929
     30#include <stdio.h>
     31
    3032/* USER CODE END Includes */
    3133
     
    5658/* USER CODE BEGIN PFP */
    5759
     60void SPI_WriteComm(uint8_t);
     61void SPI_WriteData(uint8_t);
     62
     63
    5864/* USER CODE END PFP */
    5965
     
    7177
    7278  /* USER CODE BEGIN 1 */
     79
     80  printf("Program start (%s, %s).\n", __TIME__, __DATE__);
    7381
    7482  /* USER CODE END 1 */
     
    107115  MX_SPI4_Init();
    108116  /* USER CODE BEGIN 2 */
     117
     118  HAL_GPIO_WritePin(PWM_DISPLAY_LIGHT_GPIO_Port, PWM_DISPLAY_LIGHT_Pin, GPIO_PIN_SET);
     119  HAL_GPIO_WritePin(RST_DISPLAY_GPIO_Port, RST_DISPLAY_Pin, GPIO_PIN_SET);
     120
     121  SPI_WriteComm(0x11);
     122  HAL_Delay(120);
     123
     124  SPI_WriteComm(0xFF);
     125  SPI_WriteData(0x77);
     126  SPI_WriteData(0x01);
     127  SPI_WriteData(0x00);
     128  SPI_WriteData(0x00);
     129  SPI_WriteData(0x10);
     130
     131
     132  SPI_WriteComm(0xC0);
     133  SPI_WriteData(0x4F);
     134  SPI_WriteData(0x00);
     135
     136
     137  SPI_WriteComm(0xC1);
     138  SPI_WriteData(0x07);
     139  SPI_WriteData(0x02);
     140
     141
     142  SPI_WriteComm(0xC2);
     143  SPI_WriteData(0x31);
     144  SPI_WriteData(0x05);
     145
     146  SPI_WriteComm(0xC3);
     147  SPI_WriteData(0x80);
     148  SPI_WriteData(0x02);
     149  SPI_WriteData(0x07);
     150
     151  SPI_WriteComm(0xCC);
     152  SPI_WriteData(0x10);
     153
     154  SPI_WriteComm(0xB0);
     155  SPI_WriteData(0x00);
     156  SPI_WriteData(0x0A);
     157  SPI_WriteData(0x11);
     158  SPI_WriteData(0x0C);
     159  SPI_WriteData(0x10);
     160  SPI_WriteData(0x05);
     161  SPI_WriteData(0x00);
     162  SPI_WriteData(0x08);
     163  SPI_WriteData(0x08);
     164  SPI_WriteData(0x1F);
     165  SPI_WriteData(0x07);
     166  SPI_WriteData(0x13);
     167  SPI_WriteData(0x10);
     168  SPI_WriteData(0xA9);
     169  SPI_WriteData(0x30);
     170  SPI_WriteData(0x18);
     171  SPI_WriteComm(0xB1);
     172  SPI_WriteData(0x00);
     173  SPI_WriteData(0x0B);
     174  SPI_WriteData(0x11);
     175  SPI_WriteData(0x0D);
     176  SPI_WriteData(0x0F);
     177  SPI_WriteData(0x05);
     178  SPI_WriteData(0x02);
     179  SPI_WriteData(0x07);
     180  SPI_WriteData(0x06);
     181  SPI_WriteData(0x20);
     182  SPI_WriteData(0x05);
     183  SPI_WriteData(0x15);
     184  SPI_WriteData(0x13);
     185  SPI_WriteData(0xA9);
     186  SPI_WriteData(0x30);
     187  SPI_WriteData(0x18);
     188  SPI_WriteComm(0xFF);
     189  SPI_WriteData(0x77);
     190  SPI_WriteData(0x01);
     191  SPI_WriteData(0x00);
     192  SPI_WriteData(0x00);
     193  SPI_WriteData(0x11);
     194
     195
     196  SPI_WriteComm(0xB0);
     197  SPI_WriteData(0x53);
     198  SPI_WriteComm(0xB1);
     199  SPI_WriteData(0x60);
     200
     201  SPI_WriteComm(0xB2);
     202  SPI_WriteData(0x07);
     203
     204  SPI_WriteComm(0xB3);
     205  SPI_WriteData(0x80);
     206
     207  SPI_WriteComm(0xB5);
     208  SPI_WriteData(0x49);
     209
     210  SPI_WriteComm(0xB7);
     211  SPI_WriteData(0x85);
     212
     213  SPI_WriteComm(0xB8);
     214  SPI_WriteData(0x21);
     215
     216  SPI_WriteComm(0xC1);
     217  SPI_WriteData(0x78);
     218
     219  SPI_WriteComm(0xC2);
     220  SPI_WriteData(0x78);
     221  HAL_Delay(100);
     222
     223  SPI_WriteComm(0xE0);
     224  SPI_WriteData(0x00);
     225  SPI_WriteData(0x00);
     226  SPI_WriteData(0x02);
     227
     228  SPI_WriteComm(0xE1);
     229  SPI_WriteData(0x03);
     230  SPI_WriteData(0xA0);
     231  SPI_WriteData(0x00);
     232  SPI_WriteData(0x00);
     233  SPI_WriteData(0x02);
     234  SPI_WriteData(0xA0);
     235  SPI_WriteData(0x00);
     236  SPI_WriteData(0x00);
     237  SPI_WriteData(0x00);
     238  SPI_WriteData(0x33);
     239  SPI_WriteData(0x33);
     240  SPI_WriteComm(0xE2);
     241  SPI_WriteData(0x22);
     242  SPI_WriteData(0x22);
     243  SPI_WriteData(0x33);
     244  SPI_WriteData(0x33);
     245  SPI_WriteData(0x88);
     246  SPI_WriteData(0xA0);
     247  SPI_WriteData(0x00);
     248  SPI_WriteData(0x00);
     249  SPI_WriteData(0x87);
     250  SPI_WriteData(0xA0);
     251  SPI_WriteData(0x00);
     252  SPI_WriteData(0x00);
     253
     254
     255  SPI_WriteComm(0xE3);
     256  SPI_WriteData(0x00);
     257  SPI_WriteData(0x00);
     258  SPI_WriteData(0x22);
     259  SPI_WriteData(0x22);
     260
     261  SPI_WriteComm(0xE4);
     262  SPI_WriteData(0x44);
     263  SPI_WriteData(0x44);
     264
     265  SPI_WriteComm(0xE5);
     266  SPI_WriteData(0x04);
     267  SPI_WriteData(0x84);
     268  SPI_WriteData(0xA0);
     269  SPI_WriteData(0xA0);
     270  SPI_WriteData(0x06);
     271  SPI_WriteData(0x86);
     272  SPI_WriteData(0xA0);
     273  SPI_WriteData(0xA0);
     274  SPI_WriteData(0x08);
     275  SPI_WriteData(0x88);
     276  SPI_WriteData(0xA0);
     277  SPI_WriteData(0xA0);
     278  SPI_WriteData(0x0A);
     279  SPI_WriteData(0x8A);
     280  SPI_WriteData(0xA0);
     281  SPI_WriteData(0xA0);
     282
     283  SPI_WriteComm(0xE6);
     284  SPI_WriteData(0x00);
     285  SPI_WriteData(0x00);
     286  SPI_WriteData(0x22);
     287  SPI_WriteData(0x22);
     288
     289  SPI_WriteComm(0xE7);
     290  SPI_WriteData(0x44);
     291  SPI_WriteData(0x44);
     292
     293  SPI_WriteComm(0xE8);
     294  SPI_WriteData(0x03);
     295  SPI_WriteData(0x83);
     296  SPI_WriteData(0xA0);
     297  SPI_WriteData(0xA0);
     298  SPI_WriteData(0x05);
     299  SPI_WriteData(0x85);
     300  SPI_WriteData(0xA0);
     301  SPI_WriteData(0xA0);
     302  SPI_WriteData(0x07);
     303  SPI_WriteData(0x87);
     304  SPI_WriteData(0xA0);
     305  SPI_WriteData(0xA0);
     306  SPI_WriteData(0x09);
     307  SPI_WriteData(0x89);
     308  SPI_WriteData(0xA0);
     309  SPI_WriteData(0xA0);
     310
     311  SPI_WriteComm(0xEB);
     312  SPI_WriteData(0x00);
     313  SPI_WriteData(0x01);
     314  SPI_WriteData(0xE4);
     315  SPI_WriteData(0xE4);
     316  SPI_WriteData(0x88);
     317  SPI_WriteData(0x00);
     318  SPI_WriteData(0x40);
     319
     320  SPI_WriteComm(0xEC);
     321  SPI_WriteData(0x3C);
     322  SPI_WriteData(0x01);
     323
     324  SPI_WriteComm(0xED);
     325  SPI_WriteData(0xAB);
     326  SPI_WriteData(0x89);
     327  SPI_WriteData(0x76);
     328  SPI_WriteData(0x54);
     329  SPI_WriteData(0x02);
     330  SPI_WriteData(0xFF);
     331  SPI_WriteData(0xFF);
     332  SPI_WriteData(0xFF);
     333  SPI_WriteData(0xFF);
     334  SPI_WriteData(0xFF);
     335  SPI_WriteData(0xFF);
     336  SPI_WriteData(0x20);
     337  SPI_WriteData(0x45);
     338  SPI_WriteData(0x67);
     339  SPI_WriteData(0x98);
     340  SPI_WriteData(0xBA);
     341
     342
     343  SPI_WriteComm(0x3A);
     344  SPI_WriteData(0x66);
     345
     346  SPI_WriteComm(0x36);
     347  SPI_WriteData(0x00);
     348
     349  HAL_Delay(100);
     350  SPI_WriteComm(0x29);
     351
    109352
    110353  /* USER CODE END 2 */
     
    187430/* USER CODE BEGIN 4 */
    188431
     432void SPI_Transmit(uint8_t cmd_data_toSend, uint8_t isCmd)
     433{
     434        uint16_t data[1];
     435
     436        data[0] = (uint16_t)cmd_data_toSend | ((uint16_t)isCmd << (sizeof(uint16_t) * 8));
     437
     438        HAL_SPI_Transmit(&hspi4, (const uint8_t*)data, 1, 1000);
     439}
     440
     441void SPI_WriteComm(uint8_t cmdToSend)
     442{
     443        SPI_Transmit(cmdToSend, 0);
     444}
     445
     446//------------------------------------------------------------------------------
     447
     448void SPI_WriteData(uint8_t dataToSend)
     449{
     450        SPI_Transmit(dataToSend, 1);
     451}
     452
     453//------------------------------------------------------------------------------
     454
    189455/* USER CODE END 4 */
    190456
  • ctrl/firmware/Main/CubeMX/Core/Src/spi.c

    r47 r48  
    4141  hspi4.Instance = SPI4;
    4242  hspi4.Init.Mode = SPI_MODE_MASTER;
    43   hspi4.Init.Direction = SPI_DIRECTION_1LINE;
     43  hspi4.Init.Direction = SPI_DIRECTION_2LINES_TXONLY;
    4444  hspi4.Init.DataSize = SPI_DATASIZE_9BIT;
    4545  hspi4.Init.CLKPolarity = SPI_POLARITY_LOW;
  • ctrl/firmware/Main/CubeMX/charger.ioc

    r47 r48  
    2828Dma.SPI4_TX.0.SyncSignalID=NONE
    2929File.Version=6
    30 GPIO.groupedBy=
     30GPIO.groupedBy=Group By Peripherals
    3131KeepUserPlacement=false
    3232MMTAppRegionsCount=0
     
    3535Mcu.Family=STM32H7
    3636Mcu.IP0=CORTEX_M7
    37 Mcu.IP1=DMA
    38 Mcu.IP2=MEMORYMAP
    39 Mcu.IP3=NVIC
    40 Mcu.IP4=RCC
    41 Mcu.IP5=RTC
    42 Mcu.IP6=SPI4
    43 Mcu.IP7=SYS
    44 Mcu.IPNb=8
     37Mcu.IP1=DEBUG
     38Mcu.IP2=DMA
     39Mcu.IP3=MEMORYMAP
     40Mcu.IP4=NVIC
     41Mcu.IP5=RCC
     42Mcu.IP6=RTC
     43Mcu.IP7=SPI4
     44Mcu.IP8=SYS
     45Mcu.IPNb=9
    4546Mcu.Name=STM32H723ZETx
    4647Mcu.Package=LQFP144
    4748Mcu.Pin0=PC14-OSC32_IN
    4849Mcu.Pin1=PC15-OSC32_OUT
     50Mcu.Pin10=PA14(JTCK/SWCLK)
     51Mcu.Pin11=VP_RTC_VS_RTC_Activate
     52Mcu.Pin12=VP_SYS_VS_Systick
     53Mcu.Pin13=VP_MEMORYMAP_VS_MEMORYMAP
    4954Mcu.Pin2=PH0-OSC_IN
    5055Mcu.Pin3=PH1-OSC_OUT
    5156Mcu.Pin4=PE11
    5257Mcu.Pin5=PE12
    53 Mcu.Pin6=PE14
    54 Mcu.Pin7=VP_RTC_VS_RTC_Activate
    55 Mcu.Pin8=VP_SYS_VS_Systick
    56 Mcu.Pin9=VP_MEMORYMAP_VS_MEMORYMAP
    57 Mcu.PinsNb=10
     58Mcu.Pin6=PE13
     59Mcu.Pin7=PE14
     60Mcu.Pin8=PE15
     61Mcu.Pin9=PA13(JTMS/SWDIO)
     62Mcu.PinsNb=14
    5863Mcu.ThirdPartyNb=0
    5964Mcu.UserConstants=
     
    7479NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false
    7580NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false
     81PA13(JTMS/SWDIO).Mode=Serial_Wire
     82PA13(JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO
     83PA14(JTCK/SWCLK).Mode=Serial_Wire
     84PA14(JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK
    7685PC14-OSC32_IN.Mode=LSE-External-Oscillator
    7786PC14-OSC32_IN.Signal=RCC_OSC32_IN
     
    8695PE12.GPIO_Label=SPI4_SCK_DISPLAY
    8796PE12.Locked=true
    88 PE12.Mode=Simplex_Bidirectional_Master
     97PE12.Mode=TX_Only_Simplex_Unidirect_Master
    8998PE12.Signal=SPI4_SCK
     99PE13.GPIOParameters=GPIO_Label
     100PE13.GPIO_Label=PWM_DISPLAY_LIGHT
     101PE13.Locked=true
     102PE13.Signal=GPIO_Output
    90103PE14.GPIOParameters=GPIO_Label
    91104PE14.GPIO_Label=SPI4_MOSI_DISPLAY
    92105PE14.Locked=true
    93 PE14.Mode=Simplex_Bidirectional_Master
     106PE14.Mode=TX_Only_Simplex_Unidirect_Master
    94107PE14.Signal=SPI4_MOSI
     108PE15.GPIOParameters=PinState,GPIO_Label
     109PE15.GPIO_Label=RST_DISPLAY
     110PE15.Locked=true
     111PE15.PinState=GPIO_PIN_RESET
     112PE15.Signal=GPIO_Output
    95113PH0-OSC_IN.Mode=HSE-External-Oscillator
    96114PH0-OSC_IN.Signal=RCC_OSC_IN
     
    196214RCC.Tim1OutputFreq_Value=100000000
    197215RCC.Tim2OutputFreq_Value=100000000
    198 RCC.TraceFreq_Value=64000000
     216RCC.TraceFreq_Value=100000000
    199217RCC.USART16Freq_Value=100000000
    200218RCC.USART234578Freq_Value=100000000
     
    209227SPI4.CalculateBaudRate=15.151515 MBits/s
    210228SPI4.DataSize=SPI_DATASIZE_9BIT
    211 SPI4.Direction=SPI_DIRECTION_1LINE
     229SPI4.Direction=SPI_DIRECTION_2LINES_TXONLY
    212230SPI4.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,VirtualNSS,DataSize,BaudRatePrescaler
    213231SPI4.Mode=SPI_MODE_MASTER
Note: See TracChangeset for help on using the changeset viewer.