⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lib_22eb06_mc.c

📁 使用embest IDE开发工具开发的基于LPC2294 的触摸屏开发
💻 C
📖 第 1 页 / 共 2 页
字号:
           i |= GPIO2_16__ext_latch_IOxxx_M;
           IOSET2 = i;

           //set value 0
           i = IOCLR2;
           i |= GPIO2_16__ext_latch_IOxxx_M;
           IOCLR2 = i;

       	   }
       	else
           {
           //link to gpio p2.16
           i = PINSEL2;
           i &= (~P2__16_31__GPIO_PINSEL2_MASK);
           i |= P2__16_31__GPIO_PINSEL2_VALUE;
           PINSEL2 = i;

           //set gpio p2.16 input
           i = IODIR2;
           i &= (~GPIO2_16__ext_latch_IOxxx_M);
           IODIR2 = i;
           }

       }

/**********************************************************************
* name  :    spi_extend_outputen()
* func  :    spi extend control from spi0 extend the io control
             only control the all extend io onoff
             use hardware p2.17
* para  :    extend_onoff:
             0- all off output to high resistor
             1- all on
* ret   :    none

* glob  :    none
* inc   :

* author:
* date  :

* modify:
* comment:
**********************************************************************/
INT32U spi_extend_outputen(ext_device_control outendis)
       {
       	INT32U i,j;

       	if (ext_device_all_outen==outendis)
       	   { // on the all expend output
           //link to gpio p2.17
           i = PINSEL2;
           i &= (~P2__16_31__GPIO_PINSEL2_MASK);
           i |= P2__16_31__GPIO_PINSEL2_VALUE;
           PINSEL2 = i;

           //set gpio p2.17 output
           i = IODIR2;
           i &= (~GPIO2_17__ext_out_IOxxx_M);
           i |= GPIO2_17__ext_out_IOxxx_V;
           IODIR2 = i;


           //set value 0
           i = IOCLR2;
           i |= GPIO2_17__ext_out_IOxxx_M;
           IOCLR2 = i;
       	   }
       	else
           { // off all output about expend
           //link to gpio p2.17
           i = PINSEL2;
           i &= (~P2__16_31__GPIO_PINSEL2_MASK);
           i |= P2__16_31__GPIO_PINSEL2_VALUE;
           PINSEL2 = i;

           //set gpio p2.17 input
           i = IODIR2;
           i &= (~GPIO2_17__ext_out_IOxxx_M);
           IODIR2 = i;

           }

       }



/**********************************************************************
* name  :    spi_extend_set()
* func  :    spi extend control from spi0 extend the io control
* para  :    extend_io_onoff, name


* ret   :    none

* glob  :    spi_extend_data !!!!!!!!!!!!!!!******
* inc   :

* author:
* date  :

* modify:
* comment:
**********************************************************************/
// origin spi data
/*	          module_c_MOTOR_EN,
	          module_c_MMC_SD_EN,
	          module_c_U0_EN1_EN,
	          module_c_U0_EN2_EN,
	          module_c_U1_EN,
	          module_c_RS485_EN1_EN,
	          module_c_RS485_EN2_EN,
              // next 8 bit
              module_c_AUDIO_EN,
              module_c_PS2_EN,
              module_c_SSEL1_C_EN,
              module_c_LCM_EN,
              module_c_USB_RESET_EN,
              module_c_LCM_RESET_EN,
              module_c_CF_RESET_EN,
              module_c_CF_EN,
*/
// device
/*	          module_c_MOTOR_EN,
	          module_c_MMC_SD_EN,
	          module_c_U0_EN,
	          module_c_U1_EN,
	          module_c_RS485_EN,
              // next 8 bit
              module_c_AUDIO_EN,
              module_c_PS2_EN,
              module_c_SSEL1_C_EN,
              module_c_LCM_EN,
              module_c_USB_RESET_EN,
              module_c_LCM_RESET_EN,
              module_c_CF_RESET_EN,
              module_c_CF_EN,
*/

