Compare commits

..

No commits in common. "ecbae839d35901d6bdb6fb4b83348696b885c3ba" and "b59c6e44e3e3fd3c3149c9e2dc23e7e71306d658" have entirely different histories.

5 changed files with 0 additions and 244 deletions

3
.gitmodules vendored
View File

@ -1,3 +0,0 @@
[submodule "mc8051fun"]
path = mc8051fun
url = https://git.planix.org/7u83/mc8051fun.git

View File

@ -1,57 +0,0 @@
SDCC ?= sdcc
SDAR ?= sdar
STCCODESIZE ?= 8192
SDCCOPTS ?=
SDCCREV ?= -Dstc15f204ea
STCGAL ?= stcgal
#/stcgal.py
STCGALOPTS ?=
STCGALPORT ?= /dev/ttyUSB0
STCGALPROT ?= auto
FLASHFILE ?= main.ihx
SYSCLK ?= 11059
FOSC ?=11059200L
CFLAGS ?=
LIBSRC =
LIBNAME = mc8051fun/mc8051fun.lib
PRGSRC = term.c pinsh.c
PRGOBJ =$(patsubst %.c,%.rel, $(PRGSRC))
$(FLASHFILE): $(LIBNAME) $(PRGOBJ)
$(SDCC) -o $(FLASHFILE) $(SDCCOPTS) $(SDCCREV) $(CFLAGS) $(PRGOBJ) $(LIBNAME)
$(LIBNAME): $(LIBOBJ)
$(SDAR) -rc $(LIBNAME) $(LIBOBJ)
#all:
# make uart2.ihx
%.rel: %.c
$(SDCC) $(SDCCOPTS) $(SDCCREV) -DFOSC=$(FOSC) -o $@ -c $<
eeprom:
sed -ne '/:..1/ { s/1/0/2; p }' main.hex > eeprom.hex
flash: $(FLASHFILE)
$(STCGAL) -p $(STCGALPORT) -P $(STCGALPROT) -t $(SYSCLK) $(STCGALOPTS) $(FLASHFILE)
clean:
rm -f *.ihx *.hex *.bin *.rst
rm -f *.map
rm -f *.rel
rm -f *.lst
rm -f *.sym
rm -f *.asm
rm -f *.lk
rm -f *.mem
rm -f *.lib
cpp: SDCCOPTS+=-E
cpp: main

@ -1 +0,0 @@
Subproject commit 30f410891cec7c2ccdae1aa3b6061618ce93c801

166
pinsh.c
View File

@ -1,166 +0,0 @@
#include "mc8051fun/mc8051fun.h"
#include "pinsh.h"
void (*pinsh_output_chr)(char);
uint8_t pinsh_buf[PINSH_BUF_SIZE];
volatile int pinsh_buf_pos=0;
void pinsh_irq_handler()
{
if (RI) {
unsigned char b = SBUF;
if (b=='\r'){
//pinsh_go=1;
pinsh_exec(pinsh_buf);
} else {
SBUF=b;
if (pinsh_buf_pos < PINSH_BUF_SIZE-1){
pinsh_buf[pinsh_buf_pos++]=b;
pinsh_buf[pinsh_buf_pos]=0;
}
}
RI=0;
}
}
static void pinsh_output(const char *str)
{
while(*str)
pinsh_output_chr(*str++);
}
void pinsh_welcome_msg()
{
pinsh_output("Pinsh 8051, V1.0\r\n");
}
static void show_port(int n)
{
pinsh_output("P");
uint8_t b = getport(n);
pinsh_output_chr(n+0x30);
pinsh_output("=");
for (int i=0; i<8; i++) {
if (b&(1<<(7-i)))
pinsh_output("1");
else
pinsh_output("0");
}
pinsh_output("\r\n");
}
static void show_stat()
{
for (int i=0; i<4; i++)
show_port(i);
/* uint8_t b = P0;
show_port("P0",b);
b = P1;
show_port("P1",b);
b = P2;
show_port("P2",b);
b = P3;
show_port("P3",b);
*/
}
static void syntax_error()
{
pinsh_output("Syntax error\r\n");
}
static void assign_pin(int n, int p, char val)
{
if (val){
switch(n){
case 0:
P0 |= 1<<p;
return;
case 1:
P1 |= 1<<p;
return;
case 2:
P2 |= 1<<p;
return;
case 3:
P3 |= 1<<p;
return;
}
}
switch(n){
case 0:
P0 &= (1<<p)^0xff;
return;
case 1:
P1 &= (1<<p)^0xff;
return;
case 2:
P2 &= (1<<p)^0xff;
return;
case 3:
P3 &= (1<<p)^0xff;
return;
}
}
static void assign_port(int n, const char*cmd)
{
for (int i=0; i<8 && cmd[i]!=0; i++)
{
if(cmd[i]!='0' && cmd[i]!='1'){
syntax_error();
return;
}
}
for (int i=0; i<8 && cmd[i]!=0; i++)
{
assign_pin(n,7-i,cmd[i]-0x30);
}
}
static void pinsh_exec_p(const char *cmd)
{
if (!cmd[0]){
show_stat();
return;
}
int n = cmd[0];
if(n<0x30 || n>0x33){
syntax_error();
return;
}
if(cmd[1]==0){
show_port(n-0x30);
return;
}
if(cmd[1]=='='){
assign_port(n-0x30,cmd+2);
return;
}
}
void pinsh_exec(const char *cmd)
{
if(cmd[0]=='p')
pinsh_exec_p(cmd+1);
}

17
pinsh.h
View File

@ -1,17 +0,0 @@
#ifndef PINSH_H_
#define PINSH_H_
#define PINSH_BUF_SIZE 32
extern void (*pinsh_output_chr)(char);
void pinsh_welcome_msg();
void pinsh_exec(const char *cmd);
extern uint8_t pinsh_buf[PINSH_BUF_SIZE];
extern volatile int pinsh_buf_pos;
void pinsh_uart_irq_handler();
#endif