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

📄 ioport.c

📁 Cypress公司Cy7c6xxxx芯片的USB键盘及USB鼠标的firmware代码以及一些example代码。
💻 C
字号:
#pragma option f0 /* remove page breaks from listing file */
/* 
 * CYC Code Development System
 * Tutorial Example
 * IOPORT.C
 * This code may be adapted for any purpose
 * when used with the CYC Code Development
 * System.  No warranty is implied or given
 * as to their usability for any purpose.
 * 
 * (c) Copyright 2000 Byte Craft Limited
 * 421 King St.N., Waterloo, ON, Canada, N2J 4E4
 * VOICE: 1 (519) 888 6911
 * FAX  : 1 (519) 746 6751
 * email: support@bytecraft.com
 * 
 * REVISION HISTORY
 * v1.00 AL 01/2000 Initial Version.
 */
#include <dev\c63413.h>
#include <port.h>
                                                                                                          /*_ioport_*/
void main(void)
{
        int i;

        /* initialize the IO ports to 0x00 */
        PORT0 = 0x00;
        PORT1 = 0x00;
        PORT2 = 0x00;
        PORT3 = 0x00;

        /* set PORT0 to resistive move */
        GPIO_CONFIG = PORT3_OPEN | PORT2_OPEN | PORT1_OPEN | PORT0_RESISTIVE;


        PORT_WRITE(PORT0,0x55); /* write a value to PORT0 latch and PORT0 IO pins */

        PORT0=0x55; /* write to PORT0 pins */

        PORT0_S=i; /* write to PORT0 latch */

        i=PORT_READ(PORT0); /* read PORT0 latch */

        i=PORT0_S; /* read PORT0 latch */

        i=PORT0; /* read PORT0 pins */

        /* read modify write is done by setting bit 3 in
           the latch and writing the latch to the port */
        PORT_SET_BIT(PORT0,3); /* set PORT0 pin 3 and PORT0 latch and bit 3 */

        /* read modify write is done by writing to the pins
           the value read from the pins with bit 3 set */
        PORT0.3=1; /* set PORT0 pin 3 */

        /* read modify write is done by clearing bit 3 in
           the latch and writing the latch to the port */
        PORT_CLEAR_BIT(PORT0,3); /* clear PORT0 pin 3 and PORT0 latch bit 3 */

        /* read modify write is done by writing to the pins
           the value read from the pins with bit 3 clear */
        PORT0.3=0; /* clear PORT0 pin 3 */

        PORT_READ_BIT(PORT0,3); /* read PORT0 latch bit 3 */

        i=PORT0.3; /* read PORT0 pin 3 */

        while(1); /* loop forever */
}
                                                                                                          /*_ioport_*/

⌨️ 快捷键说明

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