📄 main.lst
字号:
446 RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2,ENABLE);
447 TIM2_TimeBaseInitStruct.TIM_Prescaler = 17; // 10us resolution
448 TIM2_TimeBaseInitStruct.TIM_CounterMode=TIM_CounterMode_Up;
449 TIM2_TimeBaseInitStruct.TIM_Period = 250; // 200 ms
450 TIM2_TimeBaseInitStruct.TIM_ClockDivision = TIM_CKD_DIV1;
451 TIM_TimeBaseInit(TIM2,&TIM2_TimeBaseInitStruct);
452 TIM_ClearITPendingBit(TIM2,TIM_IT_CC2);
453 TIM_ITConfig(TIM2, TIM_IT_CC2, ENABLE);
454 TIM_Cmd(TIM2,ENABLE);
455 }
456 /*************************************************************************/
457 void NVICInit(void)
458 {
459 NVIC_InitTypeDef NVIC_InitStructure;
460 NVIC_InitStructure.NVIC_IRQChannel = TIM1_UP_IRQChannel;
461 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 9;
462 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
463 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
464 NVIC_Init(&NVIC_InitStructure);
465 NVIC_InitStructure.NVIC_IRQChannel = TIM2_IRQChannel;
466 NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 8;
467 NVIC_InitStructure.NVIC_IRQChannelSubPriority = 0;
468 NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
469 NVIC_Init(&NVIC_InitStructure);
470 }
471 /*************************************************************************
472 *
473 *
474 *************************************************************************/
475 void I2CInit()
476 {
477 I2C_InitTypeDef I2C_InitStructure;
478 GPIO_InitTypeDef GPIO_InitStructure;
479
480 RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOB, ENABLE);
481 RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C1, ENABLE);
482 /* Configure I2C1 pins: SCL and SDA */
483 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6 | GPIO_Pin_7;
484 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
485 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF_OD;
486 GPIO_Init(GPIOB, &GPIO_InitStructure);
487 I2C_DeInit(I2C1);
488 I2C_InitStructure.I2C_Mode=I2C_Mode_I2C;
489 I2C_InitStructure.I2C_DutyCycle=I2C_DutyCycle_16_9;
490 I2C_InitStructure.I2C_OwnAddress1=0xa0;
491 I2C_InitStructure.I2C_Ack=I2C_Ack_Enable;
492 I2C_InitStructure.I2C_AcknowledgedAddress=I2C_AcknowledgedAddress_7bit;
493 I2C_InitStructure.I2C_ClockSpeed=80000;
494 I2C_Init(I2C1,&I2C_InitStructure);
495 I2C_Cmd(I2C1,ENABLE);
496
497 }
498 /*************************************************************************
499 * Function Name: main
500 * Parameters: none
501 *
502 * Return: none
503 *
504 * Description: main
505 *
506 ************************************************************************/
507 void main(void)
508 {
509 volatile Int16U gSampleFlag=FALSE;
510 #ifdef DEBUG
511 debug();
512 #endif
513 ENTR_CRT_SECTION();
514 // Init clock system
515 Clk_Init();
516 #ifndef EMB_FLASH
517 /* Set the Vector Table base location at 0x20000000 */
518 NVIC_SetVectorTable(NVIC_VectTab_RAM, 0x0);
519 #else /* VECT_TAB_FLASH */
520 /* Set the Vector Table base location at 0x08000000 */
521 NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
522 #endif
523 NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
524 InitGPIO();
525 TimInit();
526 Uart1Init();
527 //I2CInit();
528 InitI2CFALSE();
529 InitTemperature();
530 NVICInit();
531 initLCDM();
532 delay_nop(5000);
533 InitADC1() ;
534 InitYear(Year);
535 ReadFM24C04(&_YT);
536 Init2515(_YT._Rate&3);
537 delay_nop(5000);
538 EXT_CRT_SECTION();
539 LCD.Mode=C_LCM_Mode0,ALAMCREG_History.Unit=5;;
540 while(1)
541 {
542 if(B_unit)
543 {
544 B_unit=FALSE;
545
546
547 if(B_CANMode==0)B_CANMode=ReadCAN(&CANR,B_CANMode,_YT._Address);
548 if(B_CANMode!=0)B_CANMode=RTS(&CANR,&CANT,&ELE[0]);
549
550 if(B_Txd!=0)B_Txd=UsartTXD(pUart1TxFifo,pUart1RxFifo,_YT._ELE);
551 else
552 B_Txd=UsartRXD(pUart1RxFifo,pUart1TxFifo);
553 scankey(&key);
554 keyserver(&key,&LCD,&_YT);
555 }
556 if(B_Disp)
557 {
558
559 B_Disp=FALSE;
560 CHK_RF(&RF,&_YT.Sensor[0]);
561 display(&LCD,&_YT,&History[0]);
562 CHK_BELL(&_YT._AlamcFaultTem,_YT._Channal&0x1);
563 ADC_TEMP(&_YT._A_Tembuf);
564 }
565 if(B_TimerOneSec)
566 {
567 B_TimerOneSec=FALSE, GPIOA->ODR^=0X4;
568 NOTS_Store(&History[0],0,&_YT.Sensor[0]);
569 Fast_TEM_NOTS(_YT._TemFast,_YT._TemTime,&_YT._AlamcFastTem,&_YT.Sensor[0]);
570 AlamcFault(&_YT.Sensor[0],&_YT,&Year[1]);
571 ALAMCREGISTER(&Year[1],&_YT.Sensor[0].ATem,&_YT.ALAMCREG,&_YT._AlamcFaultTem);
572 ReadYear(Year);
573
574 }
575 }
576 }
577 #ifdef DEBUG
578 /*******************************************************************************
579 * Function Name : assert_failed
580 * Description : Reports the name of the source file and the source line number
581 * where the assert_param error has occurred.
582 * Input : - file: pointer to the source file name
583 * - line: assert_param error line source number
584 * Output : None
585 * Return : None
586 *******************************************************************************/
587 void assert_failed(u8* file, u32 line)
588 {
589 /* User can add his own implementation to report the file name and line number,
590 ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
591
592 /* Infinite loop */
593 while (1)
594 {
595 }
596 }
597 #endif
Maximum stack usage in bytes:
Function .cstack
-------- -------
ADC_TEMP 24
Clk_Init 8
EntrCritSection 0
ExtCritSection 0
GetADC1Channel 8
I2CInit 24
InitADC1 32
InitGPIO 8
InitI2CFALSE 8
InitTemperature 0
NVICInit 8
TimInit 24
delay 0
delay_nop 16
main 8
Section sizes:
Function/Label Bytes
-------------- -----
EntrCritSection 28
ExtCritSection 24
B_unit 1
B_Disp 1
B_TimerOneSec 1
B_CANMode 1
B_Txd 1
CriticalSecCntr 4
Year 16
ALAMCREG_History 112
TemRHA 20
RF 20
key 4
LCD 8
History 1208
_YT 372
CANR 16
CANT 16
pUart1RxFifo 4
pUart1TxFifo 4
Uart1RxFifo 108
Uart1TxFifo 108
Uart1LineEvents 4
TEMP_TAB 272
Clk_Init 132
GetADC1Channel 46
InitADC1 136
ADC_TEMP 224
ADC_COUNT 2
TAD 16
delay 18
delay_nop 36
InitGPIO 224
InitTemperature 52
InitI2CFALSE 36
TimInit 158
NVICInit 66
I2CInit 128
main 492
??DataTable11 4
??DataTable14 4
??DataTable17 4
??DataTable19 4
2 047 bytes in section .bss
272 bytes in section .rodata
1 816 bytes in section .text
1 764 bytes of CODE memory (+ 52 bytes shared)
272 bytes of CONST memory
2 047 bytes of DATA memory
Errors: none
Warnings: none
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -