Skip to content

Instantly share code, notes, and snippets.

View captdam's full-sized avatar
🛠️
Back to dev

Captdam captdam

🛠️
Back to dev
View GitHub Profile
@captdam
captdam / template.a51
Last active December 19, 2018 08:55
STC89C52RC template.a51
;SFR - STC89C52RC
XICON EQU 0xC0
T2CON EQU 0xC8
T2MOD EQU 0xC9
RCAP2L EQU 0xCA
RCAP2H EQU 0xCB
TL2 EQU 0xCC
TH2 EQU 0xCD
WDT_CONTR EQU 0xE1
ISP_DATA EQU 0xE2
@captdam
captdam / func_spi.a51
Last active November 9, 2018 08:58
Intel 8051 MCU Software SPI
FUNC_SPI:
; SPI Function (Start - Send cmd - Exchange data - end)
; MSB send first
; Input: A: Send cmd; B: Send data;
; Return: A: Get data;
MISO EQU P3.4
MOSI EQU P3.5
SCLK EQU P3.6
SS EQU P3.7
@captdam
captdam / func_uart.a51
Last active December 20, 2018 05:53
Intel 8051 MCU UART functions
FUNC_UART_SEND_RAW:
; UART Function, send the value stored in ACC, in raw binary format
; Input: ACC: The value
; Output: void
MOV SBUF, A
JMP $
RET
;It is recommanded to write this block in the parent function, instead of call this function
FUNC_UART_SEND_STRING:
@captdam
captdam / Ultrasonic Sensor Demo
Last active December 20, 2018 07:48
ultrasonic-sensor.a51
;
--8-bit ALU unit
--Include libearies
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
--Block IO
entity alu is
port(
--2 4-bit divider
--Include libearies
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
--Block IO
entity divider is
port(
#include <avr/io.h>
#include <avr/interrupt.h>
#include <LiquidCrystal.h>
#include <stdint.h>
#define LED 9
#define PUSH 8
#define TIMEOUT 10000
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
@captdam
captdam / ATM.ino
Created March 23, 2019 00:57
Embeded system project2 part2
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
#include <IRremote.h>
#include <LiquidCrystal.h>
#define TIMEOUT 120
@captdam
captdam / uwinsiteTimetableGenerator.js
Created April 16, 2019 19:49
Generate a timetable on the new uWinSite page.
/*
How to use:
1. Login to your uWinSite
2. Go to: Manage Classes/View my Classes
3. Choose the semester, and you should see all your classes in the page.
4. Open the page inspector of your web browser.
5. Copy the code into the debugger and hit enter. The code is now embedded into the page.
6. Execute "timetable()" in the debuger.
7. The timetable will be generated, and it will be located at the bottom of the page.
*/
@captdam
captdam / avr-8 register.asm
Last active June 14, 2019 12:52
Temp and saved register for GCC
;Scratch, save before call child, free to use in subroutine
#define _RA R0
;Always zero, do not modify
#define _RZERO R1
;Temp register, save before call child, free to use in subroutine
#define _RT0 R18 ;Arg3
#define _RT1 R19
#define _RT2 R20 ;Arg2