added prescaler for 16 bit pwm in LPC1347 target
Fork of mbed-dev by
targets/hal/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_K66F/drivers/fsl_common.c@144:ef7eb2e8f9f7, 2016-09-02 (annotated)
- Committer:
- <>
- Date:
- Fri Sep 02 15:07:44 2016 +0100
- Revision:
- 144:ef7eb2e8f9f7
This updates the lib to the mbed lib v125
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 144:ef7eb2e8f9f7 | 1 | /* |
<> | 144:ef7eb2e8f9f7 | 2 | * Copyright (c) 2015, Freescale Semiconductor, Inc. |
<> | 144:ef7eb2e8f9f7 | 3 | * All rights reserved. |
<> | 144:ef7eb2e8f9f7 | 4 | * |
<> | 144:ef7eb2e8f9f7 | 5 | * Redistribution and use in source and binary forms, with or without modification, |
<> | 144:ef7eb2e8f9f7 | 6 | * are permitted provided that the following conditions are met: |
<> | 144:ef7eb2e8f9f7 | 7 | * |
<> | 144:ef7eb2e8f9f7 | 8 | * o Redistributions of source code must retain the above copyright notice, this list |
<> | 144:ef7eb2e8f9f7 | 9 | * of conditions and the following disclaimer. |
<> | 144:ef7eb2e8f9f7 | 10 | * |
<> | 144:ef7eb2e8f9f7 | 11 | * o Redistributions in binary form must reproduce the above copyright notice, this |
<> | 144:ef7eb2e8f9f7 | 12 | * list of conditions and the following disclaimer in the documentation and/or |
<> | 144:ef7eb2e8f9f7 | 13 | * other materials provided with the distribution. |
<> | 144:ef7eb2e8f9f7 | 14 | * |
<> | 144:ef7eb2e8f9f7 | 15 | * o Neither the name of Freescale Semiconductor, Inc. nor the names of its |
<> | 144:ef7eb2e8f9f7 | 16 | * contributors may be used to endorse or promote products derived from this |
<> | 144:ef7eb2e8f9f7 | 17 | * software without specific prior written permission. |
<> | 144:ef7eb2e8f9f7 | 18 | * |
<> | 144:ef7eb2e8f9f7 | 19 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
<> | 144:ef7eb2e8f9f7 | 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
<> | 144:ef7eb2e8f9f7 | 21 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
<> | 144:ef7eb2e8f9f7 | 22 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR |
<> | 144:ef7eb2e8f9f7 | 23 | * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
<> | 144:ef7eb2e8f9f7 | 24 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
<> | 144:ef7eb2e8f9f7 | 25 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
<> | 144:ef7eb2e8f9f7 | 26 | * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
<> | 144:ef7eb2e8f9f7 | 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
<> | 144:ef7eb2e8f9f7 | 28 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
<> | 144:ef7eb2e8f9f7 | 29 | */ |
<> | 144:ef7eb2e8f9f7 | 30 | |
<> | 144:ef7eb2e8f9f7 | 31 | #include "fsl_common.h" |
<> | 144:ef7eb2e8f9f7 | 32 | /* This is not needed for mbed */ |
<> | 144:ef7eb2e8f9f7 | 33 | #if 0 |
<> | 144:ef7eb2e8f9f7 | 34 | #include "fsl_debug_console.h" |
<> | 144:ef7eb2e8f9f7 | 35 | |
<> | 144:ef7eb2e8f9f7 | 36 | #ifndef NDEBUG |
<> | 144:ef7eb2e8f9f7 | 37 | #if (defined(__CC_ARM)) || (defined(__ICCARM__)) |
<> | 144:ef7eb2e8f9f7 | 38 | void __aeabi_assert(const char *failedExpr, const char *file, int line) |
<> | 144:ef7eb2e8f9f7 | 39 | { |
<> | 144:ef7eb2e8f9f7 | 40 | PRINTF("ASSERT ERROR \" %s \": file \"%s\" Line \"%d\" \n", failedExpr, file, line); |
<> | 144:ef7eb2e8f9f7 | 41 | for (;;) |
<> | 144:ef7eb2e8f9f7 | 42 | { |
<> | 144:ef7eb2e8f9f7 | 43 | __asm("bkpt #0"); |
<> | 144:ef7eb2e8f9f7 | 44 | } |
<> | 144:ef7eb2e8f9f7 | 45 | } |
<> | 144:ef7eb2e8f9f7 | 46 | #elif(defined(__GNUC__)) |
<> | 144:ef7eb2e8f9f7 | 47 | void __assert_func(const char *file, int line, const char *func, const char *failedExpr) |
<> | 144:ef7eb2e8f9f7 | 48 | { |
<> | 144:ef7eb2e8f9f7 | 49 | PRINTF("ASSERT ERROR \" %s \": file \"%s\" Line \"%d\" function name \"%s\" \n", failedExpr, file, line, func); |
<> | 144:ef7eb2e8f9f7 | 50 | for (;;) |
<> | 144:ef7eb2e8f9f7 | 51 | { |
<> | 144:ef7eb2e8f9f7 | 52 | __asm("bkpt #0"); |
<> | 144:ef7eb2e8f9f7 | 53 | } |
<> | 144:ef7eb2e8f9f7 | 54 | } |
<> | 144:ef7eb2e8f9f7 | 55 | #endif /* (defined(__CC_ARM)) || (defined (__ICCARM__)) */ |
<> | 144:ef7eb2e8f9f7 | 56 | #endif /* NDEBUG */ |
<> | 144:ef7eb2e8f9f7 | 57 | #endif |
<> | 144:ef7eb2e8f9f7 | 58 | void InstallIRQHandler(IRQn_Type irq, uint32_t irqHandler) |
<> | 144:ef7eb2e8f9f7 | 59 | { |
<> | 144:ef7eb2e8f9f7 | 60 | /* Addresses for VECTOR_TABLE and VECTOR_RAM come from the linker file */ |
<> | 144:ef7eb2e8f9f7 | 61 | #if defined(__CC_ARM) |
<> | 144:ef7eb2e8f9f7 | 62 | extern uint32_t Image$$VECTOR_ROM$$Base[]; |
<> | 144:ef7eb2e8f9f7 | 63 | extern uint32_t Image$$VECTOR_RAM$$Base[]; |
<> | 144:ef7eb2e8f9f7 | 64 | extern uint32_t Image$$RW_m_data$$Base[]; |
<> | 144:ef7eb2e8f9f7 | 65 | |
<> | 144:ef7eb2e8f9f7 | 66 | #define __VECTOR_TABLE Image$$VECTOR_ROM$$Base |
<> | 144:ef7eb2e8f9f7 | 67 | #define __VECTOR_RAM Image$$VECTOR_RAM$$Base |
<> | 144:ef7eb2e8f9f7 | 68 | #define __RAM_VECTOR_TABLE_SIZE (((uint32_t)Image$$RW_m_data$$Base - (uint32_t)Image$$VECTOR_RAM$$Base)) |
<> | 144:ef7eb2e8f9f7 | 69 | #elif defined(__ICCARM__) |
<> | 144:ef7eb2e8f9f7 | 70 | extern uint32_t __RAM_VECTOR_TABLE_SIZE[]; |
<> | 144:ef7eb2e8f9f7 | 71 | extern uint32_t __VECTOR_TABLE[]; |
<> | 144:ef7eb2e8f9f7 | 72 | extern uint32_t __VECTOR_RAM[]; |
<> | 144:ef7eb2e8f9f7 | 73 | #elif defined(__GNUC__) |
<> | 144:ef7eb2e8f9f7 | 74 | extern uint32_t __VECTOR_TABLE[]; |
<> | 144:ef7eb2e8f9f7 | 75 | extern uint32_t __VECTOR_RAM[]; |
<> | 144:ef7eb2e8f9f7 | 76 | extern uint32_t __RAM_VECTOR_TABLE_SIZE_BYTES[]; |
<> | 144:ef7eb2e8f9f7 | 77 | uint32_t __RAM_VECTOR_TABLE_SIZE = (uint32_t)(__RAM_VECTOR_TABLE_SIZE_BYTES); |
<> | 144:ef7eb2e8f9f7 | 78 | #endif /* defined(__CC_ARM) */ |
<> | 144:ef7eb2e8f9f7 | 79 | uint32_t n; |
<> | 144:ef7eb2e8f9f7 | 80 | uint32_t interrupts_disabled; |
<> | 144:ef7eb2e8f9f7 | 81 | |
<> | 144:ef7eb2e8f9f7 | 82 | interrupts_disabled = __get_PRIMASK(); |
<> | 144:ef7eb2e8f9f7 | 83 | __disable_irq(); |
<> | 144:ef7eb2e8f9f7 | 84 | if (SCB->VTOR != (uint32_t)__VECTOR_RAM) |
<> | 144:ef7eb2e8f9f7 | 85 | { |
<> | 144:ef7eb2e8f9f7 | 86 | /* Copy the vector table from ROM to RAM */ |
<> | 144:ef7eb2e8f9f7 | 87 | for (n = 0; n < ((uint32_t)__RAM_VECTOR_TABLE_SIZE) / sizeof(uint32_t); n++) |
<> | 144:ef7eb2e8f9f7 | 88 | { |
<> | 144:ef7eb2e8f9f7 | 89 | __VECTOR_RAM[n] = __VECTOR_TABLE[n]; |
<> | 144:ef7eb2e8f9f7 | 90 | } |
<> | 144:ef7eb2e8f9f7 | 91 | /* Point the VTOR to the position of vector table */ |
<> | 144:ef7eb2e8f9f7 | 92 | SCB->VTOR = (uint32_t)__VECTOR_RAM; |
<> | 144:ef7eb2e8f9f7 | 93 | } |
<> | 144:ef7eb2e8f9f7 | 94 | |
<> | 144:ef7eb2e8f9f7 | 95 | /* make sure the __VECTOR_RAM is noncachable */ |
<> | 144:ef7eb2e8f9f7 | 96 | __VECTOR_RAM[irq + 16] = irqHandler; |
<> | 144:ef7eb2e8f9f7 | 97 | |
<> | 144:ef7eb2e8f9f7 | 98 | if (!interrupts_disabled) { |
<> | 144:ef7eb2e8f9f7 | 99 | __enable_irq(); |
<> | 144:ef7eb2e8f9f7 | 100 | } |
<> | 144:ef7eb2e8f9f7 | 101 | } |