Git Product home page Git Product logo

test's Introduction

Hi there 👋

Techial's GitHub stats

广告位出租

Billboard rental

看板レンタル

Powered by Google translate

test's People

Contributors

techiall avatar

Stargazers

 avatar  avatar

Watchers

 avatar

test's Issues

vscode_icc7avr

前言废话

AVR 开发环境很简单,老师让我们使用的是 ICC AVR 这个软件,基于 Mega16

AVR 开发软件链接:AVR开发软件下载

5ab120b7c29f7.png

界面如上

个人是觉得这个界面很简单,对于一个强迫症患者来说,颜值第一,再考虑实用性,可惜这个软件,这两点都达不到。

我觉得写代码也要写的舒适一点,为革命保护视力,给 Visual Studio 换颜色 ,这个是之前看的文章。我觉得一个好的编译器配色方案,可以让人写代码更加舒服。

下面介绍如何用 vscode 写 avr 程序并编译成 hex 文件。

一、配置 ICC AVR 环境变量

先安装好 ICC AVR ,接着找到 ICC AVR 安装路径。打开 bin 文件夹,复制该文件夹的路径。

假设路径为 D:\iccv7avr\bin

其实和配置 Java 和 Python 环境变量差不多。

电脑(右键) - 属性 - 高级系统设置 - 环境变量 - 系统变量 - Path - 新建 - 粘贴 bin 路径 - 保存 - 退出。

打开 cmd ,输入 imakew ,若出现以下信息则说明配置成功。

D:\iccv7avr\bin\imakew.exe: Can't open makefile

二、打开 vscode 写代码并编译

安装 vscode 的过程就省了,官网就可以下载安装即可。

新建一个文件夹,名字任意。

vscode 打开该文件夹。

接着创建三个文档。

  • FIRST.lk
  • FIRST.mak
  • main.c

FIRST.lk 写入如下内容

main.o 

FIRST.mak 写入如下内容,这些参数根据自己的板子自己调整。(其实有一个方法就是在 ICC AVR 软件中创建好一个工程,然后参数什么的调好之后,复制那个后缀名为 .mak 的文件即可)

CC = iccavr
LIB = ilibw
CFLAGS =  -e -D__ICC_VERSION=722 -DATMega16  -l -g -MLongJump -MHasMul -MEnhanced -Wf-const_is_flash -DCONST="" 
ASFLAGS = $(CFLAGS) 
LFLAGS =  -g -e:0x4000 -ucrtatmega.o -bfunc_lit:0x54.0x4000 -dram_end:0x45f -bdata:0x60.0x45f -dhwstk_size:16 -beeprom:0.512 -fihx_coff -S2
FILES = main.o 

FIRST:	$(FILES)
	$(CC) -o FIRST $(LFLAGS) @FIRST.lk   -lcatm128
main.o: D:\iccv7avr\include\iom16v.h D:\iccv7avr\include\macros.h D:\iccv7avr\include\AVRdef.h
main.o:	main.c
	$(CC) -c $(CFLAGS) main.c

main.c 写入如下内容

/*
imakew -f FIRST.mak
*/
#include <iom16v.h>
#include <macros.h>

int main(void)
{
	return 0;
}

