use others finalterm

This commit is contained in:
2025-05-29 20:03:51 +08:00
parent b13f90b5b4
commit e3c9129e83
15 changed files with 4 additions and 474 deletions
+4 -1
View File
@@ -53,4 +53,7 @@ dkms.conf
# proteus workspace
*.workspace
*/Project Backups/
*/Project Backups/
# others
89C51_Simple_Calculator/
-38
View File
@@ -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
-82
View File
@@ -1,82 +0,0 @@
{
"name": "FinalTerm",
"type": "C51",
"dependenceList": [],
"srcDirs": [
"src"
],
"virtualFolder": {
"name": "<virtual_root>",
"files": [],
"folders": []
},
"outDir": "build",
"deviceName": null,
"packDir": null,
"miscInfo": {
"uid": "f8e8e5ec8af6045a09b255d06d661dfe"
},
"targets": {
"Debug": {
"excludeList": [
"src/main.c"
],
"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"
}
-20
View File
@@ -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: {}
-15
View File
@@ -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
-1
View File
@@ -1 +0,0 @@
{}
-40
View File
@@ -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": []
}
]
}
-44
View File
@@ -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.
-70
View File
@@ -1,70 +0,0 @@
/*
* @name: 51pins.h
* @author: msksbr
* @date: 2025-05-29
* @description: defines the 7 segs chars and pins for LEDs, 74HC138 and buttons
* @usage: #include "REG52.H"
*/
#include <REG52.H>
// 74HC138 pins (P1)
// controller pins
sbit ADDR0 = P1 ^ 0; // to A(A0)
sbit ADDR1 = P1 ^ 1; // to B(A1)
sbit ADDR2 = P1 ^ 2; // to C(A2)
// enable pins
sbit ADDR3 = P1 ^ 3; // to E1
sbit ENLED = P1 ^ 4; // to E2 & E3
// 7seg chars(P2)
unsigned char code seg7chars[] = {
0xFC, // 0: a b c d e f
0x60, // 1: b c
0xDA, // 2: a b g e d
0xF2, // 3: a b g c d
0x66, // 4: f g b c
0xB6, // 5: a f g c d
0xBE, // 6: a f g c d e
0xE0, // 7: a b c
0xFE, // 8: all segments
0xF6, // 9: a b c d f g
0xEE, // A: a b c e f g
0x3E, // B: c d e f g
0x9C, // C: a d e f
0x7A, // D: b c d e g
0x9E, // E: a d e f g
0x8E, // F: a e f g
0x02, // dp: decimal point
0x00, // all on
0xFF // blank: all off
};
// switch 74HC138
void switch138(unsigned char channel)
{
// @subsection: turn DEC channel to 3 BIN bits
bit A0 = channel & 0x01;
bit A1 = (channel >> 1) & 0x01;
bit A2 = (channel >> 2) & 0x01;
// @subsection: enable 74HC138
ADDR3 = 1;
ENLED = 0;
// @subsection: set 74HC138 pins
ADDR0 = A0;
ADDR1 = A1;
ADDR2 = A2;
}
// timer by ms based on timer0
void delay_ms(unsigned int ms)
{
TMOD = 0x01;
for (; ms > 0; ms--) {
TH0 = 0xFC;
TL0 = 0x66;
TR0 = 1;
while (!TF0);
TR0 = 0;
TF0 = 0;
}
}
-95
View File
@@ -1,95 +0,0 @@
/*
* @name: hms.c
* @author: msksbr
* @date: 2025-05-27
* @description: implement functions for the hms.h header file.
* @usage: #include "hms.h"
* @example: HMS *hms = newHMS(); // create a new HMS object.
* @example: hms->setHMS(hms, 12, 34, 56); // set the time to 12:34:56.
*/
#include "hms.h" // include the header file.
#include <STDLIB.H>
// setters
static void setHour(HMS *this, unsigned char hour)
{
if (hour <= 99 && hour >= 0) {
this->hour = hour;
} else {
this->hour = 0;
}
}
static void setMinute(HMS *this, unsigned char minute)
{
if (minute <= 59 && minute >= 0) {
this->minute = minute;
} else {
this->minute = 0;
}
}
static void setSecond(HMS *this, unsigned char second)
{
if (second <= 59 && second >= 0) {
this->second = second;
} else {
this->second = 0;
}
}
// getters
static unsigned char getHour(HMS *this)
{
return this->hour;
}
static unsigned char getMinute(HMS *this)
{
return this->minute;
}
static unsigned char getSecond(HMS *this)
{
return this->second;
}
// tikTok: aka. second + 1. and solve the overflow problem.
static void tikTok(HMS *this)
{
this->second++; // second + 1.
if (this->second == 60) { // if second is 60, then minute + 1.
this->second = 0; // second = 0.
this->minute++; // minute + 1.
if (this->minute == 60) { // if minute is 60, then hour + 1.
this->minute = 0; // minute = 0.
this->hour++; // hour + 1.
if (this->hour == 100) { // if hour is 100, then hour = 0.
this->hour = 0; // hour = 0.
}
}
}
}
// constructor with values.
HMS *newHMSWithValues(unsigned char hour, unsigned char minute, unsigned char second)
{
HMS *obj = (HMS *)malloc(sizeof(HMS));
if (obj) {
// bind methods to the object.
obj->setHour = setHour;
obj->setMinute = setMinute;
obj->setSecond = setSecond;
obj->getHour = getHour;
obj->getMinute = getMinute;
obj->getSecond = getSecond;
obj->tikTok = NULL; // not implemented yet.
// set the values.
obj->setHour(obj, hour);
obj->setMinute(obj, minute);
obj->setSecond(obj, second);
}
return obj;
}
// constructor
HMS *newHMS(void)
{
return newHMSWithValues(0, 0, 0);
}
-29
View File
@@ -1,29 +0,0 @@
/*
* @name: hms.h
* @author: msksbr
* @date: 2025-05-27
* @description: define Hours, Minutes and Seconds.
*/
#ifndef HMS_H_
#define HMS_H_
typedef struct HMS HMS;
struct HMS {
unsigned char hour; // 0-99
unsigned char minute; // 0-59
unsigned char second; // 0-59
// getters and setters
void (*setHour)(HMS *, unsigned char);
void (*setMinute)(HMS *, unsigned char);
void (*setSecond)(HMS *, unsigned char);
unsigned char (*getHour)(HMS *);
unsigned char (*getMinute)(HMS *);
unsigned char (*getSecond)(HMS *);
void (*tikTok)(HMS *); // aka. second + 1
};
// constructors
HMS *newHMS(void);
HMS *newHMSWithValues(unsigned char hour, unsigned char minute, unsigned char second);
#endif
-14
View File
@@ -1,14 +0,0 @@
/*
* @name: main.c
* @author: msksbr
* @date: 2025-05-27
* @description: This is the main file for the project. It contains the main function and the main loop.
* @project: A simple Timer project for 80C51 micro controller.
* @attention: This project implements the OOP in C !!!
*/
#include <reg52.h>
void main()
{
}
-25
View File
@@ -1,25 +0,0 @@
/*
* @name: testPNP.c
* @author: msksbr
* @date: 2025-05-29
* @description: test PNP power supply.
*/
#include <REG52.H>
#include "../51pins/51pins.h"
unsigned char currentChannel = 0;
void main()
{
while (1) {
P2 = 0x00;
switch138(currentChannel);
if (currentChannel == 7) {
currentChannel = 0;
} else {
currentChannel++;
}
delay_ms(1);
}
}
Binary file not shown.