//IAP #define IAP_ADDRESS 0x1FFF1FF1 unsigned param_table[5]; unsigned result_table[5]; void iap_entry(unsigned param_tab[],unsigned result_tab[]) { void (*iap)(unsigned [],unsigned []); iap = (void (*)(unsigned [],unsigned []))IAP_ADDRESS; iap(param_tab,result_tab); } //call ISP void call_ISP(void) //call ISP via IAP { NVIC->ICER[0] = 0xFFFFFFFF; //disable all interrupts param_table[0] = 57; //IAP command iap_entry(param_table,result_table); } static void StopUART(void) { uint32_t temp; /* Disable UART interrupts */ LPC_UART->IER = 0; /* Disable UART interrupts in NVIC */ NVIC_DisableIRQ(UART_IRQn); /* Ensure a clean start, no data in either TX or RX FIFO. */ while (( LPC_UART->LSR & (LSR_THRE|LSR_TEMT)) != (LSR_THRE|LSR_TEMT) ); while ( LPC_UART->LSR & LSR_RDR ) { temp = LPC_UART->RBR; /* Dump data from RX FIFO */ } /* Read to clear the line status. */ temp = LPC_UART->LSR; } void read_input(char in_data) //read input from UART/USB { switch(in_data) //switch char { case('a'):printf("Alive \n\r"); case('b'):printf("Still Alive\n\r"); break; [COLOR=Magenta] case('i')[/COLOR]:printf("Call ISP\n\r"); timer=0; while(timer<1000){;} //wait 1 second to get previous message transmitted [COLOR=Red] StopUART(); [/COLOR] //reset UART [COLOR=Red] call_ISP(); [/COLOR] //run ISP break; default: break; } } |