按下 ctrl + ` 快捷键,打开终端,或者从 vscode 界面下方拉起。

在该文件夹的目录下,输入以下命令 imakew -f FIRST.mak ,即可编译成功。成功编译的截图如下

5ab12704e7720.png

回到项目工程的文件夹,会发现生成了一下其他的文件,其中就包括了后缀名为 hex 的文件。

修改 main.c 文件的内容,保存后使用刚才的编译命令即可编译生成新的文件。其实这个过程和用 Java 写代码,然后用命令行编译 Java 过程类似。

三、链接到 avr 头文件库

把鼠标放到头文件处,点击设置连接路径,找到 name: "Win32" , 在 includepath 的最后面添加 ivvavr 的 include 文件夹。

假设路径为 D:\iccv7avr\include

这样子就链接到了 avr 的头文件库了。这样子就可以在 vscode 愉快的写 avr 代码。

WeChat Image_20180321093501.png

vscode and vcc 对比图

test_output

题库链接

http://acm.two.moe:808/JudgeOnline/

Linux 内核代码风格(供参考

https://www.kernel.org/doc/html/v4.13/translations/zh_CN/coding-style.html

1092: 输入输出练习之A+B(1)

1092: 输入输出练习之A+B(1)
题目描述
计算a+b

输入
若干组测试数据,每组测试数据占一行,包含2个整数a和b,空格隔开。

输出
对于每组测试数据,输出占一行,结果为a+b的和。

样例输入
1 5
10 20
样例输出
6
30

参考代码

#include <stdio.h>
int main(void)
{
	int a, b;
	while (~scanf("%d %d", &a, &b)) {
		printf("%d\n", a + b);
	}
	return 0;
}

//#include <stdio.h>
//int main(void)
//{
//	int a, b;
//	while (scanf("%d %d", &a, &b) != EOF) {
//		printf("%d\n", a + b);
//	}
//	return 0;
//}

1093: 输入输出练习之A+B(2)

1093: 输入输出练习之A+B(2)
题目描述
计算a+b

输入
第一行为一个整数n,接下来有n行。每行包含2个整数a和b,空格隔开。

输出
对于每对a和b,计算它们的和,并占一行输出。

样例输入
2
1 5
10 20
样例输出
6
30

参考代码

#include <stdio.h>
int main(void)
{
  	int t;
  	scanf("%d", &t);
  	while (t--) {
		int a, b;
		scanf("%d %d", &a, &b);
		printf("%d\n", a + b);
    }
	return 0;
}

1094: 输入输出练习之A+B(3)

1094: 输入输出练习之A+B(3)
题目描述
计算a+b

输入
输入包含多组测试用例。每组用例占一行,包含2个整数a和b。最后一组用例为0 0,表示输入结束,该用例不需要处理。

输出
对于每组输入用例,输入a+b的和,占一行。

样例输入
1 5
10 20
0 0
样例输出
6
30

参考代码

#include <stdio.h>
int main(void)
{
	int a, b;
	while (~scanf("%d %d", &a, &b) ) {
      	if (a == 0 && b == 0) {
        	break;
      	}
		printf("%d\n", a + b);
	}
	return 0;
}

//#include <stdio.h>
//int main(void)
//{
//#ifdef _DEBUG
//	freopen("in.txt", "r", stdin);
//	//freopen("out.txt", "w", stdout);
//#endif // _DEBUG
//	int a, b;
//	while (~scanf("%d %d", &a, &b) && (a || b)) {
//		printf("%d\n", a + b);
//	}
//	return 0;
//}

1095: 输入输出练习之A+B(4)

1095: 输入输出练习之A+B(4)
题目描述
计算整数的和。

输入
输入包含多组测试用例。每组用例占一行,每行第一个整数为n,接下来有n个整数。以0开头的用例表示输入结束,该组用例不需要处理。

输出
对于每组测试用例,计算该用例中n个整数的和,占一行输出。

样例输入
4 1 2 3 4
5 1 2 3 4 5
0 
样例输出
10
15

参考代码

#include <stdio.h>
int main(void)
{
    int t;
    while (scanf("%d", &t) && t) { 
        int n;
        int sum = 0;
        for (int i = 0; i < t; i++) {
            scanf("%d", &n);
            sum += n;
            if (sum == 0) {
                break;
            }
        }
        printf("%d\n", sum);
    }
    return 0;
}

1096: 输入输出练习之A+B(5)

1096: 输入输出练习之A+B(5)
题目描述
计算整数的和。

输入
第一行为一个整数n,接下来有n行。每一行第一个整数为m,该行接下来有m个整数。

输出
对于每组测试用例,计算m个整数的和,输出占一行。

样例输入
2
4 1 2 3 4
5 1 2 3 4 5
样例输出
10
15

参考代码

#include <stdio.h>
int main(void)
{
	int t;
	scanf("%d", &t);
	while (t--) {
		int n;
		scanf("%d", &n);
		int x;
		int num = 0;
		for (int i = 0; i < n; i++) {
			scanf("%d", &x);
			num += x;
		}
		printf("%d\n", num);
	}
	return 0;
}

1097: 输入输出练习之A+B(6)

1097: 输入输出练习之A+B(6)
题目描述
计算整数的和。

输入
输入包含多组测试用例,每组用例占一行。每组用例第一个整数为n,接下来该行有n个整数。

输出
对于每组用例,计算n个整数的和,占一行输出。

样例输入
4 1 2 3 4
5 1 2 3 4 5
样例输出
10
15

参考代码

#include <stdio.h>
int main(void)
{
	int n;
	while (~scanf("%d", &n)) {
		int x;
		int num = 0;
		for (int i = 0; i < n; i++) {
			scanf("%d", &x);
			num += x;
		}
		printf("%d\n", num);
	}
	return 0;
}

1098: 输入输出练习之A+B(7)

1098: 输入输出练习之A+B(7)
题目描述
计算a+b

输入
输入包含多组数据,每组占一行。每一行有2个整数a和b,空格隔开。

输出
对于每组数据,计算a+b的和,然后输出一个空行。

样例输入
1 5
10 20
样例输出
6

30

参考代码

#include <stdio.h>
int main(void)
{
	int a, b;
	while (~scanf("%d %d", &a, &b)) {
		printf("%d\n\n", a + b);
	}
	return 0;
}

1099: 输入输出练习之A+B(8)

1099: 输入输出练习之A+B(8)
题目描述
计算整数的和。

输入
输入第一行为一个整数n,接下来有n行。每一行开头有一个整数m,接下来有m个整数。

输出
对于每组数据,输出m个整数的和。同时每组输出之间有一个空行。

样例输入
3
4 1 2 3 4
5 1 2 3 4 5
3 1 2 3
样例输出
10

15

6

参考代码

#include <stdio.h>
int main(void)
{
#ifdef _DEBUG
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif // _DEBUG

	int n;
	scanf("%d", &n);
	int falg = 0;
	while (n--) {
		int t;
		scanf("%d", &t);
		int x;
		int sum = 0;
		for (int i = 0; i < t; i++) {
			scanf("%d", &x);
			sum += x;
		}
		printf("%d%s", sum, n == 0 ? "" : "\n\n");
	}
	return 0;
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.