reset: homework7
This commit is contained in:
@@ -1,38 +0,0 @@
|
||||
---
|
||||
BasedOnStyle: Microsoft
|
||||
Language: Cpp
|
||||
|
||||
###################################
|
||||
# indent conf
|
||||
###################################
|
||||
|
||||
UseTab: Never
|
||||
IndentWidth: 4
|
||||
TabWidth: 4
|
||||
ColumnLimit: 0
|
||||
AccessModifierOffset: -4
|
||||
NamespaceIndentation: All
|
||||
FixNamespaceComments: false
|
||||
BreakBeforeBraces: Linux
|
||||
|
||||
###################################
|
||||
# other styles
|
||||
###################################
|
||||
|
||||
#
|
||||
# for more conf, you can ref: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
|
||||
#
|
||||
|
||||
AllowShortIfStatementsOnASingleLine: true
|
||||
|
||||
AllowShortLoopsOnASingleLine: true
|
||||
|
||||
AllowShortBlocksOnASingleLine: true
|
||||
|
||||
IndentCaseLabels: true
|
||||
|
||||
SortIncludes: false
|
||||
|
||||
AlignConsecutiveMacros: AcrossEmptyLines
|
||||
|
||||
AlignConsecutiveAssignments: Consecutive
|
||||
@@ -1,80 +0,0 @@
|
||||
{
|
||||
"name": "homework7",
|
||||
"type": "C51",
|
||||
"dependenceList": [],
|
||||
"srcDirs": [
|
||||
"src"
|
||||
],
|
||||
"virtualFolder": {
|
||||
"name": "<virtual_root>",
|
||||
"files": [],
|
||||
"folders": []
|
||||
},
|
||||
"outDir": "build",
|
||||
"deviceName": null,
|
||||
"packDir": null,
|
||||
"miscInfo": {
|
||||
"uid": "a74a2e195a221198aeca03581815d248"
|
||||
},
|
||||
"targets": {
|
||||
"Debug": {
|
||||
"excludeList": [],
|
||||
"toolchain": "Keil_C51",
|
||||
"compileConfig": {
|
||||
"options": "null"
|
||||
},
|
||||
"uploader": "Custom",
|
||||
"uploadConfig": {
|
||||
"bin": "",
|
||||
"commandLine": "",
|
||||
"eraseChipCommand": ""
|
||||
},
|
||||
"uploadConfigMap": {},
|
||||
"custom_dep": {
|
||||
"name": "default",
|
||||
"incList": [],
|
||||
"libList": [],
|
||||
"defineList": []
|
||||
},
|
||||
"builderOptions": {
|
||||
"SDCC": {
|
||||
"version": 3,
|
||||
"beforeBuildTasks": [],
|
||||
"afterBuildTasks": [],
|
||||
"global": {
|
||||
"device": "mcs51",
|
||||
"optimize-type": "speed",
|
||||
"use-non-free": false
|
||||
},
|
||||
"c/cpp-compiler": {
|
||||
"language-c": "c99"
|
||||
},
|
||||
"asm-compiler": {},
|
||||
"linker": {
|
||||
"$mainFileName": "main",
|
||||
"output-format": "hex"
|
||||
}
|
||||
},
|
||||
"Keil_C51": {
|
||||
"version": 2,
|
||||
"beforeBuildTasks": [],
|
||||
"afterBuildTasks": [],
|
||||
"global": {
|
||||
"ram-mode": "SMALL",
|
||||
"rom-mode": "LARGE"
|
||||
},
|
||||
"c/cpp-compiler": {
|
||||
"optimization-type": "SPEED",
|
||||
"optimization-level": "level-8"
|
||||
},
|
||||
"asm-compiler": {},
|
||||
"linker": {
|
||||
"remove-unused": true,
|
||||
"output-format": "elf"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"version": "3.5"
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
##########################################################################################
|
||||
# Append Compiler Options For Source Files
|
||||
##########################################################################################
|
||||
|
||||
# syntax:
|
||||
# <your pattern>: <compiler options>
|
||||
# For get pattern syntax, please refer to: https://www.npmjs.com/package/micromatch
|
||||
#
|
||||
# examples:
|
||||
# 'main.cpp': --cpp11 -Og ...
|
||||
# 'src/*.c': -gnu -O2 ...
|
||||
# 'src/lib/**/*.cpp': --cpp11 -Os ...
|
||||
# '!Application/*.c': -O0
|
||||
# '**/*.c': -O2 -gnu ...
|
||||
|
||||
version: "2.0"
|
||||
options:
|
||||
Debug:
|
||||
files: {}
|
||||
virtualPathFiles: {}
|
||||
@@ -1,15 +0,0 @@
|
||||
# dot files
|
||||
/.vscode/launch.json
|
||||
/.settings
|
||||
/.eide/log
|
||||
/.eide.usr.ctx.json
|
||||
|
||||
# project out
|
||||
/build
|
||||
/bin
|
||||
/obj
|
||||
/out
|
||||
|
||||
# eide template
|
||||
*.ept
|
||||
*.eide-template
|
||||
Vendored
-1
@@ -1 +0,0 @@
|
||||
{}
|
||||
Vendored
-40
@@ -1,40 +0,0 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "build",
|
||||
"type": "shell",
|
||||
"command": "${command:eide.project.build}",
|
||||
"group": "build",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "flash",
|
||||
"type": "shell",
|
||||
"command": "${command:eide.project.uploadToDevice}",
|
||||
"group": "build",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "build and flash",
|
||||
"type": "shell",
|
||||
"command": "${command:eide.project.buildAndFlash}",
|
||||
"group": "build",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "rebuild",
|
||||
"type": "shell",
|
||||
"command": "${command:eide.project.rebuild}",
|
||||
"group": "build",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "clean",
|
||||
"type": "shell",
|
||||
"command": "${command:eide.project.clean}",
|
||||
"group": "build",
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
{
|
||||
"folders": [
|
||||
{
|
||||
"path": "."
|
||||
}
|
||||
],
|
||||
"settings": {
|
||||
"files.autoGuessEncoding": true,
|
||||
"C_Cpp.default.configurationProvider": "cl.eide",
|
||||
"C_Cpp.errorSquiggles": "disabled",
|
||||
"files.associations": {
|
||||
".eideignore": "ignore",
|
||||
"*.a51": "a51",
|
||||
"*.h": "c",
|
||||
"*.c": "c",
|
||||
"*.hxx": "cpp",
|
||||
"*.hpp": "cpp",
|
||||
"*.c++": "cpp",
|
||||
"*.cpp": "cpp",
|
||||
"*.cxx": "cpp",
|
||||
"*.cc": "cpp"
|
||||
},
|
||||
"[yaml]": {
|
||||
"editor.insertSpaces": true,
|
||||
"editor.tabSize": 4,
|
||||
"editor.autoIndent": "advanced"
|
||||
}
|
||||
},
|
||||
"extensions": {
|
||||
"recommendations": [
|
||||
"cl.eide",
|
||||
"keroc.hex-fmt",
|
||||
"xiaoyongdong.srecord",
|
||||
"hars.cppsnippets",
|
||||
"zixuanwang.linkerscript",
|
||||
"redhat.vscode-yaml",
|
||||
"IBM.output-colorizer",
|
||||
"cschlosser.doxdocgen",
|
||||
"ms-vscode.vscode-serial-monitor",
|
||||
"alefragnani.project-manager",
|
||||
"cl.stm8-debug"
|
||||
]
|
||||
}
|
||||
}
|
||||
Binary file not shown.
@@ -1,73 +0,0 @@
|
||||
/*
|
||||
* name: homework7.h
|
||||
* author: msksbr
|
||||
* date: 2025/05/22
|
||||
* description: a header file for homework7(a 51 MCU lesson homework)
|
||||
* version: 1.0
|
||||
* variables:
|
||||
* 1.0:
|
||||
* 1. pin numbers for BUS of leds, segs and matrix led
|
||||
* 2. pin numbers for BUS of 74HC138
|
||||
* functions:
|
||||
* 1.0:
|
||||
* 1. 74HC138 switcher
|
||||
* 2. timer by ms based on timer0 with mode 1
|
||||
*/
|
||||
|
||||
#include <REG52.H>
|
||||
|
||||
// variables:
|
||||
// 1. pin numbers for BUS of leds, segs and matrix led
|
||||
sbit DB0 = P0 ^ 0;
|
||||
sbit DB1 = P0 ^ 1;
|
||||
sbit DB2 = P0 ^ 2;
|
||||
sbit DB3 = P0 ^ 3;
|
||||
sbit DB4 = P0 ^ 4;
|
||||
sbit DB5 = P0 ^ 5;
|
||||
sbit DB6 = P0 ^ 6;
|
||||
sbit DB7 = P0 ^ 7;
|
||||
// 2. pin numbers for BUS of 74HC138
|
||||
sbit ADDR0 = P1 ^ 0; // @param ADDR0: to A(A0) of 74HC138
|
||||
sbit ADDR1 = P1 ^ 1; // @param ADDR1: to B(A1) of 74HC138
|
||||
sbit ADDR2 = P1 ^ 2; // @param ADDR2: to C(A2) of 74HC138
|
||||
|
||||
sbit ADDR3 = P1 ^ 3; // @param ADDR3: to E1 of 74HC138
|
||||
sbit ENLED = P1 ^ 4; // @param ENLED: to E2 & E3 of 74HC138
|
||||
|
||||
// functions:
|
||||
// 1. 74HC138 switcher
|
||||
void switch_38(unsigned char n)
|
||||
{
|
||||
// @subsection: turn n to 3 bits of binary number
|
||||
bit A0 = n & 0x01;
|
||||
bit A1 = (n >> 1) & 0x01;
|
||||
bit A2 = (n >> 2) & 0x01;
|
||||
// @subsection: turn on 74HC138
|
||||
ENLED = 0;
|
||||
ADDR3 = 1;
|
||||
// @subsection: add 3 bits of binary number to 74HC138
|
||||
ADDR0 = A0;
|
||||
ADDR1 = A1;
|
||||
ADDR2 = A2;
|
||||
}
|
||||
// 2. timer by ms based on timer0 with mode 1
|
||||
void timer0_mode1(unsigned int ms)
|
||||
{
|
||||
unsigned int i;
|
||||
// @subsection: set timer0 to mode 1
|
||||
TMOD = 0x01;
|
||||
// @subsection: set timer0 to 11.0592MHz
|
||||
TH0 = 0xFC;
|
||||
TL0 = 0x67;
|
||||
// @subsection: start timer0
|
||||
TR0 = 1;
|
||||
// @subsection: wait for timer0 to count ms times
|
||||
for (i = 0; i < ms; i++) {
|
||||
while (!TF0);
|
||||
TF0 = 0;
|
||||
TH0 = 0xFC;
|
||||
TL0 = 0x67;
|
||||
}
|
||||
// @subsection: stop timer0
|
||||
TR0 = 0;
|
||||
}
|
||||
Reference in New Issue
Block a user