lol

Dependencies:   MMA8451Q

Fork of Application by Mateusz Kowalik

Committer:
danix
Date:
Sun Jan 21 22:28:30 2018 +0000
Revision:
12:3a30cdffa27c
Parent:
10:41552d038a69
Working acelerometer and mouse

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Zaitsev 10:41552d038a69 1 /**
Zaitsev 10:41552d038a69 2 ******************************************************************************
Zaitsev 10:41552d038a69 3 * @file ticker.h
Zaitsev 10:41552d038a69 4 * @brief Microcontroller uSec ticker
Zaitsev 10:41552d038a69 5 * @internal
Zaitsev 10:41552d038a69 6 * @author ON Semiconductor.
Zaitsev 10:41552d038a69 7 * $Rev:
Zaitsev 10:41552d038a69 8 * $Date:
Zaitsev 10:41552d038a69 9 ******************************************************************************
Zaitsev 10:41552d038a69 10 * Copyright 2016 Semiconductor Components Industries LLC (d/b/a “ON Semiconductor”).
Zaitsev 10:41552d038a69 11 * All rights reserved. This software and/or documentation is licensed by ON Semiconductor
Zaitsev 10:41552d038a69 12 * under limited terms and conditions. The terms and conditions pertaining to the software
Zaitsev 10:41552d038a69 13 * and/or documentation are available at http://www.onsemi.com/site/pdf/ONSEMI_T&C.pdf
Zaitsev 10:41552d038a69 14 * (“ON Semiconductor Standard Terms and Conditions of Sale, Section 8 Software”) and
Zaitsev 10:41552d038a69 15 * if applicable the software license agreement. Do not use this software and/or
Zaitsev 10:41552d038a69 16 * documentation unless you have carefully read and you agree to the limited terms and
Zaitsev 10:41552d038a69 17 * conditions. By using this software and/or documentation, you agree to the limited
Zaitsev 10:41552d038a69 18 * terms and conditions.
Zaitsev 10:41552d038a69 19 *
Zaitsev 10:41552d038a69 20 * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
Zaitsev 10:41552d038a69 21 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
Zaitsev 10:41552d038a69 22 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
Zaitsev 10:41552d038a69 23 * ON SEMICONDUCTOR SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL,
Zaitsev 10:41552d038a69 24 * INCIDENTAL, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
Zaitsev 10:41552d038a69 25 * @endinternal
Zaitsev 10:41552d038a69 26 *
Zaitsev 10:41552d038a69 27 *
Zaitsev 10:41552d038a69 28 */
Zaitsev 10:41552d038a69 29
Zaitsev 10:41552d038a69 30 #ifndef TICKER_H_
Zaitsev 10:41552d038a69 31 #define TICKER_H_
Zaitsev 10:41552d038a69 32
Zaitsev 10:41552d038a69 33 #include "types.h"
Zaitsev 10:41552d038a69 34
Zaitsev 10:41552d038a69 35 /** Core frequency definitions. /
Zaitsev 10:41552d038a69 36 *
Zaitsev 10:41552d038a69 37 * These definitions should be adjusted to setup Orion core frequencies.
Zaitsev 10:41552d038a69 38 */
Zaitsev 10:41552d038a69 39 #define CPU_CLOCK_ROOT_HZ ( ( unsigned long ) 32000000) /**< <b> Orion 32MHz root frequency </b> */
Zaitsev 10:41552d038a69 40 #define CPU_CLOCK_DIV_32M ( 1 ) /**< <b> Divider to set up core frequency at 32MHz </b> */
Zaitsev 10:41552d038a69 41 #define CPU_CLOCK_DIV_16M ( 2 ) /**< <b> Divider to set up core frequency at 16MHz </b> */
Zaitsev 10:41552d038a69 42 #define CPU_CLOCK_DIV_8M ( 4 ) /**< <b> Divider to set up core frequency at 8MHz </b> */
Zaitsev 10:41552d038a69 43 #define CPU_CLOCK_DIV_4M ( 8 ) /**< <b> Divider to set up core frequency at 4MHz </b> */
Zaitsev 10:41552d038a69 44
Zaitsev 10:41552d038a69 45 #define CPU_CLOCK_DIV CPU_CLOCK_DIV_32M /**< <b> Selected divider to be used by application code </b> */
Zaitsev 10:41552d038a69 46
Zaitsev 10:41552d038a69 47 #define configCPU_CLOCK_HZ ( ( unsigned long ) (CPU_CLOCK_ROOT_HZ/CPU_CLOCK_DIV) )
Zaitsev 10:41552d038a69 48 #define configTICK_RATE_HZ ( ( unsigned long ) 1000000 ) // 1uSec ticker rate
Zaitsev 10:41552d038a69 49
Zaitsev 10:41552d038a69 50
Zaitsev 10:41552d038a69 51 /* Lowest priority */
Zaitsev 10:41552d038a69 52
Zaitsev 10:41552d038a69 53 #define configKERNEL_INTERRUPT_PRIORITY ( 0xFF )
Zaitsev 10:41552d038a69 54 #define configMAX_SYSCALL_INTERRUPT_PRIORITY ( 0x8F )
Zaitsev 10:41552d038a69 55
Zaitsev 10:41552d038a69 56 #define configSYSTICK_CLOCK_HZ configCPU_CLOCK_HZ
Zaitsev 10:41552d038a69 57
Zaitsev 10:41552d038a69 58 /* Constants required to manipulate the core. Registers first... */
Zaitsev 10:41552d038a69 59 #define portNVIC_SYSTICK_CTRL_REG ( * ( ( volatile unsigned long * ) 0xe000e010 ) )
Zaitsev 10:41552d038a69 60 #define portNVIC_SYSTICK_LOAD_REG ( * ( ( volatile unsigned long * ) 0xe000e014 ) )
Zaitsev 10:41552d038a69 61 #define portNVIC_SYSTICK_CURRENT_VALUE_REG ( * ( ( volatile unsigned long * ) 0xe000e018 ) )
Zaitsev 10:41552d038a69 62 #define portNVIC_INT_CTRL_REG ( * ( ( volatile unsigned long * ) 0xe000ed04 ) )
Zaitsev 10:41552d038a69 63 #define portNVIC_SYSPRI2_REG ( * ( ( volatile unsigned long * ) 0xe000ed20 ) )
Zaitsev 10:41552d038a69 64
Zaitsev 10:41552d038a69 65 /* ...then bits in the registers. */
Zaitsev 10:41552d038a69 66 #define portNVIC_SYSTICK_CLK_BIT ( 1UL << 2UL )
Zaitsev 10:41552d038a69 67 #define portNVIC_SYSTICK_INT_BIT ( 1UL << 1UL )
Zaitsev 10:41552d038a69 68 #define portNVIC_SYSTICK_ENABLE_BIT ( 1UL << 0UL )
Zaitsev 10:41552d038a69 69 #define portNVIC_SYSTICK_COUNT_FLAG_BIT ( 1UL << 16UL )
Zaitsev 10:41552d038a69 70
Zaitsev 10:41552d038a69 71 /* Orion has 4 interrupt priority bits
Zaitsev 10:41552d038a69 72 */
Zaitsev 10:41552d038a69 73 #define portNVIC_SYSTICK_PRI ( ( ( unsigned long ) configKERNEL_INTERRUPT_PRIORITY ) << 24 )
Zaitsev 10:41552d038a69 74
Zaitsev 10:41552d038a69 75 /* API definitions */
Zaitsev 10:41552d038a69 76 void fSysTickInit(void);
Zaitsev 10:41552d038a69 77
Zaitsev 10:41552d038a69 78 void fSysTickHandler(void);
Zaitsev 10:41552d038a69 79
Zaitsev 10:41552d038a69 80 uint32_t fSysTickRead(void);
Zaitsev 10:41552d038a69 81
Zaitsev 10:41552d038a69 82 void fSysTickEnableInterrupt (void);
Zaitsev 10:41552d038a69 83
Zaitsev 10:41552d038a69 84 void fSysTickDisableInterrupt (void);
Zaitsev 10:41552d038a69 85 #endif // TICKER_H_