![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
forkd
Fork of LGstaandart by
Diff: main.c
- Revision:
- 136:19b9e6abb86f
- Parent:
- 135:c1e30e0e8949
- Child:
- 138:14a0c452cf32
diff -r c1e30e0e8949 -r 19b9e6abb86f main.c --- a/main.c Thu Apr 14 16:48:48 2016 +0000 +++ b/main.c Fri Apr 15 14:20:15 2016 +0000 @@ -29,83 +29,29 @@ ******************************************************************************/ Device device; //Single global for all device hardware-independent algorithm #define IMG_START_SECTOR 0x00010000 /* Sector 16 */ -#define IMG_END_SECTOR 0x00037FFF /* Sector 20 */ +#define IMG_END_SECTOR 0x00017FFF /* Sector 20 */ + /* #define IMG_START_SECTOR 0x00030000//0x00010000 /* Sector 16 #define IMG_END_SECTOR 0x00037FFF */ -unsigned int addres = 0x1fff1fff; +unsigned int addres; + uint32_t Result[5]; extern uint32_t CMD_Mode; unsigned int secPuls; float DACF, K_DAC; int tempAMP; +//unsigned int *Add; + +unsigned int status; +unsigned int Para; int main (void) { int ttemp; + unsigned int TempA; - - //DMA_Init(); // Инициализация DMA не используем - //DACInit(); // инициализация ЦАП. - //UART_DMA_Init(); //инициализация DMA для UART.//не используем - //WDTInit(); - // G_Photo_Init(); //инициализация интерфейса I2C для фотодетектора. - //инициализация/* -//NVIC_DisableIRQ(TIMER1_IRQn); -//NVIC_DisableIRQ(TIMER2_IRQn); -//NVIC_DisableIRQ(TIMER3_IRQn); -/* -NVIC_DisableIRQ(WDT_IRQn); -NVIC_DisableIRQ(TIMER0_IRQn); -NVIC_DisableIRQ(TIMER1_IRQn); -NVIC_DisableIRQ(TIMER2_IRQn); -NVIC_DisableIRQ(TIMER3_IRQn); -NVIC_DisableIRQ(UART0_IRQn); -NVIC_DisableIRQ(UART1_IRQn); -NVIC_DisableIRQ(UART2_IRQn); -NVIC_DisableIRQ(UART3_IRQn); -NVIC_DisableIRQ(PWM1_IRQn); -NVIC_DisableIRQ(I2C0_IRQn); -NVIC_DisableIRQ(I2C1_IRQn); -NVIC_DisableIRQ(I2C2_IRQn); -NVIC_DisableIRQ(SPI_IRQn); -NVIC_DisableIRQ(SSP1_IRQn); -NVIC_DisableIRQ(PLL0_IRQn); -NVIC_DisableIRQ(RTC_IRQn); -NVIC_DisableIRQ(EINT0_IRQn); -NVIC_DisableIRQ(EINT1_IRQn); -NVIC_DisableIRQ(EINT2_IRQn); -NVIC_DisableIRQ(EINT3_IRQn); -NVIC_DisableIRQ(ADC_IRQn); -NVIC_DisableIRQ(BOD_IRQn); -NVIC_DisableIRQ(USB_IRQn); -NVIC_DisableIRQ(CAN_IRQn); -NVIC_DisableIRQ(DMA_IRQn); -NVIC_DisableIRQ(I2S_IRQn); -NVIC_DisableIRQ(RIT_IRQn); -NVIC_DisableIRQ(MCPWM_IRQn); -NVIC_DisableIRQ(QEI_IRQn); -NVIC_DisableIRQ(PLL1_IRQn); -NVIC_DisableIRQ(USBActivity_IRQn); -NVIC_DisableIRQ(CANActivity_IRQn); - */ - -//NVIC_SetPriorityGrouping(1); - - - - - - - - - - - - - - - SystemInit1(); // Инициализация контроллера: установка тактовых частот - +SystemInit1(); // Инициализация контроллера: установка тактовых частот +addres = 0x10000; //FlashDMA_Init(); // Загрузка параметров с флэш @@ -161,13 +107,17 @@ //////////////////////Выбор FlashMod/////////////////////////// //////////////////////////////////////////////////////////////// - if (Time[0] == 'W') { + if (Time[0] == 'B') { Gyro.FlashMod=1; + } + if (Time[0] == 'W') { + Gyro.FlashMod=2; } if (Time[0] == 'R') { - Gyro.FlashMod=2; + Gyro.FlashMod=3; } + /////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////// @@ -340,11 +290,7 @@ } - // Read_CMD(); -//ДИМА== посмотри пожалуйста нармално ли работуют все таймеры аппаратные и програмные, то есть нет ли где затыком по времени -// с помошью ссветодиода например помаргай в разные временна, почему в режиме "рейт" передача от гироскопа идет с разной частотой -// попробуй сделать "рейт M4" посмотри в протоколе как вклбчается и на кокой скорости работает - + Event_100KHz(); Event_1KHz(); @@ -450,52 +396,104 @@ NVIC_DisableIRQ(TIMER3_IRQn); NVIC_DisableIRQ(EINT3_IRQn); //SCB->VTOR = 0x00A000; -//boot_jump(addres); + SystemInitDef(); vIAP_ReinvokeISP(); - -SystemCoreClockUpdate1(); -vIAP_ReinvokeISP(); - - - if(u32IAP_PrepareSectors(19, 21) == IAP_STA_CMD_SUCCESS) +} - { - - - WriteCon("\r\nPrepare Sector OK"); - - /* Copy data (already) located in RAM to flash */ - Result[0]=u32IAP_CopyRAMToFlash(IMG_START_SECTOR, &TempA, 256); - WriteCon("\r\nWrite"); - if(Result[0] != IAP_STA_CMD_SUCCESS) - { - while(1); /* No way to recover. Just let Windows report a write failure */ - } - - /* Verify the flash contents with the contents in RAM */ - if(u32IAP_Compare(IMG_START_SECTOR, &TempA, 256, 0) == IAP_STA_CMD_SUCCESS) - { - WriteCon("\r\nCompare"); - } - else{WriteCon("\r\n error Compare");} - }else{WriteCon("\r\n error prepare");} - Gyro.FlashMod = 0; - - } if(Gyro.FlashMod == 2) { - Gyro.FlashMod = 0; - WriteCon("\r\Read from Flash"); - boot_jump(addres); + + NVIC_DisableIRQ(TIMER1_IRQn); + NVIC_DisableIRQ(TIMER2_IRQn); + NVIC_DisableIRQ(TIMER3_IRQn); + NVIC_DisableIRQ(EINT3_IRQn); + + SystemInitDef(); + + + + WriteCon("\r\n Start Prepare Sectors"); + if(u32IAP_PrepareSectors(18, 21) == IAP_STA_CMD_SUCCESS) + { + WriteCon("\r\nPrepare Sectors OK"); + WriteCon("\r\n Start Erase"); + + u32IAP_EraseSectors(IMG_START_SECTOR, IMG_END_SECTOR); + + WriteCon("\r\n AND Erase"); + } + else WriteCon("\r\nPrepare Sectors ERROR"); +SystemInit1(); +Gyro.FlashMod = 0; +//boot_jump(addres); + } + + + + + /* +#define IAP_STA_CMD_SUCCESS 0 +#define IAP_STA_INVALID_COMMAND 1 +#define IAP_STA_SRC_ADDR_ERROR 2 +#define IAP_STA_DST_ADDR_ERROR 3 +#define IAP_STA_SRC_ADDR_NOT_MAPPED 4 +#define IAP_STA_DST_ADDR_NOT_MAPPED 5 +#define IAP_STA_COUNT_ERROR 6 +#define IAP_STA_INVALID_SECTOR 7 +#define IAP_STA_SECTOR_NOT_BLANK 8 +#define IAP_STA_SECTOR_NOT_PREPARED_FOR_WRITE_OPERATION 9 +#define IAP_STA_COMPARE_ERROR 10 +#define IAP_STA_BUSY 11 +#define IAP_STA_INVALD_PARAM 12 +*/ + + + + + + + + + + + + + + + + + + + + +if(Gyro.FlashMod == 3) + { + + ReadFlash(); + // SystemInitDef(); +// *status=(unsigned int*)addres; + /*NVIC_DisableIRQ(TIMER1_IRQn); + NVIC_DisableIRQ(TIMER2_IRQn); + NVIC_DisableIRQ(TIMER3_IRQn); + NVIC_DisableIRQ(EINT3_IRQn);*/ + Gyro.FlashMod = 0; +// memdump(addres,4); +// addres+=0x10; +// p = (unsigned int *)((unsigned int)base & ~(unsigned int)0x3); + // WriteCon(*addres); + // status=*addres; + // SystemInit1(); + // WriteCon(status); + // addres+=0x10; + } - }//while }//main