Skip to content

Commit eb3c847

Browse files
Cocket_Nova_duino_version_2024-06-19.tar.bz2
1 parent f458225 commit eb3c847

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

127 files changed

+10353
-6
lines changed
151 KB
Binary file not shown.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include "src/system.h"
2+
#include "src/gpio.h"
3+
#include "src/delay.h"
4+
5+
#define PIN_ADC P11
6+
7+
void main(void)
8+
{
9+
CLK_config();
10+
DLY_ms(5);
11+
12+
ADC_input(PIN_ADC);
13+
14+
ADC_enable();
15+
16+
while (1)
17+
{
18+
int data = ADC_read(); // read ADC value 0 - 255 (8-bit)
19+
}
20+
}
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# ===================================================================================
2+
# Project: Original author
3+
# Author: Stefan Wagner
4+
# Year: 2023
5+
# URL: https://github.com/wagiminator
6+
# ===================================================================================
7+
# version modified by CésarBautista
8+
# Year: 2023
9+
# ===================================================================================
10+
# Type "make help" in the command line.
11+
# ===================================================================================
12+
# File Names
13+
SKETCH = main.c
14+
TARGET = $(basename $(SKETCH))
15+
INCLUDE = src
16+
17+
# Microcontroller Settings
18+
FREQ_SYS = 16000000
19+
XRAM_LOC = 0x0100
20+
XRAM_SIZE = 0x0300
21+
CODE_SIZE = 0x3800
22+
23+
# Toolchain
24+
CC = sdcc
25+
OBJCOPY = objcopy
26+
PACK_HEX = packihx
27+
28+
29+
30+
# Compiler Flags
31+
CFLAGS = -mmcs51 --model-small --no-xinit-opt
32+
CFLAGS += --xram-size $(XRAM_SIZE) --xram-loc $(XRAM_LOC) --code-size $(CODE_SIZE)
33+
CFLAGS += -I$(INCLUDE) -DF_CPU=$(FREQ_SYS)
34+
CFILES = $(SKETCH) $(wildcard $(INCLUDE)/*.c)
35+
RFILES = $(CFILES:.c=.rel)
36+
CLEAN = rm -f *.ihx *.lk *.map *.mem *.lst *.rel *.rst *.sym *.asm *.adb
37+
38+
# Symbolic Targets
39+
help:
40+
@echo "Use the following commands:"
41+
@echo "make all compile, build, and keep all files"
42+
@echo "make hex compile and build $(TARGET).hex"
43+
@echo "make bin compile and build $(TARGET).bin"
44+
@echo "make clean remove all build files"
45+
46+
%.rel : %.c
47+
@echo "Compiling $< ..."
48+
@$(CC) -c $(CFLAGS) $<
49+
50+
$(TARGET).ihx: $(RFILES)
51+
@echo "Building $(TARGET).ihx ..."
52+
@$(CC) $(notdir $(RFILES)) $(CFLAGS) -o $(TARGET).ihx
53+
54+
$(TARGET).hex: $(TARGET).ihx
55+
@echo "Building $(TARGET).hex ..."
56+
@$(PACK_HEX) $(TARGET).ihx > $(TARGET).hex
57+
58+
$(TARGET).bin: $(TARGET).ihx
59+
@echo "Building $(TARGET).bin ..."
60+
@$(OBJCOPY) -I ihex -O binary $(TARGET).ihx $(TARGET).bin
61+
62+
63+
64+
all: $(TARGET).bin $(TARGET).hex size
65+
66+
hex: $(TARGET).hex size removetemp
67+
68+
bin: $(TARGET).bin size removetemp
69+
70+
bin-hex: $(TARGET).bin $(TARGET).hex size removetemp
71+
72+
install: flash
73+
74+
size:
75+
@echo "------------------"
76+
@echo "FLASH: $(shell awk '$$1 == "ROM/EPROM/FLASH" {print $$4}' $(TARGET).mem) bytes"
77+
@echo "IRAM: $(shell awk '$$1 == "Stack" {print 248-$$10}' $(TARGET).mem) bytes"
78+
@echo "XRAM: $(shell awk '$$1 == "EXTERNAL" {print $(XRAM_LOC)+$$5}' $(TARGET).mem) bytes"
79+
@echo "------------------"
80+
81+
removetemp:
82+
@echo "Removing temporary files ..."
83+
@$(CLEAN)
84+
85+
clean: removetemp
86+
@echo "Cleaning all up ..."
87+
@$(CLEAN)
88+
@rm -f $(TARGET).hex $(TARGET).bin
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// ===================================================================================
2+
// User configurations
3+
// ===================================================================================
4+
5+
#pragma once
6+
7+
// Pin definitions
8+
#define PIN_LED P14 // buzzer pin
9+
#define PIN_SDA P30 // I2C SDA
10+
#define PIN_SCL P32 // I2C SCL
11+
12+
#define PIN_ADC P11 // pin used as ADC input
13+
#define PIN_PWM P34 // PWM pin
14+
#define PIN_BUTTON2 P15 // button pin
15+
#define PIN_BUT_START P16 // button pin
16+
17+
18+

0 commit comments

Comments
 (0)