Pārlūkot izejas kodu

Carrier Defalut Value 변경 / Flash Temp Data 적재 기능 추가

PYJ 4 gadi atpakaļ
vecāks
revīzija
1fe480a089

+ 1 - 0
Bluecell_Inc/flash.h

@@ -30,6 +30,7 @@
30 30
 #define FLASH_USER_BANK2_START_ADDR ((uint32_t)0x08048000)
31 31
 #define FLASH_USER_BANK2_END_ADDR FLASH_USER_BANK2_START_ADDR + ((uint32_t)0x1FF80)
32 32
 
33
+#define FLASH_USER_TEMPDATA_START_ADDR ((uint32_t)0x08040000)
33 34
 
34 35
 
35 36
 

+ 82 - 22
Bluecell_Src/Bluecell_operate.c

@@ -130,6 +130,7 @@ void Temp_Shutdown_ONOFF(uint8_t val);
130 130
 void UL_Path_OnOff(uint8_t Index,uint8_t value,uint8_t* path,uint8_t* PrevAtten,uint8_t* retrycnt,uint8_t* PrevRetryCnt);
131 131
 int16_t Temperature_Offset_Get(int8_t* Temp_Table,int8_t CurrTemp);
132 132
 int Bluecell_RoundCalc(double data);
133
+void DLI_FRBT_ONOFF_Set(bool);
133 134
 
134 135
 
135 136
 /***************************************************************************************/
