mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
targets/TARGET_RENESAS/TARGET_RZ_A1XX/TARGET_VK_RZ_A1H/device/nvic_wrapper.c@189:f392fc9709a3, 2019-02-20 (annotated)
- Committer:
- AnnaBridge
- Date:
- Wed Feb 20 22:31:08 2019 +0000
- Revision:
- 189:f392fc9709a3
- Parent:
- 184:08ed48f1de7f
mbed library release version 165
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 119:3921aeca8633 | 1 | /******************************************************************************* |
mbed_official | 119:3921aeca8633 | 2 | * DISCLAIMER |
mbed_official | 119:3921aeca8633 | 3 | * This software is supplied by Renesas Electronics Corporation and is only |
mbed_official | 119:3921aeca8633 | 4 | * intended for use with Renesas products. No other uses are authorized. This |
mbed_official | 119:3921aeca8633 | 5 | * software is owned by Renesas Electronics Corporation and is protected under |
mbed_official | 119:3921aeca8633 | 6 | * all applicable laws, including copyright laws. |
mbed_official | 119:3921aeca8633 | 7 | * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING |
mbed_official | 119:3921aeca8633 | 8 | * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT |
mbed_official | 119:3921aeca8633 | 9 | * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE |
mbed_official | 119:3921aeca8633 | 10 | * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. |
mbed_official | 119:3921aeca8633 | 11 | * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS |
mbed_official | 119:3921aeca8633 | 12 | * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE |
mbed_official | 119:3921aeca8633 | 13 | * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR |
mbed_official | 119:3921aeca8633 | 14 | * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE |
mbed_official | 119:3921aeca8633 | 15 | * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. |
mbed_official | 119:3921aeca8633 | 16 | * Renesas reserves the right, without notice, to make changes to this software |
mbed_official | 119:3921aeca8633 | 17 | * and to discontinue the availability of this software. By using this software, |
mbed_official | 119:3921aeca8633 | 18 | * you agree to the additional terms and conditions found by accessing the |
mbed_official | 119:3921aeca8633 | 19 | * following link: |
mbed_official | 119:3921aeca8633 | 20 | * http://www.renesas.com/disclaimer |
mbed_official | 119:3921aeca8633 | 21 | * Copyright (C) 2012 - 2015 Renesas Electronics Corporation. All rights reserved. |
mbed_official | 119:3921aeca8633 | 22 | *******************************************************************************/ |
mbed_official | 119:3921aeca8633 | 23 | /**************************************************************************//** |
mbed_official | 119:3921aeca8633 | 24 | * @file nvic_wrapper.c |
mbed_official | 119:3921aeca8633 | 25 | * $Rev: $ |
mbed_official | 119:3921aeca8633 | 26 | * $Date:: $ |
mbed_official | 119:3921aeca8633 | 27 | * @brief Wrapper between NVIC(for Cortex-M) and GIC(for Cortex-A9) |
mbed_official | 119:3921aeca8633 | 28 | ******************************************************************************/ |
mbed_official | 119:3921aeca8633 | 29 | |
mbed_official | 119:3921aeca8633 | 30 | /****************************************************************************** |
mbed_official | 119:3921aeca8633 | 31 | Includes <System Includes> , "Project Includes" |
mbed_official | 119:3921aeca8633 | 32 | ******************************************************************************/ |
mbed_official | 119:3921aeca8633 | 33 | #include "VKRZA1H.h" |
mbed_official | 119:3921aeca8633 | 34 | #include "wdt_iodefine.h" |
mbed_official | 119:3921aeca8633 | 35 | #include "nvic_wrapper.h" |
mbed_official | 119:3921aeca8633 | 36 | |
mbed_official | 119:3921aeca8633 | 37 | /****************************************************************************** |
mbed_official | 119:3921aeca8633 | 38 | Typedef definitions |
mbed_official | 119:3921aeca8633 | 39 | ******************************************************************************/ |
mbed_official | 119:3921aeca8633 | 40 | |
mbed_official | 119:3921aeca8633 | 41 | /****************************************************************************** |
mbed_official | 119:3921aeca8633 | 42 | Macro definitions |
mbed_official | 119:3921aeca8633 | 43 | ******************************************************************************/ |
mbed_official | 119:3921aeca8633 | 44 | #define PRIO_BITS (7) /* Set binary point to 0 in gic.c */ |
mbed_official | 119:3921aeca8633 | 45 | #define WDT_WTCNT_WRITE (0x5A00) |
mbed_official | 119:3921aeca8633 | 46 | #define WDT_WTCSR_WRITE (0xA500) |
mbed_official | 119:3921aeca8633 | 47 | #define WDT_WRCSR_WOVF_WRITE (0xA500) |
mbed_official | 119:3921aeca8633 | 48 | #define WDT_WRCSR_RSTE_WRITE (0x5A00) |
mbed_official | 119:3921aeca8633 | 49 | |
mbed_official | 119:3921aeca8633 | 50 | /****************************************************************************** |
mbed_official | 119:3921aeca8633 | 51 | Imported global variables and functions (from other files) |
mbed_official | 119:3921aeca8633 | 52 | ******************************************************************************/ |
mbed_official | 119:3921aeca8633 | 53 | |
mbed_official | 119:3921aeca8633 | 54 | /****************************************************************************** |
mbed_official | 119:3921aeca8633 | 55 | Exported global variables and functions (to be accessed by other files) |
mbed_official | 119:3921aeca8633 | 56 | ******************************************************************************/ |
mbed_official | 119:3921aeca8633 | 57 | |
mbed_official | 119:3921aeca8633 | 58 | /****************************************************************************** |
mbed_official | 119:3921aeca8633 | 59 | Private global variables and functions |
mbed_official | 119:3921aeca8633 | 60 | ******************************************************************************/ |
mbed_official | 119:3921aeca8633 | 61 | |
mbed_official | 119:3921aeca8633 | 62 | |
mbed_official | 119:3921aeca8633 | 63 | |
mbed_official | 119:3921aeca8633 | 64 | /* ########################## NVIC functions #################################### */ |
mbed_official | 119:3921aeca8633 | 65 | void NVIC_SetPriorityGrouping(uint32_t PriorityGroup) |
mbed_official | 119:3921aeca8633 | 66 | { |
mbed_official | 119:3921aeca8633 | 67 | GIC_SetBinaryPoint(PriorityGroup); |
mbed_official | 119:3921aeca8633 | 68 | } |
mbed_official | 119:3921aeca8633 | 69 | |
mbed_official | 119:3921aeca8633 | 70 | |
mbed_official | 119:3921aeca8633 | 71 | uint32_t NVIC_GetPriorityGrouping(void) |
mbed_official | 119:3921aeca8633 | 72 | { |
AnnaBridge | 184:08ed48f1de7f | 73 | return GIC_GetBinaryPoint(); |
mbed_official | 119:3921aeca8633 | 74 | } |
mbed_official | 119:3921aeca8633 | 75 | |
mbed_official | 119:3921aeca8633 | 76 | |
mbed_official | 119:3921aeca8633 | 77 | void NVIC_EnableIRQ(IRQn_Type IRQn) |
mbed_official | 119:3921aeca8633 | 78 | { |
mbed_official | 119:3921aeca8633 | 79 | GIC_EnableIRQ(IRQn); |
mbed_official | 119:3921aeca8633 | 80 | } |
mbed_official | 119:3921aeca8633 | 81 | |
mbed_official | 119:3921aeca8633 | 82 | |
mbed_official | 119:3921aeca8633 | 83 | void NVIC_DisableIRQ(IRQn_Type IRQn) |
mbed_official | 119:3921aeca8633 | 84 | { |
mbed_official | 119:3921aeca8633 | 85 | GIC_DisableIRQ(IRQn); |
mbed_official | 119:3921aeca8633 | 86 | } |
mbed_official | 119:3921aeca8633 | 87 | |
mbed_official | 119:3921aeca8633 | 88 | |
mbed_official | 119:3921aeca8633 | 89 | uint32_t NVIC_GetPendingIRQ(IRQn_Type IRQn) |
mbed_official | 119:3921aeca8633 | 90 | { |
mbed_official | 119:3921aeca8633 | 91 | uint32_t pending; |
mbed_official | 119:3921aeca8633 | 92 | |
mbed_official | 119:3921aeca8633 | 93 | pending = GIC_GetIRQStatus(IRQn); |
mbed_official | 119:3921aeca8633 | 94 | pending = (pending & 0x00000001); |
mbed_official | 119:3921aeca8633 | 95 | |
mbed_official | 119:3921aeca8633 | 96 | return pending; |
mbed_official | 119:3921aeca8633 | 97 | } |
mbed_official | 119:3921aeca8633 | 98 | |
mbed_official | 119:3921aeca8633 | 99 | |
mbed_official | 119:3921aeca8633 | 100 | void NVIC_SetPendingIRQ(IRQn_Type IRQn) |
mbed_official | 119:3921aeca8633 | 101 | { |
mbed_official | 119:3921aeca8633 | 102 | GIC_SetPendingIRQ(IRQn); |
mbed_official | 119:3921aeca8633 | 103 | } |
mbed_official | 119:3921aeca8633 | 104 | |
mbed_official | 119:3921aeca8633 | 105 | |
mbed_official | 119:3921aeca8633 | 106 | void NVIC_ClearPendingIRQ(IRQn_Type IRQn) |
mbed_official | 119:3921aeca8633 | 107 | { |
mbed_official | 119:3921aeca8633 | 108 | GIC_ClearPendingIRQ(IRQn); |
mbed_official | 119:3921aeca8633 | 109 | } |
mbed_official | 119:3921aeca8633 | 110 | |
mbed_official | 119:3921aeca8633 | 111 | |
mbed_official | 119:3921aeca8633 | 112 | uint32_t NVIC_GetActive(IRQn_Type IRQn) |
mbed_official | 119:3921aeca8633 | 113 | { |
mbed_official | 119:3921aeca8633 | 114 | uint32_t active; |
mbed_official | 119:3921aeca8633 | 115 | |
mbed_official | 119:3921aeca8633 | 116 | active = GIC_GetIRQStatus(IRQn); |
mbed_official | 119:3921aeca8633 | 117 | active = ((active >> 1) & 0x00000001); |
mbed_official | 119:3921aeca8633 | 118 | |
mbed_official | 119:3921aeca8633 | 119 | return active; |
mbed_official | 119:3921aeca8633 | 120 | } |
mbed_official | 119:3921aeca8633 | 121 | |
mbed_official | 119:3921aeca8633 | 122 | |
mbed_official | 119:3921aeca8633 | 123 | void NVIC_SetPriority(IRQn_Type IRQn, uint32_t priority) |
mbed_official | 119:3921aeca8633 | 124 | { |
mbed_official | 119:3921aeca8633 | 125 | GIC_SetPriority(IRQn, (priority << 3)); |
mbed_official | 119:3921aeca8633 | 126 | } |
mbed_official | 119:3921aeca8633 | 127 | |
mbed_official | 119:3921aeca8633 | 128 | |
mbed_official | 119:3921aeca8633 | 129 | uint32_t NVIC_GetPriority(IRQn_Type IRQn) |
mbed_official | 119:3921aeca8633 | 130 | { |
mbed_official | 119:3921aeca8633 | 131 | uint32_t priority_field; |
mbed_official | 119:3921aeca8633 | 132 | |
mbed_official | 119:3921aeca8633 | 133 | priority_field = GIC_GetPriority(IRQn); |
mbed_official | 119:3921aeca8633 | 134 | priority_field = (priority_field >> 3); |
mbed_official | 119:3921aeca8633 | 135 | return priority_field; |
mbed_official | 119:3921aeca8633 | 136 | } |
mbed_official | 119:3921aeca8633 | 137 | |
mbed_official | 119:3921aeca8633 | 138 | |
mbed_official | 119:3921aeca8633 | 139 | uint32_t NVIC_EncodePriority (uint32_t PriorityGroup, uint32_t PreemptPriority, uint32_t SubPriority) |
mbed_official | 119:3921aeca8633 | 140 | { |
mbed_official | 119:3921aeca8633 | 141 | uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */ |
mbed_official | 119:3921aeca8633 | 142 | uint32_t PreemptPriorityBits; |
mbed_official | 119:3921aeca8633 | 143 | uint32_t SubPriorityBits; |
mbed_official | 119:3921aeca8633 | 144 | |
mbed_official | 119:3921aeca8633 | 145 | PreemptPriorityBits = ((7 - PriorityGroupTmp) > PRIO_BITS) ? PRIO_BITS : 7 - PriorityGroupTmp; |
mbed_official | 119:3921aeca8633 | 146 | SubPriorityBits = ((PriorityGroupTmp + PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + PRIO_BITS; |
mbed_official | 119:3921aeca8633 | 147 | |
mbed_official | 119:3921aeca8633 | 148 | return ( |
mbed_official | 119:3921aeca8633 | 149 | ((PreemptPriority & ((1 << (PreemptPriorityBits)) - 1)) << SubPriorityBits) | |
mbed_official | 119:3921aeca8633 | 150 | ((SubPriority & ((1 << (SubPriorityBits )) - 1))) |
mbed_official | 119:3921aeca8633 | 151 | ); |
mbed_official | 119:3921aeca8633 | 152 | } |
mbed_official | 119:3921aeca8633 | 153 | |
mbed_official | 119:3921aeca8633 | 154 | |
mbed_official | 119:3921aeca8633 | 155 | void NVIC_DecodePriority (uint32_t Priority, uint32_t PriorityGroup, uint32_t* pPreemptPriority, uint32_t* pSubPriority) |
mbed_official | 119:3921aeca8633 | 156 | { |
mbed_official | 119:3921aeca8633 | 157 | uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */ |
mbed_official | 119:3921aeca8633 | 158 | uint32_t PreemptPriorityBits; |
mbed_official | 119:3921aeca8633 | 159 | uint32_t SubPriorityBits; |
mbed_official | 119:3921aeca8633 | 160 | |
mbed_official | 119:3921aeca8633 | 161 | PreemptPriorityBits = ((7 - PriorityGroupTmp) > PRIO_BITS) ? PRIO_BITS : 7 - PriorityGroupTmp; |
mbed_official | 119:3921aeca8633 | 162 | SubPriorityBits = ((PriorityGroupTmp + PRIO_BITS) < 7) ? 0 : PriorityGroupTmp - 7 + PRIO_BITS; |
mbed_official | 119:3921aeca8633 | 163 | |
mbed_official | 119:3921aeca8633 | 164 | *pPreemptPriority = (Priority >> SubPriorityBits) & ((1 << (PreemptPriorityBits)) - 1); |
mbed_official | 119:3921aeca8633 | 165 | *pSubPriority = (Priority ) & ((1 << (SubPriorityBits )) - 1); |
mbed_official | 119:3921aeca8633 | 166 | } |
mbed_official | 119:3921aeca8633 | 167 | |
mbed_official | 119:3921aeca8633 | 168 | void NVIC_SystemReset(void) |
mbed_official | 119:3921aeca8633 | 169 | { |
mbed_official | 119:3921aeca8633 | 170 | uint16_t reg; |
mbed_official | 119:3921aeca8633 | 171 | uint8_t dummy_read; |
mbed_official | 119:3921aeca8633 | 172 | /* Use Watch Dog Timer to system reset */ |
mbed_official | 119:3921aeca8633 | 173 | |
mbed_official | 119:3921aeca8633 | 174 | /* Set WT/IT bit of WTCSR to 1 = Watch Dog */ |
mbed_official | 119:3921aeca8633 | 175 | /* CLK = 000, 1xP0phi(=33.3333MHz) = 7.7us */ |
mbed_official | 119:3921aeca8633 | 176 | reg = (WDT_WTCSR_WRITE | 0x0058); |
mbed_official | 119:3921aeca8633 | 177 | WDTWTCSR = reg; |
mbed_official | 119:3921aeca8633 | 178 | |
mbed_official | 119:3921aeca8633 | 179 | /* Clear Count reg */ |
mbed_official | 119:3921aeca8633 | 180 | reg = (WDT_WTCNT_WRITE | 0x0000); |
mbed_official | 119:3921aeca8633 | 181 | WDTWTCNT = reg; |
mbed_official | 119:3921aeca8633 | 182 | |
mbed_official | 119:3921aeca8633 | 183 | /* Clear WOVF flag */ |
mbed_official | 119:3921aeca8633 | 184 | dummy_read = WDTWRCSR; |
mbed_official | 119:3921aeca8633 | 185 | reg = (WDT_WRCSR_WOVF_WRITE | (dummy_read & 0x0000)); |
mbed_official | 119:3921aeca8633 | 186 | WDTWRCSR = reg; |
mbed_official | 119:3921aeca8633 | 187 | /* Enable Internal Reset */ |
mbed_official | 119:3921aeca8633 | 188 | reg = (WDT_WRCSR_RSTE_WRITE | 0x005F); |
mbed_official | 119:3921aeca8633 | 189 | WDTWRCSR = reg; |
mbed_official | 119:3921aeca8633 | 190 | |
mbed_official | 119:3921aeca8633 | 191 | /* Watch Dog start */ |
mbed_official | 119:3921aeca8633 | 192 | reg = (WDT_WTCSR_WRITE | 0x0078); |
mbed_official | 119:3921aeca8633 | 193 | WDTWTCSR = reg; |
mbed_official | 119:3921aeca8633 | 194 | |
mbed_official | 119:3921aeca8633 | 195 | while(1); /* wait Internal Reset */ |
mbed_official | 119:3921aeca8633 | 196 | } |
mbed_official | 119:3921aeca8633 | 197 | |
mbed_official | 119:3921aeca8633 | 198 | /* ################################## SysTick function ############################################ */ |
mbed_official | 119:3921aeca8633 | 199 | uint32_t SysTick_Config(uint32_t ticks) |
mbed_official | 119:3921aeca8633 | 200 | { |
mbed_official | 119:3921aeca8633 | 201 | /* Not support this function */ |
mbed_official | 119:3921aeca8633 | 202 | /* Use mbed Ticker */ |
mbed_official | 119:3921aeca8633 | 203 | return (1); /* impossible */ |
mbed_official | 119:3921aeca8633 | 204 | } |
mbed_official | 119:3921aeca8633 | 205 | |
mbed_official | 119:3921aeca8633 | 206 | |
mbed_official | 119:3921aeca8633 | 207 | /* ##################################### Debug In/Output function ########################################### */ |
mbed_official | 119:3921aeca8633 | 208 | uint32_t ITM_SendChar (uint32_t ch) |
mbed_official | 119:3921aeca8633 | 209 | { |
mbed_official | 119:3921aeca8633 | 210 | /* Not support this function */ |
mbed_official | 119:3921aeca8633 | 211 | /* Use mbed Serial */ |
mbed_official | 119:3921aeca8633 | 212 | return (ch); |
mbed_official | 119:3921aeca8633 | 213 | } |
mbed_official | 119:3921aeca8633 | 214 | |
mbed_official | 119:3921aeca8633 | 215 | |
AnnaBridge | 184:08ed48f1de7f | 216 | int32_t ITM_ReceiveChar (void) |
AnnaBridge | 184:08ed48f1de7f | 217 | { |
mbed_official | 119:3921aeca8633 | 218 | /* Not support this function */ |
mbed_official | 119:3921aeca8633 | 219 | /* Use mbed Serial */ |
mbed_official | 119:3921aeca8633 | 220 | return (-1); /* no character available */ |
mbed_official | 119:3921aeca8633 | 221 | } |
mbed_official | 119:3921aeca8633 | 222 | |
mbed_official | 119:3921aeca8633 | 223 | |
AnnaBridge | 184:08ed48f1de7f | 224 | int32_t ITM_CheckChar (void) |
AnnaBridge | 184:08ed48f1de7f | 225 | { |
mbed_official | 119:3921aeca8633 | 226 | /* Not support this function */ |
mbed_official | 119:3921aeca8633 | 227 | /* Use mbed Serial */ |
mbed_official | 119:3921aeca8633 | 228 | return (0); /* no character available */ |
mbed_official | 119:3921aeca8633 | 229 | } |
mbed_official | 119:3921aeca8633 | 230 |