📄 22eb06_lib_modulecontrol.c
字号:
/*
***********************************************************************
Embest Info&Tech Co., Ltd. All rights reserved.
www.embedinfo.com
***********************************************************************
---------------- file information -------------------------------------
file name: 22eb06_lib_modulecontrol.c
version : v0
author : peter pan / panqan@hotmail.com
begin : 2006-02-10
finish : 2006-02-10
define : lpc22eb06 module control to enable or disable the module
notes :
---------------- modify information -----------------------------------
version :
modify :
begin :
finish :
define :
-----------------------------------------------------------------------
*/
// (--------------------- compiler condition --------------------------
/*
#ifdef xxx
#define xxx
#endif
*/
// --------------------- compiler condition --------------------------)
/*-------------------------------------------------------------------*/
/* include files */
/*---------------------------------------------------------------- --*/
#include "22eb06_lib_modulecontrol.h"
/*-------------------------------------------------------------------*/
/* variable define */
/*-------------------------------------------------------------------*/
/*
INT32U XXXXXX;
*/
INT32U spi_extend_data=module_c_all_off;
/*-------------------------------------------------------------------*/
/* extern function declare */
/*-------------------------------------------------------------------*/
/*--- define in XXX.c ---
extern void XXX();
*/
/*-------------------------------------------------------------------*/
/* extern variable declare */
/*-------------------------------------------------------------------*/
/*--- USED in XXX() ---
XXX SSS; // used inXXX()
*/
/*-------------------------------------------------------------------*/
/* function code */
/*-------------------------------------------------------------------*/
/**********************************************************************
* name : display88_latch
* func : latch the spi send to 595 data used p2.19
* para : LATCH_EN
1: latch the send data
0: off the latch
* ret : xxxx
* glob : xxxx
* inc :
* author:
* date :
* modify:
* comment:
**********************************************************************/
INT32U display88_latch(INT32U LATCH_EN)
{
INT32U i,j;
if (1==LATCH_EN)
{
//link to gpio p2.19U
i = PINSEL2;
i &= (~P2__16_31__GPIO_MASK);
i |= P2__16_31__GPIO;
PINSEL2 = i;
//set value 0
i = IOCLR2;
i |= GPIO2_19_88latch;
IOCLR2 = i;
//set gpio p2.19 output
i = IODIR2;
i &= (~GPIO2_19_88latch_MASK);
i |= GPIO2_19_88latch;
IODIR2 = i;
//set value 0
i = IOCLR2;
i |= GPIO2_19_88latch;
IOCLR2 = i;
//set value 1
i = IOSET2;
i |= GPIO2_19_88latch;
IOSET2 = i;
//set value 0
i = IOCLR2;
i |= GPIO2_19_88latch;
IOCLR2 = i;
}
else
{
//link to gpio p2.19
i = PINSEL2;
i &= (~P2__16_31__GPIO_MASK);
i |= P2__16_31__GPIO;
PINSEL2 = i;
//set gpio p2.19 input
i = IODIR2;
i &= (~GPIO2_19_88latch_MASK);
IODIR2 = i;
}
}
/**********************************************************************
* name : display88_outputen
* func : enable the display88 outputen
* para : OUTPUTEN
1: EN output
0: off output
* ret : xxxx
* glob : xxxx
* inc :
* author:
* date :
* modify:
* comment:
**********************************************************************/
INT32U display88_outputen(INT32U OUTPUTEN)
{
INT32U i,j;
if (1==OUTPUTEN)
{
//link to gpio p2.18
i = PINSEL2;
i &= (~P2__16_31__GPIO_MASK);
i |= P2__16_31__GPIO;
PINSEL2 = i;
//set gpio p2.18 output
i = IODIR2;
i &= (~GPIO2_18_88EN_MASK);
i |= GPIO2_18_88EN;
IODIR2 = i;
//set value 0
i = IOCLR2;
i |= GPIO2_18_88EN_MASK;
// i &= (~GPIO2_18_88EN_MASK);
IOCLR2 = i;
}
else
{
//link to gpio p2.18
i = PINSEL2;
i &= (~P2__16_31__GPIO_MASK);
i |= P2__16_31__GPIO;
PINSEL2 = i;
//set gpio p2.18 input
i = IODIR2;
i &= (~GPIO2_18_88EN_MASK);
IODIR2 = i;
}
}
/**********************************************************************
* name : spi_extend_latch
* func : latch the spi send to 595 data used p2.16
* para : LATCH_EN
1: latch the send data
0: off the latch
* ret : xxxx
* glob : xxxx
* inc :
* author:
* date :
* modify:
* comment:
**********************************************************************/
INT32U spi_extend_latch(INT32U LATCH_EN)
{
INT32U i,j;
if (1==LATCH_EN)
{
//link to gpio p2.16
i = PINSEL2;
i &= (~P2__16_31__GPIO_MASK);
i |= P2__16_31__GPIO;
PINSEL2 = i;
//set value 0
i = IOCLR2;
i |= GPIO2_16_spi_extend_latch;
IOCLR2 = i;
//set gpio p2.16 output
i = IODIR2;
i &= (~GPIO2_16_spi_extend_latch_MASK);
i |= GPIO2_16_spi_extend_latch;
IODIR2 = i;
//set value 0
i = IOCLR2;
i |= GPIO2_16_spi_extend_latch_MASK;
IOCLR2 = i;
//set value 1
i = IOSET2;
i |= GPIO2_16_spi_extend_latch_MASK;
IOSET2 = i;
//set value 0
i = IOCLR2;
i |= GPIO2_16_spi_extend_latch_MASK;
IOCLR2 = i;
}
else
{
//link to gpio p2.16
i = PINSEL2;
i &= (~P2__16_31__GPIO_MASK);
i |= P2__16_31__GPIO;
PINSEL2 = i;
//set gpio p2.16 input
i = IODIR2;
i &= (~GPIO2_16_spi_extend_latch_MASK);
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(INT32U OUTPUTEN)
{
INT32U i,j;
if (1==OUTPUTEN)
{ // on the all expend output
//link to gpio p2.17
i = PINSEL2;
i &= (~P2__16_31__GPIO_MASK);
i |= P2__16_31__GPIO;
PINSEL2 = i;
//set gpio p2.17 output
i = IODIR2;
i &= (~GPIO2_17_spi_extend_out_MASK);
i |= GPIO2_17_spi_extend_out;
IODIR2 = i;
//set value 0
i = IOCLR2;
i |= GPIO2_17_spi_extend_out_MASK;
IOCLR2 = i;
}
else
{ // off all output about expend
//link to gpio p2.17
i = PINSEL2;
i &= (~P2__16_31__GPIO_MASK);
i |= P2__16_31__GPIO;
PINSEL2 = i;
//set gpio p2.17 input
i = IODIR2;
i &= (~GPIO2_17_spi_extend_out_MASK);
IODIR2 = i;
}
}
/**********************************************************************
* name : spi_extend_set()
* func : spi extend control from spi0 extend the io control
* para : extend_io_onoff: 0-on, 1-0ff, module name
* ret : none
* glob : xxxx
* inc :
* author:
* date :
* modify:
* comment:
**********************************************************************/
void spi_extend_set(INT32U extend_io_onoff, module_c_device device_name)
{ // extend_io_onff: '1' off '0' on
INT16U spi_extend_data_t=1;
INT16U spi_extend_data_mask=1;
INT8U spi_extend_data_h;
INT8U spi_extend_data_l;
switch (device_name)
{
case module_c_MOTOR_EN:
spi_extend_data_t=module_c_MOTOR_EN0;
spi_extend_data_mask=module_c_MOTOR_MASK;
break;
case module_c_MMC_SD_EN:
spi_extend_data_t=module_c_MMC_SD_EN0;
spi_extend_data_mask=module_c_MMC_SD_MASK;
break;
case module_c_U0_EN:
spi_extend_data_t=module_c_U0_EN1_EN1+module_c_U0_EN2_EN0;
spi_extend_data_mask=module_c_U0_MASK_1+module_c_U0_MASK_2;
break;
case module_c_U1_EN:
spi_extend_data_t=module_c_U1_EN1;
spi_extend_data_mask=module_c_U1_MASK;
break;
case module_c_RS485_EN:
spi_extend_data_t=module_c_RS485_EN1_EN0+module_c_RS485_EN2_EN1;
spi_extend_data_mask=module_c_RS485_MASK1+module_c_RS485_MASK2;
break;
case module_c_AUDIO_EN:
spi_extend_data_t=module_c_AUDIO_EN0;
spi_extend_data_mask=module_c_AUDIO_MASK;
break;
case module_c_PS2_EN:
spi_extend_data_t=module_c_PS2_EN0;
spi_extend_data_mask=module_c_PS2_MASK;
break;
case module_c_SSEL1_C_EN:
spi_extend_data_t=module_c_SSEL1_C_EN1;
spi_extend_data_mask=module_c_SSEL1_C_MASK;
break;
case module_c_LCM_EN:
spi_extend_data_t=module_c_LCM_EN0;
spi_extend_data_mask=module_c_LCM_EN_MASK;
break;
case module_c_USB_RESET_EN:
spi_extend_data_t=module_c_USB_RESET_EN0;
spi_extend_data_mask=module_c_USB_RESET_MASK;
break;
case module_c_LCM_RESET_EN:
spi_extend_data_t=module_c_LCM_RESET_EN0;
spi_extend_data_mask=module_c_LCM_RESET_MASK;
break;
case module_c_CF_RESET_EN:
spi_extend_data_t=module_c_CF_RESET_EN0;
spi_extend_data_mask=module_c_CF_RESET_MASK;
break;
case module_c_CF_EN:
spi_extend_data_t=module_c_CF_EN0;
spi_extend_data_mask=module_c_CF_EN_MASK;
break;
default:
break;
}
if (extend_io_onoff != 0) // off current device
spi_extend_data_t = (~spi_extend_data_t)&spi_extend_data_mask;
spi_extend_data &= (~spi_extend_data_mask);
spi_extend_data |= spi_extend_data_t;
spi_extend_data_h = (spi_extend_data>>8);
spi_extend_data_l = (spi_extend_data & 0xff);
spi_data_send(0, spi_extend_data_h);
spi_data_send(0, spi_extend_data_l);
spi_extend_latch(1);
spi_extend_outputen(1);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -