Changeset 48 for ctrl/firmware/Main/CubeMX
- Timestamp:
- Dec 5, 2024, 1:46:10 PM (6 weeks ago)
- Location:
- ctrl/firmware/Main/CubeMX
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
ctrl/firmware/Main/CubeMX/Core/Inc/main.h
r45 r48 62 62 #define SPI4_SCK_DISPLAY_Pin GPIO_PIN_12 63 63 #define SPI4_SCK_DISPLAY_GPIO_Port GPIOE 64 #define PWM_DISPLAY_LIGHT_Pin GPIO_PIN_13 65 #define PWM_DISPLAY_LIGHT_GPIO_Port GPIOE 64 66 #define SPI4_MOSI_DISPLAY_Pin GPIO_PIN_14 65 67 #define SPI4_MOSI_DISPLAY_GPIO_Port GPIOE 68 #define RST_DISPLAY_Pin GPIO_PIN_15 69 #define RST_DISPLAY_GPIO_Port GPIOE 66 70 67 71 /* USER CODE BEGIN Private defines */ -
ctrl/firmware/Main/CubeMX/Core/Src/gpio.c
r47 r48 57 57 __HAL_RCC_GPIOD_CLK_ENABLE(); 58 58 59 /*Configure GPIO pin Output Level */ 60 HAL_GPIO_WritePin(GPIOE, PWM_DISPLAY_LIGHT_Pin|RST_DISPLAY_Pin, GPIO_PIN_RESET); 61 59 62 /*Configure GPIO pins : PE2 PE3 PE4 PE5 60 63 PE6 PE7 PE8 PE9 61 PE10 PE13 PE15 PE0 62 PE1 */ 64 PE10 PE0 PE1 */ 63 65 GPIO_InitStruct.Pin = GPIO_PIN_2|GPIO_PIN_3|GPIO_PIN_4|GPIO_PIN_5 64 66 |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; 67 68 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; 68 69 GPIO_InitStruct.Pull = GPIO_NOPULL; … … 96 97 PA4 PA5 PA6 PA7 97 98 PA8 PA9 PA10 PA11 98 PA12 PA1 3 PA14 PA15 */99 PA12 PA15 */ 99 100 GPIO_InitStruct.Pin = GPIO_PIN_0|GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3 100 101 |GPIO_PIN_4|GPIO_PIN_5|GPIO_PIN_6|GPIO_PIN_7 101 102 |GPIO_PIN_8|GPIO_PIN_9|GPIO_PIN_10|GPIO_PIN_11 102 |GPIO_PIN_12|GPIO_PIN_1 3|GPIO_PIN_14|GPIO_PIN_15;103 |GPIO_PIN_12|GPIO_PIN_15; 103 104 GPIO_InitStruct.Mode = GPIO_MODE_ANALOG; 104 105 GPIO_InitStruct.Pull = GPIO_NOPULL; … … 129 130 HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); 130 131 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 131 139 /*Configure GPIO pins : PD8 PD9 PD10 PD11 132 140 PD12 PD13 PD14 PD15 -
ctrl/firmware/Main/CubeMX/Core/Src/main.c
r47 r48 28 28 /* USER CODE BEGIN Includes */ 29 29 30 #include <stdio.h> 31 30 32 /* USER CODE END Includes */ 31 33 … … 56 58 /* USER CODE BEGIN PFP */ 57 59 60 void SPI_WriteComm(uint8_t); 61 void SPI_WriteData(uint8_t); 62 63 58 64 /* USER CODE END PFP */ 59 65 … … 71 77 72 78 /* USER CODE BEGIN 1 */ 79 80 printf("Program start (%s, %s).\n", __TIME__, __DATE__); 73 81 74 82 /* USER CODE END 1 */ … … 107 115 MX_SPI4_Init(); 108 116 /* 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 109 352 110 353 /* USER CODE END 2 */ … … 187 430 /* USER CODE BEGIN 4 */ 188 431 432 void 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 441 void SPI_WriteComm(uint8_t cmdToSend) 442 { 443 SPI_Transmit(cmdToSend, 0); 444 } 445 446 //------------------------------------------------------------------------------ 447 448 void SPI_WriteData(uint8_t dataToSend) 449 { 450 SPI_Transmit(dataToSend, 1); 451 } 452 453 //------------------------------------------------------------------------------ 454 189 455 /* USER CODE END 4 */ 190 456 -
ctrl/firmware/Main/CubeMX/Core/Src/spi.c
r47 r48 41 41 hspi4.Instance = SPI4; 42 42 hspi4.Init.Mode = SPI_MODE_MASTER; 43 hspi4.Init.Direction = SPI_DIRECTION_ 1LINE;43 hspi4.Init.Direction = SPI_DIRECTION_2LINES_TXONLY; 44 44 hspi4.Init.DataSize = SPI_DATASIZE_9BIT; 45 45 hspi4.Init.CLKPolarity = SPI_POLARITY_LOW; -
ctrl/firmware/Main/CubeMX/charger.ioc
r47 r48 28 28 Dma.SPI4_TX.0.SyncSignalID=NONE 29 29 File.Version=6 30 GPIO.groupedBy= 30 GPIO.groupedBy=Group By Peripherals 31 31 KeepUserPlacement=false 32 32 MMTAppRegionsCount=0 … … 35 35 Mcu.Family=STM32H7 36 36 Mcu.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 37 Mcu.IP1=DEBUG 38 Mcu.IP2=DMA 39 Mcu.IP3=MEMORYMAP 40 Mcu.IP4=NVIC 41 Mcu.IP5=RCC 42 Mcu.IP6=RTC 43 Mcu.IP7=SPI4 44 Mcu.IP8=SYS 45 Mcu.IPNb=9 45 46 Mcu.Name=STM32H723ZETx 46 47 Mcu.Package=LQFP144 47 48 Mcu.Pin0=PC14-OSC32_IN 48 49 Mcu.Pin1=PC15-OSC32_OUT 50 Mcu.Pin10=PA14(JTCK/SWCLK) 51 Mcu.Pin11=VP_RTC_VS_RTC_Activate 52 Mcu.Pin12=VP_SYS_VS_Systick 53 Mcu.Pin13=VP_MEMORYMAP_VS_MEMORYMAP 49 54 Mcu.Pin2=PH0-OSC_IN 50 55 Mcu.Pin3=PH1-OSC_OUT 51 56 Mcu.Pin4=PE11 52 57 Mcu.Pin5=PE12 53 Mcu.Pin6=PE1 454 Mcu.Pin7= VP_RTC_VS_RTC_Activate55 Mcu.Pin8= VP_SYS_VS_Systick56 Mcu.Pin9= VP_MEMORYMAP_VS_MEMORYMAP57 Mcu.PinsNb=1 058 Mcu.Pin6=PE13 59 Mcu.Pin7=PE14 60 Mcu.Pin8=PE15 61 Mcu.Pin9=PA13(JTMS/SWDIO) 62 Mcu.PinsNb=14 58 63 Mcu.ThirdPartyNb=0 59 64 Mcu.UserConstants= … … 74 79 NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false 75 80 NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false 81 PA13(JTMS/SWDIO).Mode=Serial_Wire 82 PA13(JTMS/SWDIO).Signal=DEBUG_JTMS-SWDIO 83 PA14(JTCK/SWCLK).Mode=Serial_Wire 84 PA14(JTCK/SWCLK).Signal=DEBUG_JTCK-SWCLK 76 85 PC14-OSC32_IN.Mode=LSE-External-Oscillator 77 86 PC14-OSC32_IN.Signal=RCC_OSC32_IN … … 86 95 PE12.GPIO_Label=SPI4_SCK_DISPLAY 87 96 PE12.Locked=true 88 PE12.Mode= Simplex_Bidirectional_Master97 PE12.Mode=TX_Only_Simplex_Unidirect_Master 89 98 PE12.Signal=SPI4_SCK 99 PE13.GPIOParameters=GPIO_Label 100 PE13.GPIO_Label=PWM_DISPLAY_LIGHT 101 PE13.Locked=true 102 PE13.Signal=GPIO_Output 90 103 PE14.GPIOParameters=GPIO_Label 91 104 PE14.GPIO_Label=SPI4_MOSI_DISPLAY 92 105 PE14.Locked=true 93 PE14.Mode= Simplex_Bidirectional_Master106 PE14.Mode=TX_Only_Simplex_Unidirect_Master 94 107 PE14.Signal=SPI4_MOSI 108 PE15.GPIOParameters=PinState,GPIO_Label 109 PE15.GPIO_Label=RST_DISPLAY 110 PE15.Locked=true 111 PE15.PinState=GPIO_PIN_RESET 112 PE15.Signal=GPIO_Output 95 113 PH0-OSC_IN.Mode=HSE-External-Oscillator 96 114 PH0-OSC_IN.Signal=RCC_OSC_IN … … 196 214 RCC.Tim1OutputFreq_Value=100000000 197 215 RCC.Tim2OutputFreq_Value=100000000 198 RCC.TraceFreq_Value= 64000000216 RCC.TraceFreq_Value=100000000 199 217 RCC.USART16Freq_Value=100000000 200 218 RCC.USART234578Freq_Value=100000000 … … 209 227 SPI4.CalculateBaudRate=15.151515 MBits/s 210 228 SPI4.DataSize=SPI_DATASIZE_9BIT 211 SPI4.Direction=SPI_DIRECTION_ 1LINE229 SPI4.Direction=SPI_DIRECTION_2LINES_TXONLY 212 230 SPI4.IPParameters=VirtualType,Mode,Direction,CalculateBaudRate,VirtualNSS,DataSize,BaudRatePrescaler 213 231 SPI4.Mode=SPI_MODE_MASTER
Note: See TracChangeset
for help on using the changeset viewer.