ソースを参照

Table 구조체 Enum 추가 / EEPROM Write Read 기능 추가 수정필요 / ADC Data 평균 취하는 기능 추가

PYJ 5 年 前
コミット
c1d7e82f1c

File diff suppressed because it is too large
+ 2 - 2
.mxproject


+ 259 - 55
Bluecell_Inc/Bluecell_operate.h

@@ -330,7 +330,10 @@ enum DATATYPE
330 330
     AGC2_EN = 0x62,
331 331
     AGC3_EN = 0x63,
332 332
     AGC4_EN = 0x64,
333
+    ATT_TableSet = 0x70,
334
+    ATT_TableGet = 0x71,
333 335
 	Bluecell_StatusReq = 0x77,
336
+	Bluecell_StatusSave = 0x78,
334 337
 };
335 338
 
336 339
 
@@ -435,54 +438,54 @@ typedef struct{
435 438
 typedef struct{
436 439
     uint8_t bluecell_header;
437 440
     uint8_t bluecell_type;
438
-    uint8_t bluecell_length;    
439
-    uint8_t bluecell_crcindex;        
441
+    uint8_t bluecell_length;
442
+    uint8_t bluecell_crcindex;
440 443
     uint8_t Selftest0;
441 444
     uint8_t Selftest1;
442 445
     uint8_t Selftest2;
443
-    uint8_t Selftest3;    
444
-    uint8_t ATT_DL1_PATH;    
445
-    uint8_t ATT_DL2_PATH;    
446
-    uint8_t ATT_DL3_PATH;    
447
-    uint8_t ATT_DL4_PATH;        
448
-    uint8_t ATT_UL1_PATH;        
449
-    uint8_t ATT_UL2_PATH;        
450
-    uint8_t ATT_UL3_PATH;        
446
+    uint8_t Selftest3;
447
+    uint8_t ATT_DL1_PATH;
448
+    uint8_t ATT_DL2_PATH;
449
+    uint8_t ATT_DL3_PATH;
450
+    uint8_t ATT_DL4_PATH;
451
+    uint8_t ATT_UL1_PATH;
452
+    uint8_t ATT_UL2_PATH;
453
+    uint8_t ATT_UL3_PATH;
451 454
     uint8_t ATT_UL4_PATH;
452
-    uint8_t ATT_DL1_H;    
453
-    uint8_t ATT_DL1_L;        
454
-    uint8_t ATT_DL2_H;    
455
-    uint8_t ATT_DL2_L;        
456
-    uint8_t ATT_DL3_H;    
457
-    uint8_t ATT_DL3_L;        
458
-    uint8_t ATT_DL4_H;    
459
-    uint8_t ATT_DL4_L;        
460
-    uint8_t ATT_UL1_H;    
461
-    uint8_t ATT_UL1_L;        
462
-    uint8_t ATT_UL2_H;    
463
-    uint8_t ATT_UL2_L;        
464
-    uint8_t ATT_UL3_H;    
465
-    uint8_t ATT_UL3_L;        
455
+    uint8_t ATT_DL1_H;
456
+    uint8_t ATT_DL1_L;
457
+    uint8_t ATT_DL2_H;
458
+    uint8_t ATT_DL2_L;
459
+    uint8_t ATT_DL3_H;
460
+    uint8_t ATT_DL3_L;
461
+    uint8_t ATT_DL4_H;
462
+    uint8_t ATT_DL4_L;
463
+    uint8_t ATT_UL1_H;
464
+    uint8_t ATT_UL1_L;
465
+    uint8_t ATT_UL2_H;
466
+    uint8_t ATT_UL2_L;
467
+    uint8_t ATT_UL3_H;
468
+    uint8_t ATT_UL3_L;
466 469
     uint8_t ATT_UL4_H;
467 470
     uint8_t ATT_UL4_L;
468
-    uint8_t DET_DL1_IN_H;
469
-    uint8_t DET_DL1_IN_L;    
470
-    uint8_t DET_DL2_IN_H;
471
-    uint8_t DET_DL2_IN_L;    
472
-    uint8_t DET_DL3_IN_H;
473
-    uint8_t DET_DL3_IN_L;    
474
-    uint8_t DET_DL4_IN_H;
475
-    uint8_t DET_DL4_IN_L;    
476
-    uint8_t DET_UL1_IN_H;
477
-    uint8_t DET_UL1_IN_L;    
478
-    uint8_t DET_UL2_IN_H;
479
-    uint8_t DET_UL2_IN_L;    
480
-    uint8_t DET_UL3_IN_H;
481
-    uint8_t DET_UL3_IN_L;    
482
-    uint8_t DET_UL4_IN_H;
483
-    uint8_t DET_UL4_IN_L;        
484
-    uint8_t DET_TEMP_H;            
485
-    uint8_t DET_TEMP_L;                
471
+    uint8_t DET_DL1_IN_H;//ADC3   5
472
+    uint8_t DET_DL1_IN_L;//ADC3   5
473
+    uint8_t DET_DL2_IN_H;//ADC3   6 
474
+    uint8_t DET_DL2_IN_L;//ADC3   6
475
+    uint8_t DET_DL3_IN_H;//ADC3   7
476
+    uint8_t DET_DL3_IN_L;//ADC3   7
477
+    uint8_t DET_DL4_IN_H;//ADC3   8   
478
+    uint8_t DET_DL4_IN_L;//ADC3   8
479
+    uint8_t DET_UL1_IN_H;//ADC1   4  
480
+    uint8_t DET_UL1_IN_L;//ADC1   4 
481
+    uint8_t DET_UL2_IN_H;//ADC1   5 
482
+    uint8_t DET_UL2_IN_L;//ADC1   5
483
+    uint8_t DET_UL3_IN_H;//ADC1   6
484
+    uint8_t DET_UL3_IN_L;//ADC1   6
485
+    uint8_t DET_UL4_IN_H;//ADC3   4
486
+    uint8_t DET_UL4_IN_L;//ADC3   4
487
+    uint8_t DET_TEMP_H;
488
+    uint8_t DET_TEMP_L;
486 489
     uint8_t ATT_AGC1_ONOFF;
487 490
     uint8_t ATT_ALC1_ONOFF;
488 491
     uint8_t ATT_AGC2_ONOFF;
@@ -491,24 +494,188 @@ typedef struct{
491 494
     uint8_t ATT_ALC3_ONOFF;
492 495
     uint8_t ATT_AGC4_ONOFF;
493 496
     uint8_t ATT_ALC4_ONOFF;
494
-    uint8_t ATT_AGC1_H;
495
-    uint8_t ATT_AGC1_L;    
496 497
     uint8_t ATT_ALC1_H;
497
-    uint8_t ATT_ALC1_L;    
498
-    uint8_t ATT_AGC2_H;
499
-    uint8_t ATT_AGC2_L;    
498
+    uint8_t ATT_ALC1_L;
500 499
     uint8_t ATT_ALC2_H;
501
-    uint8_t ATT_ALC2_L;    
502
-    uint8_t ATT_AGC3_H;
503
-    uint8_t ATT_AGC3_L;    
500
+    uint8_t ATT_ALC2_L;
504 501
     uint8_t ATT_ALC3_H;
505
-    uint8_t ATT_ALC3_L;    
506
-    uint8_t ATT_AGC4_H;
507
-    uint8_t ATT_AGC4_L;    
502
+    uint8_t ATT_ALC3_L;
508 503
     uint8_t ATT_ALC4_H;
509
-    uint8_t ATT_ALC4_L;    
510
-    uint8_t bluecell_crc;        
504
+    uint8_t ATT_ALC4_L;
505
+    uint8_t ATT_AGC1_H;
506
+    uint8_t ATT_AGC1_L;
507
+    uint8_t ATT_AGC2_H;
508
+    uint8_t ATT_AGC2_L;
509
+    uint8_t ATT_AGC3_H;
510
+    uint8_t ATT_AGC3_L;
511
+    uint8_t ATT_AGC4_H;
512
+    uint8_t ATT_AGC4_L;
513
+    uint8_t bluecell_crc;
514
+    uint8_t bluecell_etx;
515
+
511 516
 }BLUESTATUS_st;
517
+typedef struct{
518
+  uint16_t Table_0_0_dBm	;
519
+  uint16_t Table_0_5_dBm	;
520
+  uint16_t Table_1_0_dBm	;
521
+  uint16_t Table_1_5_dBm	;
522
+  uint16_t Table_2_0_dBm	;
523
+  uint16_t Table_2_5_dBm	;
524
+  uint16_t Table_3_0_dBm	;
525
+  uint16_t Table_3_5_dBm	;
526
+  uint16_t Table_4_0_dBm	;
527
+  uint16_t Table_4_5_dBm	;
528
+  uint16_t Table_5_0_dBm	;
529
+  uint16_t Table_5_5_dBm	;
530
+  uint16_t Table_6_0_dBm	;
531
+  uint16_t Table_6_5_dBm	;
532
+  uint16_t Table_7_0_dBm	;
533
+  uint16_t Table_7_5_dBm	;
534
+  uint16_t Table_8_0_dBm	;
535
+  uint16_t Table_8_5_dBm	;
536
+  uint16_t Table_9_0_dBm	;
537
+  uint16_t Table_9_5_dBm	;
538
+  uint16_t Table_10_0_dBm;
539
+  uint16_t Table_10_5_dBm;
540
+  uint16_t Table_11_0_dBm;
541
+  uint16_t Table_11_5_dBm;
542
+  uint16_t Table_12_0_dBm;
543
+  uint16_t Table_12_5_dBm;
544
+  uint16_t Table_13_0_dBm;
545
+  uint16_t Table_13_5_dBm;
546
+  uint16_t Table_14_0_dBm;
547
+  uint16_t Table_14_5_dBm;
548
+  uint16_t Table_15_0_dBm;
549
+  uint16_t Table_15_5_dBm;
550
+  uint16_t Table_16_0_dBm;
551
+  uint16_t Table_16_5_dBm;
552
+  uint16_t Table_17_0_dBm;
553
+  uint16_t Table_17_5_dBm;
554
+  uint16_t Table_18_0_dBm;
555
+  uint16_t Table_18_5_dBm;
556
+  uint16_t Table_19_0_dBm;
557
+  uint16_t Table_19_5_dBm;
558
+  uint16_t Table_20_0_dBm;
559
+  uint16_t Table_20_5_dBm;
560
+  uint16_t Table_21_0_dBm;
561
+  uint16_t Table_21_5_dBm;
562
+  uint16_t Table_22_0_dBm;
563
+  uint16_t Table_22_5_dBm;
564
+  uint16_t Table_23_0_dBm;
565
+  uint16_t Table_23_5_dBm;
566
+  uint16_t Table_24_0_dBm;
567
+  uint16_t Table_24_5_dBm;
568
+  uint16_t Table_25_0_dBm;
569
+  uint16_t Table_25_5_dBm;
570
+  uint16_t Table_26_0_dBm;
571
+  uint16_t Table_26_5_dBm;
572
+  uint16_t Table_27_0_dBm;
573
+  uint16_t Table_27_5_dBm;
574
+  uint16_t Table_28_0_dBm;
575
+  uint16_t Table_28_5_dBm;
576
+  uint16_t Table_29_0_dBm;
577
+  uint16_t Table_29_5_dBm;
578
+  uint16_t Table_30_0_dBm;
579
+  uint16_t Table_30_5_dBm;
580
+  uint16_t Table_31_0_dBm;
581
+  uint16_t Table_31_5_dBm;
582
+}ATT_TABLE_st;
583
+typedef struct{
584
+
585
+  uint16_t Table_Det5_dBm	;
586
+  uint16_t Table_Det4_dBm	;
587
+  uint16_t Table_Det3_dBm	;
588
+  uint16_t Table_Det2_dBm	;
589
+  uint16_t Table_Det1_dBm	;
590
+  uint16_t Table_Det0_dBm	;
591
+  uint16_t Table_Det_1_dBm	;
592
+  uint16_t Table_Det_2_dBm	;
593
+  uint16_t Table_Det_3_dBm	;
594
+  uint16_t Table_Det_4_dBm	;
595
+  uint16_t Table_Det_5_dBm	;
596
+  uint16_t Table_Det_6_dBm	;
597
+  uint16_t Table_Det_7_dBm	;
598
+  uint16_t Table_Det_8_dBm	;
599
+  uint16_t Table_Det_9_dBm	;
600
+  uint16_t Table_Det_10_dBm	;
601
+  uint16_t Table_Det_11_dBm	;
602
+  uint16_t Table_Det_12_dBm	;
603
+  uint16_t Table_Det_13_dBm	;
604
+  uint16_t Table_Det_14_dBm	;
605
+  uint16_t Table_Det_15_dBm	;
606
+  uint16_t Table_Det_16_dBm	;
607
+  uint16_t Table_Det_17_dBm	;
608
+  uint16_t Table_Det_18_dBm	;
609
+  uint16_t Table_Det_19_dBm	;
610
+  uint16_t Table_Det_20_dBm	;
611
+  uint16_t Table_Det_21_dBm	;
612
+  uint16_t Table_Det_22_dBm	;
613
+  uint16_t Table_Det_23_dBm	;
614
+  uint16_t Table_Det_24_dBm	;
615
+  uint16_t Table_Det_25_dBm	;
616
+}DET_TABLEDL_st;
617
+typedef struct{
618
+  uint16_t Table_Det_15_dBm	;
619
+  uint16_t Table_Det_16_dBm	;
620
+  uint16_t Table_Det_17_dBm	;
621
+  uint16_t Table_Det_18_dBm	;
622
+  uint16_t Table_Det_19_dBm	;
623
+  uint16_t Table_Det_20_dBm	;
624
+  uint16_t Table_Det_21_dBm	;
625
+  uint16_t Table_Det_22_dBm	;
626
+  uint16_t Table_Det_23_dBm	;
627
+  uint16_t Table_Det_24_dBm	;
628
+  uint16_t Table_Det_25_dBm	;
629
+  uint16_t Table_Det_26_dBm	;
630
+  uint16_t Table_Det_27_dBm	;
631
+  uint16_t Table_Det_28_dBm	;
632
+  uint16_t Table_Det_29_dBm	;
633
+  uint16_t Table_Det_30_dBm	;
634
+  uint16_t Table_Det_31_dBm	;
635
+  uint16_t Table_Det_32_dBm	;
636
+  uint16_t Table_Det_33_dBm	;
637
+  uint16_t Table_Det_34_dBm	;
638
+  uint16_t Table_Det_35_dBm	;
639
+  uint16_t Table_Det_36_dBm	;
640
+  uint16_t Table_Det_37_dBm	;
641
+  uint16_t Table_Det_38_dBm	;
642
+  uint16_t Table_Det_39_dBm	;
643
+  uint16_t Table_Det_40_dBm	;
644
+  uint16_t Table_Det_41_dBm	;
645
+  uint16_t Table_Det_42_dBm	;
646
+  uint16_t Table_Det_43_dBm	;
647
+  uint16_t Table_Det_44_dBm	;
648
+  uint16_t Table_Det_45_dBm	;
649
+  uint16_t Table_Det_46_dBm	;
650
+  uint16_t Table_Det_47_dBm	;
651
+  uint16_t Table_Det_48_dBm	;
652
+  uint16_t Table_Det_49_dBm	;
653
+  uint16_t Table_Det_50_dBm	;
654
+  uint16_t Table_Det_51_dBm	;
655
+  uint16_t Table_Det_52_dBm	;
656
+  uint16_t Table_Det_53_dBm	;
657
+  uint16_t Table_Det_54_dBm	;
658
+  uint16_t Table_Det_55_dBm	;
659
+  uint16_t Table_Det_56_dBm	;
660
+  uint16_t Table_Det_57_dBm	;
661
+  uint16_t Table_Det_58_dBm	;
662
+  uint16_t Table_Det_59_dBm	;
663
+  uint16_t Table_Det_60_dBm	;
664
+}DET_TABLEUL_st;
665
+
666
+typedef struct{
667
+
668
+  uint16_t Table_10_Temp;
669
+  uint16_t Table_15_Temp;
670
+  uint16_t Table_20_Temp;
671
+  uint16_t Table_25_Temp;
672
+  uint16_t Table_30_Temp;
673
+  uint16_t Table_35_Temp;
674
+  uint16_t Table_40_Temp;
675
+  uint16_t Table_45_Temp;
676
+  uint16_t Table_50_Temp;
677
+  uint16_t Table_55_Temp;
678
+}TEMP_TABLE_st;
512 679
 typedef enum{
513 680
   Bluecell_DET_UL1_ADC_INDEX_H = 0,
514 681
   Bluecell_DET_UL1_ADC_INDEX_L,
@@ -535,4 +702,41 @@ typedef enum{
535 702
 }Bluecell_ADC3_Index;
536 703
 #define ADC1_EA Bluecell_ADC1_MaxLength /2
537 704
 #define ADC3_EA Bluecell_ADC3_MaxLength /2
705
+
706
+
707
+extern ATT_TABLE_st Att_DL1;
708
+extern ATT_TABLE_st Att_DL2;
709
+extern ATT_TABLE_st Att_DL3;
710
+extern ATT_TABLE_st Att_DL4;
711
+extern ATT_TABLE_st Att_UL1;
712
+extern ATT_TABLE_st Att_UL2;
713
+extern ATT_TABLE_st Att_UL3;
714
+extern ATT_TABLE_st Att_UL4;
715
+
716
+extern DET_TABLEDL_st Det_DL1;
717
+extern DET_TABLEDL_st Det_DL2;
718
+extern DET_TABLEDL_st Det_DL3;
719
+extern DET_TABLEDL_st Det_DL4;
720
+
721
+extern DET_TABLEUL_st Det_UL1;
722
+extern DET_TABLEUL_st Det_UL2;
723
+extern DET_TABLEUL_st Det_UL3;
724
+extern DET_TABLEUL_st Det_UL4;
725
+
726
+extern TEMP_TABLE_st Temp_DL1;
727
+extern TEMP_TABLE_st Temp_DL2;
728
+extern TEMP_TABLE_st Temp_DL3;
729
+extern TEMP_TABLE_st Temp_DL4;
730
+
731
+extern TEMP_TABLE_st Temp_UL1;
732
+extern TEMP_TABLE_st Temp_UL2;
733
+extern TEMP_TABLE_st Temp_UL3;
734
+extern TEMP_TABLE_st Temp_UL4;
735
+
736
+extern BLUESTATUS_st bluecell_Currdatastatus;
737
+
738
+
739
+
740
+extern void Bluecell_DataInit();
741
+
538 742
 #endif /* BLUECELL_OPERATE_H_ */

+ 198 - 0
Bluecell_Inc/eeprom.h

@@ -0,0 +1,198 @@
1
+/*
2
+ * eeprom.h
3
+ *
4
+ *  Created on: 2020. 4. 22.
5
+ *      Author: parkyj
6
+ */
7
+
8
+#ifndef EEPROM_H_
9
+#define EEPROM_H_
10
+
11
+
12
+#define EEPROM_M24C08_ID                  0xA0
13
+#define EEPROM_Block0_ADDRESS             EEPROM_M24C08_ID
14
+#define EEPROM_ATT_BASE					  0x0000
15
+
16
+#define EEPROM_ATT_DL1_TABLE_ADDRESDS	  EEPROM_ATT_BASE               + (sizeof(ATT_TABLE_st)            * 2)
17
+#define EEPROM_ATT_DL2_TABLE_ADDRESDS	  EEPROM_ATT_DL1_TABLE_ADDRESDS + (sizeof(ATT_TABLE_st)            * 2)
18
+#define EEPROM_ATT_DL3_TABLE_ADDRESDS	  EEPROM_ATT_DL2_TABLE_ADDRESDS + (sizeof(ATT_TABLE_st)            * 2)
19
+#define EEPROM_ATT_DL4_TABLE_ADDRESDS	  EEPROM_ATT_DL3_TABLE_ADDRESDS + (sizeof(ATT_TABLE_st)            * 2)
20
+
21
+#define EEPROM_ATT_UL1_TABLE_ADDRESDS	  EEPROM_ATT_DL4_TABLE_ADDRESDS + (sizeof(ATT_TABLE_st)            * 2)
22
+#define EEPROM_ATT_UL2_TABLE_ADDRESDS	  EEPROM_ATT_UL1_TABLE_ADDRESDS + (sizeof(ATT_TABLE_st)            * 2)
23
+#define EEPROM_ATT_UL3_TABLE_ADDRESDS	  EEPROM_ATT_UL2_TABLE_ADDRESDS + (sizeof(ATT_TABLE_st)            * 2)
24
+#define EEPROM_ATT_UL4_TABLE_ADDRESDS	  EEPROM_ATT_UL3_TABLE_ADDRESDS + (sizeof(ATT_TABLE_st)            * 2)
25
+
26
+#define EEPROM_DET_DL1_TABLE_ADDRESDS	  EEPROM_ATT_UL4_TABLE_ADDRESDS + (sizeof(DET_TABLEDL_st)          * 2)
27
+#define EEPROM_DET_DL2_TABLE_ADDRESDS	  EEPROM_DET_DL1_TABLE_ADDRESDS + (sizeof(DET_TABLEDL_st)          * 2)
28
+#define EEPROM_DET_DL3_TABLE_ADDRESDS	  EEPROM_DET_DL2_TABLE_ADDRESDS + (sizeof(DET_TABLEDL_st)          * 2)
29
+#define EEPROM_DET_DL4_TABLE_ADDRESDS	  EEPROM_DET_DL3_TABLE_ADDRESDS + (sizeof(DET_TABLEDL_st)          * 2)
30
+
31
+#define EEPROM_DET_UL1_TABLE_ADDRESDS	  EEPROM_DET_DL4_TABLE_ADDRESDS + (sizeof(DET_TABLEUL_st)          * 2)
32
+#define EEPROM_DET_UL2_TABLE_ADDRESDS	  EEPROM_DET_UL1_TABLE_ADDRESDS + (sizeof(DET_TABLEUL_st)          * 2)
33
+#define EEPROM_DET_UL3_TABLE_ADDRESDS	  EEPROM_DET_UL2_TABLE_ADDRESDS + (sizeof(DET_TABLEUL_st)          * 2)
34
+#define EEPROM_DET_UL4_TABLE_ADDRESDS	  EEPROM_DET_UL3_TABLE_ADDRESDS + (sizeof(DET_TABLEUL_st)          * 2)
35
+
36
+#define EEPROM_TEMP_DL1_TABLE_ADDRESDS	  EEPROM_DET_UL4_TABLE_ADDRESDS + (sizeof(TEMP_TABLE_st)           * 2)
37
+#define EEPROM_TEMP_DL2_TABLE_ADDRESDS	  EEPROM_TEMP_DL1_TABLE_ADDRESDS +( sizeof(TEMP_TABLE_st)          * 2)
38
+#define EEPROM_TEMP_DL3_TABLE_ADDRESDS	  EEPROM_TEMP_DL2_TABLE_ADDRESDS +( sizeof(TEMP_TABLE_st)          * 2)
39
+#define EEPROM_TEMP_DL4_TABLE_ADDRESDS	  EEPROM_TEMP_DL3_TABLE_ADDRESDS +( sizeof(TEMP_TABLE_st)          * 2)
40
+
41
+#define EEPROM_TEMP_UL1_TABLE_ADDRESDS	  EEPROM_TEMP_DL4_TABLE_ADDRESDS +( sizeof(TEMP_TABLE_st)          * 2)
42
+#define EEPROM_TEMP_UL2_TABLE_ADDRESDS	  EEPROM_TEMP_UL1_TABLE_ADDRESDS +( sizeof(TEMP_TABLE_st)          * 2)
43
+#define EEPROM_TEMP_UL3_TABLE_ADDRESDS	  EEPROM_TEMP_UL2_TABLE_ADDRESDS +( sizeof(TEMP_TABLE_st)          * 2)
44
+#define EEPROM_TEMP_UL4_TABLE_ADDRESDS	  EEPROM_TEMP_UL3_TABLE_ADDRESDS +( sizeof(TEMP_TABLE_st)          * 2)
45
+
46
+
47
+#define EEPROM_WINDOW_STATUS_ADDRESDS	  EEPROM_TEMP_UL4_TABLE_ADDRESDS +( sizeof(BLUESTATUS_st)          * 2)
48
+
49
+#define MAKE_ADDRESS(_addr, _e2)            ((uint8_t)EEPROM_M24C08_ADDR | \
50
+                                             ((_e2) ? EEPROM_M24C08_ADDR_E2 : 0) | \
51
+                                             ((uint8_t)((_addr) >> 7) & EEPROM_M24C08_BYTE_ADDR_H))
52
+
53
+#define EEPROM_M24C08_ADDR                  0xA0        //!< M24C08 device identifier
54
+#define EEPROM_M24C08_ADDR_E2               0x08        //!< M24C08 E2 address bit
55
+
56
+
57
+
58
+
59
+#define EEPROM_M24C08_BYTE_ADDR_H           0x06
60
+
61
+HAL_StatusTypeDef EEPROM_M24C08_Read(uint16_t devid,uint16_t Address,uint16_t* data,uint8_t size);
62
+HAL_StatusTypeDef EEPROM_M24C08_write(uint16_t devid,uint16_t Address,uint16_t* data,uint8_t size);
63
+
64
+HAL_StatusTypeDef EEPROM_M24C08_ByteRead(uint16_t devid,uint16_t Address,uint8_t* data,uint8_t size);
65
+HAL_StatusTypeDef EEPROM_M24C08_Bytewrite(uint16_t devid,uint16_t Address,uint8_t* data,uint8_t size);
66
+
67
+void EEPROM_M24C08_Init(void);
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+
80
+
81
+
82
+
83
+// Exported type definitions --------------------------------------------------
84
+/**
85
+ * The possible states the EEPROM driver can be in.
86
+ */
87
+typedef enum
88
+{
89
+    EE_UNINIT = 0,      //!< Driver has not been initialized
90
+    EE_IDLE,            //!< Driver has been initialized and is ready to start a transfer
91
+    EE_FINISH,          //!< Driver has finished with a transfer
92
+    EE_READ,            //!< Driver is doing a read operation
93
+    EE_WRITE_SEND,      //!< Driver is writing data
94
+    EE_WRITE_WAIT       //!< Driver is waiting for the EEPROM to finish a write cycle
95
+} EEPROM_Status;
96
+
97
+/**
98
+ * The possible outcomes of an operation.
99
+ */
100
+typedef enum
101
+{
102
+    EE_OK = 0,      //!< Indicates success
103
+    EE_BUSY,        //!< Indicates that the driver is currently busy doing a transfer
104
+    EE_ERROR        //!< Indicates an error condition
105
+} EEPROM_Error;
106
+
107
+/**
108
+ * Contains static configuration for the board such as populated peripherals, fitted resistor values and Ethernet MAC
109
+ * address, that are stored on the EEPROM.
110
+ */
111
+
112
+// Macros ---------------------------------------------------------------------
113
+
114
+#ifndef LOBYTE
115
+#define LOBYTE(x)  ((uint8_t)(x & 0x00FF))
116
+#endif
117
+#ifndef HIBYTE
118
+#define HIBYTE(x)  ((uint8_t)((x & 0xFF00) >> 8))
119
+#endif
120
+#define MAKE_ADDRESS(_addr, _e2)            ((uint8_t)EEPROM_M24C08_ADDR | \
121
+                                             ((_e2) ? EEPROM_M24C08_ADDR_E2 : 0) | \
122
+                                             ((uint8_t)((_addr) >> 7) & EEPROM_M24C08_BYTE_ADDR_H))
123
+
124
+// Constants ------------------------------------------------------------------
125
+
126
+/**
127
+ * @defgroup EEPROM_M24C08_ADDRESS M24C08 Address definitions
128
+ * 
129
+ * The address byte that is sent to an M24C08 consists of 4 parts:
130
+ *  + The device identifier {@link EEPROM_M24C08_ADDR} (4 bits)
131
+ *  + An address bit {@link EEPROM_M24C08_ADDR_E2} that is either set or not, depending on the value of the `E2` pin on
132
+ *    the M24C08 device
133
+ *  + The two most significant bits of the memory address to be read/written {@link EEPROM_M24C08_BYTE_ADDR_H}
134
+ *  + The standard I2C read/write bit
135
+ * @{
136
+ */
137
+#define EEPROM_M24C08_ADDR                  0xA0        //!< M24C08 device identifier
138
+#define EEPROM_M24C08_ADDR_E2               0x08        //!< M24C08 E2 address bit
139
+/**
140
+ * Bitmask for the M24C08 I2C Address bits that are used for the high byte of the memory address. The address bits are
141
+ * either the high byte shifted left by one or the 16 bit address shifted right by 7 and then masked.
142
+ */
143
+#define EEPROM_M24C08_BYTE_ADDR_H           0x06
144
+/** @} */
145
+
146
+/**
147
+ * Timeout in ms for I2C communication
148
+ */
149
+#define EEPROM_I2C_TIMEOUT                  0x200
150
+
151
+/**
152
+ * EEPROM size in bytes
153
+ */
154
+#define EEPROM_SIZE                         0x400
155
+
156
+/**
157
+ * Mask for the page address, a page write can only write to addresses which have the same page address
158
+ */
159
+#define EEPROM_PAGE_MASK                    0x03F0
160
+
161
+/**
162
+ * Page size of the EEPROM, only one page can be written at a time
163
+ */
164
+#define EEPROM_PAGE_SIZE                    0x10
165
+
166
+/**
167
+ * Configuration data offset, that is the first address of the configuration data space
168
+ */
169
+#define EEPROM_CONFIG_OFFSET                0
170
+
171
+/**
172
+ * Size of the configuration data section in bytes
173
+ */
174
+#define EEPROM_CONFIG_SIZE                  128
175
+
176
+/**
177
+ * Data offset, that is the first address for arbitrary data
178
+ */
179
+#define EEPROM_DATA_OFFSET                  0x80
180
+
181
+/**
182
+ * Size of the data section in bytes, this is the EEPROM size minus the data offset
183
+ */
184
+#define EEPROM_DATA_SIZE                    (EEPROM_SIZE - EEPROM_DATA_OFFSET)
185
+
186
+/**
187
+ * Size of the settings buffer in bytes
188
+ */
189
+#define EEPROM_SETTINGS_SIZE                64
190
+
191
+// Exported functions ---------------------------------------------------------
192
+
193
+
194
+
195
+// ----------------------------------------------------------------------------
196
+
197
+
198
+#endif /* EEPROM_H_ */

File diff suppressed because it is too large
+ 625 - 127
Bluecell_Src/Bluecell_operate.c


+ 2 - 1
Bluecell_Src/CRC.c

@@ -9,6 +9,7 @@
9 9
 /*									CRC16	TABLE						    			 */
10 10
 /*---------------------------------------------------------------------------------------*/
11 11
 #include <CRC.h>
12
+#include "uart.h"
12 13
 const unsigned short Table_CRC16[]  = {
13 14
 	0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
14 15
 	0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
@@ -45,7 +46,7 @@ const unsigned short Table_CRC16[]  = {
45 46
 };
46 47
 
47 48
 //-----------------------------------------------
48
-//UART CRC üũ ÇÔ¼ö
49
+//UART CRC üũ �Լ�
49 50
 //-----------------------------------------------
50 51
 unsigned short genCRC16(char *buf_ptr, int len)
51 52
 {

+ 1 - 1
Bluecell_Src/PE43711.c

@@ -167,7 +167,7 @@ void PE43711_ALL_atten_ctrl(ALL_PE43711_st ATT){
167 167
 void PE43711_atten_ctrl(PE43711_st ATT ,uint8_t data){
168 168
     uint8_t i = 0;
169 169
     uint8_t temp = 0;
170
-    data = 4 * data;
170
+    //data = 4 * data; // ATTEN ERROR 수정 
171 171
     temp = (uint8_t)data;
172 172
     
173 173
     HAL_GPIO_WritePin(ATT.LE_PORT,ATT.LE_PIN,GPIO_PIN_RESET);

+ 205 - 0
Bluecell_Src/eeprom.c

@@ -0,0 +1,205 @@
1
+/*
2
+ * eeprom.c
3
+ *
4
+ *  Created on: 2020. 4. 22.
5
+ *      Author: parkyj
6
+ */
7
+#include "main.h"
8
+#include "eeprom.h"
9
+#include "Bluecell_operate.h"
10
+#include "stm32f1xx_hal.h"
11
+/* Includes ------------------------------------------------------------------*/   
12
+HAL_StatusTypeDef EEPROM_M24C08_ByteRead(uint16_t devid,uint16_t Address,uint8_t* data,uint8_t size);
13
+
14
+
15
+
16
+
17
+
18
+
19
+
20
+
21
+
22
+
23
+void EEPROM_M24C08_Init(void){
24
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_ATT_BASE,&Att_DL1.Table_0_0_dBm,sizeof(ATT_TABLE_st) );
25
+//    printf("%x\r\n",Att_DL1.Table_0_0_dBm);
26
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_ATT_DL1_TABLE_ADDRESDS,&Att_DL2.Table_0_0_dBm,sizeof(ATT_TABLE_st) );
27
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_ATT_DL2_TABLE_ADDRESDS,&Att_DL3.Table_0_0_dBm,sizeof(ATT_TABLE_st) );
28
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_ATT_DL3_TABLE_ADDRESDS,&Att_DL4.Table_0_0_dBm,sizeof(ATT_TABLE_st) );
29
+
30
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_ATT_DL4_TABLE_ADDRESDS,&Att_UL1.Table_0_0_dBm,sizeof(ATT_TABLE_st) );
31
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_ATT_UL1_TABLE_ADDRESDS,&Att_UL2.Table_0_0_dBm,sizeof(ATT_TABLE_st) );
32
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_ATT_UL2_TABLE_ADDRESDS,&Att_UL3.Table_0_0_dBm,sizeof(ATT_TABLE_st) );
33
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_ATT_UL3_TABLE_ADDRESDS,&Att_UL4.Table_0_0_dBm,sizeof(ATT_TABLE_st) );
34
+
35
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_ATT_UL4_TABLE_ADDRESDS,&Det_DL1.Table_Det5_dBm,sizeof(DET_TABLEDL_st) );
36
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_DET_DL1_TABLE_ADDRESDS,&Det_DL2.Table_Det5_dBm,sizeof(DET_TABLEDL_st) );
37
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_DET_DL2_TABLE_ADDRESDS,&Det_DL3.Table_Det5_dBm,sizeof(DET_TABLEDL_st) );
38
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_DET_DL3_TABLE_ADDRESDS,&Det_DL4.Table_Det5_dBm,sizeof(DET_TABLEDL_st) );
39
+
40
+
41
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_DET_DL4_TABLE_ADDRESDS,&Det_UL1.Table_Det_15_dBm,sizeof(DET_TABLEUL_st) );
42
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_DET_UL1_TABLE_ADDRESDS,&Det_UL2.Table_Det_15_dBm,sizeof(DET_TABLEUL_st) );
43
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_DET_UL2_TABLE_ADDRESDS,&Det_UL3.Table_Det_15_dBm,sizeof(DET_TABLEUL_st) );
44
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_DET_UL3_TABLE_ADDRESDS,&Det_UL4.Table_Det_15_dBm,sizeof(DET_TABLEUL_st) );
45
+
46
+
47
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_DET_UL4_TABLE_ADDRESDS,&Temp_DL1.Table_10_Temp,sizeof(TEMP_TABLE_st) );
48
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_TEMP_DL1_TABLE_ADDRESDS,&Temp_DL2.Table_10_Temp,sizeof(TEMP_TABLE_st) );
49
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_TEMP_DL2_TABLE_ADDRESDS,&Temp_DL3.Table_10_Temp,sizeof(TEMP_TABLE_st) );
50
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_TEMP_DL3_TABLE_ADDRESDS,&Temp_DL4.Table_10_Temp,sizeof(TEMP_TABLE_st) );
51
+
52
+
53
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_TEMP_DL4_TABLE_ADDRESDS,&Temp_UL1.Table_10_Temp,sizeof(TEMP_TABLE_st) );
54
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_TEMP_UL1_TABLE_ADDRESDS,&Temp_UL2.Table_10_Temp,sizeof(TEMP_TABLE_st) );
55
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_TEMP_UL2_TABLE_ADDRESDS,&Temp_UL3.Table_10_Temp,sizeof(TEMP_TABLE_st) );
56
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_TEMP_UL3_TABLE_ADDRESDS,&Temp_UL4.Table_10_Temp,sizeof(TEMP_TABLE_st) );
57
+
58
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_TEMP_UL4_TABLE_ADDRESDS,&bluecell_Currdatastatus.bluecell_header,sizeof(BLUESTATUS_st) );
59
+    printf("bluecell_Currdatastatus.ATT_DL1_H : %x\r\n",bluecell_Currdatastatus.ATT_DL1_H);
60
+    printf("bluecell_Currdatastatus.ATT_DL1_L : %x\r\n",bluecell_Currdatastatus.ATT_DL1_L);        
61
+    
62
+    printf("EEPROM INIT COMPLETE\r\n");
63
+
64
+}
65
+
66
+
67
+
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+#if 0 // PYJ.2020.04.23_BEGIN -- 
76
+
77
+
78
+void eepromtest(){
79
+    memset(&eepdata[0],0x33,100);
80
+    for(int i = 0; i < 100; i ++ ){
81
+        printf("data[%d] : %x \r\n",i,eepdata[i]);
82
+        EEPROM_M24C08_Bytewrite(EEPROM_M24C08_ID,EEPROM_ATT_BASE + i,&eepdata[i],1);
83
+    }  
84
+    for(int i = 0; i < 100; i ++ ){
85
+        EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_ATT_BASE + i,&eepdata[i],1);
86
+        printf("data[%d] : %x \r\n",i,eepdata[i]);
87
+    }  
88
+//    EEPROM_M24C08_Read(EEPROM_M24C08_ID,EEPROM_ATT_BASE,&eepdata[0],100);
89
+//    for(int i = 0; i < 100; i ++ ){
90
+//        printf("data[%d] : %x \r\n",i,eepdata[i]);
91
+//    }    
92
+
93
+}
94
+#endif // PYJ.2020.04.23_END -- 
95
+
96
+
97
+
98
+HAL_StatusTypeDef EEPROM_M24C08_Read(uint16_t devid,uint16_t Address,uint16_t* data,uint8_t size){
99
+   HAL_StatusTypeDef ret = HAL_ERROR;
100
+#if 0 // PYJ.2020.04.23_BEGIN -- 
101
+   for(uint16_t i = 0; i < size / 2; i++){
102
+//       ret = HAL_I2C_Mem_Read(&hi2c2, devid,(Address + (i * 2)), I2C_MEMADD_SIZE_16BIT, &data[i], 2, 512);
103
+
104
+//       printf("READdata[%d] : %x \r\n",i,data[i]);
105
+       if(ret == HAL_ERROR){
106
+         printf("Read ERR\r\n");
107
+       }
108
+     HAL_Delay(10);
109
+#else
110
+//      ret = HAL_I2C_Mem_Read(&hi2c2, devid,Address, I2C_MEMADD_SIZE_16BIT, data, size, 512);
111
+////       printf("READdata[%d] : %x \r\n",i,data[i]);
112
+//      if(ret == HAL_ERROR){
113
+//        printf("Read ERR\r\n");
114
+//      }
115
+//    HAL_Delay(10);
116
+    ret = HAL_I2C_Mem_Read(&hi2c2, devid, Address, I2C_MEMADD_SIZE_16BIT, data, size, 512);
117
+      if(ret == HAL_ERROR)
118
+            printf("Write ERR\r\n");
119
+
120
+    HAL_Delay(10);
121
+     return ret; 
122
+
123
+
124
+#endif // PYJ.2020.04.23_END -- 
125
+
126
+    return ret;   
127
+}
128
+HAL_StatusTypeDef EEPROM_M24C08_write(uint16_t devid,uint16_t Address,uint16_t* data,uint8_t size){
129
+    HAL_StatusTypeDef ret = HAL_ERROR;
130
+#if 0 // PYJ.2020.04.23_BEGIN -- 
131
+    for(int i = 0; i < size / 2; i++){
132
+        ret = HAL_I2C_Mem_Write(&hi2c2, devid,(Address + (i * 2)),  I2C_MEMADD_SIZE_16BIT, &data[i], 2, 512);
133
+        if(ret == HAL_ERROR)
134
+            printf("Write ERR\r\n");
135
+//        printf("Writedata[%d] : %x \r\n",i,data[i]);
136
+        HAL_Delay(10);
137
+    }
138
+#else
139
+//    ret = HAL_I2C_Mem_Write(&hi2c2, devid,Address,  I2C_MEMADD_SIZE_16BIT, data, size, 1024);
140
+//    if(ret == HAL_ERROR)
141
+//        printf("Write ERR\r\n");
142
+////        printf("Writedata[%d] : %x \r\n",i,data[i]);
143
+//    HAL_Delay(10);
144
+     ret = HAL_I2C_Mem_Write(&hi2c2, devid, Address,  I2C_MEMADD_SIZE_16BIT, data, size, 512);
145
+       if(ret == HAL_ERROR)
146
+             printf("Write ERR\r\n");
147
+
148
+     HAL_Delay(10);
149
+
150
+
151
+#endif // PYJ.2020.04.23_END -- 
152
+    return ret;
153
+}
154
+
155
+
156
+
157
+
158
+
159
+HAL_StatusTypeDef EEPROM_M24C08_ByteRead(uint16_t devid,uint16_t Address,uint8_t* data,uint8_t size){
160
+   HAL_StatusTypeDef ret = HAL_ERROR;
161
+   for(int i = 0; i < size; i++){
162
+     ret = HAL_I2C_Mem_Read(&hi2c2, devid, Address + i, I2C_MEMADD_SIZE_8BIT, &data[i], 1, 1024);
163
+       if(ret == HAL_ERROR)
164
+        printf("Write ERR\r\n");
165
+//     ret = HAL_I2C_Mem_Read_IT(&hi2c2, devid, Address + i, I2C_MEMADD_SIZE_8BIT, &data[i], 1);
166
+     HAL_Delay(10);
167
+   }
168
+    return ret;   
169
+}
170
+HAL_StatusTypeDef EEPROM_M24C08_Bytewrite(uint16_t devid,uint16_t Address,uint8_t* data,uint8_t size){
171
+    HAL_StatusTypeDef ret = HAL_ERROR;
172
+    for(int i = 0; i < size; i++){
173
+        ret = HAL_I2C_Mem_Write(&hi2c2, devid, Address + i,  I2C_MEMADD_SIZE_8BIT, &data[i], 1, 1024);
174
+        if(ret == HAL_ERROR)
175
+              printf("Write ERR\r\n");
176
+//        ret = HAL_I2C_Mem_Write_IT(&hi2c2, devid, Address + i, I2C_MEMADD_SIZE_8BIT, &data[i], 1);
177
+        HAL_Delay(7);
178
+    }
179
+    return ret;
180
+}
181
+
182
+
183
+
184
+
185
+
186
+
187
+
188
+
189
+
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+
205
+

+ 184 - 0
Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_crc.h

@@ -0,0 +1,184 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_crc.h
4
+  * @author  MCD Application Team
5
+  * @brief   Header file of CRC HAL module.
6
+  ******************************************************************************
7
+  * @attention
8
+  *
9
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
10
+  * All rights reserved.</center></h2>
11
+  *
12
+  * This software component is licensed by ST under BSD 3-Clause license,
13
+  * the "License"; You may not use this file except in compliance with the
14
+  * License. You may obtain a copy of the License at:
15
+  *                        opensource.org/licenses/BSD-3-Clause
16
+  *
17
+  ******************************************************************************
18
+  */
19
+
20
+/* Define to prevent recursive inclusion -------------------------------------*/
21
+#ifndef STM32F1xx_HAL_CRC_H
22
+#define STM32F1xx_HAL_CRC_H
23
+
24
+#ifdef __cplusplus
25
+extern "C" {
26
+#endif
27
+
28
+/* Includes ------------------------------------------------------------------*/
29
+#include "stm32f1xx_hal_def.h"
30
+
31
+/** @addtogroup STM32F1xx_HAL_Driver
32
+  * @{
33
+  */
34
+
35
+/** @addtogroup CRC
36
+  * @{
37
+  */
38
+
39
+/* Exported types ------------------------------------------------------------*/
40
+/** @defgroup CRC_Exported_Types CRC Exported Types
41
+  * @{
42
+  */
43
+
44
+/**
45
+  * @brief  CRC HAL State Structure definition
46
+  */
47
+typedef enum
48
+{
49
+  HAL_CRC_STATE_RESET     = 0x00U,  /*!< CRC not yet initialized or disabled */
50
+  HAL_CRC_STATE_READY     = 0x01U,  /*!< CRC initialized and ready for use   */
51
+  HAL_CRC_STATE_BUSY      = 0x02U,  /*!< CRC internal process is ongoing     */
52
+  HAL_CRC_STATE_TIMEOUT   = 0x03U,  /*!< CRC timeout state                   */
53
+  HAL_CRC_STATE_ERROR     = 0x04U   /*!< CRC error state                     */
54
+} HAL_CRC_StateTypeDef;
55
+
56
+
57
+/**
58
+  * @brief  CRC Handle Structure definition
59
+  */
60
+typedef struct
61
+{
62
+  CRC_TypeDef                 *Instance;   /*!< Register base address        */
63
+
64
+  HAL_LockTypeDef             Lock;        /*!< CRC Locking object           */
65
+
66
+  __IO HAL_CRC_StateTypeDef   State;       /*!< CRC communication state      */
67
+
68
+} CRC_HandleTypeDef;
69
+/**
70
+  * @}
71
+  */
72
+
73
+/* Exported constants --------------------------------------------------------*/
74
+/** @defgroup CRC_Exported_Constants CRC Exported Constants
75
+  * @{
76
+  */
77
+
78
+/**
79
+  * @}
80
+  */
81
+
82
+/* Exported macros -----------------------------------------------------------*/
83
+/** @defgroup CRC_Exported_Macros CRC Exported Macros
84
+  * @{
85
+  */
86
+
87
+/** @brief Reset CRC handle state.
88
+  * @param  __HANDLE__ CRC handle.
89
+  * @retval None
90
+  */
91
+#define __HAL_CRC_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_CRC_STATE_RESET)
92
+
93
+/**
94
+  * @brief  Reset CRC Data Register.
95
+  * @param  __HANDLE__ CRC handle
96
+  * @retval None
97
+  */
98
+#define __HAL_CRC_DR_RESET(__HANDLE__) ((__HANDLE__)->Instance->CR |= CRC_CR_RESET)
99
+
100
+/**
101
+  * @brief Store data in the Independent Data (ID) register.
102
+  * @param __HANDLE__ CRC handle
103
+  * @param __VALUE__  Value to be stored in the ID register
104
+  * @note  Refer to the Reference Manual to get the authorized __VALUE__ length in bits
105
+  * @retval None
106
+  */
107
+#define __HAL_CRC_SET_IDR(__HANDLE__, __VALUE__) (WRITE_REG((__HANDLE__)->Instance->IDR, (__VALUE__)))
108
+
109
+/**
110
+  * @brief Return the data stored in the Independent Data (ID) register.
111
+  * @param __HANDLE__ CRC handle
112
+  * @note  Refer to the Reference Manual to get the authorized __VALUE__ length in bits
113
+  * @retval Value of the ID register
114
+  */
115
+#define __HAL_CRC_GET_IDR(__HANDLE__) (((__HANDLE__)->Instance->IDR) & CRC_IDR_IDR)
116
+/**
117
+  * @}
118
+  */
119
+
120
+
121
+/* Private macros --------------------------------------------------------*/
122
+/** @defgroup  CRC_Private_Macros CRC Private Macros
123
+  * @{
124
+  */
125
+
126
+/**
127
+  * @}
128
+  */
129
+
130
+/* Exported functions --------------------------------------------------------*/
131
+/** @defgroup CRC_Exported_Functions CRC Exported Functions
132
+  * @{
133
+  */
134
+
135
+/* Initialization and de-initialization functions  ****************************/
136
+/** @defgroup CRC_Exported_Functions_Group1 Initialization and de-initialization functions
137
+  * @{
138
+  */
139
+HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc);
140
+HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc);
141
+void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc);
142
+void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc);
143
+/**
144
+  * @}
145
+  */
146
+
147
+/* Peripheral Control functions ***********************************************/
148
+/** @defgroup CRC_Exported_Functions_Group2 Peripheral Control functions
149
+  * @{
150
+  */
151
+uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength);
152
+uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength);
153
+/**
154
+  * @}
155
+  */
156
+
157
+/* Peripheral State and Error functions ***************************************/
158
+/** @defgroup CRC_Exported_Functions_Group3 Peripheral State functions
159
+  * @{
160
+  */
161
+HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc);
162
+/**
163
+  * @}
164
+  */
165
+
166
+/**
167
+  * @}
168
+  */
169
+
170
+/**
171
+  * @}
172
+  */
173
+
174
+/**
175
+  * @}
176
+  */
177
+
178
+#ifdef __cplusplus
179
+}
180
+#endif
181
+
182
+#endif /* STM32F1xx_HAL_CRC_H */
183
+
184
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 330 - 0
Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_crc.c

