// // TK-PIE // Copyright (c) 2016 - Fabio Belavenuto & Victor Trucco // // All rights reserved // // Redistribution and use in source and synthezised forms, with or without // modification, are permitted provided that the following conditions are met: // // Redistributions of source code must retain the above copyright notice, // this list of conditions and the following disclaimer. // // Redistributions in synthesized form must reproduce the above copyright // notice, this list of conditions and the following disclaimer in the // documentation and/or other materials provided with the distribution. // // Neither the name of the author nor the names of other contributors may // be used to endorse or promote products derived from this software without // specific prior written permission. // // THIS CODE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. // // You are responsible for any legal issues arising from your use of this code. // //------------------------------------------------------------------------------- extern void PUT32 ( unsigned int, unsigned int ); extern void PUT16 ( unsigned int, unsigned int ); extern void PUT8 ( unsigned int, unsigned int ); extern unsigned int GET32 ( unsigned int ); extern void BRANCHTO ( unsigned int ); extern void dummy ( unsigned int ); #define ARM_TIMER_CTL 0x2000B408 #define ARM_TIMER_CNT 0x2000B420 #define GPFSEL1 0x20200004 #define GPSET0 0x2020001C #define GPCLR0 0x20200028 #define GPPUD 0x20200094 #define GPPUDCLK0 0x20200098 #define AUX_ENABLES 0x20215004 #define AUX_MU_IO_REG 0x20215040 #define AUX_MU_IER_REG 0x20215044 #define AUX_MU_IIR_REG 0x20215048 #define AUX_MU_LCR_REG 0x2021504C #define AUX_MU_MCR_REG 0x20215050 #define AUX_MU_LSR_REG 0x20215054 #define AUX_MU_MSR_REG 0x20215058 #define AUX_MU_SCRATCH 0x2021505C #define AUX_MU_CNTL_REG 0x20215060 #define AUX_MU_STAT_REG 0x20215064 #define AUX_MU_BAUD_REG 0x20215068 void timer_init ( void ) { //0xF9+1 = 250 //250MHz/250 = 1MHz PUT32(ARM_TIMER_CTL,0x00F90000); PUT32(ARM_TIMER_CTL,0x00F90200); } //------------------------------------------------------------------------- unsigned int timer_tick ( void ) { return(GET32(ARM_TIMER_CNT)); }