Skip to content

Commit

Permalink
Still broken, cannot fix "c++: error: unrecognized command-line optio…
Browse files Browse the repository at this point in the history
…n ‘--opt-code-size’~"
  • Loading branch information
KenwoodFox committed Jul 31, 2024
1 parent 40a1baa commit c00bd83
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 23 deletions.
22 changes: 22 additions & 0 deletions Firmware/boards/ch552.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"build": {
"f_cpu": "24000000",
"size_iram": 256,
"size_xram": 1024,
"size_code": 14336,
"size_heap": 128,
"mcu": "ch552t",
"cpu": "mcs51"
},
"frameworks": [],
"upload": {
"maximum_ram_size": 1280,
"maximum_size": 14336,
"protocol": "stcgal",
"stcgal_protocol": "stc15",
"protocols": ["stcgal"]
},
"name": "Generic CH552",
"url": "http://www.wch.cn/product/CH552.html",
"vendor": "WCH"
}
2 changes: 2 additions & 0 deletions Firmware/link_medium.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Import("env")
env.Append(LINKFLAGS=["--model-medium"])
19 changes: 7 additions & 12 deletions Firmware/platformio.ini
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
[env:ATmega8]
framework = arduino
platform = atmelavr
board = ATmega8
[env:CH552G]
platform = intel_mcs51
board = ch552

; # Upload method
; upload_protocol = usbasp # For tag-connect
extra_scripts = link_medium.py

; Dont check packages (bug in avr for attiny?)
check_skip_packages = yes

# Deps
lib_deps =
Arduino-Lufa
build_flags =
-Wall
-I$PROJECT_PACKAGES_DIR/toolchain-sdcc/include/**
50 changes: 50 additions & 0 deletions Firmware/src/delay.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#include "delay.h"

#define MAIN_Fosc 16000000L //Define the clock
//#define MAIN_Fosc 11059200L //Define the clock

void delay_c_ms(unsigned char ms) //Software delay in mili-sec
{ //Calibrated for STC on SDCC
unsigned int i;
do
{
i = MAIN_Fosc / 13000;
while (--i); // 14T per loop
} while (--ms);
}

void delay_c_ds(unsigned char ds) //Software delay in deci-sec
{ //Calibrated for STC on SDCC
unsigned int i;
do
{
i = MAIN_Fosc / 1300;
while (--i); // 14T per loop
} while (--ds);
}

void delay_s_ms(unsigned char ms) //Software delay in mili-sec
{ //Calibrated for Nuvoton N76E003
ms; //Must declare delay variable
__asm
MOV R2,dpl //Variable ms was passed via dpl
00001$: MOV R1,#0x08 //8 x 12.5ms produces 1ms total
00002$: MOV R0,#0xFA //FA is 12.5ms (or C7 is 100us)
00003$: DJNZ R0,00003$
DJNZ R1,00002$
DJNZ R2,00001$
__endasm;
}

void delay_s_ds(unsigned char ds) //Software delay in deci-sec
{ //Calibrated for Nuvoton N76E003
ds; //Must declare delay variable
__asm
MOV R2,dpl //Variable ds was passed via dpl
00001$: MOV R1,#0x50 //80 x 12.5ms produces 1ds total
00002$: MOV R0,#0xFA //FA is 12.5ms (or C7 is 100us)
00003$: DJNZ R0,00003$
DJNZ R1,00002$
DJNZ R2,00001$
__endasm;
}
9 changes: 9 additions & 0 deletions Firmware/src/delay.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#ifndef __DELAY_H
#define __DELAY_H

void delay_c_ms(unsigned char ms);
void delay_s_ms(unsigned char ms);
void delay_c_ds(unsigned char ds);
void delay_s_ds(unsigned char ds);

#endif
27 changes: 16 additions & 11 deletions Firmware/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@
* by 1721 Tidal Force!
*/

#include <Arduino.h>
#include "delay.h"

void setup()
void main(void)
{
pinMode(LED_BUILTIN, OUTPUT);
}
INIT_PIN // Macro if needed to initialize output pin
while (1)
{
ledPin = 0x00; // LED on
delay_c_ds(250); // Software delay 2500ms
ledPin = 0xff; // LED off
delay_s_ds(250); // Software delay 2500ms

void loop()
{
digitalWrite(LED_BUILTIN, HIGH);
delay(1000);
digitalWrite(LED_BUILTIN, LOW);
delay(1000);
}
// int n;
// ledPin = 0; // LED on
// for (n = 0; n < 50000; n++); // waste some cycles
// ledPin = 1; // LED off
// for (n = 0; n < 50000; n++); // waste some cycles
}
}

0 comments on commit c00bd83

Please sign in to comment.