@@ -0,0 +1,330 @@
1
+/**
2
+  ******************************************************************************
3
+  * @file    stm32f1xx_hal_crc.c
4
+  * @author  MCD Application Team
5
+  * @brief   CRC HAL module driver.
6
+  *          This file provides firmware functions to manage the following
7
+  *          functionalities of the Cyclic Redundancy Check (CRC) peripheral:
8
+  *           + Initialization and de-initialization functions
9
+  *           + Peripheral Control functions
10
+  *           + Peripheral State functions
11
+  *
12
+  @verbatim
13
+ ===============================================================================
14
+                     ##### How to use this driver #####
15
+ ===============================================================================
16
+    [..]
17
+         (+) Enable CRC AHB clock using __HAL_RCC_CRC_CLK_ENABLE();
18
+         (+) Initialize CRC calculator
19
+             (++) specify generating polynomial (peripheral default or non-default one)
20
+             (++) specify initialization value (peripheral default or non-default one)
21
+             (++) specify input data format
22
+             (++) specify input or output data inversion mode if any
23
+         (+) Use HAL_CRC_Accumulate() function to compute the CRC value of the
24
+             input data buffer starting with the previously computed CRC as
25
+             initialization value
26
+         (+) Use HAL_CRC_Calculate() function to compute the CRC value of the
27
+             input data buffer starting with the defined initialization value
28
+             (default or non-default) to initiate CRC calculation
29
+
30
+  @endverbatim
31
+  ******************************************************************************
32
+  * @attention
33
+  *
34
+  * <h2><center>&copy; Copyright (c) 2016 STMicroelectronics.
35
+  * All rights reserved.</center></h2>
36
+  *
37
+  * This software component is licensed by ST under BSD 3-Clause license,
38
+  * the "License"; You may not use this file except in compliance with the
39
+  * License. You may obtain a copy of the License at:
40
+  *                        opensource.org/licenses/BSD-3-Clause
41
+  *
42
+  ******************************************************************************
43
+  */
44
+
45
+/* Includes ------------------------------------------------------------------*/
46
+#include "stm32f1xx_hal.h"
47
+
48
+/** @addtogroup STM32F1xx_HAL_Driver
49
+  * @{
50
+  */
51
+
52
+/** @defgroup CRC CRC
53
+  * @brief CRC HAL module driver.
54
+  * @{
55
+  */
56
+
57
+#ifdef HAL_CRC_MODULE_ENABLED
58
+
59
+/* Private typedef -----------------------------------------------------------*/
60
+/* Private define ------------------------------------------------------------*/
61
+/* Private macro -------------------------------------------------------------*/
62
+/* Private variables ---------------------------------------------------------*/
63
+/* Private function prototypes -----------------------------------------------*/
64
+
65
+/* Exported functions --------------------------------------------------------*/
66
+
67
+/** @defgroup CRC_Exported_Functions CRC Exported Functions
68
+  * @{
69
+  */
70
+
71
+/** @defgroup CRC_Exported_Functions_Group1 Initialization and de-initialization functions
72
+ *  @brief    Initialization and Configuration functions.
73
+ *
74
+@verbatim
75
+ ===============================================================================
76
+            ##### Initialization and de-initialization functions #####
77
+ ===============================================================================
78
+    [..]  This section provides functions allowing to:
79
+      (+) Initialize the CRC according to the specified parameters
80
+          in the CRC_InitTypeDef and create the associated handle
81
+      (+) DeInitialize the CRC peripheral
82
+      (+) Initialize the CRC MSP (MCU Specific Package)
83
+      (+) DeInitialize the CRC MSP
84
+
85
+@endverbatim
86
+  * @{
87
+  */
88
+
89
+/**
90
+  * @brief  Initialize the CRC according to the specified
91
+  *         parameters in the CRC_InitTypeDef and create the associated handle.
92
+  * @param  hcrc CRC handle
93
+  * @retval HAL status
94
+  */
95
+HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc)
96
+{
97
+  /* Check the CRC handle allocation */
98
+  if (hcrc == NULL)
99
+  {
100
+    return HAL_ERROR;
101
+  }
102
+
103
+  /* Check the parameters */
104
+  assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance));
105
+
106
+  if (hcrc->State == HAL_CRC_STATE_RESET)
107
+  {
108
+    /* Allocate lock resource and initialize it */
109
+    hcrc->Lock = HAL_UNLOCKED;
110
+    /* Init the low level hardware */
111
+    HAL_CRC_MspInit(hcrc);
112
+  }
113
+
114
+  /* Change CRC peripheral state */
115
+  hcrc->State = HAL_CRC_STATE_READY;
116
+
117
+  /* Return function status */
118
+  return HAL_OK;
119
+}
120
+
121
+/**
122
+  * @brief  DeInitialize the CRC peripheral.
123
+  * @param  hcrc CRC handle
124
+  * @retval HAL status
125
+  */
126
+HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc)
127
+{
128
+  /* Check the CRC handle allocation */
129
+  if (hcrc == NULL)
130
+  {
131
+    return HAL_ERROR;
132
+  }
133
+
134
+  /* Check the parameters */
135
+  assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance));
136
+
137
+  /* Check the CRC peripheral state */
138
+  if (hcrc->State == HAL_CRC_STATE_BUSY)
139
+  {
140
+    return HAL_BUSY;
141
+  }
142
+
143
+  /* Change CRC peripheral state */
144
+  hcrc->State = HAL_CRC_STATE_BUSY;
145
+
146
+  /* Reset CRC calculation unit */
147
+  __HAL_CRC_DR_RESET(hcrc);
148
+
149
+  /* Reset IDR register content */
150
+  CLEAR_BIT(hcrc->Instance->IDR, CRC_IDR_IDR);
151
+
152
+  /* DeInit the low level hardware */
153
+  HAL_CRC_MspDeInit(hcrc);
154
+
155
+  /* Change CRC peripheral state */
156
+  hcrc->State = HAL_CRC_STATE_RESET;
157
+
158
+  /* Process unlocked */
159
+  __HAL_UNLOCK(hcrc);
160
+
161
+  /* Return function status */
162
+  return HAL_OK;
163
+}
164
+
165
+/**
166
+  * @brief  Initializes the CRC MSP.
167
+  * @param  hcrc CRC handle
168
+  * @retval None
169
+  */
170
+__weak void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc)
171
+{
172
+  /* Prevent unused argument(s) compilation warning */
173
+  UNUSED(hcrc);
174
+
175
+  /* NOTE : This function should not be modified, when the callback is needed,
176
+            the HAL_CRC_MspInit can be implemented in the user file
177
+   */
178
+}
179
+
180
+/**
181
+  * @brief  DeInitialize the CRC MSP.
182
+  * @param  hcrc CRC handle
183
+  * @retval None
184
+  */
185
+__weak void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc)
186
+{
187
+  /* Prevent unused argument(s) compilation warning */
188
+  UNUSED(hcrc);
189
+
190
+  /* NOTE : This function should not be modified, when the callback is needed,
191
+            the HAL_CRC_MspDeInit can be implemented in the user file
192
+   */
193
+}
194
+
195
+/**
196
+  * @}
197
+  */
198
+
199
+/** @defgroup CRC_Exported_Functions_Group2 Peripheral Control functions
200
+ *  @brief    management functions.
201
+ *
202
+@verbatim
203
+ ===============================================================================
204
+                      ##### Peripheral Control functions #####
205
+ ===============================================================================
206
+    [..]  This section provides functions allowing to:
207
+      (+) compute the 32-bit CRC value of a 32-bit data buffer
208
+          using combination of the previous CRC value and the new one.
209
+
210
+       [..]  or
211
+
212
+      (+) compute the 32-bit CRC value of a 32-bit data buffer
213
+          independently of the previous CRC value.
214
+
215
+@endverbatim
216
+  * @{
217
+  */
218
+
219
+/**
220
+  * @brief  Compute the 32-bit CRC value of a 32-bit data buffer
221
+  *         starting with the previously computed CRC as initialization value.
222
+  * @param  hcrc CRC handle
223
+  * @param  pBuffer pointer to the input data buffer.
224
+  * @param  BufferLength input data buffer length (number of uint32_t words).
225
+  * @retval uint32_t CRC (returned value LSBs for CRC shorter than 32 bits)
226
+  */
227
+uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength)
228
+{
229
+  uint32_t index;      /* CRC input data buffer index */
230
+  uint32_t temp = 0U;  /* CRC output (read from hcrc->Instance->DR register) */
231
+
232
+  /* Change CRC peripheral state */
233
+  hcrc->State = HAL_CRC_STATE_BUSY;
234
+
235
+  /* Enter Data to the CRC calculator */
236
+  for (index = 0U; index < BufferLength; index++)
237
+  {
238
+    hcrc->Instance->DR = pBuffer[index];
239
+  }
240
+  temp = hcrc->Instance->DR;
241
+
242
+  /* Change CRC peripheral state */
243
+  hcrc->State = HAL_CRC_STATE_READY;
244
+
245
+  /* Return the CRC computed value */
246
+  return temp;
247
+}
248
+
249
+/**
250
+  * @brief  Compute the 32-bit CRC value of a 32-bit data buffer
251
+  *         starting with hcrc->Instance->INIT as initialization value.
252
+  * @param  hcrc CRC handle
253
+  * @param  pBuffer pointer to the input data buffer.
254
+  * @param  BufferLength input data buffer length (number of uint32_t words).
255
+  * @retval uint32_t CRC (returned value LSBs for CRC shorter than 32 bits)
256
+  */
257
+uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength)
258
+{
259
+  uint32_t index;      /* CRC input data buffer index */
260
+  uint32_t temp = 0U;  /* CRC output (read from hcrc->Instance->DR register) */
261
+
262
+  /* Change CRC peripheral state */
263
+  hcrc->State = HAL_CRC_STATE_BUSY;
264
+
265
+  /* Reset CRC Calculation Unit (hcrc->Instance->INIT is
266
+  *  written in hcrc->Instance->DR) */
267
+  __HAL_CRC_DR_RESET(hcrc);
268
+
269
+  /* Enter 32-bit input data to the CRC calculator */
270
+  for (index = 0U; index < BufferLength; index++)
271
+  {
272
+    hcrc->Instance->DR = pBuffer[index];
273
+  }
274
+  temp = hcrc->Instance->DR;
275
+
276
+  /* Change CRC peripheral state */
277
+  hcrc->State = HAL_CRC_STATE_READY;
278
+
279
+  /* Return the CRC computed value */
280
+  return temp;
281
+}
282
+
283
+/**
284
+  * @}
285
+  */
286
+
287
+/** @defgroup CRC_Exported_Functions_Group3 Peripheral State functions
288
+ *  @brief    Peripheral State functions.
289
+ *
290
+@verbatim
291
+ ===============================================================================
292
+                      ##### Peripheral State functions #####
293
+ ===============================================================================
294
+    [..]
295
+    This subsection permits to get in run-time the status of the peripheral.
296
+
297
+@endverbatim
298
+  * @{
299
+  */
300
+
301
+/**
302
+  * @brief  Return the CRC handle state.
303
+  * @param  hcrc CRC handle
304
+  * @retval HAL state
305
+  */
306
+HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc)
307
+{
308
+  /* Return CRC handle state */
309
+  return hcrc->State;
310
+}
311
+
312
+/**
313
+  * @}
314
+  */
315
+
316
+/**
317
+  * @}
318
+  */
319
+
320
+
321
+#endif /* HAL_CRC_MODULE_ENABLED */
322
+/**
323
+  * @}
324
+  */
325
+
326
+/**
327
+  * @}
328
+  */
329
+
330
+/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/

