|
|||||||||||
| 技術(shù)交流 | 電路欣賞 | 工控天地 | 數(shù)字廣電 | 通信技術(shù) | 電源技術(shù) | 測控之家 | EMC技術(shù) | ARM技術(shù) | EDA技術(shù) | PCB技術(shù) | 嵌入式系統(tǒng) 驅(qū)動(dòng)編程 | 集成電路 | 器件替換 | 模擬技術(shù) | 新手園地 | 單 片 機(jī) | DSP技術(shù) | MCU技術(shù) | IC 設(shè)計(jì) | IC 產(chǎn)業(yè) | CAN-bus/DeviceNe |
大家?guī)兔聪逻@個(gè)程序,WINCE下的RTC時(shí)鐘設(shè)置 |
| 作者:參天小樹 欄目:嵌入式系統(tǒng) |
// // COPYRIGHT (c) Microsoft CORPORATION. All rights reserved. // // // Use of this source code is subject to the terms of the Microsoft end-user // license agreement (EULA) under which you licensed this SOFTWARE PRODUCT. // If you did not accept the terms of the EULA, you are not authorized to use // this source code. For a copy of the EULA, please see the LICENSE.RTF on your // INSTALL media. // /* -*-C-*- * * $Revision: 1.5 $ * $Author: xinxing $ * $Date: 2005/04/29 02:45:54 $ * * COPYRIGHT (c) 1999 ARM Limited * All Rights Reserved * * timex20t.c - ARMX20T (X = 7, 9, 10) platform timer routines */ #ifndef _HW_DEFS_ #define _HW_DEFS_ #include <windows.h> #include "C:\WINCE420\PUBLIC\COMMON\OAK\INC\nkintr.h" extern BOOL (*KLocalFileTimeToFileTime)(const FILETIME *, LPFILETIME); #include "C:\WINCE420\PLATFORM\ep931x\inc\hwdefs.h" DWORD dwReschedIncrement; extern volatile LARGE_INTEGER CurTicks; // The following CONTROL the debug OUTPUT of the alarm & set functions #define DEBUG_ALARM 0 #define DEBUG_SET 0 static volatile BOOL gfInitRTC = TRUE; static FILETIME gftLastFileTime; static LARGE_INTEGER gliLastCurTicks; // in ms // // The following are located in hal\interrupt.c // They are used to CONTROL the alarm setting. // extern volatile BOOL gfRTCAlarm; // Is the RTC alarm enabled? extern volatile LARGE_INTEGER gliRTCAlarmTicks; // Date & time of the alarm. // // Multipling by 161111 and then right shifting by 13 is the same as 10000000 / TIMER_508KHZ_FREQ // // This gives you the NUMBER of 100 nano second chunks...(nano chunks) // #define TICKS_TO_NANO_CHUNKS( time ) (time) *= 161111; (time) = ((time) >> 13) // // Multiply by 33 and then right shift by 24 is the same as TIMER_508KHZ_FREQ / 10000000 // This will give us TICKS // #define NANO_CHUNKS_TO_TICKS( time ) (time) = ((time) << 13); (time) = (time) / 161111 //// #define VIRTUAL_SYSTEM_ASIC_REGS_BASE (0x90000000 | 0x20000000) #define GPIO_PGDR (volatile ULONG *)(GPIO_BASE + 0x0038) #define GPIO_PGDDR (volatile ULONG *)(GPIO_BASE + 0x003C) #define EEDRIVE (volatile DWORD *)(GPIO_BASE + 0x00C8) #define WRITE_ADDRESS 0xD0 #define READ_ADDRESS 0xD1 typedef union { struct { unsigned int EECLK:1; unsigned int EEDATA:1; unsigned int UNUSED:30; } Field; unsigned int VALUE; } GPIO_DATA_REG_TYPE; typedef union { struct { unsigned int EECLK:1; unsigned int EEDATA:1; unsigned int UNUSED:30; } Field; unsigned int VALUE; } GPIO_DATA_DIR_REG_TYPE; typedef struct tGPIO { GPIO_DATA_REG_TYPE PGDR; // 0038 GPIO_DATA_DIR_REG_TYPE PGDDR; // 003C }GPIOG; //typedef struct _SYSTEMTIME { // unsigned LONG wYear; // unsigned LONG wMonth; // unsigned LONG wDayOfWeek; // unsigned LONG wDay; // unsigned LONG wHour; // unsigned LONG wMinute; // unsigned LONG wSecond; // unsigned LONG wMilliseconds; //} SYSTEMTIME, *PSYSTEMTIME; typedef SYSTEMTIME *PSYSTEMTIME; /// //#include "ds1337.h" unsigned LONG ds1337_bias=0; unsigned LONG ds1337_current_sec=0; static volatile GPIOG * const gpio_g = (GPIOG *)(GPIO_BASE + 0x0038); #define PERIOD_US_100HZ 10 #define DELAY_US (PERIOD_US_100HZ/2) void gen_ack(int not_ack); int wait_ack(void); /// /* EOF timex20t.c */ /* * Delay Function. */ void MyDelayInuSec(unsigned LONG uS) { unsigned LONG passed, startTime; startTime= *TIM_DEBUGVALUELOW; passed=0; while ( passed < uS) { passed = (*TIM_DEBUGVALUELOW - startTime); } } /* * Write the registers of DS1337, */ int write_ds1337(int address,const CHAR* pdata, int nbytes) { int i,j; // // Wait for bus not busy. // gpio_g->PGDDR.Field.EECLK =0; gpio_g->PGDDR.Field.EEDATA =0; while( !(gpio_g->PGDR.VALUE & 0x3) ){} // // Start Condition. // gpio_g->PGDDR.Field.EECLK =0; gpio_g->PGDDR.Field.EEDATA =1; gpio_g->PGDR.Field.EEDATA = 0; while( gpio_g->PGDR.Field.EECLK != 1 ){} // // Send DS1337 Slave Address For Write. // gpio_g->PGDDR.Field.EECLK =1; gpio_g->PGDDR.Field.EEDATA =1; gpio_g->PGDR.Field.EECLK = 0; MyDelayInuSec(DELAY_US); for(i=0;i<8;i++) { gpio_g->PGDR.Field.EEDATA = ((WRITE_ADDRESS>>(7-i))& |
| 2樓: | >>參與討論 |
| 作者: devicegate 于 2006/12/6 22:18:00 發(fā)布:
:) 你想問什么呢? |
|
|
|
| 免費(fèi)注冊為維庫電子開發(fā)網(wǎng)會(huì)員,參與電子工程師社區(qū)討論,點(diǎn)此進(jìn)入 |
Copyright © 1998-2006 m.58mhw.cn 浙ICP證030469號(hào) |