Skip to content

Instantly share code, notes, and snippets.

ryanhu Ryanhu1015

Block or report user

Report or block Ryanhu1015

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@Ryanhu1015
Ryanhu1015 / RF_recv.c
Last active Mar 1, 2019
embedded rookie
View RF_recv.c
unsigned char tmpbuf[128];
void light_condition_receiver(void);
void RxPacket(void);
void main(void)
{
//hardware initialization...
if(P3_5)
{
@Ryanhu1015
Ryanhu1015 / RF.c
Last active Feb 2, 2019
embedded rookie
View RF.c
#include "globalvar.h" // button2_time_cnt is defined in the header file
#include "function.h"
#define P3_5 1 // if P3_5 is 1, it will be the transmitter
#define period 1000
unsigned char Packet_Tx[8]; // if initialize, this array will be a "constant", which can't be modified in code.
void WriteFIFO(void);
void WriteFIFO(void)
View button_clicked.c
#define Button1_SW1 P3_2 // P3_2 is one of the input button pin
unsigned int button1_time_cnt; //global variable
void Timer0ISR (void) interrupt 1 // trigger per 1 ms
{
TF0 = 0; // Clear Timer0 interrupt
TH0 = (65536-t0hrel)>>8; // Reload Timer0 high byte,low byte
TL0 = 65536-t0hrel;
button1_time_cnt <<= 1 ;
@Ryanhu1015
Ryanhu1015 / adc_test_2.c
Last active Oct 20, 2018
embedded rookie
View adc_test_2.c
unsigned short ADCbuffer;
unsigned short wc_DelayTimeOutCounter;
//skip the functions prototypes
void main(){
//initiate hardware
//..
//..
while(1){
if(wc_DelayTimeOutCounter==100){ // grab the value per second
View adc_test.c
void ADC_Init(void);
void ADC_Init(){
P0M=0x38;// set I/O as input/output mode
P0CON |= 0x02;//let P01 as a pure analog pin
P0UR=0;// disable the pull-high
ADM=0x81;// enable ADC function, and use AIN1
ADR=0x60;// enable AIN channel, and set clock rate = fosc/1
@Ryanhu1015
Ryanhu1015 / uart_test_2.c
Last active Sep 23, 2018
embedded rookie
View uart_test_2.c
void txsenddata(short);
char ch;
char chstring[]="Please type something to test: ";
void main(){
for(int i=0; i<sizeof(chstring); i++) txsenddata(chstring[i]);
while(1){
if(enableWrite){
txsenddata(ch);
enableWrite=0;
@Ryanhu1015
Ryanhu1015 / uart_test.c
Last active Sep 23, 2018
embedded rookie
View uart_test.c
void UART_Init(void);
void txsenddata(short);
char rxreceivedata(void);
uint8_t enableWrite=0;
char ch;
char chstring[]="Please type something to test: ";
void main(){
//initial function setting..
for (int i=0; i<sizeof(chstring); i++) txsenddata(chstring[i]);
@Ryanhu1015
Ryanhu1015 / pwm.c
Last active Aug 27, 2018
embedded rookie
View pwm.c
enum{off, on, pwm}
sbit pwmOut = P0^1;
const int pwmValue=96;//120*0.8, which means 80% dutycycle
void PWM_Init(void);
void PWM(uint8_t status);
void PWM_Init(){
T3YH=0x78;// 0-120 pieces
T3YL=0x00;
@Ryanhu1015
Ryanhu1015 / timer0.c
Created Aug 27, 2018
embedded rookie
View timer0.c
#include <stdio.h>
#include <SN8F5701.H>
//variable
int count_millis=0;
uint8_t count_sec=0;
uint8_t count_min=0;
//prototype of functions
void Timer0_Init(void);
@Ryanhu1015
Ryanhu1015 / main.c
Created Aug 20, 2018
embedded rookie
View main.c
#include <stdio.h>
#include <SN8F5701.H>
void Timer0_Init(void);
void main(){
//initial function write down here, like the one "setup" function in Arduino
Timer0_Init();
//
while(1){
//just like the "loop" function in Arduino
You can’t perform that action at this time.