+ 13 - 2
Inc/main.h

@@ -55,8 +55,19 @@ extern "C" {
55 55
 void Error_Handler(void);
56 56
 
57 57
 /* USER CODE BEGIN EFP */
58
-extern uint32_t ADC1value[Bluecell_ADC1_MaxLength / 2];
59
-extern uint32_t ADC3value[Bluecell_ADC3_MaxLength / 2];
58
+extern volatile uint16_t ADC1value[4];
59
+extern volatile uint16_t ADC3value[5];
60
+extern volatile uint32_t ADC1_Average_value[4];
61
+extern volatile uint32_t ADC3_Average_value[5];
62
+
63
+extern uint8_t adc1cnt;
64
+extern uint8_t adc3cnt;
65
+
66
+extern ADC_HandleTypeDef hadc1;
67
+extern ADC_HandleTypeDef hadc3;
68
+extern I2C_HandleTypeDef hi2c2;
69
+
70
+
60 71
 /* USER CODE END EFP */
61 72
 
62 73
 /* Private defines -----------------------------------------------------------*/

+ 1 - 1
Inc/stm32f1xx_hal_conf.h

@@ -39,7 +39,7 @@
39 39
 /*#define HAL_CAN_LEGACY_MODULE_ENABLED   */
40 40
 /*#define HAL_CEC_MODULE_ENABLED   */
41 41
 /*#define HAL_CORTEX_MODULE_ENABLED   */
42
-/*#define HAL_CRC_MODULE_ENABLED   */
42
+#define HAL_CRC_MODULE_ENABLED
43 43
 /*#define HAL_DAC_MODULE_ENABLED   */
44 44
 #define HAL_DMA_MODULE_ENABLED
45 45
 /*#define HAL_ETH_MODULE_ENABLED   */

+ 2 - 0
STM32F103ZET_JDASMBIC.elf.launch

@@ -33,6 +33,7 @@
33 33
 <booleanAttribute key="org.eclipse.cdt.debug.mi.core.verboseMode" value="false" />
34 34
 <stringAttribute key="org.eclipse.cdt.dsf.gdb.DEBUG_NAME" value="${TOOLCHAIN_PATH}/arm-atollic-eabi-gdb" />
35 35
 <intAttribute key="org.eclipse.cdt.launch.ATTR_BUILD_BEFORE_LAUNCH_ATTR" value="2" />
36
+<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_REGISTER_GROUPS" value="" />
36 37
 <stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="Debug/STM32F103ZET_JDASMBIC.elf" />
37 38
 <stringAttribute key="org.eclipse.cdt.launch.PROJECT_ATTR" value="STM32F103ZET_JDASMBIC" />
38 39
 <stringAttribute key="org.eclipse.cdt.launch.PROJECT_BUILD_CONFIG_ID_ATTR" value="" />
@@ -43,4 +44,5 @@
43 44
 <listEntry value="4" />
44 45
 </listAttribute>
45 46
 <stringAttribute key="org.eclipse.dsf.launch.MEMORY_BLOCKS" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#xD;&#xA;&lt;memoryBlockExpressionList context=&quot;reserved-for-future-use&quot;/&gt;&#xD;&#xA;" />
47
+<stringAttribute key="process_factory_id" value="org.eclipse.cdt.dsf.gdb.GdbProcessFactory" />
46 48
 </launchConfiguration>

File diff suppressed because it is too large
+ 40 - 34
STM32F103ZET_JDASMBIC.ioc


+ 177 - 14
Src/main.c

@@ -27,6 +27,7 @@
27 27
 #include "PE43711.h"
28 28
 #include "uart.h"
29 29
 #include "Bluecell_operate.h"
30
+#include "eeprom.h"
30 31
 /* USER CODE END Includes */
31 32
 
32 33
 /* Private typedef -----------------------------------------------------------*/
@@ -49,6 +50,8 @@ ADC_HandleTypeDef hadc3;
49 50
 DMA_HandleTypeDef hdma_adc1;
50 51
 DMA_HandleTypeDef hdma_adc3;
51 52
 
53
+CRC_HandleTypeDef hcrc;
54
+
52 55
 I2C_HandleTypeDef hi2c2;
53 56
 
54 57
 TIM_HandleTypeDef htim6;
@@ -59,8 +62,11 @@ DMA_HandleTypeDef hdma_usart1_rx;
59 62
 DMA_HandleTypeDef hdma_usart1_tx;
60 63
 
61 64
 /* USER CODE BEGIN PV */
62
-uint32_t ADC1value[Bluecell_ADC1_MaxLength / 2] = {0,};
63
-uint32_t ADC3value[Bluecell_ADC3_MaxLength / 2] = {0,};
65
+volatile uint16_t ADC1value[4];
66
+volatile uint16_t ADC3value[5];
67
+volatile uint32_t ADC1_Average_value[4];
68
+volatile uint32_t ADC3_Average_value[5];
69
+
64 70
 volatile uint32_t AdcTimerCnt = 0;
65 71
 volatile uint32_t LedTimerCnt = 0;
66 72
 volatile uint32_t UartRxTimerCnt = 0;
@@ -77,6 +83,7 @@ static void MX_ADC1_Init(void);
77 83
 static void MX_ADC3_Init(void);
78 84
 static void MX_USART2_UART_Init(void);
79 85
 static void MX_TIM6_Init(void);
86
+static void MX_CRC_Init(void);
80 87
 static void MX_NVIC_Init(void);
81 88
 /* USER CODE BEGIN PFP */
82 89
 
@@ -99,6 +106,119 @@ int _write (int file, uint8_t *ptr, uint16_t len)
99 106
     HAL_UART_Transmit(&huart1, ptr, len,10);
100 107
     return len;
101 108
 }
