/** \brief Test case: TC_CoreFunc_FAULTMASK \details - Check if __get_FAULTMASK and __set_FAULTMASK intrinsic can be used to manipulate FAULTMASK. - Check if __enable_fault_irq and __disable_fault_irq are reflected in FAULTMASK. */ void TC_CoreFunc_FAULTMASK (void) { uint32_t orig = __get_FAULTMASK(); // toggle faultmask uint32_t faultmask = (orig & ~0x01U) | (~orig & 0x01U); __set_FAULTMASK(faultmask); uint32_t result = __get_FAULTMASK(); ASSERT_TRUE(result == faultmask); __disable_fault_irq(); result = __get_FAULTMASK(); ASSERT_TRUE((result & 0x01U) == 1U); __enable_fault_irq(); result = __get_FAULTMASK(); ASSERT_TRUE((result & 0x01U) == 0U); __disable_fault_irq(); result = __get_FAULTMASK(); ASSERT_TRUE((result & 0x01U) == 1U); __set_FAULTMASK(orig); }
void Init_Cpu(void) { __set_PSP((uint32_t)msp_top); __set_PRIMASK(1); __set_FAULTMASK(1); __set_CONTROL(0); #if (CN_CPU_OPTIONAL_FPU == 1) startup_scb_reg->CPACR = (3UL << 20)|(3UL << 22); //使能FPU startup_scb_reg->FPCCR = (1UL << 31); //关闭lazy stacking #endif switch(startup_scb_reg->CPUID) { } extern void SysClockInit(void); SysClockInit(); #ifdef USE_HAL_DRIVER HAL_TickInit(); #endif extern void SRAM_Init(void); SRAM_Init(); IAP_SelectLoadProgam(); }
void Init_Cpu(void) { __set_PSP((uint32_t)msp_top); __set_PRIMASK(1); __set_FAULTMASK(1); __set_CONTROL(0); #if (CN_CPU_OPTIONAL_FPU == 1) pg_scb_reg->CPACR = (3UL << 20)|(3UL << 22); //使能FPU pg_scb_reg->FPCCR = (1UL << 31); //关闭lazy stacking #endif switch(pg_scb_reg->CPUID) { // case cn_revision_r0p1://todo // break; //好像没什么要做的 } extern void WDT_Disable(void); WDT_Disable(); //关狗 extern void SysClockInit(void); SysClockInit(); extern void SDRAM_Init(void); SDRAM_Init(); extern void Cache_Init(void); Cache_Init(); Load_Preload(); }
void Init_Cpu(void) { __set_PSP((uint32_t)msp_top); __set_PRIMASK(1); __set_FAULTMASK(1); __set_CONTROL(0); switch(pg_scb_reg->CPUID) { case cn_revision_r0p0: break; //市场没有版本0的芯片 case cn_revision_r1p0: pg_scb_reg->CCR |= 1<<bo_scb_ccr_stkalign; break; case cn_revision_r1p1: pg_scb_reg->CCR |= 1<<bo_scb_ccr_stkalign; break; case cn_revision_r2p0:break; //好像没什么要做的 } pg_inflash_fpec_reg->ACR &= ~(u32)0x1f; pg_inflash_fpec_reg->ACR |= (CN_CFG_MCLK-1)/24000000; //设置等待周期。 pg_inflash_fpec_reg->ACR |= 0x10; //开启预取 if(((pg_rcc_reg->CR & cn_cr_check_mask) != cn_cr_check) || ((pg_rcc_reg->CFGR & cn_cfgr_check_mask) != cn_cfgr_check)) { //开始初始化时钟 //step1:复位时钟控制寄存器 pg_rcc_reg->CR |= (uint32_t)0x00000001; // 复位 SW[1:0], HPRE[3:0], PPRE1[2:0], PPRE2[2:0], ADCPRE[1:0] MCO[2:0] 位 pg_rcc_reg->CFGR &= (uint32_t)0xF8FF0000; // 复位 HSEON, CSSON and PLLON 位 pg_rcc_reg->CR &= (uint32_t)0xFEF6FFFF; // 复位 HSEBYP 位 pg_rcc_reg->CR &= (uint32_t)0xFFFBFFFF; // 复位 PLLSRC, PLLXTPRE, PLLMUL[3:0] and USBPRE 位 pg_rcc_reg->CFGR &= (uint32_t)0xFF80FFFF; // 禁止所有中断 pg_rcc_reg->CIR = 0x00000000; //step2:设置各时钟控制位以及倍频、分频值 pg_rcc_reg->CFGR = cn_cfgr_set+(7<<24); // set clock configuration register pg_rcc_reg->CR = cn_cr_set; // set clock control register while(bb_rcc_cr_hserdy ==0); while(bb_rcc_cr_pllrdy ==0); } SRAM_Init(); Load_Preload(); }
// ============================================================================= // 功能:CORTEX M3内核启动函数,系统复位启动后,从汇编向量表跳转到C的第一个函数。函数 // 会初始化主堆栈和用户堆栈,配置内核寄存器,然后初始化时钟模块。 // 参数:无 // 返回:无 // ============================================================================= void Init_Cpu(void) { __set_PSP((uint32_t)msp_top); __set_PRIMASK(1); __set_FAULTMASK(1); __set_CONTROL(0); switch(pg_scb_reg->CPUID) { case cn_revision_r0p0: break; //市场没有版本0的芯片 case cn_revision_r1p0: pg_scb_reg->CCR |= 1<<bo_scb_ccr_stkalign; break; case cn_revision_r1p1: pg_scb_reg->CCR |= 1<<bo_scb_ccr_stkalign; break; case cn_revision_r2p0:break; //好像没什么要做的 } SystemInit(); Load_Preload(); return; }
static int handle_reset(int argc, char **argv) { __set_FAULTMASK(1); NVIC_SystemReset(); return 0; }
/* * ϵͳÈí¼þ¸´Î» */ void Soft_Reset(void) { __set_FAULTMASK(1); /* ¹Ø±ÕËùÓÐÖÐ¶Ï */ NVIC_SystemReset(); /* ϵͳ¸´Î» */ }
void SoftReset(void) { __set_FAULTMASK(1); NVIC_SystemReset(); }
/* * 系统软件复位 */ void Soft_Reset(void) { __set_FAULTMASK(1); /* 关闭所有中断 */ NVIC_SystemReset(); /* 系统复位 */ }
/* ps command * List all of tasks */ static int reset(int argc, char *argv[]) { __set_FAULTMASK(1); SCB->AIRCR = 0x05FA0004; return 0; }
void SysReset(void) { __set_FAULTMASK(1); // 关闭所有中端 NVIC_SystemReset();// 复位 while(1); }
/****************************************************************************** * @brief 软件复位 * @param None * @retval None ******************************************************************************/ void SoftReset(void) { __set_FAULTMASK(1); // 关闭所有中端 NVIC_SystemReset(); // 复位 }
void GPS_Init(unsigned int baud) { //Turn on GPS via GPIO //GPS enable pin is p5[4] //GPIO_SetDir(5, 1<<4, GPIO_DIRECTION_OUTPUT); //LPC_GPIO5->SET = 1<<4; //Give GPS time to power on- may not be necessary, at least not this much time Delay(500); //Set pins to be UART3 pins PINSEL_ConfigPin(4, 28, 2); //pin 118, TX PINSEL_ConfigPin(4, 29, 2); //pin 122, RX UART_CFG_Type cfg; UART_FIFO_CFG_Type fifocfg; UART_ConfigStructInit(&cfg); cfg.Baud_rate = baud; UART_Init(UART_3, &cfg); //Defaults are OK- no DMA, interrupt on every character UART_FIFOConfigStructInit(&fifocfg); UART_FIFOConfig(UART_3, &fifocfg); UART_TxCmd(UART_3, ENABLE); Delay(500); //Send message to disable messages we don't care about //NOTE: This is the right string for RMC and nothing else //$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29\r\n //This string should enable GGA and nothing else //$PMTK314,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29\r\n #if USE_GPS_MSG_GGA uint8_t* txstr = "$PMTK314,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29\r\n"; #else uint8_t* txstr = "$PMTK314,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0*29\r\n"; #endif UART_Send(UART_3, txstr, 51, BLOCKING); //Enable interrupt on data received UART_IntConfig(UART_3, UART_INTCFG_RBR, ENABLE); UART_IntConfig(UART_3, UART_INTCFG_RLS, ENABLE); Delay(100); //Allow GPS to wake MCU up from sleep __set_FAULTMASK(0); __set_PRIMASK(0); SCB->SCR = 0; //Set message as invalid before enabling iterrupt valid = 0; GPSUARTIndex = 0; NVIC_EnableIRQ(UART3_IRQn); //Set state to GPS on gpsActive = 1; return; }
void TaskUSBHID(void *pdata) { //uint8_t InBuffer[8]={1,2,3,4,5,6,7,8}; uint8_t wFlashBuffer[4]={0},rFlashBuffer[4]; while(1) { //1,校准 //2,japan,america,china //3,updata //4,数据上传 //5,通道反相 if (HIDReceive_Buffer[0] == 0x01) //calibration { /* Create a new task to do the adc calibration */ OSTaskCreateExt(RC_Channel_Calibrate_Process, (void *)0, &Task_Start_Stk[Task_Start_Size - 1], Task_Start_Prio, Task_Start_Prio, Task_Start_Stk, Task_Start_Size, (void *)0, OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR); } else if (HIDReceive_Buffer[0] == 0x02)//handStyle { RC_Profile_Cfg.amjp=HIDReceive_Buffer[1]; if(writeMask(HIDmask_address_calibration,(uint8_t *)&RC_Profile_Cfg, sizeof(struct RC_Profile_Cfg_t)) ==0) { } } else if (HIDReceive_Buffer[0] == 0x03)//updata { if(writeMask(HIDmask_address_boot,HIDReceive_Buffer+1,4) ==0) { // } else { __set_FAULTMASK(1); NVIC_SystemReset();// } } else if (HIDReceive_Buffer[0] == 0x04) { //??????? /********* UserToPMABufferCopy(InBuffer, GetEPTxAddr(ENDP1), 6); SetEPTxCount(ENDP1, 6); SetEPTxValid(ENDP1); *********/ } else if (HIDReceive_Buffer[0] == 0x05) { //adc反向,1-4通道占一位0000xxxx RC_Profile_Cfg.chann_reverse=HIDReceive_Buffer[1]; if(writeMask(HIDmask_address_calibration,(uint8_t *)&RC_Profile_Cfg, sizeof(struct RC_Profile_Cfg_t)) ==0) { } } HIDReceive_Buffer[0]=0; OSTimeDly(OS_TICKS_PER_SEC/10); } }