@@ -4281,6 +4282,7 @@ void Factory_Set(){
4281 4282
     type +=  HAL_GPIO_ReadPin(UNIT_ID3_GPIO_Port,UNIT_ID3_Pin) << 3;
4282 4283
 //    printf("Factory Set Start \r\n");
4283 4284
     /*ALARM MASK*/
4285
+    
4284 4286
     bluecell_Currdatastatus.ALARM_MASK1 = 0x80;
4285 4287
     bluecell_Currdatastatus.ALARM_MASK2 = 0xFF ;
4286 4288
     bluecell_Currdatastatus.ALARM_MASK3 = 0xFF;
@@ -4291,7 +4293,7 @@ void Factory_Set(){
4291 4293
     /*Temp High Thread Hold*/
4292 4294
     bluecell_Currdatastatus.Temp_High_Threshold = Temp_THREADHOLD_DEFAULT;
4293 4295
     /*Carrier On off*/
4294
-    bluecell_Currdatastatus.Carrier_ON_OFF = Temp_THREADHOLD_DEFAULT;    
4296
+    bluecell_Currdatastatus.Carrier_ON_OFF = CARRIER_DEFAULT;    
4295 4297
     /*DL PATH */
4296 4298
     bluecell_Currdatastatus.ATT_DL1_PATH = PATH_DEFAULT;    
4297 4299
     bluecell_Currdatastatus.ATT_DL2_PATH = PATH_DEFAULT;    
@@ -4544,8 +4546,7 @@ void Factory_Set(){
4544 4546
     bluecell_Prevdatastatus.ATT_UL3_L = 0xFF;    
4545 4547
     bluecell_Prevdatastatus.ATT_UL4_L = 0xFF;    
4546 4548
 
4547
-
4548
-
4549
+    DLI_FRBT_ONOFF_Set(true);
4549 4550
     
4550 4551
     
4551 4552
 
@@ -4791,7 +4792,7 @@ void TimeSetting(uint8_t* data){
4791 4792
 //    printf("Time Set Complete\r\n");
4792 4793
 }
4793 4794
 void Carrier_ONOFF(uint8_t val){
4794
-    if(val == 1){
4795
+    if(val != 0){
4795 4796
         bluecell_Currdatastatus.ATT_DL1_PATH = PATH_DEFAULT;    
4796 4797
         bluecell_Currdatastatus.ATT_DL2_PATH = PATH_DEFAULT;    
4797 4798
         bluecell_Currdatastatus.ATT_DL3_PATH = PATH_DEFAULT;    
@@ -5329,7 +5330,32 @@ void Alarm_Report_Send(uint16_t Alarm_type,uint8_t val){
5329 5330
     Uart1_Data_Send(&Alarm_ReportData[0],sizeof(Alarm_ReportData));
5330 5331
 //    printf(" Alarm_ReportData[MBIC_PAYLOADSTART + 42] : %x \r\n", Alarm_ReportData[MBIC_PAYLOADSTART + 42]);
5331 5332
 }
5332
-
5333
+void DLI_FRBT_ONOFF_Set(bool val){
5334
+    if(val == 0){                
5335
+        bluecell_Currdatastatus.DLI_FRBT_Status = FRBT_IDEL; 
5336
+        for(int i = 0; i < DLI_FRBT_Time_Index_Max; i++){
5337
+           PrevFRBT_Day[DLI_FRBT_Time_Year + i] = FRBT_Day[DLI_FRBT_Time_Year + i] = 0;
5338
+        }
5339
+        Last_Day = 0;
5340
+        Prev_Last_Day = 0;
5341
+        FRBT_UserCtrl = 0;                    
5342
+    }
5343
+    else{
5344
+        bluecell_Currdatastatus.DLI_FRBT_Status = FRBT_TRACKING; 
5345
+    }
5346
+    DLI_FRBT_ON_OFF_Set(val);
5347
+    bluecell_Currdatastatus.DLI_FRBT_Atten1_H = DLI_FRBT_ATTEN_DEFALUT;
5348
+    bluecell_Currdatastatus.DLI_FRBT_Atten2_H = DLI_FRBT_ATTEN_DEFALUT;
5349
+    bluecell_Currdatastatus.DLI_FRBT_Atten3_H = DLI_FRBT_ATTEN_DEFALUT;
5350
+    bluecell_Currdatastatus.DLI_FRBT_Atten4_H = DLI_FRBT_ATTEN_DEFALUT;
5351
+    bluecell_Currdatastatus.DLI_FRBT_Atten1_L= DLI_FRBT_ATTEN_DEFALUT;    
5352
+    bluecell_Currdatastatus.DLI_FRBT_Atten2_L= DLI_FRBT_ATTEN_DEFALUT;    
5353
+    bluecell_Currdatastatus.DLI_FRBT_Atten3_L= DLI_FRBT_ATTEN_DEFALUT;    
5354
+    bluecell_Currdatastatus.DLI_FRBT_Atten4_L= DLI_FRBT_ATTEN_DEFALUT;    
5355
+    bluecell_Currdatastatus.DLI_FRBT_D_Day  = DLI_FRBT_DAY_DEFAULT;
5356
+    Bluecell_StructCpy(&DataWrite[0],&bluecell_Currdatastatus.bluecell_header,sizeof(BLUESTATUS_st));
5357
+    EEPROM_M24C08_write(EEPROM_M24C08_ID ,(EEPROM_WINDOW_STATUS_ADDRESDS),&DataWrite[0],sizeof(BLUESTATUS_st));
5358
+}
5333 5359
 bool MBIC_Operate(uint8_t* data){
5334 5360
 //    Bluecell_StructCpy(&Txdata[0],&bluecell_Currdatastatus.bluecell_header,sizeof(BLUESTATUS_st));
5335 5361
 	uint8_t datatype = data[MBIC_PAYLOADSTART + 1];
@@ -5421,6 +5447,8 @@ bool MBIC_Operate(uint8_t* data){
5421 5447
     else if(cmd == MBIC_SET){
5422 5448
        protocolReplay:
5423 5449
         datatype = data[MBIC_PAYLOADSTART + 1];
5450
+//        printf("datatype : %x \r\n",datatype);
5451
+//        printf("bluecell_Currdatastatus.Carrier_ON_OFF : %d \r\n",bluecell_Currdatastatus.Carrier_ON_OFF);
5424 5452
         switch(datatype){
5425 5453
             case  Alarm_Mask                              :
5426 5454
                 bluecell_Currdatastatus.ALARM_MASK1 = data[MBIC_PAYLOADSTART + 3]; 
@@ -5475,6 +5503,7 @@ bool MBIC_Operate(uint8_t* data){
5475 5503
                 Bluecell_StructCpy(&DataWrite[0],&bluecell_Currdatastatus.bluecell_header,sizeof(BLUESTATUS_st));
5476 5504
                 EEPROM_M24C08_write(EEPROM_M24C08_ID ,(EEPROM_WINDOW_STATUS_ADDRESDS),&DataWrite[0],sizeof(BLUESTATUS_st));
5477 5505
                 EEPROM_M24C08_Read(EEPROM_M24C08_ID,EEPROM_WINDOW_STATUS_ADDRESDS,&bluecell_Currdatastatus.bluecell_header,sizeof(BLUESTATUS_st) );
5506
+                printf("bluecell_Currdatastatus.FRBT ON OFF : %d \r\n",bluecell_Currdatastatus.DLI_FRBT_ON_OFF);
5478 5507
                 printf("bluecell_Currdatastatus.CPU_Bank_Select : %d \r\n",bluecell_Currdatastatus.CPU_Bank_Select);
5479 5508
                 printf("I will Booting Bank : %d \r\n",bluecell_Currdatastatus.CPU_Current_Bank);
5480 5509
                 printf("Reset : \r\n");
@@ -5526,12 +5555,18 @@ bool MBIC_Operate(uint8_t* data){
5526 5555
 //                printf(" bluecell_Currdatastatus.ATT_DL1_PATH : %d \r\n", bluecell_Currdatastatus.ATT_DL1_PATH);
5527 5556
                 break;
5528 5557
             case  Carrier_ON_OFF                          :
5558
+//                for(int tt = 0; tt < 4; tt++)
5559
+//                    printf("Carrier : data[MBIC_PAYLOADSTART + %d] : %x \r\n",tt,data[MBIC_PAYLOADSTART + tt]);
5529 5560
                 bluecell_Currdatastatus.Carrier_ON_OFF = data[MBIC_PAYLOADSTART + 3]; 
5530 5561
                 Carrier_ONOFF(bluecell_Currdatastatus.Carrier_ON_OFF);
5562
+//                printf("bluecell_Currdatastatus.Carrier_ON_OFF : %x \r\n",bluecell_Currdatastatus.Carrier_ON_OFF);
5531 5563
                 break;
5532 5564
             case  DLI_RF_Path1_ON_OFF             :
5533
-                if(bluecell_Currdatastatus.Carrier_ON_OFF == false)
5534
-                    return true;
5565
+//                printf("data[MBIC_PAYLOADSTART + 3] : %d \r\n",data[MBIC_PAYLOADSTART + 3]);
5566
+                if(bluecell_Currdatastatus.Carrier_ON_OFF == false){
5567
+                      break;
5568
+//                    return true;
5569
+                }
5535 5570
                 if(data[MBIC_PAYLOADSTART + 3] != 0)
5536 5571
                     bluecell_Currdatastatus.Path_TempSave_Bit |= 0x80;
5537 5572
                 else
@@ -5544,8 +5579,12 @@ bool MBIC_Operate(uint8_t* data){
5544 5579
                     &bluecell_Prevdatastatus.DLI_Shutdown_Retry_Count1)  ;      
5545 5580
                 break;
5546 5581
             case  DLI_RF_Path2_ON_OFF                     :
5547
-                if(bluecell_Currdatastatus.Carrier_ON_OFF == false)
5548
-                    return true;
5582
+//                printf("data[MBIC_PAYLOADSTART + 3] : %d \r\n",data[MBIC_PAYLOADSTART + 3]);
5583
+                if(bluecell_Currdatastatus.Carrier_ON_OFF == false){
5584
+                    break;
5585
+//                    return true;
5586
+                }
5587
+
5549 5588
                 if(data[MBIC_PAYLOADSTART + 3] != 0)
5550 5589
                     bluecell_Currdatastatus.Path_TempSave_Bit |= 0x40; 
5551 5590
                 else
@@ -5559,8 +5598,11 @@ bool MBIC_Operate(uint8_t* data){
5559 5598
                     &bluecell_Prevdatastatus.DLI_Shutdown_Retry_Count2)  ;                  
5560 5599
                 break;
5561 5600
             case  DLI_RF_Path3_ON_OFF                     :
5562
-                if(bluecell_Currdatastatus.Carrier_ON_OFF == false)
5563
-                    return true;
5601
+//                printf("data[MBIC_PAYLOADSTART + 3] : %d \r\n",data[MBIC_PAYLOADSTART + 3]);
5602
+                if(bluecell_Currdatastatus.Carrier_ON_OFF == false){
5603
+                    break;
5604
+//                    return true;
5605
+                }
5564 5606
                 if(data[MBIC_PAYLOADSTART + 3] != 0)
5565 5607
                     bluecell_Currdatastatus.Path_TempSave_Bit |= 0x20;
5566 5608
                     else
@@ -5574,8 +5616,12 @@ bool MBIC_Operate(uint8_t* data){
5574 5616
 
5575 5617
                 break;
5576 5618
             case  DLI_RF_Path4_ON_OFF                     :
5577
-                if(bluecell_Currdatastatus.Carrier_ON_OFF == false)
5578
-                    return true;
5619
+//                printf("data[MBIC_PAYLOADSTART + 3] : %d \r\n",data[MBIC_PAYLOADSTART + 3]);
5620
+                if(bluecell_Currdatastatus.Carrier_ON_OFF == false){
5621
+                    break;
5622
+//                    return true;
5623
+                }
5624
+
5579 5625
                 if(data[MBIC_PAYLOADSTART + 3] != 0)
5580 5626
                     bluecell_Currdatastatus.Path_TempSave_Bit |= 0x10;
5581 5627
                 else
@@ -5797,8 +5843,12 @@ bool MBIC_Operate(uint8_t* data){
5797 5843
 
5798 5844
                 break;
5799 5845
             case  ULO_RF_Path1_ON_OFF            :
5800
-                if(bluecell_Currdatastatus.Carrier_ON_OFF == false)
5801
-                    return true;
5846
+//                printf("data[MBIC_PAYLOADSTART + 3] : %d \r\n",data[MBIC_PAYLOADSTART + 3]);
5847
+                if(bluecell_Currdatastatus.Carrier_ON_OFF == false){
5848
+                    break;
5849
+//                    return true;
5850
+                }
5851
+
5802 5852
                 if(data[MBIC_PAYLOADSTART + 3] != 0)
5803 5853
                     bluecell_Currdatastatus.Path_TempSave_Bit |= 0x08;
5804 5854
                 else
@@ -5812,8 +5862,11 @@ bool MBIC_Operate(uint8_t* data){
5812 5862
 
5813 5863
                 break;
5814 5864
             case  ULO_RF_Path2_ON_OFF                    :
5815
-                if(bluecell_Currdatastatus.Carrier_ON_OFF == false)
5816
-                  return true;
5865
+//                printf("data[MBIC_PAYLOADSTART + 3] : %d \r\n",data[MBIC_PAYLOADSTART + 3]);
5866
+                if(bluecell_Currdatastatus.Carrier_ON_OFF == false){
5867
+                    break;
5868
+//                    return true;
5869
+                }
5817 5870
                 if(data[MBIC_PAYLOADSTART + 3] != 0)
5818 5871
                     bluecell_Currdatastatus.Path_TempSave_Bit |= 0x04;
5819 5872
                 else
@@ -5826,8 +5879,11 @@ bool MBIC_Operate(uint8_t* data){
5826 5879
                     &bluecell_Prevdatastatus.ULO_Shutdown_Retry_Count2)  ;  
5827 5880
                 break;
5828 5881
             case  ULO_RF_Path3_ON_OFF                    :
5829
-                if(bluecell_Currdatastatus.Carrier_ON_OFF == false)
5830
-                  return true;
5882
+//                printf("data[MBIC_PAYLOADSTART + 3] : %d \r\n",data[MBIC_PAYLOADSTART + 3]);
5883
+                if(bluecell_Currdatastatus.Carrier_ON_OFF == false){
5884
+                    break;
5885
+//                    return true;
5886
+                }
5831 5887
                 if(data[MBIC_PAYLOADSTART + 3] != 0)
5832 5888
                     bluecell_Currdatastatus.Path_TempSave_Bit |= 0x02;
5833 5889
                 else
@@ -5840,8 +5896,11 @@ bool MBIC_Operate(uint8_t* data){
5840 5896
                     &bluecell_Prevdatastatus.ULO_Shutdown_Retry_Count3)  ;  
5841 5897
                 break;
5842 5898
             case  ULO_RF_Path4_ON_OFF                    :
5843
-                if(bluecell_Currdatastatus.Carrier_ON_OFF == false)
5844
-                  return true;
5899
+//                printf("data[MBIC_PAYLOADSTART + 3] : %d \r\n",data[MBIC_PAYLOADSTART + 3]);
5900
+                if(bluecell_Currdatastatus.Carrier_ON_OFF == false){
5901
+                    break;
5902
+//                    return true;
5903
+                }
5845 5904
                 if(data[MBIC_PAYLOADSTART + 3] != 0)
5846 5905
                     bluecell_Currdatastatus.Path_TempSave_Bit |= 0x01;
5847 5906
                 else
@@ -5961,7 +6020,7 @@ bool MBIC_Operate(uint8_t* data){
5961 6020
 			    tempdata  = ULO_LEVEL_HIGH_THREADHOLD_DEFAULT;
5962 6021
 			    bluecell_Currdatastatus.ULO_Level_High_Threshold_H = ((tempdata & 0xFF00) >> 8);
5963 6022
 			    bluecell_Currdatastatus.ULO_Level_High_Threshold_L = ((tempdata & 0x00FF));    				
5964
-//                bluecell_Currdatastatus.ULO_Level_High_Threshold_default = data[MBIC_PAYLOADSTART + 3]; 
6023
+//              bluecell_Currdatastatus.ULO_Level_High_Threshold_default = data[MBIC_PAYLOADSTART + 3]; 
5965 6024
                 break;
5966 6025
 #if 0 // PYJ.2020.09.03_BEGIN -- 
5967 6026
             case ULO_SelfTest1:
@@ -6051,6 +6110,7 @@ bool MBIC_Operate(uint8_t* data){
6051 6110
         Length = MBIC_DataSend(data);
6052 6111
         Bluecell_StructCpy(&DataWrite[0],&bluecell_Currdatastatus.bluecell_header,sizeof(BLUESTATUS_st));
6053 6112
         EEPROM_M24C08_write(EEPROM_M24C08_ID ,(EEPROM_WINDOW_STATUS_ADDRESDS),&DataWrite[0],sizeof(BLUESTATUS_st));
6113
+//        printf("HFR Command Exit\r\n");
6054 6114
     }
6055 6115
     else if(cmd == MBIC_Table_Get){
6056 6116
         /*Table Get */

+ 3 - 2
Bluecell_Src/MBIC_Bootloader.c

@@ -13,6 +13,7 @@
13 13
 #include "flash.h"
14 14
 #include "CRC.h"
15 15
 #include "uart.h"
16
+#include "eeprom.h"
16 17
 
17 18
 extern bool EraseInit;
18 19
 
@@ -20,7 +21,8 @@ extern uint8_t Bank_Flash_write(uint8_t* data,uint32_t StartBankAddress);
20 21
 extern void MBIC_DataErase_Func(uint8_t bank_num);
21 22
 extern uint8_t MBIC_APIFLASH_Func(uint8_t* data,uint32_t size,uint8_t bank_num);
22 23
 extern void MBIC_DataBankWrite(uint8_t BankNum);
23
-
24
+extern void DLI_FRBT_ONOFF_Set(bool);
25
+extern uint8_t DataWrite[sizeof(BLUESTATUS_st)];
24 26
 
25 27
 
26 28
 
@@ -474,7 +476,6 @@ void MBIC_Bootloader_FirmwareUpdate(uint8_t* data){
474 476
                 printf("Crc Success \r\n");
475 477
             }else{
476 478
                 data[MBIC_PAYLOADSTART + index++] = 0;  
477
-                printf("Crc Failed \r\n");                
478 479
             }
479 480
             data[MBIC_PAYLOADSTART + index++] = 1;    
480 481
             

+ 5 - 4
Bluecell_Src/eeprom.c

@@ -89,6 +89,7 @@ void EEPROM_M24C08_Init(void){
89 89
 //    ALC_TEMP[2] = bluecell_Currdatastatus.MBIC_ULO_ALC_Atten3_H << 8 | bluecell_Currdatastatus.MBIC_ULO_ALC_Atten3_L;
90 90
 //    ALC_TEMP[3] = bluecell_Currdatastatus.MBIC_ULO_ALC_Atten4_H << 8 | bluecell_Currdatastatus.MBIC_ULO_ALC_Atten4_L;
91 91
     EEPROM_M24C08_Read(EEPROM_M24C08_ID,EEPROM_WINDOW_STATUS_ADDRESDS,&bluecell_Currdatastatus.bluecell_header,sizeof(BLUESTATUS_st) );
92
+    printf("bluecell_Currdatastatus.DLI_FRBT : %x \r\n",bluecell_Currdatastatus.DLI_FRBT_ON_OFF);
92 93
 //    EEPROM_DataCheck();
93 94
 
94 95
     EEPROM_M24C08_Read(EEPROM_M24C08_ID,EEPROM_ATT_BASE              ,&Att_DL1.Table_0_0_dBm,sizeof(ATT_TABLE_st) );
@@ -271,13 +272,13 @@ void EEPROM_M24C08_Init(void){
271 272
         bluecell_Currdatastatus.ATT_UL4_L = bluecell_Currdatastatus.SelfTest_ATT_UL4_L ;                    
272 273
     }
273 274
     bluecell_Currdatastatus.SelfTest = false;
274
-printf("bluecell_Currdatastatus.DLI_Level_High_Threshold_H : %x \r\n",bluecell_Currdatastatus.DLI_Level_High_Threshold_H);
275
-printf("bluecell_Currdatastatus.DLI_Level_High_Threshold_L : %x \r\n",bluecell_Currdatastatus.DLI_Level_High_Threshold_L);
275
+//printf("bluecell_Currdatastatus.DLI_Level_High_Threshold_H : %x \r\n",bluecell_Currdatastatus.DLI_Level_High_Threshold_H);
276
+//printf("bluecell_Currdatastatus.DLI_Level_High_Threshold_L : %x \r\n",bluecell_Currdatastatus.DLI_Level_High_Threshold_L);
276 277
 //    bluecell_Currdatastatus.DLI_FRBT_Status = 7;
277 278
     bluecell_Currdatastatus.ALARM_TESTMODE = 0;
278 279
     bluecell_Currdatastatus.Type = 0;
279
-
280
-    if(bluecell_Currdatastatus.Carrier_ON_OFF == true){
280
+    printf("bluecell_Currdatastatus.Carrier_ON_OFF : %d \r\n",bluecell_Currdatastatus.Carrier_ON_OFF);
281
+    if(bluecell_Currdatastatus.Carrier_ON_OFF != false){
281 282
         if(bluecell_Currdatastatus.Path_TempSave_Bit & 0x80)
282 283
             bluecell_Currdatastatus.ATT_DL1_PATH = true;
283 284
         else

+ 72 - 58
Bluecell_Src/flash.c

@@ -9,6 +9,11 @@
9 9
 #include "MBIC_Bootloader.h"
10 10
 #include "bluecell_operate.h"
11 11
 #include "eeprom.h"
12
+
13
+
14
+
15
+bool MBIC_APIFLASH_Byte_Func(uint8_t data,uint32_t Addr,uint32_t size);
16
+
12 17
 uint8_t flashinit = 0;
13 18
 uint32_t Address = FLASH_USER_START_ADDR;
14 19
 volatile static uint32_t UserAddress;
@@ -49,6 +54,26 @@ uint8_t CurrFlash_BankCheck(){
49 54
     return HFR_BANK2_SEL;
50 55
 }
51 56
 
57
+void Flash_TempDataRead(uint8_t Bank){
58
+    uint32_t  CurrAddress = 0;
59
+    uint32_t i = 0;
60
+    //uint8_t ret = 0;
61
+    CurrAddress = FLASH_USER_TEMPDATA_START_ADDR;
62
+    
63
+    uint8_t* Currdata = (uint8_t*)CurrAddress;
64
+    //'1: BANK1, 2: BANK2, 3: Factory 
65
+     printf("Currdata[0] : %x \r\n",Currdata[0]);    
66
+    if(Currdata[0] == 0xFF){
67
+        bluecell_Currdatastatus.DLI_FRBT_ON_OFF = true;
68
+        MBIC_APIFLASH_Byte_Func(0,FLASH_USER_TEMPDATA_START_ADDR,1);
69
+        printf("FRBT Force ON\r\n");            
70
+    }else{
71
+        printf("Already Setting is completed\r\n");
72
+    }
73
+    printf("Currdata[0] : %x \r\n",Currdata[0]);    
74
+
75
+
76
+}
52 77
 
53 78
 void Flash_InitRead() // ?占쏙옙湲고븿?占쏙옙
54 79
 {
@@ -750,64 +775,6 @@ uint8_t MBIC_APIFLASH_Func(uint8_t* data,uint32_t size,uint8_t bank_num){
750 775
       (area defined by FLASH_USER_START_ADDR and FLASH_USER_END_ADDR) ***********/
751 776
     
752 777
     /* Fill EraseInit structure*/
753
-#if 0 // PYJ.2020.06.29_BEGIN -- 
754
-    if(EraseInit == false){
755
-    ret = bluecell_Currdatastatus.CPU_Current_Bank;
756
-    if(bank_num == HFR_AUTO_SEL){
757
-        if(ret == HFR_BANK2)
758
-            bank_num = HFR_BANK1;
759
-        else
760
-            bank_num = HFR_BANK2;
761
-    }else{
762
-        if(ret == HFR_BANK2)
763
-            bank_num = HFR_BANK1;
764
-        else
765
-            bank_num = HFR_BANK2;
766
-
767
-    }
768
-    printf("Curr Bank BANK %d I will download Bank2 \r\n",ret,bank_num);
769
-    
770
-
771
-    if(bank_num == HFR_BANK2){
772
-        EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
773
-        EraseInitStruct.PageAddress = FLASH_USER_BANK2_START_ADDR;
774
-        EraseInitStruct.NbPages     = ((FLASH_USER_BANK2_END_ADDR - FLASH_USER_BANK2_START_ADDR) / FLASH_PAGE_SIZE) + 1;
775
-        MBIC_Address = FLASH_USER_BANK2_START_ADDR;
776
-        printf("I will download Bank2 \r\n");
777
-        printf("Erase BANK 2 \r\n");
778
-    }else{
779
-        EraseInitStruct.TypeErase   = FLASH_TYPEERASE_PAGES;
780
-        EraseInitStruct.PageAddress = FLASH_USER_BANK1_START_ADDR;
781
-        EraseInitStruct.NbPages     = ((FLASH_USER_BANK1_END_ADDR - FLASH_USER_BANK1_START_ADDR) / FLASH_PAGE_SIZE) + 1;
782
-        MBIC_Address = FLASH_USER_BANK1_START_ADDR;
783
-        printf("I will download Bank1 \r\n");        
784
-        printf("Erase BANK 1 \r\n");        
785
-    }
786
-        printf("NbPages : %x \r\n",EraseInitStruct.NbPages );
787
-        printf("EraseInitStruct.PageAddress : %x \r\n",EraseInitStruct.PageAddress);
788
-
789
-        printf("Erase Start\r\n");
790
-        if (HAL_FLASHEx_Erase(&EraseInitStruct, &PAGEError) != HAL_OK)
791
-        {
792
-          /*
793
-            Error occurred while page erase.
794
-            User can add here some code to deal with this error.
795
-            PAGEError will contain the faulty page and then to know the code error on this page,
796
-            user can call function 'HAL_FLASH_GetError()'
797
-          */
798
-          /* Infinite loop */
799
-          while (1)
800
-          {
801
-            /* Make LED2 blink (100ms on, 2s off) to indicate error in Erase operation */
802
-            printf("HAL_FLASHEx_Erase Error\r\n");
803
-            HAL_Delay(2000);
804
-          }
805
-        }
806
-        EraseInit = true;
807
-        printf("Erase End\r\n");
808
-    }
809
-#endif // PYJ.2020.06.29_END -- 
810
-
811 778
     /* Program the user Flash area word by word
812 779
       (area defined by FLASH_USER_START_ADDR and FLASH_USER_END_ADDR) ***********/
813 780
     
@@ -848,6 +815,53 @@ uint8_t MBIC_APIFLASH_Func(uint8_t* data,uint32_t size,uint8_t bank_num){
848 815
         MemoryProgramStatus != 0: number of words not programmed correctly ******/
849 816
 }
850 817
     
818
+bool MBIC_APIFLASH_Byte_Func(uint8_t data,uint32_t Addr,uint32_t size){
819
+    //static FLASH_EraseInitTypeDef EraseInitStruct;
820
+    //static uint32_t PAGEError = 0;
821
+    static uint32_t DownloadIndex;
822
+    static __IO uint32_t data32 = 0 , MemoryProgramStatus = 0;
823
+    int dataindex = 0;
824
+    uint32_t writedata = 0;
825
+    HAL_FLASH_Unlock();
826
+    //uint32_t i = 0;
827
+    uint8_t ret = 0;
828
+
829
+    /* Erase the user Flash area
830
+      (area defined by FLASH_USER_START_ADDR and FLASH_USER_END_ADDR) ***********/
831
+    
832
+    /* Fill EraseInit structure*/
833
+    /* Program the user Flash area word by word
834
+      (area defined by FLASH_USER_START_ADDR and FLASH_USER_END_ADDR) ***********/
835
+    
836
+//    MBIC_Address = FLASH_USER_BANK1_START_ADDR;
837
+    printf("HAL_FLASH_Program Start %x \r\n",Addr);
838
+    DownloadIndex += size;
839
+     for(int downindex = 0; downindex < size; downindex+=4)
840
+     {
841
+       writedata  = data ;
842
+       writedata += 0xFF << 8 ;
843
+       writedata += 0xFF << 16;
844
+       writedata += 0xFF << 24;      
845
+       if (HAL_FLASH_Program(FLASH_TYPEPROGRAM_WORD, Addr,writedata) == HAL_OK)
846
+       {
847
+         Addr +=  4;
848
+       }
849
+       else
850
+       {
851
+           printf("HAL_FLASH_Program Error\r\n");
852
+           printf("Flash Failed %x \r\n",Addr);
853
+       }
854
+     }
855
+
856
+     printf("HAL_FLASH_Program END   %x \r\n",Addr);
857
+    /* Lock the Flash to disable the flash control register access (recommended
858
+       to protect the FLASH memory against possible unwanted operation) *********/
859
+    HAL_FLASH_Lock();
860
+    /* Check if the programmed data is OK
861
+        MemoryProgramStatus = 0: data programmed correctly
862
+        MemoryProgramStatus != 0: number of words not programmed correctly ******/
863
+}
864
+    
851 865
 
852 866
 #endif // PYJ.2020.06.24_END -- 
853 867
 

+ 1 - 0
Src/main.c

@@ -336,6 +336,7 @@ int main(void)
336 336
   Flash_InitRead();
337 337
   Booting_LedInit();
338 338
   HFR_TypeInit();
339
+  Flash_TempDataRead(bluecell_Currdatastatus.CPU_Current_Bank);
339 340
   InitUartQueue(&TerminalQueue);
340 341
   bluecell_Currdatastatus.LED_TEST = true;
341 342
   Led_ToggleCntSet = 6; // Booting Led 3Cnt  ,Led Test 10Cnt