109
+uint8_t adc1cnt = 0 ;
110
+uint8_t adc3cnt = 0 ;
111
+
112
+
113
+void HAL_ADC_ConvCpltCallback(ADC_HandleTypeDef* hadc)
114
+{
115
+//?��?��?�� 코드 ?��?��
116
+//만약 ?��?�� adc?���?? �???��?�� ?�� ?��?���?? ?��?���?? ?��?��?? 같이 조건�?? ?��?��
117
+
118
+    if(hadc->Instance == hadc1.Instance)
119
+    {
120
+        for(int i = 0; i < 5; i++){
121
+            ADC1_Average_value[i] += ADC1value[i]  ;
122
+        }
123
+        adc1cnt++;
124
+    }
125
+    if(hadc->Instance == hadc3.Instance)
126
+    {
127
+        for(int i = 0; i < 6; i++){
128
+            ADC3_Average_value[i] += ADC3value[i]  ;
129
+        }
130
+        adc3cnt++;
131
+    }
132
+
133
+}
134
+
135
+#if 0 // PYJ.2020.04.23_BEGIN -- 
136
+uint8_t eepdata[100];
137
+void eepromtest(){
138
+    memset(&eepdata[0],0x33,100);
139
+    for(int i = 0; i < 100; i ++ ){
140
+        printf("data[%d] : %x \r\n",i,eepdata[i]);
141
+        EEPROM_M24C08_Bytewrite(EEPROM_M24C08_ID,EEPROM_ATT_BASE + i,&eepdata[i],1);
142
+    }  
143
+    for(int i = 0; i < 100; i ++ ){
144
+        EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,EEPROM_ATT_BASE + i,&eepdata[i],1);
145
+        printf("data[%d] : %x \r\n",i,eepdata[i]);
146
+    }  
147
+//    EEPROM_M24C08_Read(EEPROM_M24C08_ID,EEPROM_ATT_BASE,&eepdata[0],100);
148
+//    for(int i = 0; i < 100; i ++ ){
149
+//        printf("data[%d] : %x \r\n",i,eepdata[i]);
150
+//    }    
151
+
152
+}
153
+uint8_t i2ctest[10] = {22,};
154
+uint8_t i2cTestData[1] = {44};
155
+#endif // PYJ.2020.04.23_END -- 
156
+uint16_t eepromtestarray[1024];
157
+uint16_t eepromtestReadarray[1024];
158
+uint8_t eepromtestarray1[EEPROM_WINDOW_STATUS_ADDRESDS];
159
+uint8_t eepromtestReadarray1[EEPROM_WINDOW_STATUS_ADDRESDS];
160
+
161
+void EEPROMTEST_J(){
162
+    int aa = 256;
163
+    for(int i = 0; i< 512; i++)
164
+        eepromtestarray[i] = i;
165
+    EEPROM_M24C08_Bytewrite(EEPROM_M24C08_ID,MAKE_ADDRESS(EEPROM_ATT_BASE     ,1),&eepromtestarray[0],0xFF);
166
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,MAKE_ADDRESS(EEPROM_ATT_BASE      ,1),&eepromtestReadarray[0],0xFF);
167
+//    EEPROM_M24C08_ByteRead(0xa0|0x01 ),MAKE_ADDRESS(EEPROM_ATT_BASE + 150,0),&eepromtestReadarray[150],150);
168
+    for(int i = 0; i< 128; i++)
169
+        printf("index [%d]: %d \r\n",i,eepromtestReadarray[i]);
170
+    EEPROM_M24C08_Bytewrite(EEPROM_M24C08_ID,MAKE_ADDRESS(EEPROM_ATT_BASE + aa    ,1),&eepromtestarray[128],0xFF);
171
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,MAKE_ADDRESS(EEPROM_ATT_BASE  + aa       ,1),&eepromtestReadarray[128],0xFF);
172
+    for(int i = 128; i< 256; i++)
173
+        printf("index [%d]: %d \r\n",i,eepromtestReadarray[i]);
174
+    EEPROM_M24C08_Bytewrite(EEPROM_M24C08_ID,MAKE_ADDRESS(EEPROM_ATT_BASE + aa * 2    ,1),&eepromtestarray[256],0xFF);
175
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID,MAKE_ADDRESS(EEPROM_ATT_BASE  + aa * 2       ,1),&eepromtestReadarray[256],0xFF);
176
+    for(int i = 256; i< 384; i++)
177
+        printf("index [%d]: %d \r\n",i,eepromtestReadarray[i]);
178
+#if 0 // PYJ.2020.04.23_BEGIN -- 
179
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID ,MAKE_ADDRESS(EEPROM_ATT_DL2_TABLE_ADDRESDS,0),&eepromtestReadarray[0],EEPROM_WINDOW_STATUS_ADDRESDS);
180
+    for(int i = 0; i< EEPROM_WINDOW_STATUS_ADDRESDS; i++)
181
+        printf("%d ",eepromtestReadarray[i]);
182
+       printf("\r\n");    
183
+    EEPROM_M24C08_ByteRead(EEPROM_M24C08_ID ,MAKE_ADDRESS(EEPROM_ATT_DL3_TABLE_ADDRESDS,0),&eepromtestReadarray[0],EEPROM_WINDOW_STATUS_ADDRESDS);
184
+    for(int i = 0; i< EEPROM_WINDOW_STATUS_ADDRESDS; i++)
185
+        printf("%d ",eepromtestReadarray[i]);
186
+           printf("\r\n");
187
+#endif // PYJ.2020.04.23_END -- 
188
+
189
+}
190
+#if 1 // PYJ.2020.04.23_BEGIN -- 
191
+void eepromtest_j1(){
192
+  for(int i = 0; i< 128; i++)
193
+      eepromtestarray[i] = i;
194
+
195
+  EEPROM_M24C08_write(EEPROM_M24C08_ID ,0,eepromtestarray,128);
196
+
197
+  EEPROM_M24C08_Read(EEPROM_M24C08_ID ,0,eepromtestReadarray,128);
198
+  
199
+   for(int i = 0; i< 128; i++)
200
+       printf("%d ",eepromtestReadarray[i]);
201
+          printf("\r\n");
202
+
203
+}
204
+#endif // PYJ.2020.04.23_END -- 
205
+#if 0 // PYJ.2020.04.23_BEGIN -- 
206
+void eepromtest_j1(){
207
+  for(int i = 0; i< 128; i++)
208
+        eepromtestarray[i] = i;
209
+
210
+  HAL_I2C_Mem_Write(&hi2c2,0xa0|((0x01&0x0300>>7)),(0x01&0xff),I2C_MEMADD_SIZE_16BIT,eepromtestarray,128,100);
211
+  HAL_Delay(10);
212
+  HAL_I2C_Mem_Read(&hi2c2,0xa0|((0x01&0x0300>>7)),(0x01&0xff),I2C_MEMADD_SIZE_16BIT,eepromtestReadarray,128,100);
213
+    for(int i = 0; i< 128; i++)
214
+        printf("%d ",eepromtestReadarray[i]);
215
+       printf("\r\n");
216
+
217
+
218
+}
219
+#endif // PYJ.2020.04.23_END -- 
220
+
221
+
102 222
 /* USER CODE END 0 */
