//*****************************************************************************
//							MAIN FUNCTION
//*****************************************************************************
void main()
{
#if defined(ewarm)
    IntVTableBaseSet((unsigned long)&__vector_table);
#endif

    //
    // Board Initialization
    //
    MCUInit();
    InitTerm();         //set the parameters of uart0
    //
    // Enable the SYSTICK interrupt
    //
    IntEnable(FAULT_SYSTICK);
	//
	// Start the SimpleLink Host
	//
    VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY);
	//
	// Start the WlanAPMode task
	//
    osi_TaskCreate( WlanAPMode,
    				(const signed char*)"wireless LAN in AP mode",
    				2048, NULL, 1, NULL );
	//
	// Start the task scheduler
	//
    osi_start();
}
Example #2
0
//主程序
int main()
{
    INT8U remember;
 	DISABLE_INTERRUPTS;            //禁止总中断
 	//1. 芯片初始化
 	MCUInit();
    //2. 模块初始化
	SCIInit();                     //(1) 串口初始化
 	TimerInit();                   //(2) 定时器1初始化
    //3. 内存初始化
    //(1) "时分秒"缓存初始化(00:00:00)
	time[0] = 0;
	time[1] = 0;
	time[2] = 0;
	//(2) 临时变量remember初始化
    remember = time[2];
    //(3) 全局变量TimInterCount初始化
 	TimInterCount = 0;
 	//4. 开放各模块中断
    EnableSCIReInt;                //(1) 开放SCI0接收中断
    EnableT1OVInt;                 //(2) 开放定时器1溢出中断
    //5. 开放总中断
	ENABLE_INTERRUPTS;             //开总中断
	while (1)
	{
        if (time[2] != remember)
        {
            SCISendN(3, time);     //发送当前"时分秒"
            remember = time[2];    //remember中存放当前秒值
        }
    }
}
Example #3
0
int main(void) {
	__bis_SR_register(GIE);
	MCUInit();
	I2C_masterInit();
	TimerInit();
	I2C_enable();
	//TA0CCTL1 |= CCIE;
	TA1CCTL1 |= CCIE;
	while (1)
	{

	}
}
Example #4
0
//主函数
int main()
{
    DISABLE_INTERRUPTS;       //禁止总中断
    //1. 芯片初始化
    MCUInit();
    //2. 模块初始化
    ICInit();                 //输入捕捉初始化
    LEDInit();                //小灯驱动头文件
    //3. 开放总中断
    ENABLE_INTERRUPTS;        //开放总中断
    //主循环
    while(1)
    {
    }
}
Example #5
0
void main(void) 
{      
    INT8U i;
    
    DISABLE_INTERRUPTS;    //关总中断    
    //1.芯片初始化
    MCUInit();
    //2. 模块初始化    
    SCIInit();    //(1) 串口初始化

    while (1)
    {     
        i = SCIReN(1,SerialBuff);              //等待接收1个数据
        if (i == 0) SCISendN(1,SerialBuff);    //发送接到的数据
    }
}
Example #6
0
//主函数
int  main()
{
    INT8U i, j;
    INT16U value[2];
    
    MCUInit();    //系统初始化
    SCIInit();    //串行口初始化
    SPIInit();    //SPI通信初始化
    //程序总循环入口
    while (1)
    {
       ADCP(3, 1, 2, value);    //取33路AD转换16次平均值放入ADValue[33]
       SCISendN(4,(INT8U *)value);
       for (i=0; i<100; i++)
           for (j=0; j<200; j++)
               Delay();
    }
}
//*****************************************************************************
//							MAIN FUNCTION
//*****************************************************************************
void main()
{
  
  
    
#if defined(ewarm)
    IntVTableBaseSet((unsigned long)&__vector_table);
#endif

    //
    // Board Initialization
    //
    MCUInit();
    //
    
    
    // Enable the SYSTICK interrupt
    //
    IntEnable(FAULT_SYSTICK);
    

    
    UART_PRINT("hellow i am in\n\r");   
    
	//
	// Start the SimpleLink Host
	//
    VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY);
	//
   // WlanStationMode(NULL);
      
  //  UART_PRINT("hellow i am in\n\r");
    
	// Start the WlanStationMode task
	//
    osi_TaskCreate( WlanStationMode,
    				(const signed char*)"wireless LAN in station mode",
    				2048, NULL, 1, NULL );
	//
	// Start the task scheduler
	//
    osi_start();
}
//*****************************************************************************
//							MAIN FUNCTION
//*****************************************************************************
void main()
{
  
  
    
#if defined(ewarm)
    IntVTableBaseSet((unsigned long)&__vector_table);
#endif

    //
    // Board Initialization
    //
    MCUInit();
    //
    
    
    // Enable the SYSTICK interrupt
    //
    IntEnable(FAULT_SYSTICK);
    
    sysTickInit();
    
    
    
	//
	// Start the SimpleLink Host
	//
    VStartSimpleLinkSpawnTask(SPAWN_TASK_PRIORITY);
	//
   // WlanStationMode(NULL);
      
  //  UART_PRINT("hellow i am in\n\r");
    
	// Start the WlanStationMode task
	//

    if(OSI_OK !=osi_TaskCreate( WlanStationMode,
    				(const signed char*)"WlanStationMode task",
    				2048, NULL, 3, NULL ))
      UART_PRINT("WlanStationMode failed\n\r");   
        
   if(OSI_OK != osi_TaskCreate( taskServer,
    				(const signed char*)"taskServer",
    				2048, NULL, 2, (OsiTaskHandle)&ServerTaskHandle ) )
     UART_PRINT("taskServer failed\n\r");
    
    if(OSI_OK != osi_TaskCreate( taskClient,
    				(const signed char*)"taskClient",
    				2048, NULL, 1, (OsiTaskHandle)&clientTaskHandle ))
      UART_PRINT("taskClient failed\n\r");
    
    
 /*   
    if(OSI_OK != osi_TaskCreate( taskTest1,
    				(const signed char*)"taskTest1",
    				2048, NULL, 1, NULL ))
      UART_PRINT("taskTest1 failed\n\r"); 
    
    if(OSI_OK != osi_TaskCreate( taskTest2,
    				(const signed char*)"taskTest2",
    				2048, NULL, 1, NULL ))
      UART_PRINT("taskTest1 failed\n\r"); 
*/       
    
	//
	// Start the task scheduler
	//
    //osi_start();
    vTaskStartScheduler();
}
Example #9
0
//主函数
int main()
{
    INT8U i;
    INT8U j;
    INT8U k;
    INT8U flag;    //写字节奇偶个数标志
    
    DISABLE_INTERRUPTS;    //禁止总中断
    //1. 芯片初始化
    MCUInit();
    //2. 模块初始化 
    SCIInit();    //串行口初始化
    //3.内存初始化
    //把存放在RAM区的机器码赋值给数组PrgOfRam,供Flash擦写函数调用
    for (i=0; i<18; i++)
        PrgOfRam[i] = P[i];
    
    //主循环
    while (1)
    {
        i = SCIReN(1,SerialBuff);
        if (i != 0) continue;
        switch (SerialBuff[0])
        {
        //收到提问信号
        case '?' :
            {
                SCISendN(11,"E:PAGE:ADDR",0x00);           //擦除命令格式
                SCISendN(2, (void *)Line_end,0x00);
                SCISendN(18,"W:PAGE:ADDR:N:DATA",0x00);    //写入命令格式
                SCISendN(2, (void *)Line_end,0x00);
                SCISendN(13,"R:PAGE:ADDR:N",0x00);         //读取命令格式
                SCISendN(2,(void *)Line_end,0x00);
                break;
            }
        //收到擦除信号
        case 'E' :
            {
                j = SCIReN(8,SerialBuff);
                if (j == 0)
                {
                    //将收到的字符数据转换成十六进制数据
                    for (k=1; k<8; k++)
                        if((SerialBuff[k]>='0') && (SerialBuff[k]<='9'))
                            SerialBuff[k] = SerialBuff[k]-'0';
                         else SerialBuff[k] = SerialBuff[k]-'A'+0x0A;
                    //对页号和地址处理
                    page=CvtPage(SerialBuff);
                    addr=CvtAddr(SerialBuff);
                    //擦除指定的扇区
                    Flash_Erase_Sector(page,addr);
                    //发送擦除结果
                    SCISendN(250,(void *)addr,page);
                }
                break;
            }
        //收到写入信号
        case 'W' :
            {
                j = SCIReN(11,SerialBuff);
                if (j == 0)
                {
                    //将收到的字符数据转换成十六进制数据
                    for (k=1; k<10; k++)
                        if ((SerialBuff[k]>='0') && (SerialBuff[k]<='9'))
                            SerialBuff[k] = SerialBuff[k]-'0';
                        else SerialBuff[k] = SerialBuff[k]-'A'+0x0A;
                    //对页号和地址处理
                    page=CvtPage(SerialBuff);
                    addr=CvtAddr(SerialBuff);
                    //接收写入的数据个数
                    N = SerialBuff[9];
                    //接收写入的数据
                    k = SCIReN(N,SerialBuff);
                    //对数据的奇偶个数进行处理
                    if (k == 0) 
                    {
                        flag = 0;
                        if(1 == N%2)
                        {
                            SerialBuff[N] = 0xFF;
                            N += 1;
                            flag = 1;
                        }
                        //写入数据
                        Flash_Write_Nword(page,addr,(INT16U)SerialBuff,N/2);
                        if(1 == flag)
                        {
                            N -= 1;
                        }
                        //发送写入到Flash的数据
                        SCISendN(N,(void *)addr,page);
                    }
                }  
                break;
            }
        //收到读取信号
        case 'R' :
            {
                i = SCIReN(10,SerialBuff);
                if (i == 0)
                {
                    //将收到的字符数据转换成十六进制数据
                    for (i=1; i<10; i++)
                        if((SerialBuff[i]>='0') && (SerialBuff[i]<='9'))
                            SerialBuff[i] = SerialBuff[i]-'0';
                         else   SerialBuff[i] = SerialBuff[i]-'A'+0x0A;
                    //对页号和地址处理
                    page=CvtPage(SerialBuff);
                    addr=CvtAddr(SerialBuff);
                    //接收要读取的数据个数
                    N = SerialBuff[9];
                    //发送要读取的数据
                    SCISendN(N,(void *)addr,page);
                }
                break;
            }
        }
    }
}
Example #10
0
/* ================= main ====================
      desc: 程序入口函数
      pre:  无
      Post: 无       
*/
void main(void) {
    // Local Declarations
    byte laser_history_array[LASER_HISTORY_MAX]; //激光管历史状态数组
  
  	Bool temp_usualRoad_flag = TRUE;      //当前判断是否正常路段标志
  	Bool last_usualRoad_flag = TRUE;      //上次判断是否正常路段标志
  	Bool stopCar_flag = FALSE;            //停车标志
  	Bool breakCar_flag = FALSE;           //刹车标志
  
  	byte startlineFlag_count = 0;         //经过起始线的次数
  	byte laser_hitNum = 1;                //照到黑线的激光管个数
  	byte inside_count = INSIDE_COUNT_MAX; //激光管连续在黑线范围内的次数
  	byte outside_count = 0;               //激光管连续在黑线外的次数
  	byte last_error = 0;                  //直道加速匀速控制的上次误差
  	 
  	LASER_STATUS last_laserStatus = MID7;  //上次激光管状态
  	LASER_STATUS temp_laserStatus = MID7;  //当前激光管状态
  	int last_turnAngle = PWM1_MID;     //上次舵机调整的角度
  	int temp_turnAngle = PWM1_MID;     //当前舵机需要调整的角度	
  	int last_speed = PWM3_FAST0;   //上次速度
  	int temp_speed = PWM3_FAST0;   //当前速度 
  	
  	int i;
    int testcount=0;  //发送激光管信息计数值定义
  	for(i=0;i<LASER_HISTORY_MAX;i++) {
  	    laser_history_array[i] = MID7;
  	}
  	
    // Statements
    DisableInterrupts;
    MCUInit();
  	SmartcarInit();
  	EnableInterrupts;
  
    for(;;) {  
         if(PITINTE_PINTE0 == 0) {    //若PIT0采集中断为关,即道路信息采集完成
              laser_hitNum = 15 - CalculateLaserHitNum(g_temp_laser_array);
              temp_usualRoad_flag =  IsUsualRoad (laser_hitNum); //判断是否为正常道路
              if (temp_usualRoad_flag) {
                  temp_laserStatus = GetLaserStatus(last_laserStatus,g_temp_laser_array,laser_hitNum,&inside_count,&breakCar_flag,laser_history_array,&outside_count); //得到当前激光管状态
                  temp_turnAngle = CalculateAngle(temp_laserStatus); //得到舵机需要调整的转角      
                  temp_speed = CalculateSpeed (temp_turnAngle,stopCar_flag,inside_count,outside_count); //得到需要输出的速度
              } 
              else {
                  if((last_usualRoad_flag == TRUE)&&(laser_hitNum>=8&&laser_hitNum<=11)) {          //一定执行
                      startlineFlag_count = CountStartlineFlag(startlineFlag_count,g_temp_laser_array); //计算小车经过起始线的次数
                      if(startlineFlag_count == 2)  
                            stopCar_flag = TRUE; //若是第二次经过起始线,停车标志置位,即停车
                      StopCar(stopCar_flag);      
                  }
              } /**/
            
              
       testcount++;
              
              if(testcount%50==0){
                
               testcount=1;   
             SendSmartcarInfo(g_temp_laser_array,temp_laserStatus,last_laserStatus,g_temp_pulse);//发送激光管信息
                  } /*   */
              PITINTE_PINTE0 = 1;    //开PIT0采集中断 
        }           
        DerectionCtrl(temp_turnAngle); //调整舵机
        
        if(breakCar_flag == TRUE) {  //若直道入弯,反转减速刹车
            BreakCar(g_temp_pulse, &breakCar_flag);
        }  
        else
            SpeedCtrl(temp_speed,g_temp_pulse,&last_error);         //调整正转速度
         
        last_speed = temp_speed;                        //保存当前速度
        last_laserStatus = temp_laserStatus;            //保存当前激光管状态
        last_turnAngle = temp_turnAngle;                //保存当前舵机转角
        last_usualRoad_flag = temp_usualRoad_flag;      //保存当前是否正常道路的标志 
        
        for(i=LASER_HISTORY_MAX-1;i>0;i--){             //保存激光管历史状态
            laser_history_array[i] =  laser_history_array[i-1];   
        }
        laser_history_array[0] = temp_laserStatus;
    }
} //main
Example #11
0
//主函数
int main()
{
    INT8U i;
    INT8U j;
    INT8U k;
    INT8U flag;    //读写字节奇偶个数标志    
    INT8U Line_end[2];
    INT8U Convert(INT8U ASC1,INT8U ASC2);
    
    DISABLE_INTERRUPTS;    //禁止总中断
    //1. 芯片初始化
    MCUInit();
    //2. 模块初始化 
    SCIInit();    //(1) 串行口初始化
    //3.内存初始化
    //ASCII码换行符    
    Line_end[0]=13;
    Line_end[1]=10;    
    //把存放在RAM区的机器码赋值给数组PrgOfRam,供Flash擦写函数调用
    for (i=0; i<18; i++)
        PrgOfRam[i] = P[i];    
    //后门机制密码
    for(i=0;i<8;i++)
        BackdoorKey[i]=0xFF;
    //安全字节
    SecureByte[0]=0xFF;
    SecureByte[1]=0xFE;
    //主循环
    while (1)
    {
        i = SCIReN(1,SerialBuff);
        if (i != 0) continue;
        switch (SerialBuff[0])
        {
        //收到提问信号
        case '?' :
            {
                SCISendN(11,"E:PAGE:ADDR");           //擦除命令格式
                SCISendN(2, (void *)Line_end);
                SCISendN(18,"W:PAGE:ADDR:N:DATA");    //写入命令格式
                SCISendN(2, (void *)Line_end);
                SCISendN(13,"R:PAGE:ADDR:N");         //读取命令格式
                SCISendN(2,(void *)Line_end);
                SCISendN(13,"S:BackdoorKey");         //设置密码命令格式
                SCISendN(2,(void *)Line_end);
                SCISendN(12,"C:SecureByte");          //设置安全状态命令格式
                SCISendN(2,(void *)Line_end);
                SCISendN(24,"U:BackdoorKey");         //解除安全模式命令格式
                SCISendN(2,(void *)Line_end);
                break;
            }
        //收到擦除信号
        case 'E' :
            {
                j = SCIReN(8,SerialBuff);
                if (j == 0)
                {
                    //将收到的字符数据转换成十六进制数据
                    for (k=1; k<8; k++)
                        if((SerialBuff[k]>='0') && (SerialBuff[k]<='9'))
                            SerialBuff[k] = SerialBuff[k]-'0';
                         else SerialBuff[k] = SerialBuff[k]-'A'+0x0A;
                    //对页号和地址处理
                    page=CvtPage(SerialBuff);
                    addr=CvtAddr(SerialBuff);
                    //擦除指定的扇区
                    Flash_Erase_Sector(page,addr);
                    //发送擦除结果
                    SCISendN(250,(void *)addr);
                }
                break;
            }
        //收到写入信号
        case 'W' :
            {
                j = SCIReN(11,SerialBuff);
                if (j == 0)
                {
                    //将收到的字符数据转换成十六进制数据
                    for (k=1; k<10; k++)
                        if ((SerialBuff[k]>='0') && (SerialBuff[k]<='9'))
                            SerialBuff[k] = SerialBuff[k]-'0';
                        else SerialBuff[k] = SerialBuff[k]-'A'+0x0A;
                    //对页号和地址处理
                    page=CvtPage(SerialBuff);
                    addr=CvtAddr(SerialBuff);
                    //接收写入的数据个数
                    N = SerialBuff[9];
                    //接收写入的数据
                    k = SCIReN(N,SerialBuff);
                    //对数据的奇偶个数进行处理
                    if (k == 0) 
                    {
                        flag = 0;
                        if(1 == N%2)
                        {
                            SerialBuff[N] = 0xFF;
                            N += 1;
                            flag = 1;
                        }
                        //写入数据
                        Flash_Write_Nword(page,addr,(INT16U)SerialBuff,N/2);
                        if(1 == flag)
                        {
                            N -= 1;
                        }
                        //发送写入到Flash的数据
                        SCISendN(N,(void *)addr);
                    }
                }  
                break;
            }
        //收到读取信号
        case 'R' :
            {
                i = SCIReN(10,SerialBuff);
                if (i == 0)
                {
                    //将收到的字符数据转换成十六进制数据                    
                    for (i=1; i<10; i++)
                        if((SerialBuff[i]>='0') && (SerialBuff[i]<='9'))
                            SerialBuff[i] = SerialBuff[i]-'0';
                         else   SerialBuff[i] = SerialBuff[i]-'A'+0x0A;
                    //对页号和地址处理
                    page=CvtPage(SerialBuff);
                    addr=CvtAddr(SerialBuff);
                    //接收要读取的数据个数
                    N = SerialBuff[9];
                    //发送要读取的数据
                    SCISendN(N,(void *)addr);                   
                }
                break;
            }
        //设置后门机制进入密码
        case 'S' :
            {
                i = SCIReN(17,SerialBuff);
                if (i == 0)
                {
                    for(i=0; i<8; i++)
                        BackdoorKey[i]=Convert(SerialBuff[i*2+1],SerialBuff[i*2+2]);
                    Flash_SetKey(BackdoorKey);
                    SCISendN(8,(void *)0xFF00);
                }  
                break;
            }
         //改变安全状态
         case 'C' :
            {
                i = SCIReN(3,SerialBuff);
                if (i == 0)
                {
                    SecureByte[1]=Convert(SerialBuff[1],SerialBuff[2]);
                    Flash_SetStatus(SecureByte);
                    SCISendN(1,(void *)0xFF0F);
                }  
                break;
            }
        //使用后门机制解密
        case 'U' :
            {
                i = SCIReN(17,SerialBuff);
                if (i == 0)
                {
                    for(i=0; i<8; i++)
                        BackdoorKey[i]=Convert(SerialBuff[i*2+1],SerialBuff[i*2+2]);
                    Flash_unsecured(BackdoorKey);
                    SCISendN(20,"Unsercured Success !");
                    SCISendN(2,(void *)Line_end);
                }  
                break;
            }
        } 
    }  
}