| | |
| | | |
| | | void sys_reset(uint32_t error) |
| | | { |
| | | LOG_INFO(TRACE_MODULE_DRIVER, "system reboot%x", error); |
| | | //LOG_INFO(TRACE_MODULE_DRIVER, "system reboot%x", error); |
| | | |
| | | delay_us(10000); |
| | | |
| | | // reboot |
| | | reset_module(RESET_MODULE_REBOOT); |
| | | } |
| | | |
| | | void delay_US(uint32_t nTimer) |
| | | { |
| | | uint32_t i=0; |
| | | for(i=0;i<nTimer;i++){ |
| | | __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP(); |
| | | __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP(); |
| | | __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP(); |
| | | __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP(); |
| | | __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP(); |
| | | __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP(); |
| | | __NOP();__NOP();__NOP();__NOP(); |
| | | } |
| | | } |
| | | void delay_ms(uint32_t nTimer) |
| | | { |
| | | uint32_t i=1000*nTimer; |
| | | delay_US(i); |
| | | } |
| | | void delay_us(uint32_t cnt) |
| | | { |
| | | #define SYSTEM_CLOCK_MHZ 62.4 |
| | |
| | | "bhi loop%=\n" |
| | | "pop {r4,r5}\n" |
| | | "exit%=:\n" |
| | | : |
| | | : [mult_hi] "i"(SYSTEM_CLOCK_MULT_HI), [mult_lo] "i"(SYSTEM_CLOCK_MULT_LO), [shift] "i"(SYSTEM_CLOCK_LSLS_BITS), [adjust] "i"(AAPCS_PREP_CYCLES), |
| | | [decr] "i"(DELAY_LOOP_CYCLES)); |
| | | : |
| | | : [mult_hi] "i"(SYSTEM_CLOCK_MULT_HI), [mult_lo] "i"(SYSTEM_CLOCK_MULT_LO), [shift] "i"(SYSTEM_CLOCK_LSLS_BITS), [adjust] "i"(AAPCS_PREP_CYCLES), |
| | | [decr] "i"(DELAY_LOOP_CYCLES)); |
| | | |
| | | #if defined(__GNUC__) && !defined(__ARMCC_VERSION) |
| | | __asm volatile(".syntax divided\n"); |
| | | #endif |
| | | } |
| | | |
| | | //void delay_us(uint32_t nTimer) |
| | | //{ |
| | | // uint32_t i=0; |
| | | // for(i=0;i<nTimer;i++){ |
| | | // __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP(); |
| | | // __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP(); |
| | | // __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP(); |
| | | // __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP(); |
| | | // __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP(); |
| | | // __NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP();__NOP(); |
| | | // __NOP();__NOP();__NOP();__NOP(); |
| | | // } |
| | | //} |
| | | uint8_t count_bits(uint32_t value) |
| | | { |
| | | uint8_t count = 0; |