void spi_extend_set(ext_device_control extend_io_onoff, module_c_device device_name)
     {
//    glob
//    INT32U spi_extend_data;
      INT32U spi_extend_data_mask;
      INT32U spi_extend_data_value;
      INT32U spi_extend_data_t;
      INT32U spi_extend_data_h;
      INT32U spi_extend_data_l;

      INT32U i,j,k;

      if (extend_io_onoff == ext_device_on)
         {     // on current device
          //get the module mask and value
          switch (device_name)
                 {
                  case module_c_MOTOR_EN:
                                              spi_extend_data_mask = module_c_MOTOR_MASK;
                                              spi_extend_data_value = module_c_MOTOR_EN0;
              	     		    			  break;
                  case module_c_MMC_SD_EN:
                                              spi_extend_data_mask = module_c_MMC_SD_MASK;
                                              spi_extend_data_value = module_c_MMC_SD_EN0;
              	     					      break;
                  case module_c_U0_EN:
                                              spi_extend_data_mask = module_c_U0_MASK_1+module_c_U0_MASK_2;
                                              spi_extend_data_value = module_c_U0_EN1_EN1+module_c_U0_EN2_EN0;
                  	     					  break;
                  case module_c_U1_EN:
                                              spi_extend_data_mask = module_c_U1_MASK;
                                              spi_extend_data_value = module_c_U1_EN1;
              	         					  break;
                  case module_c_RS485_EN:
                                              spi_extend_data_mask = module_c_RS485_MASK1+module_c_RS485_MASK2;
                                              spi_extend_data_value = module_c_RS485_EN1_EN0+module_c_RS485_EN2_EN1;
              	         					  break;
                  case module_c_AUDIO_EN:
                                              spi_extend_data_mask = (module_c_AUDIO_MASK<<8);
                                              spi_extend_data_value = (module_c_AUDIO_EN0<<8);
              	     		    			  break;
                  case module_c_PS2_EN:
                                              spi_extend_data_mask = (module_c_PS2_MASK<<8);
                                              spi_extend_data_value = (module_c_PS2_EN0<<8);
              	         					  break;
                  case module_c_SSEL1_C_EN:
                                              spi_extend_data_mask = (module_c_SSEL1_C_MASK<<8);
                                              spi_extend_data_value = (module_c_SSEL1_C_EN1<<8);
                  	     					  break;
                  case module_c_LCM_EN:
                                              spi_extend_data_mask = (module_c_LCM_EN_MASK<<8);
                                              spi_extend_data_value = (module_c_LCM_EN0<<8);
                  	     					  break;
                  case module_c_USB_RESET_EN:
                                              spi_extend_data_mask = (module_c_USB_RESET_MASK<<8);
                                              spi_extend_data_value = (module_c_USB_RESET_EN0<<8);
                  	     					  break;
                  case module_c_LCM_RESET_EN:
                                              spi_extend_data_mask = (module_c_LCM_RESET_MASK<<8);
                                              spi_extend_data_value = (module_c_LCM_RESET_EN0<<8);
              	     				    	  break;
                  case module_c_CF_RESET_EN:
                                              spi_extend_data_mask = (module_c_CF_RESET_MASK<<8);
                                              spi_extend_data_value = (module_c_CF_RESET_EN0<<8);
              	     					      break;
                  case module_c_CF_EN:
                                              spi_extend_data_mask = (module_c_CF_EN_MASK<<8);
                                              spi_extend_data_value = (module_c_CF_EN0<<8);
              	     					      break;
                  default:
              	     					      break;
                 }
         }
      else
         {     // off current device
          //get the module mask and value
          switch (device_name)
                 {
                  case module_c_MOTOR_EN:
                                              spi_extend_data_mask = module_c_MOTOR_MASK;
                                              spi_extend_data_value = module_c_MOTOR_DIS;
              	     		    			  break;
                  case module_c_MMC_SD_EN:
                                              spi_extend_data_mask = module_c_MMC_SD_MASK;
                                              spi_extend_data_value = module_c_MMC_SD_DIS;
              	     					      break;
                  case module_c_U0_EN:
                                              spi_extend_data_mask = module_c_U0_MASK_1+module_c_U0_MASK_2;
                                              spi_extend_data_value = module_c_U0_EN1_DIS+module_c_U0_EN2_DIS;
                  	     					  break;
                  case module_c_U1_EN:
                                              spi_extend_data_mask = module_c_U1_MASK;
                                              spi_extend_data_value = module_c_U1_DIS;
              	         					  break;
                  case module_c_RS485_EN:
                                              spi_extend_data_mask = module_c_RS485_MASK1+module_c_RS485_MASK2;
                                              spi_extend_data_value = module_c_RS485_EN1_DIS+module_c_RS485_EN2_DIS;
              	         					  break;
                  case module_c_AUDIO_EN:
                                              spi_extend_data_mask = (module_c_AUDIO_MASK<<8);
                                              spi_extend_data_value = (module_c_AUDIO_DIS<<8);
              	     		    			  break;
                  case module_c_PS2_EN:
                                              spi_extend_data_mask = (module_c_PS2_MASK<<8);
                                              spi_extend_data_value = (module_c_PS2_DIS<<8);
              	         					  break;
                  case module_c_SSEL1_C_EN:
                                              spi_extend_data_mask = (module_c_SSEL1_C_MASK<<8);
                                              spi_extend_data_value = (module_c_SSEL1_C_DIS<<8);
                  	     					  break;
                  case module_c_LCM_EN:
                                              spi_extend_data_mask = (module_c_LCM_EN_MASK<<8);
                                              spi_extend_data_value = (module_c_LCM_DIS<<8);
                  	     					  break;
                  case module_c_USB_RESET_EN:
                                              spi_extend_data_mask = (module_c_USB_RESET_MASK<<8);
                                              spi_extend_data_value = (module_c_USB_RESET_DIS<<8);
                  	     					  break;
                  case module_c_LCM_RESET_EN:
                                              spi_extend_data_mask = (module_c_LCM_RESET_MASK<<8);
                                              spi_extend_data_value = (module_c_LCM_RESET_DIS<<8);
              	     				    	  break;
                  case module_c_CF_RESET_EN:
                                              spi_extend_data_mask = (module_c_CF_RESET_MASK<<8);
                                              spi_extend_data_value = (module_c_CF_RESET_DIS<<8);
              	     					      break;
                  case module_c_CF_EN:
                                              spi_extend_data_mask = (module_c_CF_EN_MASK<<8);
                                              spi_extend_data_value = (module_c_CF_DIS<<8);
              	     					      break;
                  default:
              	     					      break;
                 }
         }

      i = g_spi_extend_data;
      i &= ~spi_extend_data_mask;
      i |= spi_extend_data_value;
      //---------------------------------
      g_spi_extend_data=i; //change the g
      //----------------------------------
      j = i;
      i &= 0xff00;
      k = (i>>8);
      j &= 0x00ff;

      spi_extend_data_h=k;
      spi_extend_data_l=j;
      // send data through spi0
      spi_data_send(spi_c0, spi_extend_data_h);
      spi_data_send(spi_c0, spi_extend_data_l);
      // latch and output enable
      spi_extend_latch(ext_device_all_latchen);
      spi_extend_outputen(ext_device_all_outen);

     }