103 223
 
104 224
 /**
@@ -136,27 +256,47 @@ int main(void)
136 256
   MX_ADC3_Init();
137 257
   MX_USART2_UART_Init();
138 258
   MX_TIM6_Init();
259
+  MX_CRC_Init();
139 260
 
140 261
   /* Initialize interrupts */
141 262
   MX_NVIC_Init();
142 263
   /* USER CODE BEGIN 2 */
264
+  while(!(HAL_ADCEx_Calibration_Start(&hadc3)==HAL_OK));
265
+  while(!(HAL_ADCEx_Calibration_Start(&hadc1)==HAL_OK));
266
+  HAL_ADC_Start_DMA(&hadc3, (uint16_t*)ADC3value, 5);
267
+  HAL_ADC_Start_DMA(&hadc1, (uint16_t*)ADC1value, 4);
268
+
143 269
   InitUartQueue(&TerminalQueue);
144 270
   setbuf(stdout, NULL);
145
-  while(!(HAL_ADCEx_Calibration_Start(&hadc1)==HAL_OK));
146
-  while(!(HAL_ADCEx_Calibration_Start(&hadc3)==HAL_OK));
147 271
   PE43711_PinInit();
148
-  HAL_ADC_Start_DMA(&hadc1, (uint32_t*)ADC1value, Bluecell_ADC1_MaxLength / 2);
149
-  HAL_ADC_Start_DMA(&hadc3, (uint32_t*)ADC3value, Bluecell_ADC3_MaxLength / 2);
272
+//  EEPROM_M24C08_Init();
273
+//  Bluecell_DataInit();
274
+
275
+#if 0 // PYJ.2020.04.22_BEGIN -- 
276
+  EEPROM_M24C08_write(0xA0,0,i2cTestData,1);
277
+  printf("i2c Test Data1 %d\r\n",i2ctest[0]);
278
+  EEPROM_M24C08_Read(0xA0,0x00,i2ctest,2);
279
+  printf("i2c Test Data2 %d\r\n",i2ctest[0]);
280
+  printf("i2c Test Data2 %d\r\n",i2ctest[1]);
281
+#endif // PYJ.2020.04.22_END -- 
150 282
   /* USER CODE END 2 */
