Sync work
This commit is contained in:
parent
efa5673e71
commit
f3e8069a62
7 changed files with 23 additions and 145 deletions
|
@ -1,5 +1,5 @@
|
||||||
sdcc -mmcs51 -o lc.ihx lc.c -D FOSC_160000 -I../include
|
sdcc-sdcc -mmcs51 -o lc.ihx lc.c -D FOSC_160000 -I../include
|
||||||
sdcc -mmcs51 --model-large -c MySensors.c -D FOSC_160000 -D MY_NODE_ID=201 -I../include
|
sdcc-sdcc -mmcs51 --model-large -c MySensors.c -D FOSC_160000 -D MY_NODE_ID=201 -I../include
|
||||||
sdcc -mmcs51 --model-large -o chan8.ihx chan8.c MySensors.rel -D FOSC_160000 -I../include
|
sdcc-sdcc -mmcs51 --model-large -o chan8.ihx chan8.c MySensors.rel -D FOSC_160000 -I../include
|
||||||
sdcc -mmcs51 --model-large -c MySensors.c -D FOSC_160000 -D MY_NODE_ID=202 -I../include
|
sdcc-sdcc -mmcs51 --model-large -c MySensors.c -D FOSC_160000 -D MY_NODE_ID=202 -I../include
|
||||||
sdcc -mmcs51 --model-large -o rs485relay.ihx rs485relay.c MySensors.rel -D FOSC_160000 -I../include
|
sdcc-sdcc -mmcs51 --model-large -o rs485relay.ihx rs485relay.c MySensors.rel -D FOSC_160000 -I../include
|
||||||
|
|
12
boards/lc.c
12
boards/lc.c
|
@ -113,6 +113,9 @@ void process(unsigned char cmd, unsigned int len, unsigned char *buffer) {
|
||||||
len = strlen(buffer);
|
len = strlen(buffer);
|
||||||
sendpkt(1, len, buffer);
|
sendpkt(1, len, buffer);
|
||||||
break;
|
break;
|
||||||
|
case 2: /* Config */
|
||||||
|
sendpkt(2, 0, NULL); /* No GPIO Pins */
|
||||||
|
break;
|
||||||
case 3: /* WIFI State */
|
case 3: /* WIFI State */
|
||||||
sendpkt(3, 0, NULL);
|
sendpkt(3, 0, NULL);
|
||||||
break;
|
break;
|
||||||
|
@ -120,6 +123,15 @@ void process(unsigned char cmd, unsigned int len, unsigned char *buffer) {
|
||||||
tuya_receive(len, buffer);
|
tuya_receive(len, buffer);
|
||||||
break;
|
break;
|
||||||
case 8: /* Query Command */
|
case 8: /* Query Command */
|
||||||
|
buffer[0] = 0;
|
||||||
|
buffer[1] = 1;
|
||||||
|
buffer[2] = 1;
|
||||||
|
buffer[3] = 0;
|
||||||
|
buffer[4] = 1;
|
||||||
|
buffer[5] = 1;
|
||||||
|
buffer[6] = 1;
|
||||||
|
buffer[7] = 0;
|
||||||
|
sendpkt(7, 8, buffer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,15 +13,12 @@
|
||||||
#include <nuvoton/functions.h>
|
#include <nuvoton/functions.h>
|
||||||
#include <nuvoton/N76E003.h>
|
#include <nuvoton/N76E003.h>
|
||||||
#include <nuvoton/Common.h>
|
#include <nuvoton/Common.h>
|
||||||
#include <nuvoton/Delay.h>
|
|
||||||
#include <nuvoton/SFR_Macro.h>
|
#include <nuvoton/SFR_Macro.h>
|
||||||
|
|
||||||
// 16Mhz clock
|
// 16Mhz clock
|
||||||
#define CLOCK 16000000L
|
#define CLOCK 16000000L
|
||||||
// Divide by 12
|
|
||||||
#define T0CLOCK ((CLOCK)/12L)
|
|
||||||
// Per milisecond
|
// Per milisecond
|
||||||
#define T0_1MS ((T0CLOCK)/1000L)
|
#define T0_1MS ((CLOCK)/1000L)
|
||||||
|
|
||||||
static void msdelay(unsigned long int count)
|
static void msdelay(unsigned long int count)
|
||||||
{
|
{
|
||||||
|
@ -62,14 +59,14 @@ void main() {
|
||||||
P01 = 0;
|
P01 = 0;
|
||||||
P13 = 0;
|
P13 = 0;
|
||||||
msdelay(500);
|
msdelay(500);
|
||||||
P01 = 0;
|
P01 = 1;
|
||||||
P13 = 0;
|
P13 = 0;
|
||||||
msdelay(500);
|
msdelay(500);
|
||||||
P01 = 0;
|
P01 = 0;
|
||||||
P13 = 0;
|
P13 = 1;
|
||||||
msdelay(500);
|
msdelay(500);
|
||||||
P01 = 0;
|
P01 = 1;
|
||||||
P13 = 0;
|
P13 = 1;
|
||||||
msdelay(500);
|
msdelay(500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
sdcc -mmcs51 -o blink_raw.ihx blink_raw.c -D FOSC_160000 -I../include
|
sdcc-sdcc -mmcs51 -o blink_raw.ihx blink_raw.c -D FOSC_160000 -I../include
|
||||||
|
|
|
@ -1,115 +0,0 @@
|
||||||
/*---------------------------------------------------------------------------------------------------------*/
|
|
||||||
/* */
|
|
||||||
/* Copyright(c) 2016 Nuvoton Technology Corp. All rights reserved. */
|
|
||||||
/* */
|
|
||||||
/*---------------------------------------------------------------------------------------------------------*/
|
|
||||||
|
|
||||||
//***********************************************************************************************************
|
|
||||||
// Nuvoton Technoledge Corp.
|
|
||||||
// Website: http://www.nuvoton.com
|
|
||||||
// E-Mail : MicroC-8bit@nuvoton.com
|
|
||||||
// Date : Apr/21/2016
|
|
||||||
//***********************************************************************************************************
|
|
||||||
|
|
||||||
#include "nuvoton/N76E003.h"
|
|
||||||
#include "nuvoton/Common.h"
|
|
||||||
#include "nuvoton/Delay.h"
|
|
||||||
#include "nuvoton/SFR_Macro.h"
|
|
||||||
#include "nuvoton/functions.h"
|
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
|
||||||
void Timer0_Delay100us(UINT32 u32CNT)
|
|
||||||
{
|
|
||||||
clr_T0M; //T0M=0, Timer0 Clock = Fsys/12
|
|
||||||
TMOD |= 0x01; //Timer0 is 16-bit mode
|
|
||||||
set_TR0; //Start Timer0
|
|
||||||
while (u32CNT != 0)
|
|
||||||
{
|
|
||||||
TL0 = LOBYTE(TIMER_DIV12_VALUE_100us); //Find define in "Function_define.h" "TIMER VALUE"
|
|
||||||
TH0 = HIBYTE(TIMER_DIV12_VALUE_100us);
|
|
||||||
while (TF0 != 1); //Check Timer0 Time-Out Flag
|
|
||||||
clr_TF0;
|
|
||||||
u32CNT --;
|
|
||||||
}
|
|
||||||
clr_TR0; //Stop Timer0
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void Timer0_Delay1ms(UINT32 u32CNT)
|
|
||||||
{
|
|
||||||
clr_T0M; //T0M=0, Timer0 Clock = Fsys/12
|
|
||||||
TMOD |= 0x01; //Timer0 is 16-bit mode
|
|
||||||
set_TR0; //Start Timer0
|
|
||||||
while (u32CNT != 0)
|
|
||||||
{
|
|
||||||
TL0 = LOBYTE(TIMER_DIV12_VALUE_1ms); //Find define in "Function_define.h" "TIMER VALUE"
|
|
||||||
TH0 = HIBYTE(TIMER_DIV12_VALUE_1ms);
|
|
||||||
while (TF0 != 1); //Check Timer0 Time-Out Flag
|
|
||||||
clr_TF0;
|
|
||||||
u32CNT --;
|
|
||||||
}
|
|
||||||
clr_TR0; //Stop Timer0
|
|
||||||
}
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void Timer1_Delay10ms(UINT32 u32CNT)
|
|
||||||
{
|
|
||||||
clr_T1M; //T1M=0, Timer1 Clock = Fsys/12
|
|
||||||
TMOD |= 0x10; //Timer1 is 16-bit mode
|
|
||||||
set_TR1; //Start Timer1
|
|
||||||
while (u32CNT != 0)
|
|
||||||
{
|
|
||||||
TL1 = LOBYTE(TIMER_DIV12_VALUE_10ms); //Find define in "Function_define.h" "TIMER VALUE"
|
|
||||||
TH1 = HIBYTE(TIMER_DIV12_VALUE_10ms);
|
|
||||||
while (TF1 != 1); //Check Timer1 Time-Out Flag
|
|
||||||
clr_TF1;
|
|
||||||
u32CNT --;
|
|
||||||
}
|
|
||||||
clr_TR1; //Stop Timer1
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void Timer2_Delay500us(UINT32 u32CNT)
|
|
||||||
{
|
|
||||||
clr_T2DIV2; //Timer2 Clock = Fsys/4
|
|
||||||
clr_T2DIV1;
|
|
||||||
set_T2DIV0;
|
|
||||||
set_TR2; //Start Timer2
|
|
||||||
while (u32CNT != 0)
|
|
||||||
{
|
|
||||||
TL2 = LOBYTE(TIMER_DIV4_VALUE_500us); //Find define in "Function_define.h" "TIMER VALUE"
|
|
||||||
TH2 = HIBYTE(TIMER_DIV4_VALUE_500us);
|
|
||||||
while (TF2 != 1); //Check Timer2 Time-Out Flag
|
|
||||||
clr_TF2;
|
|
||||||
u32CNT --;
|
|
||||||
}
|
|
||||||
clr_TR2; //Stop Timer2
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void Timer3_Delay100ms(UINT32 u32CNT)
|
|
||||||
{
|
|
||||||
T3CON = 0x07; //Timer3 Clock = Fsys/128
|
|
||||||
set_TR3; //Trigger Timer3
|
|
||||||
while (u32CNT != 0)
|
|
||||||
{
|
|
||||||
RL3 = LOBYTE(TIMER_DIV128_VALUE_100ms); //Find define in "Function_define.h" "TIMER VALUE"
|
|
||||||
RH3 = HIBYTE(TIMER_DIV128_VALUE_100ms);
|
|
||||||
while ((T3CON&SET_BIT4) != SET_BIT4); //Check Timer3 Time-Out Flag
|
|
||||||
clr_TF3;
|
|
||||||
u32CNT --;
|
|
||||||
}
|
|
||||||
clr_TR3; //Stop Timer3
|
|
||||||
}
|
|
||||||
//------------------------------------------------------------------------------
|
|
||||||
void Timer3_Delay10us(UINT32 u32CNT)
|
|
||||||
{
|
|
||||||
T3CON = 0x07; //Timer3 Clock = Fsys/128
|
|
||||||
set_TR3; //Trigger Timer3
|
|
||||||
while (u32CNT != 0)
|
|
||||||
{
|
|
||||||
RL3 = LOBYTE(TIMER_DIV4_VALUE_10us); //Find define in "Function_define.h" "TIMER VALUE"
|
|
||||||
RH3 = HIBYTE(TIMER_DIV4_VALUE_10us);
|
|
||||||
while ((T3CON&SET_BIT4) != SET_BIT4); //Check Timer3 Time-Out Flag
|
|
||||||
clr_TF3;
|
|
||||||
u32CNT --;
|
|
||||||
}
|
|
||||||
clr_TR3; //Stop Timer3
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
sdcc -mmcs51 -c Delay.c -D FOSC_160000 -I../include
|
|
||||||
#sdcc -mmcs51 -c Common.c -D FOSC_160000 -I../include
|
|
||||||
sdcc -mmcs51 -o 2relays.ihx main.c Delay.rel -D FOSC_160000 -I../include
|
|
|
@ -1,13 +0,0 @@
|
||||||
{
|
|
||||||
"boot_select": "aprom",
|
|
||||||
"pwm_enabled_during_ocd": false,
|
|
||||||
"ocd_enabled": true,
|
|
||||||
"reset_pin_disabled": false,
|
|
||||||
"locked": false,
|
|
||||||
"ldrom_size": "0kb",
|
|
||||||
"bod_disabled": false,
|
|
||||||
"bod_voltage": "2v2",
|
|
||||||
"iap_enabled_in_brownout": false,
|
|
||||||
"bod_reset_disabled": false,
|
|
||||||
"wdt": "disabled"
|
|
||||||
}
|
|
Loading…
Reference in a new issue