/**********************************************************************
* name  :    spi_extend_alloff()
* func  :    spi extend control from spi0 extend the io control
	         all off the device use to init the sys
* para  :    


* ret   :    none

* glob  :    spi_extend_data !!!!!!!!!!!!!!!******
* inc   :

* author:
* date  :

* modify:
* comment:
**********************************************************************/
void spi_extend_alloff(void)
     {

      INT32U spi_extend_data_h;
      INT32U spi_extend_data_l;

      spi_extend_data_h=module_c_all_module_off_BH;
      spi_extend_data_l=module_c_all_module_off_BL;
      // send data through spi0
      spi_data_send(spi_c0, spi_extend_data_h);
      spi_data_send(spi_c0, spi_extend_data_l);
      // latch and output enable
      spi_extend_latch(ext_device_all_latchen);
      spi_extend_outputen(ext_device_all_outen);

     }



//--------------------------------------------------------------------)





/**********************************************************************
* name  :    dc_motor(dc_motor_direction direction, INT32U dc_motor_speed)
* func  :    set dc_motor direction and motor speed
* para  :    direction        ---- motor run direction
	         dc_motor_speed   ---- motor run speed value


* ret   :    none

* glob  :    none
* inc   :

* author:
* date  :

* modify:
* comment:
**********************************************************************/
INT32U dc_motor(dc_motor_direction direction, INT32U dc_motor_speed)
               {
               	INT32U i,j,k;
               	
               	//linker
               	//set p to gpio and pwm
               	i = PINSEL0;
                i &= ~motor_control_PINSEL0_MASK;
              	i |= motor_control_PINSEL0_VALUE;
               	PINSEL0 = i;

                //set pwm


               }












/**********************************************************************
* name  :    dc_motor_onoff(on_off_value onoff)
* func  :    control the dc motor on off
* para  :    onoff   ---- control the motor


* ret   :    none

* glob  :    none
* inc   :

* author:
* date  :

* modify:
* comment:
**********************************************************************/
INT32U dc_motor_onoff(on_off_value onoff)
                     {
                     	
                     	
                     	
                     }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -