Example #1
0
int PASCAL WinMain( HINSTANCE hInstance, HINSTANCE x1, LPSTR lpCmdLine, int x2 )
{
  short i;
  char buf[128];

  //BreakPoint();
  DefineDLLEntry( 1, (void *) Lib1, DLL_WORD, DLL_DWORD, DLL_WORD,
                      DLL_ENDLIST );
  DefineDLLEntry( 2, (void *) Lib2, DLL_DWORD, DLL_WORD, DLL_ENDLIST );
  DefineDLLEntry( 3, (void *) Lib3, DLL_PTR, DLL_WORD, DLL_WORD,
                      DLL_DWORD, DLL_WORD, DLL_DWORD, DLL_ENDLIST );
  DefineDLLEntry( 4, (void *) WEP, DLL_WORD,
                      DLL_ENDLIST );
  i = GetSS();
  #ifdef __cplusplus
  {
    ostrstream sout( buf, sizeof( buf ) );
    sout << "DLL32 Started, SS=" << hex << i << ends;
    MessageBox( NULL, sout.str(), "DLL32", MB_OK | MB_TASKMODAL );
  }
  #else
    sprintf( buf, "DLL32 Started, SS=%hx", i );
    MessageBox( NULL, buf, "DLL32", MB_OK | MB_TASKMODAL );
  #endif
  return( 1 );
}
Example #2
0
void update_time(void){
#if 0
	time2.year = RTC_GetTime(LPC_RTC, RTC_TIMETYPE_YEAR);
	time2.month = RTC_GetTime(LPC_RTC, RTC_TIMETYPE_MONTH);
	time2.dom = RTC_GetTime(LPC_RTC, RTC_TIMETYPE_DAYOFMONTH);
	time2.dow = RTC_GetTime(LPC_RTC, RTC_TIMETYPE_DAYOFWEEK);
	time2.doy = RTC_GetTime(LPC_RTC, RTC_TIMETYPE_DAYOFYEAR);
	time2.hh = RTC_GetTime(LPC_RTC, RTC_TIMETYPE_HOUR);
	time2.mm = RTC_GetTime(LPC_RTC, RTC_TIMETYPE_MINUTE);
	time2.ss = RTC_GetTime(LPC_RTC, RTC_TIMETYPE_SECOND);
#endif
	time2.unix = RTC_time_FindUnixtime(GetY(), GetM(), GetDOM(), GetHH(), GetMM(), GetSS());
	UNIX = time2.unix;
//	_DBG("[INFO]-time2.unix = ");_DBD32(time2.unix);_DBG(" (");_DBG(__FILE__);_DBG(":");_DBD16(__LINE__);_DBG(")\r\n");
}
Example #3
0
extern "C" void RTC_IRQHandler(void){
//	RTC_ClearIntPending(LPC_RTC, RTC_INT_COUNTER_INCREASE);
//	secondlyCheck();
//	return;
	uint32_t secval;
	// This is increment counter interrupt
	if (RTC_GetIntPending(LPC_RTC, RTC_INT_COUNTER_INCREASE)){
		// Clear pending interrupt
		RTC_ClearIntPending(LPC_RTC, RTC_INT_COUNTER_INCREASE);
		_60th_SEC_COUNT=0;
		time2.second_inc=1;
		//run  checks at xx:xx:00
		if(!GetSS()){
			//run  checks at xx:00:00
			if(!GetMM()){
				//run daily checks at 00:00:00
				if(!GetHH()){
					//run weekly checks at Mon 00:00:00
					if(1 == GetDOW()){
						//run weekly checks at 1st Mon 00:00:00
						if(1 == GetDOM()){
							//run weekly checks at Jan 1st Mon 00:00:00
							if(1 == GetM()){
								yearlyCheck();
							}
							monthlyCheck();
						}
						weeklyCheck();
					}
					dailyCheck();
				}
				hourlyCheck();
			}
			minutelyCheck();
		}
		secondlyCheck();
	}

	// Continue to check the Alarm match
	if (RTC_GetIntPending(LPC_RTC, RTC_INT_ALARM)){
		// Clear pending interrupt
		RTC_ClearIntPending(LPC_RTC, RTC_INT_ALARM);
		set_next_alarm();
		sort_alarms();
		/* Send debug information */
//		_DBG_ ("ALARM 10s matched!");
	}
}
Example #4
0
trap_retval ReqProg_load( void )
{
    prog_load_ret       *ret;

                                                                          _DBG(("We're in AccLoadProg"));
    GetSysRegs( &SysRegs );
    ret = GetOutPtr( 0 );
    ret->err = 0;
    ret->flags = LD_FLAG_IS_BIG | LD_FLAG_IS_PROT | LD_FLAG_IS_STARTED | LD_FLAG_DISPLAY_DAMAGED;
    ret->task_id = 4;
    ret->mod_handle = 0;
    Regs.DS = Regs.ES = Regs.FS = Regs.GS = GetDS();
    Regs.SS = GetSS();
    Regs.ESP = (dword)ADSStack + ADSSTACK_SIZE - sizeof( dword );
    Regs.CS = GetCS();
    Regs.EIP = (dword)&ADSLoop;
    Regs.EFL = GetFL();
    Regs.EAX = Regs.EBX = Regs.ECX = Regs.EDX = Regs.ESI = 0;
    Regs.EDI = Regs.EBP = 0;
    IntNum = -1;
                                                                          _DBG(("We're back from AccLoadProg"));
    return( sizeof( *ret ) );
}
Example #5
0
static void TestASM()
{
	CommentLine("TestASM");
	println("testing asm");
	printf("Accumulator EAX: %p\n", GetEAX());
	printf("Base        EBX: %p\n", GetEBX());
	printf("Counter     ECX: %p\n", GetECX());
	printf("Data        EDX: %p\n", GetEDX());

	printf("src str ndx ESI: %p\n", GetESI());
	printf("dst str ndx EDI: %p\n", GetEDI());

	printf("stack top   ESP: %p\n", GetESP());
	printf("frame base  EBP: %p\n", GetEBP());
//	printf("insn ptr    EIP: %p\n", GetEIP());

	printf("code segment CS: %p\n", GetCS());
	printf("stack        SS: %p\n", GetSS());

	printf("data segment DS: %p\n", GetDS());
	printf("data segment ES: %p\n", GetES());


}
Example #6
0
void RTC_print_time(void){
	char buffer[100];
    time_t rawtime;
    struct tm * timeinfo;


//	xprintf(INFO "%d/%d/%d %d:%d:%d" " (%s:%d)\n",GetDOM(),GetM(),GetY(),GetHH(),GetMM(),GetSS(),_F_,_L_);
	time( &rawtime );
    timeinfo = localtime ( &rawtime );
	strftime(buffer,90,"%d/%m/%Y %I:%M:%S%p WOY:%U DOY:%j",timeinfo);
	xprintf(INFO "%s" " (%s:%d)\n", buffer,_F_,_L_);
//	xprintf(INFO "%d/%d/%d %d:%d:%d" " (%s:%d)\n",_F_,_L_);
//	xprintf(INFO "Unix: %d" " (%s:%d)\n",time2.unix,_F_,_L_);

//	xprintf(INFO "Sunrise: %d" " (%s:%d)\n",time2.sunrise_unix,_F_,_L_);
	timeinfo = localtime ( &time2.sunrise_unix );
	strftime(buffer,80,"Sunrise: %I:%M:%S%p.",timeinfo);
	xprintf(INFO "%s" " (%s:%d)\n", buffer,_F_,_L_);

//	xprintf(INFO "Sunset: %d" " (%s:%d)\n",time2.sunset_unix,_F_,_L_);
	timeinfo = localtime ( &time2.sunset_unix );
	strftime(buffer,80,"Sunset: %I:%M:%S%p.",timeinfo);
	xprintf(INFO "%s" " (%s:%d)\n", buffer,_F_,_L_);

//	xprintf(INFO "Noon: %d" " (%s:%d)\n",time2.noon_unix,_F_,_L_);
	timeinfo = localtime ( &time2.noon_unix );
	strftime(buffer,80,"Noon: %I:%M:%S%p.",timeinfo);
	xprintf(INFO "%s" " (%s:%d)\n", buffer,_F_,_L_);

	xprintf(INFO "It's %s" " (%s:%d)\n",time2.day_night ? "Night time" : "Day time" ,_F_,_L_);
//	xprintf(INFO "Day/Night: %d" " (%s:%d)\n",time2.day_night,_F_,_L_);
	xprintf(INFO "DST begin: %d end: %d" " (%s:%d)\n",time2.DST_begin_calculated,time2.DST_end_calculated,_F_,_L_);


#if 0
	_DBG("[INFO]-Date=");
	_DBD(GetDOM());
	_DBG("/");
	_DBD(GetM());
	_DBG("/");
	_DBD16(GetY());
	_DBG(" (");_DBG(__FILE__);_DBG(":");_DBD16(__LINE__);_DBG(")\r\n");

	_DBG("[INFO]-Time=");
	_DBD(GetHH());
	_DBG(":");
	_DBD(GetMM());
	_DBG(":");
	_DBD(GetSS());
	_DBG(" (");_DBG(__FILE__);_DBG(":");_DBD16(__LINE__);_DBG(")\r\n");

	_DBG("[INFO]-Unix: ");
	_DBD32(time2.unix);
	_DBG("  Sunrise: ");
	_DBD32(time2.sunrise_unix);
	_DBG("  Sunset: ");
	_DBD32(time2.sunset_unix);
	_DBG("  Noon: ");
	_DBD32(time2.noon_unix);
	_DBG("  Day/Night: ");
	_DBD(time2.day_night);
	_DBG(" (");_DBG(__FILE__);_DBG(":");_DBD16(__LINE__);_DBG(")\r\n");

	_DBG("[INFO]-DST begin: ");
	_DBD32(time2.DST_begin_calculated);
	_DBG("  end: ");
	_DBD32(time2.DST_end_calculated);
	_DBG(" (");_DBG(__FILE__);_DBG(":");_DBD16(__LINE__);_DBG(")\r\n");
#endif
}
Example #7
0
//LED Patterns
void LED_time(){
	resetLeds();
	uint8_t HH = GetHH();
	uint8_t MM = GetMM();
	uint8_t SS = GetSS();
	HH>11 ? HH-=12 : 0;

#ifdef SetLED
	// Remove the tails
	SS<5 ? SetLED((SS+60)*3-13,0) : SetLED(SS*3-13,0);
	MM<4 ? SetLED((MM+60)*3-11,0) : SetLED(MM*3-11,0);
	HH<2 ? SetLED((HH+11)*3*5,0) : SetLED((HH-1)*3*5,0);
	HH<2 ? SetLED((HH+11)*3*5-3,0) : SetLED((HH-1)*3*5-3,0);
	HH<2 ? SetLED((HH+11)*3*5-6,0) : SetLED((HH-1)*3*5-6,0);

	// Seconds Blue
//	for (SS=0;SS<60;SS++){
		SetLED(SS*3+2,MAX_BRIGHTNESS);
		SS<1 ? SetLED((SS+60)*3-1,MAX_BRIGHTNESS/5*4) : SetLED(SS*3-1,MAX_BRIGHTNESS/5*4);
		SS<2 ? SetLED((SS+60)*3-4,MAX_BRIGHTNESS/5*3) : SetLED(SS*3-4,MAX_BRIGHTNESS/5*3);
		SS<3 ? SetLED((SS+60)*3-7,MAX_BRIGHTNESS/5*2) : SetLED(SS*3-7,MAX_BRIGHTNESS/5*2);
		SS<4 ? SetLED((SS+60)*3-10,MAX_BRIGHTNESS/5) : SetLED(SS*3-10,MAX_BRIGHTNESS/5);
//		calulateLEDMIBAMBits();
//		delay_ms(100);
//		SetLED(SS*3+2,0);
//		SS<1 ? SetLED((SS+60)*3-1,0) : SetLED(SS*3-1,0);
//		SS<2 ? SetLED((SS+60)*3-4,0) : SetLED(SS*3-4,0);
//		SS<3 ? SetLED((SS+60)*3-7,0) : SetLED(SS*3-7,0);
//		SS<4 ? SetLED((SS+60)*3-10,0) : SetLED(SS*3-10,0);
//		calulateLEDMIBAMBits();
//	}
	// Minutes Green
//	for (MM=0;MM<60;MM++){
		SetLED(MM*3+1,MAX_BRIGHTNESS);
		MM<1 ? SetLED((MM+60)*3-2,MAX_BRIGHTNESS/4*3) : SetLED(MM*3-2,MAX_BRIGHTNESS/4*3);
		MM<2 ? SetLED((MM+60)*3-5,MAX_BRIGHTNESS/4*2) : SetLED(MM*3-5,MAX_BRIGHTNESS/4*2);
		MM<3 ? SetLED((MM+60)*3-8,MAX_BRIGHTNESS/4*1) : SetLED(MM*3-8,MAX_BRIGHTNESS/4*1);
//		MM<4 ? SetLED((MM+60)*3-11,0x19/5) : SetLED(MM*3-11,0x19/5);
//		calulateLEDMIBAMBits();
//		delay_ms(100);
//		SetLED(MM*3+1,0);
//		MM<1 ? SetLED((MM+60)*3-2,0) : SetLED(MM*3-2,0);
//		MM<2 ? SetLED((MM+60)*3-5,0) : SetLED(MM*3-5,0);
//		MM<3 ? SetLED((MM+60)*3-8,0) : SetLED(MM*3-8,0);
//		MM<4 ? SetLED((MM+60)*3-11,0) : SetLED(MM*3-11,0);
//		calulateLEDMIBAMBits();
//	}
	//Hours red
//	for (HH=0;HH<12;HH++){
		SetLED(HH*3*5,MAX_BRIGHTNESS);
		HH<1 ? SetLED((HH+12)*3*5-3,MAX_BRIGHTNESS/3*2) : SetLED(HH*3*5-3,MAX_BRIGHTNESS/3*2);
		HH<1 ? SetLED((HH+12)*3*5-6,MAX_BRIGHTNESS/3*1) : SetLED(HH*3*5-6,MAX_BRIGHTNESS/3*1);
//		HH<1 ? SetLED((HH+12)*3*5-9,0x33/5*2) : SetLED(HH*3*5-9,0x33/5*2);
//		HH<1 ? SetLED((HH+12)*3*5-12,0x19/5) : SetLED(HH*3*5-12,0x19/5);
//		calulateLEDMIBAMBits();
//		delay_ms(1000);
//		SetLED(HH*3*5,0);
//		HH<1 ? SetLED((HH+12)*3*5-3,0) : SetLED(HH*3*5-3,0);
//		HH<1 ? SetLED((HH+12)*3*5-6,0) : SetLED(HH*3*5-6,0);
//		HH<1 ? SetLED((HH+12)*3*5-9,0) : SetLED(HH*3*5-9,0);
//		HH<1 ? SetLED((HH+12)*3*5-12,0) : SetLED(HH*3*5-12,0);
//	}
#endif //SetLED

	// Remove the tails
//	SS<5 ? SetRGB((SS+60)-5,0,0,0) : SetRGB(SS-5,0,0,0);
//	MM<4 ? SetRGB((MM+60)-4,0,0,0) : SetRGB(MM-4,0,0,0);
//	HH<2 ? SetRGB((HH+11)*5,0,0,0) : SetRGB((HH-1)*5,0,0,0);
//	HH<2 ? SetRGB((HH+11)*5-2,0,0,0) : SetRGB((HH-1)*5-2,0,0,0);
//	HH<2 ? SetRGB((HH+11)*5-3,0,0,0) : SetRGB((HH-1)*5-3,0,0,0);

	for(uint8_t i=0;i<RGBS;i++)
		SetRGBALL(BC_R,BC_G,BC_B);

	// Seconds Blue
//	for (SS=0;SS<60;SS++){
		SetRGB(SS,SC_R,SC_G,SC_B);
		SS<1 ? SetRGB((SS+60)-1,SC_R/5*4,SC_G/5*4,SC_B/5*4) : SetRGB(SS-1,SC_R/5*4,SC_G/5*4,SC_B/5*4);
		SS<2 ? SetRGB((SS+60)-2,SC_R/5*3,SC_G/5*3,SC_B/5*3) : SetRGB(SS-2,SC_R/5*3,SC_G/5*3,SC_B/5*3);
		SS<3 ? SetRGB((SS+60)-3,SC_R/5*2,SC_G/5*2,SC_B/5*2) : SetRGB(SS-3,SC_R/5*2,SC_G/5*2,SC_B/5*2);
		SS<4 ? SetRGB((SS+60)-4,SC_R/5*1,SC_G/5*1,SC_B/5*1) : SetRGB(SS-4,SC_R/5*1,SC_G/5*1,SC_B/5*1);
//	}
	// Minutes Green
//	for (MM=0;MM<60;MM++){
		SetRGB(MM,MC_R,MC_G,MC_B);
		MM<1 ? SetRGB((MM+60)-1,MC_R/5*4,MC_G/5*4,MC_B/5*4) : SetRGB(MM-1,MC_R/5*4,MC_G/5*4,MC_B/5*4);
		MM<2 ? SetRGB((MM+60)-2,MC_R/5*3,MC_G/5*3,MC_B/5*3) : SetRGB(MM-2,MC_R/5*3,MC_G/5*3,MC_B/5*3);
		MM<3 ? SetRGB((MM+60)-3,MC_R/5*2,MC_G/5*2,MC_B/5*2) : SetRGB(MM-3,MC_R/5*2,MC_G/5*2,MC_B/5*2);
//		MM<4 ? SetRGB((MM+60)-4,0,0x19/,05) : SetRGB(MM-4,0,0x19/5,0);
//	}
	//Hours red
//	for (HH=0;HH<12;HH++){
		SetRGB((HH+12)*5,HC_R,HC_G,HC_B);
		HH<1 ? SetRGB((HH+12)*5-1,HC_R/5*4,HC_G/5*4,HC_B/5*4) : SetRGB(HH*5-1,HC_R/5*4,HC_G/5*4,HC_B/5*4);
		HH<1 ? SetRGB((HH+12)*5-2,HC_R/5*3,HC_G/5*3,HC_B/5*3) : SetRGB(HH*5-2,HC_R/5*3,HC_G/5*3,HC_B/5*3);
//		HH<1 ? SetRGB((HH+12)*5-3,0x33/5*2,0,0) : SetRGB(HH*5-3,0x33/5*2,0,0);
//		HH<1 ? SetRGB((HH+12)*5-4,0x19/5,0,0) : SetRGB(HH*5-4,0x19/5,0,0);
//	}

	calulateLEDMIBAMBits();
}