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

📄 main.c

📁 利用psoc进行usb及capsense的程序编写
💻 C
字号:
//----------------------------------------------------------------------------
// C main line for example 1
//
// Copyright 2005, John Hyde,  USB Design By Example
// You may use this program for development but you may not sell or publish it
// without the written permission of the author
//
// Send questions to john@USB_By_Example.com
//----------------------------------------------------------------------------

#include <m8c.h>        // part specific constants and macros
#include "PSoCAPI.h"    // PSoC API definitions for all User Modules
#include "usb.h"

// Declare the function prototypes
#pragma fastcall16 init_hardware
#pragma fastcall16 scan_buttons
#pragma fastcall16 update_LEDs
void init_hardware(void);
BYTE scan_buttons(void);
void update_LEDs(BYTE Value);

extern BYTE SOF_Flag;	// Set in SOF_ISR
extern BYTE USB_INTERFACE_0_OUT_RPT_DATA[8];
BYTE buttons_now;		// Current value of debounced buttons
BYTE buttons_report;	// A one byte OUT report
BYTE lights_report;		// A one byte IN report

void main() {
	init_hardware();
	M8C_EnableGInt;
	USB_Start(0, USB_5V_OPERATION);
	
	while (!USB_bGetConfiguration());
	USB_INT_REG |= USB_INT_SOF_MASK;
	
	while (1) {
		if (SOF_Flag) {
// Arrive here every 1 msec
			SOF_Flag = 0;
			buttons_now = scan_buttons();
			if (buttons_report != buttons_now) {
// If buttons have changed then tell the host
				buttons_report = buttons_now;
				USB_LoadInEP(2, &buttons_report, 1, USB_TOGGLE);
				}
// If a lights report has been received update the local display
			lights_report = USB_INTERFACE_0_OUT_RPT_DATA[0];
			update_LEDs(lights_report);
			}
		}
	}

⌨️ 快捷键说明

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