151 283
 
152 284
   /* Infinite loop */
153 285
   /* USER CODE BEGIN WHILE */
286
+    uint16_t ret = 0;
287
+
288
+//    EEPROMTEST_J();
289
+    
290
+    
291
+
292
+
293
+    printf("Project Start\r\n");
154 294
   while (1)
155 295
   {
156 296
 //	  HAL_GPIO_TogglePin(GPIOG,GPIO_PIN_14);
157
-//	  HAL_Delay(1000);
158 297
     Boot_LED_Toggle();
159 298
     Uart_Check();
299
+    ADC_Check();
160 300
     /* USER CODE END WHILE */
161 301
 
162 302
     /* USER CODE BEGIN 3 */
@@ -222,9 +362,6 @@ static void MX_NVIC_Init(void)
222 362
   /* DMA1_Channel5_IRQn interrupt configuration */
223 363
   HAL_NVIC_SetPriority(DMA1_Channel5_IRQn, 0, 0);
224 364
   HAL_NVIC_EnableIRQ(DMA1_Channel5_IRQn);
225
-  /* ADC1_2_IRQn interrupt configuration */
226
-  HAL_NVIC_SetPriority(ADC1_2_IRQn, 0, 0);
227
-  HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
228 365
   /* I2C2_EV_IRQn interrupt configuration */
229 366
   HAL_NVIC_SetPriority(I2C2_EV_IRQn, 0, 0);
230 367
   HAL_NVIC_EnableIRQ(I2C2_EV_IRQn);
@@ -282,7 +419,7 @@ static void MX_ADC1_Init(void)
282 419
   */
283 420
   sConfig.Channel = ADC_CHANNEL_4;
284 421
   sConfig.Rank = ADC_REGULAR_RANK_1;
285
-  sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
422
+  sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5;
286 423
   if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
287 424
   {
288 425
     Error_Handler();
@@ -305,7 +442,7 @@ static void MX_ADC1_Init(void)
305 442
   }
306 443
   /** Configure Regular Channel 
307 444
   */
308
-  sConfig.Channel = ADC_CHANNEL_4;
445
+  sConfig.Channel = ADC_CHANNEL_12;
309 446
   sConfig.Rank = ADC_REGULAR_RANK_4;
310 447
   if (HAL_ADC_ConfigChannel(&hadc1, &sConfig) != HAL_OK)
311 448
   {
@@ -351,7 +488,7 @@ static void MX_ADC3_Init(void)
351 488
   */
352 489
   sConfig.Channel = ADC_CHANNEL_4;
353 490
   sConfig.Rank = ADC_REGULAR_RANK_1;
354
-  sConfig.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;
491
+  sConfig.SamplingTime = ADC_SAMPLETIME_239CYCLES_5;
355 492
   if (HAL_ADC_ConfigChannel(&hadc3, &sConfig) != HAL_OK)
356 493
   {
357 494
     Error_Handler();
@@ -394,6 +531,32 @@ static void MX_ADC3_Init(void)
394 531
 
395 532
 }
396 533
 
534
+/**
535
+  * @brief CRC Initialization Function
536
+  * @param None
537
+  * @retval None
538
+  */
539
+static void MX_CRC_Init(void)
540
+{
541
+
542
+  /* USER CODE BEGIN CRC_Init 0 */
543
+
544
+  /* USER CODE END CRC_Init 0 */
545
+
546
+  /* USER CODE BEGIN CRC_Init 1 */
547
+
548
+  /* USER CODE END CRC_Init 1 */
549
+  hcrc.Instance = CRC;
550
+  if (HAL_CRC_Init(&hcrc) != HAL_OK)
551
+  {
552
+    Error_Handler();
553
+  }
554
+  /* USER CODE BEGIN CRC_Init 2 */
555
+
556
+  /* USER CODE END CRC_Init 2 */
557
+
558
+}
559
+
397 560
 /**
398 561
   * @brief I2C2 Initialization Function
399 562
   * @param None
@@ -410,7 +573,7 @@ static void MX_I2C2_Init(void)
410 573
 
411 574
   /* USER CODE END I2C2_Init 1 */
412 575
   hi2c2.Instance = I2C2;
413
-  hi2c2.Init.ClockSpeed = 100000;
576
+  hi2c2.Init.ClockSpeed = 400000;
414 577
   hi2c2.Init.DutyCycle = I2C_DUTYCYCLE_2;
415 578
   hi2c2.Init.OwnAddress1 = 0;
416 579
   hi2c2.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;

+ 49 - 2
Src/stm32f1xx_hal_msp.c

@@ -129,7 +129,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
129 129
     hdma_adc1.Init.MemInc = DMA_MINC_ENABLE;
130 130
     hdma_adc1.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
131 131
     hdma_adc1.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
132
-    hdma_adc1.Init.Mode = DMA_NORMAL;
132
+    hdma_adc1.Init.Mode = DMA_CIRCULAR;
133 133
     hdma_adc1.Init.Priority = DMA_PRIORITY_LOW;
134 134
     if (HAL_DMA_Init(&hdma_adc1) != HAL_OK)
135 135
     {
@@ -138,6 +138,9 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
138 138
 
139 139
     __HAL_LINKDMA(hadc,DMA_Handle,hdma_adc1);
140 140
 
141
+    /* ADC1 interrupt Init */
142
+    HAL_NVIC_SetPriority(ADC1_2_IRQn, 0, 0);
143
+    HAL_NVIC_EnableIRQ(ADC1_2_IRQn);
141 144
   /* USER CODE BEGIN ADC1_MspInit 1 */
142 145
 
143 146
   /* USER CODE END ADC1_MspInit 1 */
@@ -171,7 +174,7 @@ void HAL_ADC_MspInit(ADC_HandleTypeDef* hadc)
171 174
     hdma_adc3.Init.MemInc = DMA_MINC_ENABLE;
172 175
     hdma_adc3.Init.PeriphDataAlignment = DMA_PDATAALIGN_HALFWORD;
173 176
     hdma_adc3.Init.MemDataAlignment = DMA_MDATAALIGN_HALFWORD;
174
-    hdma_adc3.Init.Mode = DMA_NORMAL;
177
+    hdma_adc3.Init.Mode = DMA_CIRCULAR;
175 178
     hdma_adc3.Init.Priority = DMA_PRIORITY_LOW;
176 179
     if (HAL_DMA_Init(&hdma_adc3) != HAL_OK)
177 180
     {
@@ -252,6 +255,50 @@ void HAL_ADC_MspDeInit(ADC_HandleTypeDef* hadc)
252 255
 
253 256
 }
254 257
 
258
+/**
259
+* @brief CRC MSP Initialization
260
+* This function configures the hardware resources used in this example
261
+* @param hcrc: CRC handle pointer
262
+* @retval None
263
+*/
264
+void HAL_CRC_MspInit(CRC_HandleTypeDef* hcrc)
265
+{
266
+  if(hcrc->Instance==CRC)
267
+  {
268
+  /* USER CODE BEGIN CRC_MspInit 0 */
269
+
270
+  /* USER CODE END CRC_MspInit 0 */
271
+    /* Peripheral clock enable */
272
+    __HAL_RCC_CRC_CLK_ENABLE();
273
+  /* USER CODE BEGIN CRC_MspInit 1 */
274
+
275
+  /* USER CODE END CRC_MspInit 1 */
276
+  }
277
+
278
+}
279
+
280
+/**
281
+* @brief CRC MSP De-Initialization
282
+* This function freeze the hardware resources used in this example
283
+* @param hcrc: CRC handle pointer
284
+* @retval None
285
+*/
286
+void HAL_CRC_MspDeInit(CRC_HandleTypeDef* hcrc)
287
+{
288
+  if(hcrc->Instance==CRC)
289
+  {
290
+  /* USER CODE BEGIN CRC_MspDeInit 0 */
291
+
292
+  /* USER CODE END CRC_MspDeInit 0 */
293
+    /* Peripheral clock disable */
294
+    __HAL_RCC_CRC_CLK_DISABLE();
295
+  /* USER CODE BEGIN CRC_MspDeInit 1 */
296
+
297
+  /* USER CODE END CRC_MspDeInit 1 */
298
+  }
299
+
300
+}
301
+
255 302
 /**
256 303
 * @brief I2C MSP Initialization
257 304
 * This function configures the hardware resources used in this example