@@ -120,11 +120,6 @@ void checkResetSourse(void)
120120 __HAL_RCC_CLEAR_RESET_FLAGS ();
121121}
122122
123- bool CC1101_reinit (void )
124- {
125- return TI_init (& hspi2 , NSS_CS_GPIO_Port , NSS_CS_Pin ); // CS
126- }
127-
128123static void stm32_cacheEnable (void )
129124{
130125#if (INSTRUCTION_CACHE_ENABLE != 0U ) /* Enable caching instructions */
@@ -181,24 +176,11 @@ int main(void)
181176 MX_TIM2_Init ();
182177 /* USER CODE BEGIN 2 */
183178
184- /* Setting up the display */
185- LCD_SPI_Connected_data spi_con =
186- {
187- .spi = SPI1 ,
188- .dma_tx = dma_tx_1 , // data DMA
189- .reset_port = LCD_RESET_GPIO_Port ,
190- .reset_pin = LCD_RESET_Pin ,
191- .dc_port = LCD_DC_GPIO_Port ,
192- .dc_pin = LCD_DC_Pin ,
193- .cs_port = LCD_CS_GPIO_Port ,
194- .cs_pin = LCD_CS_Pin
195- };
196-
197179#ifndef LCD_DYNAMIC_MEM
198180 LCD_Handler lcd1 ;
199181#endif
200- // Creating a display handler ILI9341
201- LCD = LCD_DisplayAdd (LCD ,
182+
183+ LCD = LCD_DisplayAdd (LCD ,
202184#ifndef LCD_DYNAMIC_MEM
203185 & lcd1 ,
204186#endif
@@ -214,64 +196,65 @@ int main(void)
214196 ILI9341_SetWindow ,
215197 ILI9341_SleepIn ,
216198 ILI9341_SleepOut ,
217- & spi_con ,
199+ displayInit_getSpiPortSettings () ,
218200 LCD_DATA_16BIT_BUS ,
219201 bkl_data );
220202
221203 lcd = LCD ; //Pointer to the first display in the list
222204 LCD_Init (lcd );
223205 LCD_Fill (lcd , COLOR_RED );
224206
225-
226207 XPT2046_InitTouch (& touch1 , 20 , & cnt_touch ); //initializing the handler XPT2046
227208
228209#if !CALIBRATE_EN
229- tCoef coef = {.D = 0x00022b4253626d37 ,
230- .Dx1 = 0xffffd9e9e85d81b6 ,
231- .Dx2 = 0x0000005a555c98ab ,
232- .Dx3 = 0x022dd7f0419e66b7 ,
233- .Dy1 = 0xffffff6065e10c98 ,
234- .Dy2 = 0x0000343b820dc8bf ,
235- .Dy3 = 0xff9cc25725238e55 };
236- touch1 .coef = coef ;
210+ touch1 .coef = * displayInit_getCalibrationCoefficient ();
237211#else
238- calibrateTouchEnable ();
212+ calibrateTouchEnable ();
239213#endif
240214
241- #if RUN_DEMO
215+ #if RUN_LCD_DEMO
242216 LCD_Fill (lcd , COLOR_WHITE );
243217 Draw_TouchPenDemo (& touch1 , lcd );
244218 RoadCircleDemo (& touch1 , lcd );
245219#endif
246-
247220 LCD_Fill (lcd , COLOR_BLACK );
248-
249- // test C++
250- debugPrintf ("C++ test: %s" CLI_NEW_LINE , test_cpp_function () ? "true" : "false" );
251-
252221 /* USER CODE END 2 */
253222
254223 /* Infinite loop */
255224 /* USER CODE BEGIN WHILE */
256225
226+ #if CLI_ENABLE
227+ cli_init ();
228+ #endif // CLI_ENABLE
229+
230+ debugPrintf ("C++ test: %s" CLI_NEW_LINE , test_cpp_function () ? "true" : "false" );
231+
257232 buzzer_init (BUZZER_GPIO_Port , BUZZER_Pin );
258- buzzer_enable ();
259- LL_mDelay (9 );
260- buzzer_disable ();
233+ buzzer_soundOn (BUZZ_SOUND_TEST );
261234 debugPrintf ("Buzzer test..." CLI_NEW_LINE );
262235
263236 adc_enable ();
264237
265238 debugPrintf ("CC1101 init..." CLI_NEW_LINE );
266-
267239 LCD_WriteString (lcd , 5 , 25 , "CC1101 int..." ,
268240 & Font_8x13 , COLOR_WHITE , COLOR_BLACK , LCD_SYMBOL_PRINT_FAST );
269241
270- CC1101_customSetCSpin (& hspi2 , NSS_CS_GPIO_Port , NSS_CS_Pin );
242+ #if CC1101_CUSTOM_OLD_CONFIG
243+ CC1101_setCarrierFreq (CFREQ_433 );
244+ CC1101_setDevAddress (1 );
245+ #endif
246+
271247
272- bool error_state = CC1101_power_up_reset ();
248+ bool error_state = CC1101_init (& hspi2 ,
249+ NSS_CS_GPIO_Port , NSS_CS_Pin , // CS pin
250+ GPIOB , LL_GPIO_PIN_14 , // MISO pin
251+ GPIOB , LL_GPIO_PIN_12 ); // GDO pin
273252
274- if (error_state )
253+ if (!error_state )
254+ {
255+ debugPrintf (CLI_OK "CC1101 init pass" CLI_NEW_LINE );
256+ }
257+ else
275258 {
276259 LCD_WriteString (lcd , 5 , 55 , "CC1101 not found!" ,
277260 & Font_8x13 , COLOR_WHITE , COLOR_RED , LCD_SYMBOL_PRINT_FAST );
@@ -281,20 +264,13 @@ calibrateTouchEnable();
281264 }
282265 }
283266
284- #if CUSTOM_OLD_CONFIG
285- TI_setCarrierFreq (CFREQ_433 );
286- TI_setDevAddress (1 );
287- #endif
288- error_state = CC1101_reinit ();
289- if (!error_state ) debugPrintf (CLI_OK "CC1101 init pass" CLI_NEW_LINE );
290-
291267 encoder_init ();
292268
293269 /* USER CODE END WHILE */
294270
295271 /* USER CODE BEGIN 3 */
296272
297- scheduler ();
273+ scheduler_run ();
298274
299275 /* USER CODE END 3 */
300276}
0 commit comments